Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    DynamicForm.validate not validating TimeItem

    Creating a new record with an invalid time value, there is no error indication on the form, and the record is not added.

    The log indicates the value "8:00 xx" is rejected at the server.
    === 2014-08-15 19:18:48,468 [sor2] DEBUG RPCManager - Request #1 (DSRequest) payload: {
    values:{
    DueReminderDate:new Date(1408060800000),
    DueReminderTime:"8:00 xx",
    CommunityID:101,
    ProjectID:102,
    TaskID:101,
    StatusChangeOption:true,
    AnyChangeOption:false,
    DueReminderOption:false,
    TeamMemberID:104
    },
    operationConfig:{
    dataSource:"TaskSubscriber",
    operationType:"add"
    },
    componentId:"TaskSubscriberForm",
    appID:"builtinApplication",
    operation:"TaskSubscriber_add",
    oldValues:{
    },
    criteria:{
    }
    }
    === 2014-08-15 19:18:48,483 [sor2] INFO IDACall - Performing 1 operation(s)
    === 2014-08-15 19:18:48,483 [sor2] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null
    === 2014-08-15 19:18:48,483 [sor2] DEBUG DeclarativeSecurity - DataSource TaskSubscriber is not in the pre-checked list, processing...
    === 2014-08-15 19:18:48,483 [sor2] DEBUG AppBase - [builtinApplication.TaskSubscriber_add] No userTypes defined, allowing anyone access to all operatio
    ns for this application
    === 2014-08-15 19:18:48,483 [sor2] DEBUG AppBase - [builtinApplication.TaskSubscriber_add] No public zero-argument method named '_TaskSubscriber_add' f
    ound, performing generic datasource operation
    === 2014-08-15 19:18:48,483 [sor2] DEBUG ValidationContext - [builtinApplication.TaskSubscriber_add] Adding validation errors at path '/TaskSubscriber/
    DueReminderTime': {errorMessage=Must be a time.}
    === 2014-08-15 19:18:48,483 [sor2] INFO Validation - [builtinApplication.TaskSubscriber_add] Validation error: [
    {
    DueReminderTime:{
    errorMessage:"Must be a time."
    }
    }
    ]
    This is true, even if a 'valid' value "8:00" is entered.
    === 2014-08-15 19:22:12,953 [sor3] DEBUG RPCManager - Request #1 (DSRequest) payload: {
    values:{
    DueReminderDate:new Date(1408060800000),
    DueReminderTime:"08:00 AM",
    CommunityID:101,
    ProjectID:102,
    TaskID:101,
    StatusChangeOption:true,
    AnyChangeOption:false,
    DueReminderOption:false,
    TeamMemberID:102
    },
    operationConfig:{
    dataSource:"TaskSubscriber",
    operationType:"add"
    },
    componentId:"TaskSubscriberForm",
    appID:"builtinApplication",
    operation:"TaskSubscriber_add",
    oldValues:{
    },
    criteria:{
    }
    }
    === 2014-08-15 19:22:12,968 [sor3] INFO IDACall - Performing 1 operation(s)
    === 2014-08-15 19:22:12,969 [sor3] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null
    === 2014-08-15 19:22:12,969 [sor3] DEBUG DeclarativeSecurity - DataSource TaskSubscriber is not in the pre-checked list, processing...
    === 2014-08-15 19:22:12,969 [sor3] DEBUG AppBase - [builtinApplication.TaskSubscriber_add] No userTypes defined, allowing anyone access to all operatio
    ns for this application
    === 2014-08-15 19:22:12,969 [sor3] DEBUG AppBase - [builtinApplication.TaskSubscriber_add] No public zero-argument method named '_TaskSubscriber_add' f
    ound, performing generic datasource operation
    === 2014-08-15 19:22:12,969 [sor3] DEBUG ValidationContext - [builtinApplication.TaskSubscriber_add] Adding validation errors at path '/TaskSubscriber/
    DueReminderTime': {errorMessage=Must be a time.}
    === 2014-08-15 19:22:12,969 [sor3] INFO Validation - [builtinApplication.TaskSubscriber_add] Validation error: [
    {
    DueReminderTime:{
    errorMessage:"Must be a time."
    }
    }
    ]
    But, works when the value "08:00" is entered.
    === 2014-08-15 19:24:01,842 [sor7] DEBUG RPCManager - Request #1 (DSRequest) payload: {
    values:{
    DueReminderDate:new Date(1408060800000),
    DueReminderTime:new Date(28800000),
    CommunityID:101,
    ProjectID:102,
    TaskID:101,
    StatusChangeOption:true,
    AnyChangeOption:false,
    DueReminderOption:false,
    TeamMemberID:102
    },
    operationConfig:{
    dataSource:"TaskSubscriber",
    operationType:"add"
    },
    componentId:"TaskSubscriberForm",
    appID:"builtinApplication",
    operation:"TaskSubscriber_add",
    oldValues:{
    },
    criteria:{
    }
    }
    Form validation is done before saving. Here is the SAVE button code.
    Code:
    if (form.validate(false)) {  // alert("validation succeeded."); /**/
        form.saveData();
        if (!form.hasErrors()) {
            oldValues = null;
            newValues = null;
            form.rememberValues();
            form.newLogEntry = null;
            //form.setValue("Notes", null);
            form.getItem("SaveButton").setDisabled(true);
            form.getItem("UndoButton").setDisabled(true);
            form.changesPending = false;
            TaskSubscriberWindow.closeClick();
        } else { alert("errors during save.");
        }
    } else {  alert("validation failed.");  /**/
    }
    And, here is the form.
    Code:
    isc.DynamicForm.create({ ID:"TaskSubscriberForm",
        autoDraw:false,
        dataSource:"TaskSubscriber",
        numCols:6,
        overflow:"hidden",
        fields:[
            {
                name:"TaskID",
                _constructor:"HiddenItem"
            },
            {
                name:"ProjectID",
                visible:false,
                disabled:false,
                _constructor:"TextItem"
            },
            {
                name:"CommunityID",
                endRow:true,
                visible:false,
                disabled:false,
                _constructor:"TextItem"
            },
            {
                name:"TeamMemberID",
                title:"Team Member",
                visible:false,
                width:300,
                colSpan:3,
                required:true,
                valueField:"TeamMemberID",
                displayField:"TeamMemberName",
                optionDataSource:TeamMember,
                optionOperationId:"excludeCurrentTaskSubscribers",
                autoFetchData:false,
                cachePickListResults:"false",
                _constructor:"SelectItem"
            },
            {
                canEdit:false,
                name:"TeamMemberName",
                title:"Team Member",
                width:300,
                colSpan:3,
                visible:false,
                shouldSaveValue:false,
                disabled:false,
                _constructor:"TextItem"
            },
            {
                name:"UndoButton",
                title:"UNDO",
                startRow:false,
                endRow:false,
                disabled:true,
                click:"Log.setPriority(\"Log\", 5);\nLog.logDebug(\"********************** TaskSubscribersForm.UndoButton.Click\");\n\n    var form = this.form;\n    form.reset();\n    form.changesPending = false;\n    form.newLogEntry = null;\n    form.getItem(\"SaveButton\").setDisabled(true);\n    form.getItem(\"UndoButton\").setDisabled(true);\n    form.clearErrors(true);\n\nLog.logDebug(\"***END***END***END*** TaskSubscribersForm.UndoButton.Click\");",
                _constructor:"ButtonItem"
            },
            {
                name:"SaveButton",
                title:"SAVE",
                startRow:false,
                disabled:true,
                click:"TaskSubscriberForm_SaveButton_click(this.form);",
                _constructor:"ButtonItem"
            },
            {
                name:"AnyChangeOption",
                title:"Any Change Option",
                titleOrientation:"top",
                _constructor:"CheckboxItem"
            },
            {
                name:"StatusChangeOption",
                title:"StatusChangeOption",
                titleOrientation:"top",
                prompt:"Select to be alerted on changes in status, due date or owner.",
                _constructor:"CheckboxItem"
            },
            {
                name:"DueReminderOption",
                title:"Due Reminder Option",
                titleOrientation:"top",
                startRow:false,
                _constructor:"CheckboxItem"
            },
            {
                name:"DueReminderDate",
                title:"Due Reminder Date",
                titleOrientation:"top",
                _constructor:"DateItem"
            },
            {
                name:"DueReminderTime",
                title:"Due Reminder Time",
                titleOrientation:"top",
                defaultValue:"08:00 am",
                _constructor:"TimeItem"
            }
        ],
        width:"100%",
        height:"100%",
        visibilityChanged:"",
        itemChanged:"Log.setPriority(\"Log\", 5);\nLog.logDebug(\"********************** TaskSubscribersForm.itemChanged\");\n\n    this.getItem(\"SaveButton\").setDisabled(false);\n    this.getItem(\"UndoButton\").setDisabled(false);\n\nLog.logDebug(\"***END***END***END*** TaskSubscribersForm.itemChanged\"); "
    })
    I am puzzled.

    If the TimeItem validation fails on the server, why not at the client on the form, first?

    Why does the server accept '08:00' as input, but not '8:00'?

    Interesting, yes?

    Rick



    P.S. I am running SmartClient Version: v8.3p_2014-06-27/EVAL on Mozilla Firefox 20.0 with Firebug using Windows 7 Premium 64 bit.
    Last edited by RickBollinger; 15 Aug 2014, 11:37. Reason: details

    #2
    Anomaly: not clicking in form field results in incorrect parsing.

    If I save the form without clicking in the DueReminderTime field, I get this curious result.
    === 2014-08-18 14:16:12,179 [sor1] DEBUG RPCManager - Request #1 (DSRequest) payload: {
    values:{
    DueReminderDate:new Date(1408320000000),
    CommunityID:101,
    ProjectID:101,
    IssueID:101,
    StatusChangeOption:true,
    AnyChangeOption:false,
    DueReminderOption:false,
    DueReminderTime:"08:00 AM",
    TeamMemberID:104
    },
    operationConfig:{
    dataSource:"IssueSubscriber",
    operationType:"add"
    },
    componentId:"IssueSubscriberForm",
    appID:"builtinApplication",
    operation:"IssueSubscriber_add",
    oldValues:{
    },
    criteria:{
    }
    }
    === 2014-08-18 14:16:12,181 [sor1] INFO IDACall - Performing 1 operation(s)
    === 2014-08-18 14:16:12,181 [sor1] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null
    === 2014-08-18 14:16:12,182 [sor1] DEBUG DeclarativeSecurity - DataSource IssueSubscriber is not in the pre-checked list, processing...
    === 2014-08-18 14:16:12,182 [sor1] DEBUG AppBase - [builtinApplication.IssueSubscriber_add] No userTypes defined, allowing anyone access to all operati
    ons for this application
    === 2014-08-18 14:16:12,183 [sor1] DEBUG AppBase - [builtinApplication.IssueSubscriber_add] No public zero-argument method named '_IssueSubscriber_add'
    found, performing generic datasource operation
    === 2014-08-18 14:16:12,184 [sor1] DEBUG ValidationContext - [builtinApplication.IssueSubscriber_add] Adding validation errors at path '/IssueSubscribe
    r/DueReminderTime': {errorMessage=Must be a time.}
    === 2014-08-18 14:16:12,185 [sor1] INFO Validation - [builtinApplication.IssueSubscriber_add] Validation error: [
    {
    DueReminderTime:{
    errorMessage:"Must be a time."
    }
    }
    ]
    Just clicking in the field causes it to be parsed correctly.
    === 2014-08-18 14:15:55,175 [sor7] DEBUG RPCManager - Request #1 (DSRequest) payload: {
    values:{
    DueReminderDate:new Date(1408320000000),
    CommunityID:101,
    ProjectID:101,
    IssueID:101,
    StatusChangeOption:true,
    AnyChangeOption:false,
    DueReminderOption:false,
    DueReminderTime:new Date(28800000),
    TeamMemberID:103
    },
    operationConfig:{
    dataSource:"IssueSubscriber",
    operationType:"add"
    },
    componentId:"IssueSubscriberForm",
    appID:"builtinApplication",
    operation:"IssueSubscriber_add",
    oldValues:{
    },
    criteria:{
    }
    }
    === 2014-08-18 14:15:55,176 [sor7] INFO IDACall - Performing 1 operation(s)
    === 2014-08-18 14:15:55,177 [sor7] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null
    === 2014-08-18 14:15:55,177 [sor7] DEBUG DeclarativeSecurity - DataSource IssueSubscriber is not in the pre-checked list, processing...
    === 2014-08-18 14:15:55,178 [sor7] DEBUG AppBase - [builtinApplication.IssueSubscriber_add] No userTypes defined, allowing anyone access to all operati
    ons for this application
    === 2014-08-18 14:15:55,179 [sor7] DEBUG AppBase - [builtinApplication.IssueSubscriber_add] No public zero-argument method named '_IssueSubscriber_add'
    found, performing generic datasource operation
    === 2014-08-18 14:15:55,180 [sor7] INFO SQLDataSource - [builtinApplication.IssueSubscriber_add] Performing add operation with
    criteria: {DueReminderDate:new Date(1408320000000),CommunityID:101,ProjectID:101,IssueID:101,StatusChangeOption:true,AnyChangeOption:false,DueR
    eminderOption:false,DueReminderTime:new Date(28800000),TeamMemberID:103} values: {DueReminderDate:new Date(1408320000000),CommunityID:101,Projec
    tID:101,IssueID:101,StatusChangeOption:true,AnyChangeOption:false,DueReminderOption:false,DueReminderTime:new Date(28800000),TeamMemberID:103}
    === 2014-08-18 14:15:55,181 [sor7] DEBUG SQLValuesClause - [builtinApplication.IssueSubscriber_add] Sequences: {}
    === 2014-08-18 14:15:55,182 [sor7] DEBUG PoolableSQLConnectionFactory - [builtinApplication.IssueSubscriber_add] Connection was already closed in valid
    ateObject - returning false
    === 2014-08-18 14:15:55,183 [sor7] DEBUG PoolableSQLConnectionFactory - [builtinApplication.IssueSubscriber_add] DriverManager fetching connection for
    PlanetProjectDB via jdbc url jdbc:mysql://localhost:3306/PUBLIC
    === 2014-08-18 14:15:55,183 [sor7] DEBUG PoolableSQLConnectionFactory - [builtinApplication.IssueSubscriber_add] Passing credentials getConnection sepa
    rately from JDBC URL
    === 2014-08-18 14:15:55,199 [sor7] DEBUG PoolableSQLConnectionFactory - [builtinApplication.IssueSubscriber_add] makeObject() created a pooled Connecti
    on '2592323'
    === 2014-08-18 14:15:55,199 [sor7] DEBUG PoolableSQLConnectionFactory - [builtinApplication.IssueSubscriber_add] Executing pingTest 'select 1 from dual
    ' on connection 2592323
    === 2014-08-18 14:15:55,201 [sor7] DEBUG SQLConnectionManager - [builtinApplication.IssueSubscriber_add] Returning borrowed connection '2592323'
    === 2014-08-18 14:15:55,201 [sor7] DEBUG SQLTransaction - [builtinApplication.IssueSubscriber_add] Started new PlanetProjectDB transaction "2592323"
    === 2014-08-18 14:15:55,202 [sor7] DEBUG SQLDriver - [builtinApplication.IssueSubscriber_add] About to execute SQL update in 'PlanetProjectDB' using co
    nnection'2592323'
    === 2014-08-18 14:15:55,202 [sor7] INFO SQLDriver - [builtinApplication.IssueSubscriber_add] Executing SQL update on 'PlanetProjectDB': INSERT INTO PU
    BLIC.IssueSubscriber (AnyChangeOption, CommunityID, DueReminderDate, DueReminderOption, DueReminderTime, IssueID, ProjectID, StatusChangeOption, TeamMe
    mberID) VALUES (0, 101, '2014-08-18', 0, '1970-01-01 08:00:00', 101, 101, 1, 103)
    === 2014-08-18 14:15:55,272 [sor7] DEBUG SQLDataSource - [builtinApplication.IssueSubscriber_add] add operation affected 1 rows
    I thought it was a missing '0' or something. So, I changed the default value to be '10:00'. But, further testing found that was not a fix. Correct parsing depended on whether I clicked anywhere in the field.

    Any clues how to fix this? I am sure it would annoy my users who would like to accept the default value by just leaving it alone.

    Thanks,

    Rick

    Comment

    Working...
    X