Announcement

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

    Error : Wrong format for time fields when serializing a FilterBuilder

    Detected with Smartclient 8.3 (v8.3p_2013-04-25/Pro Deployment (built 2013-04-25)) but same error with Smartclient 9.0

    Reproduced with the last version of SC8.3 from the feature explorer : http://smartclient.com/docs/8.3/a/system/reference/SmartClient_Explorer.html

    Past the code below, enter a time value for the "Ma Time" field and click the "serialize" button. In the console, the serialized form contains a date like "1970-01-01" instead of the inputted time.

    Code:
    var filter = isc.FilterBuilder.create({
    	dataSource: isc.DataSource.create({
            ID: "dateTest",
            clientOnly: true,
    		fields: [{title:"Ma Time", name:"atime", type:"time"}]
    	})
    });
    
    var button = isc.IButton.create({
        title: "Serialize",
        click: function() {
            var txt = DataSource.getDataSource("dateTest").xmlSerialize(filter.getCriteria(true));
            console.log(txt);
        }
    });
    
    isc.VLayout.create({members: [filter, button]});
    Tested with Firefox 24 and Chromium 28

    #2
    xmlSerialize() takes a Record. You are passing AdvancedCriteria, which is not the same as a Record.

    AdvancedCriteria containing time values are correctly serialized when passed in an appropriate context, such as RestDataSource.fetchData().

    Comment


      #3
      Originally posted by Isomorphic View Post
      xmlSerialize() takes a Record. You are passing AdvancedCriteria, which is not the same as a Record.
      But in the documentation of AdvancedCriteria : http://smartclient.com/docs/8.3/a/b/c/go.html#object..AdvancedCriteria it's said : "Other servers may receive AdvancedCriteria in the most convenient format. You can implement DataSource.transformRequest() to translate the JavaScript AdvancedCriteria object directly into a SQL-like language, or serialize to XML using DataSource.xmlSerialize()."

      So the documentation is wrong ? Or there is something I misunderstood ?

      Comment


        #4
        The docs are correct - xmlSerialize() expects a Record that conforms to the fields of the DataSource. An AdvancedCriteria, if treated as a record, would have fields "fieldName", "operator", "value", etc.

        Instead of trying to make this into a bug (it isn't), if you explain what you are trying to do, Isomorphic or others may suggest an approach.

        Comment


          #5
          Sorry if you thought that I'm trying to transform a misuse to a bug. But english is not my native language, so please excuse me. I try to explain only facts and I'm not good for doing nice sentences.

          What we are trying to do is what is written in the code : serialize a xml representation of the filter to send it to a server process of our own to manage it.

          When we serialize the filter as shown in the code example I sent before, here is what we got if we input "12:42" for the "Ma Time" field :

          Code:
          <dateTest _constructor="AdvancedCriteria">
              <operator>and</operator>
              <criteria>
              	<fieldName>atime</fieldName>
              	<operator>equals</operator>
              	<value>[B]1970-01-01[/B]</value>
              </criteria>
          </dateTest>
          Instead of "1970-01-01" we were waiting to get the inputed time. Is the a way to get it in HH:MM format ?

          Thanks if you can explain me how to do.

          Comment


            #6
            There's no available API to get an AdvancedCriteria serialized exactly as the RestDataSource would do it.

            if you already have the RestDataSource sending requests to your server, just grab the inbound request.

            If not, you could convert all dates in the request to Strings yourself, then serialize the rest of the data to XML after that, if you provide appropriate DataSource to get the tags right (eg declare "criteria" field as type "multiple" so you get surrounding <criteria> tags - see DataSource.multiple for details).

            If you prefer that the framework just handled this via a new API that does exactly what you need, consider Feature Sponsorship.

            Comment

            Working...
            X