Announcement

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

    DataSourceDateTimeField with valueXPath and DateTimeItem with dataPath

    When I use both the DSField.setValueXPath feature and FormItem.setDataPath with a datetime field then the value is not converted to local time. Â See xhr and screenshots.
    SGWT: 5.0p 09/18/2015 18:33

    Attached code instead since the formatting is all messed up here.

    Request:
    Code:
    POST /smart-gwt-0/item?isc_dataFormat=json HTTP/1.1
    Host: 127.0.0.1:8888
    Connection: keep-alive
    Content-Length: 329
    Origin: http://localhost:8888
    User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.93 Safari/537.36
    Content-Type: application/json
    Accept: */*
    Referer: http://localhost:8888/smart-gwt-0/
    Accept-Encoding: gzip, deflate
    Accept-Language: en-US,en;q=0.8
    Cookie: GLog=%7B%0D%20%20%20%20trackRPC%3Afalse%0D%7D
    
    {
        "dataSource":"isc_Main8_1$1_0", 
        "operationType":"update", 
        "textMatchStyle":"exact", 
        "componentId":"isc_Main8_1$2_0", 
        "data":{
            "item":{
                "date":"2015-09-18T22:00:00.000"
            }
        }, 
        "oldValues":{
            "item":{
                "date":"2015-09-18T22:00:00.000"
            }
        }
    }
    Response:
    Code:
    HTTP/1.1 200 OK
    Server: Apache-Coyote/1.1
    Content-Type: application/json;charset=UTF-8
    Transfer-Encoding: chunked
    Date: Fri, 18 Sep 2015 22:28:10 GMT
    HTTP/1.1 200 OK
    Server: Apache-Coyote/1.1
    Content-Type: application/json;charset=UTF-8
    Transfer-Encoding: chunked
    Date: Fri, 18 Sep 2015 22:28:10 GMT
    
    69
    {"response":{"startRow":0,"data":[{"item":{"date":"2015-09-18T22:00:00.000"}}],"endRow":1,"totalRows":1}}
    0
    Attached Files
    Last edited by pghosh; 18 Sep 2015, 14:49. Reason: Attached Main8.java

    #2
    What's up with this editor?  Can I not copy and paste in it anymore?

    Comment


      #3
      It looks like you are expecting that valueXPath will be applied when serializing data to be sent to the server. It doesn't work this way; valueXPath only affects how the browser reads data, and not the other way around. This means that the data structure you pass to DataSource "add" or "update" operations should not be nested as you have it.

      Also, we only recommend use of the dataPath feature for certain very rare legacy situations. You almost certainly do not want to use it; in fact it seems like you tried to use it because you thought valueXPath would do more than it actually does.

      We're aware of several issues with the editor in the new version of VBulletin - we are still working to find a way to just turn it completely off and use plain text again.

      Comment


        #4
        Here are the things that I've noticed with this example:
        • If I don't specify FormItem.setDataPath then the DSDateTimeField.setValueXPath is honored and the date value is adjusted for TimeZone and the form values are submitted as a flat structure when form.saveData is called
        • If I specify the FormItem.setDataPath in conjunction with DSDateTimeField.setValueXPath then the date value is not adjusted for TZ and appears in ISO8601 format.  However when save is clicked the form data is submitted as a nested structure.
        This behavior seems inconsistent.  setValueXPath should behave the same same regardless of the properties of the formItem.  What is your recommendation for editing nested data structures that contain date times and to have them be submitted as the same nested structure?
        Thanks.

        Comment


          #5
          Those two things you've noticed are exactly what you should expect from the docs and our explanation. Let's try another explanation:

          valueXPath parses a hierarchical message from the server into a flat data structure. When you use valueXPath, the data structure used in the browser, for editing and saving, is flat (non-hierarchical).
          dataPath is for editing a hierarchical data structure in the browser. Setting this on a form causes the form to manipulate and produce hierarchical structures.
          So when you use dataPath settings on the form and cause it to produce a hierarchical data structure, then you pass that to a DataSource for serialization that is expecting a flat structure, you have provided invalid input and what you see happening is expected to happen.

          As far as submitting nested structures to a server, we have support for WSDL, and we have support for nested structures where one DataSource record is embedded within another (master-detail), which you achieve by declaring that the type of a DataSourceField is the ID of another DataSource (see dataSourceField.type, dataSourceField.multiple, etc).

          As far as more eccentric XML or JSON structures where individual fields appear under random containing elements, with no concept of distinct records, if you need a serialization like that, you write your own code for it (again, unless you are using WSDL).

          Comment

          Working...
          X