Announcement

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

    SelectItem with dataPath doesn't work after update

    Hi,

    I'm using smartGWT version 2.5 and have following problem with SelectItems (in all browsers).

    I have a Person entity with association ManyToOne to Address entity, I'd like to show person in DynamicForm with SelectItem address.

    DynamicForm has assigned RestDataSource in json format and address field in that datasource has type of address RestDataSource, both dataSources are connected to server's services. Response of fetching data to form has following format:
    Code:
    {
        "response": {
            "totalRows": 1,
            "data": [
                {
                    "address": {
                        "id": "1",
                        "name": "Street1"
                    },
                    "birthDate": "2011-08-07",
                    "deceasedDate": "2011-08-08 22:24:12",
                    "id": 1,
                    "maidenName": "Hrasko",
                    "title": "Person 1"
                }
            ],
            "status": 0,
            "startRow": 0,
            "endRow": 0
        }
    }

    Address SelectItem has following properties:
    Code:
    address.setOptionDataSource(addressDataSource);
    address.setDisplayField("name");
    address.setValueField("id");
    address.setDataPath("address/id");
    When fetch response arrived, data are set to form and then smartGwt invoke additional request to retrieve missing properties for address - display property, when this response arrives, selectItem is correctly set up with value "Street 1".

    When I call saveData() on that form, saving service is call that has exactly the same response like fetching service, but smartGWT tries to fetch missing values for selectItem with these criteria (previously after fetch response it was "id"=1):
    Code:
    "id"={"id"=1, "name"="Street 1}
    and when response arrives with exact the same format like previously after fetching, select item is set up with value "[Object Object]" instead of "Street 1"

    It seems for me that dataPath after update is ignored.

    Could you please help me where can be problem?

    thanks,

    michal

    #2
    If you can put this together as a minimal, runnable test case we can take a look.

    Comment


      #3
      I created sample project for my problem:
      - TestForm extends DynamicForm with SelectedItem that displays embedded address
      - TestEntry entry point that creates form with save button
      - *.js test files


      Test scenario:
      1. when application is loaded, person data is fetched
      request:
      Code:
      {
      "dataSource":"PERSON_DS", "operationType":"fetch", "componentId":"isc_TestForm_0", "data":null, "oldValues":null 
      }
      response:
      Code:
      {"response": {
              "totalRows": 1,
              "status": 0,
              "data": [
                  {
                  	"id": 1,
                      "name": "test person",
                      "address": {
                      	"id" : 1,
                      	"street": "street"
                      }
                  }
              ],
              "startRow": 0,
              "endRow": 0
          }
      }
      there is also fetched missing properties for address, request:
      Code:
      {
      "dataSource":"ADDRESS_ID", "operationType":"fetch", "componentId":"isc_TestForm_0", "data":{ "id":1 }, "oldValues":null 
      }
      response:
      Code:
      {
      "response": {
              "totalRows": 1,
              "status": 0,
              "data": [
                  {
                  	"id": 1,
                      "street": "street"
                  }
              ],
              "startRow": 0,
              "endRow": 0
          }
      }
      2. when you press save button, update request is invoked. This update has exact the same response than fetch operation.
      SmartGWT then tries to fetch missing data by this request:
      Code:
      {
      "dataSource":"ADDRESS_ID", "operationType":"fetch", "componentId":"isc_TestForm_0", "data":{ "id":{ "id":1, "street":"street" } }, "oldValues":null 
      }
      That is not correct, because in "id" element is whole address record
      Response is again the same as before:
      Code:
      {"response": {
              "totalRows": 1,
              "status": 0,
              "data": [
                  {
                  	"id": 1,
                      "street": "street"
                  }
              ],
              "startRow": 0,
              "endRow": 0
          }
      }
      but in select item is [Object Object]

      thanks for help,

      michal
      Attached Files

      Comment


        #4
        Hi,

        are you able to reproduce the problem from my test classes or you need some extension of them? I can also package whole project if it's necessary.

        thanks,

        michal

        Comment


          #5
          It's queued to be looked at but is currently behind other reports from supported customers. Please be patient (or buy support and be impatient! :)

          Comment


            #6
            Actually, a question on this - your update response lacks the subobject that the SelectItem refers to with it's dataPath. This is roughly like saying that the address it just tried to update has been deleted - what were you hoping the component would do at this point?

            Comment


              #7
              I think response contains that subobject.
              Response data contains following record (the same as in fetch response because no change were made):
              Code:
                          {
                          	"id": 1,
                              "name": "test",
                              "address": {
                              	"id" : 1,
                              	"street": "street"
                              }
                          }
              Select item's value refers to address/id element that is there.

              Fetch operation has exactly the same response and there it work as I expected but after update operation component takes whole address record as its value instead of path from dataPath

              I expect that if fetch and update operation has exactly the same responses, databound component should behave the same after both operations.

              thanks.

              Comment


                #8
                Hi,

                we already paid support, this issue is quite important for me, please send me recommandation why that selectItem doesn't work as expected,

                thanks,

                michal

                Comment


                  #9
                  Welcome to support. We're taking a look.

                  Comment


                    #10
                    Ok - we've made a framework change to address this issue.
                    This fix will be present in the next nightly build on both the 2.5 and 3.x branches.

                    Note that the 2.5 branch is a bug-fix-only release branch - the only changes it contains since the official 2.5 release are fixes to bugs discovered since that release. 3.x includes a lot of new feature work as well.

                    Take a look and let us know if it doesn't resolve the issue for you

                    Regards
                    Isomorphic Software

                    Comment


                      #11
                      your fix solved my problem,

                      thanks, good work,

                      Michal

                      Comment

                      Working...
                      X