Announcement

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

    TimeItem isTime validator returning error?

    Trying to figure out why my list grid with a field of type "time" is returning a validation error saying it is not a time. Here is the error:

    Code:
    15:08:18.339:XRP6:WARN:RestDataSource:shiftDS:shiftDS.start: value: "2010-12-07T09:00:00" failed on validator: {type: "isTime",
    typeCastValidator: true,
    _generated: true,
    defaultErrorMessage: "Must be a time."}
    15:08:18.339:XRP6:WARN:RestDataSource:shiftDS:shiftDS.end: value: "2010-12-07T21:00:00" failed on validator: {type: "isTime",
    typeCastValidator: true,
    _generated: true,
    defaultErrorMessage: "Must be a time."}
    and my datasource definition:
    Code:
    	isc.RestDataSource.create({
    		 ID: "shiftDS"
    		,fields: [
    			 {name: "shiftid", hidden: true, primaryKey: true}
    			,{name: "start", title: "Start", type: "time", width: "50%"}
    			,{name: "end",  title: "End", type: "time", width: "50%"}
    		 ]
    		,dataFormat: "json"
    I am simply entering "9am" and "9pm" for the start and end fields. Do I need to explicitly specify a formatter of some sort? I thought the TimeItem field would format the input automatically?

    Using SC7.0

    Thanks

    #2
    "time" means a time without a date.

    Comment


      #3
      right. I never put in a date. So why would there be a date added to the post? Since the TimeItem is automatically formatting my input, I would assume it should format the value correctly.

      Comment


        #4
        This doesn't look like it's related to input, rather, it's related to parsing the response from your server - your server appears to be returning data that includes a date value in addition to time.

        Comment


          #5
          Upon further research of TimeItem, it appears that it's supposed to be passed as a date object -- http://forums.smartclient.com/showthread.php?t=578&highlight=timeitem+date This is confirmed when I looked at the response in the console

          Code:
          {
              actionURL:"src/controller/shiftDMI.php", 
              showPrompt:false, 
              transport:"xmlHttpRequest", 
              useSimpleHttp:true, 
              promptStyle:"dialog", 
              params:{
                  start:new Date(1291798800000), 
                  end:new Date(1291842000000), 
                  _operationType:"add", 
                  _componentId:"shifts", 
                  _dataSource:"shiftDS"
              }, 
              httpMethod:"POST", 
              sendNoQueue:true, 
              bypassCache:true, 
              callback:{
                  target:null
              }, 
              willHandleError:true, 
              serverOutputAsString:true, 
              clientContext:{
                  saveCallback:null, 
                  newValues:{
                      start:new Date(1291798800000), 
                      end:new Date(1291842000000)
                  }, 
                  editInfo:{
                      editValuesID:"_0", 
                      rowNum:0, 
                      colNum:1, 
                      values:'$$BACKREF$$:.actionURL.showPrompt.transport.useSimpleHttp.promptStyle.params.httpMethod.sendNoQueue.bypassCache.callback.willHandleError.serverOutputAsString.clientContext.saveCallback.newValues', 
                      oldValues:null, 
                      editCompletionEvent:"enter"
                  }
              }, 
              data:null
          }
          But it appears that the validator does not like the date object? Is there a way to turn off the validator? I also don't see the "isTime" ValidatorType in the 7.0 documentation.

          Comment


            #6
            Once again, you continue to look at the request side of things or talk about user input, but this doesn't look like it's related to input or to requests, rather, it's related to parsing the response from your server - your server appears to be returning data that includes a date value in addition to time.

            Comment


              #7
              Isn't the response supposed to be a Date? Based on the documentation, TimeItem is stores the value as a Date. From what I understand, validation occurs before it hits the server and before it hits the fetch. If I need to parse and massage the data when it hits the fetch, I can understand. But isn't this error happening in the validator? Error logs said, "failed on validator" ?

              Comment


                #8
                Validators are also run to parse wire data. See the docs - in an XML or JSON response, you are expected to use the XML Schema formats for date, time, and datetime. The time format does not (and should not) include a date value. This is entirely orthogonal from in-memory representation of the objects.

                Comment


                  #9
                  Ok, I found the problem with my understanding.

                  I thought that the input goes through the validator first before it gets to the DataSource. So I assumed it never reached my dataURL. But having turned on some debugging I realize that validation comes after. Once I parse it in the server and back to the response, it looks like I'm ok.

                  But does that seem right? I always thought validation comes first. Or is there a difference with a RestDataSource?

                  Comment


                    #10
                    User inputs are validated when you call validate(), before anything is sent to the server.

                    As a totally separate process, with any data integration approach except the SmartGWT server, responses to DSRequests run through the validation logic in order to turn String values (such as those received in XML or JSON) into correct JavaScript/Java types inside the browser.

                    Comment

                    Working...
                    X