Announcement

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

    No updated to null fields are present in request's "data" list

    Hi

    On DynamicForm I have SelectItem for Department name:

    Code:
    final SelectItem itemDepartment = new SelectItem("idDepartment");
    itemDepartment.setTitle("Department");
    itemDepartment.setOptionDataSource(DepartmentDataSource.getInstance());
    itemDepartment.setValueField("id");
    itemDepartment.setDisplayField("depName");
    itemDepartment.setIcons(clearPicker);
    the clearPicker defined as
    Code:
    PickerIcon clearPicker = new PickerIcon(PickerIcon.CLEAR, new FormItemClickHandler() {  
        public void onFormItemClick(FormItemIconClickEvent event) {
              event.getItem().clearValue();
        }  
    });
    Almost everything works fine. But when record had Department defined and then it was removed by using clearPicker I can't save this record with new (null) value for idDepartment field.

    the request that I can see in transformRequest looks like this:
    Code:
     
    request.getJsObj(): {
    ...
        "data":{
            "id":16, 
            "date":"2011-01-23T23:00:00", 
            "description":"test description"
        }, 
    ...
        "oldValues":{
            "id":16, 
            "idDepartment":10, 
            "date":"2011-01-23T23:00:00", 
            "description":"test description"
        }, 
    ...
    So field "idDepartment" is present in "oldValues" section and absent in "data".

    I also noticed that when I delete date from DateItem defined on the same DynamicForm the request looks like
    Code:
    request.getJsObj(): {
    ...
        "data":{
            "id":16, 
            "date":null, 
            "description":"test description"
        }, 
    ...
        "oldValues":{
            "id":16, 
            "description":"test description"
        }, 
    ...
    field "date" is present in "data" section and absent in "oldValues".

    It was tested on SmartGWT LGPL 2.3 and 2.4

    Is it correct behavior for request's "data" and "oldValues" lists?
    Last edited by Oleg; 24 Jan 2011, 09:42.

    #2
    Use setValue(null) if you are actually trying to establish that the field is changing to an explicit null value rather than to no value specified.

    Comment


      #3
      Unfortunately using
      event.getItem().setValue(null);
      just raise "The method setValue(Date) is ambiguous for the type FormItem" error during the compilation.

      Comment


        #4
        You've already got the null value you want for the date field with clearValue() - use setValue(null) for the text field.

        Comment


          #5
          Sorry, but clearPicker is defined for "idDepartment" field which is Integer. And I can pass to setValue() values of int or String or boolean types. But null is raising the "The method setValue(Date) is ambiguous for the type FormItem" error even when clearPicker is just defined in the class and not assigned to any item on the form.
          Last edited by Oleg; 24 Jan 2011, 13:56.

          Comment


            #6
            Doesn't typecasting the null to be a String null disambiguate the call?

            Comment


              #7
              Hi Isomorphic

              Typecasting is working fine. The problem is solved.
              Thank you for help very much!

              Comment

              Working...
              X