Announcement

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

    allowEmptyInput no data send to server

    Hi,

    I've got a problem with Databound DynamicForm with SelectItem field.
    This item is also databound with simple datasource consisting of to fields: id, name.
    And I've got to setAllowEmptyValue()
    Problem appears when a user tries to clean this field.
    No data about this field is being send to server.
    As I recall earlier field was send with "null" value.
    Is it a bug or feature and I need to configure somehow this datasource.
    I'm using now official SmartGWT-2.4
    Thanks for any help.
    Best regards

    #2
    Hi,

    Has anyone else saw this problem?
    I've checked latest nightly build and problem still exists.
    I think its high priority problem because you cannot clean value for any field that uses databound select item. Server simply doesn't receive any data about this field so does not change it's value.
    I've checked also on my older projects that uses this combination and problem exists in all of them.
    Was some inside procedures changed and should I use different approach to allow users to clean value from a databound select field?
    I'm looking forward to any answer or clue.
    It's high priority to me.
    Best regards

    Comment


      #3
      This of course depends on the server side implementation that you are using, but for example when using RestDataSource, and Java backend, you can use Jackson library to serialize/deserialize your objects, and configure the parser using annotations on your domain objects, to treat missing values as null's.

      That's just a wild speculation, and is unlikely to help you in any way. You need to provide more information about the server side code, and sample client test case that is failing for you.

      regards,
      Andrius J.
      disclaimer: I am not affiliated with Isomorphic, but now I do realize why some posts are just getting ignored. Help us help you :)

      Comment


        #4
        On server side I'm using my own PHP implementation.
        Unfortunately I cannot change server side code to just set values to null whenever the value on update isn't set. That's because in many cases not all data is provided to client in every case and not all fields need to be updated. Such behaviour would cause fatal consequences to my applications.
        Thanks for your reply.
        Best regards

        Comment


          #5
          Code:
              private static DataSource createDs(String entity) {
          
                  RestDataSource restDataSource = new RestDataSource();
                  restDataSource.setID(entity);
                  restDataSource.setDataFormat(DSDataFormat.JSON);
                  DataSourceTextField idField = new DataSourceTextField("_id", "ID");
                  idField.setPrimaryKey(true);
                  idField.setCanEdit(false);
                  OperationBinding fetch = new OperationBinding();
                  fetch.setOperationType(DSOperationType.FETCH);
                  fetch.setDataProtocol(DSProtocol.POSTPARAMS);
                  OperationBinding add = new OperationBinding();
                  add.setOperationType(DSOperationType.ADD);
                  add.setDataProtocol(DSProtocol.POSTMESSAGE);
                  OperationBinding update = new OperationBinding();
                  update.setOperationType(DSOperationType.UPDATE);
                  update.setDataProtocol(DSProtocol.POSTMESSAGE);
                  OperationBinding remove = new OperationBinding();
                  remove.setOperationType(DSOperationType.REMOVE);
                  remove.setDataProtocol(DSProtocol.POSTMESSAGE);
                  restDataSource.setOperationBindings(fetch, add, update, remove);
                  restDataSource.setFetchDataURL("/" + restDataSource.getID() + "/fetch.do");
                  restDataSource.setAddDataURL("/" + restDataSource.getID() + "/add.do");
                  restDataSource.setUpdateDataURL("/" + restDataSource.getID() + "/update.do");
                  restDataSource.setRemoveDataURL("/" + restDataSource.getID() + "/remove.do");
                  restDataSource.setFields(idField);
                  dataSources.put(entity, restDataSource);
                  return restDataSource;
              }
          If you create your ds like this (please note the
          Code:
           add.setDataProtocol(DSProtocol.POSTMESSAGE);
          , you will get the records posted as Json content, not as simple post parameters, and it's very easy to parse the message on the serverside. Haven't been doing any Json related stuff with php, but I am sure there are libraries out there to help you with that.

          regards,
          Andrius J.

          Comment


            #6
            Something like this I already have ;)
            Exactly I've made my own class that extends RestDataSource and configures it for sending data as JSON for correct URL address depending on used action (fetch, add, update, remove).
            It all works fine and both sides. From server side I also sends JSON response so that my DataSource could provide special message or just provide errors informations to forms.
            Only problem I have with this is that some functionality in SmartGWT was changed. Earlier in a form with field like this:
            Code:
            SelectItem fieldCalendarId = new SelectItem("calendar_id");
            fieldCalendarId.setOptionDataSource(dsCalendars);
            fieldCalendarId.setDisplayField(dsCalendars.getTitleField());
            fieldCalendarId.setValueField("id");
            fieldCalendarId.setWidth("*");
            fieldCalendarId.setAllowEmptyValue(true);
            user could select empty value from ComboBox and "null" value was send to server. Unfortunately it was somehow changed and now if I select in this ComboBox empty value now data about this field is being send to server (other fields are send correctly). For same reason Isomorphic disabled sending null value to server. Question is how to enable this behaviour again. I don't believe that so important behaviour was changed without absolutely no possible way to adjust it.
            In JavaDoc there is nothing about this.

            For now I'm thinking about adding some additional icon that would set value to "null" without option setAllowEmptyValue().

            I know how to apply on server automatic change to null on server when no data about some field is provided but for me it's not a solution. For example what if many client side datasources are connected to one on server side and some provide only general information and others detailed ones. I use some of this in my applications to limit data operation on client and to decrease bandwidth usage.

            Best regards

            Comment


              #7
              If anyone would have the same problem, I've found simple workaround.
              Instead setting attribute setAllowEmptyValue(true), I've added picker icon that sets value to null. In that case null value is being sent to server.
              Don't know why it doesn't happened in official solution (with setAllowEmtyInput(true)) but this workaround for now works fine.
              Code:
              SelectItem fieldProducerId= new SelectItem("producer_id");
              fieldProducerId.setOptionDataSource(dsProducers);
              fieldProducerId.setValueField("id");
              fieldProducerId.setDisplayField(dsProducers.getTitleField());
              		
              PickerIcon fieldProducerIdDelete = new PickerIcon(new Picker("box/silk/bin.png"), new FormItemClickHandler() {
              	public void onFormItemClick(FormItemIconClickEvent event) {
              		event.getItem().setValue((Integer)null);
              	}				
              });
              fieldProducerIdDelete.setWidth(16);
              fieldProducerIdDelete.setHeight(16);
              fieldProducerId.setIcons(fieldProducerIdDelete);
              It also works with PickTreeItem.
              Maybe this will help someone.
              Best regards.

              Comment


                #8
                We are using a SmartGWT EE build from 4/25, and have found that with a databound SelectItem that has allowEmtpyValues(true) set, that the blank values are NOT being sent to the server in the RPC request on an Update operation:

                BK option selected:

                {
                "dataSource":"PoItem",
                "operationType":"update",
                "operationId":"update_PoItem_member(F017)",
                "componentId":"isc_ValuesManager_3",
                "data":{
                "IUVL":13,
                "IONO":"EDS0928",
                "ItemNumber":"0820-00832-8300-00-000",
                "IPPK":"N",
                "IASQ":"1",
                "IUCD":"BK",
                "PoItemDetails":[

                Blank option selected (IUCD field is now missing):

                {
                "dataSource":"PoItem",
                "operationType":"update",
                "operationId":"update_PoItem_member(F017)",
                "componentId":"isc_ValuesManager_3",
                "data":{
                "IONO":"EDS0928",
                "ItemNumber":"0820-00832-8300-00-000",
                "IPPK":"N",
                "IASQ":"1",
                "PoItemDetails":[

                It is possible to put in a workaround on a field-by-field basis, so that if on a changed event if the value of the selectItem is null, you reset it to say "", but this is not feasible to implement across all of our data-bound selectItems.

                Can you advise on this issue and a fix ASAP?

                Thanks.

                Comment


                  #9
                  This should not be happening by default (and we've verified that it's working as expected) on recent builds.
                  We'd recommend:

                  - verify that you don't have the 'noNullUpdates' property set on your dataSource
                  - update to the most recent nightly build and re-test in case this was a temporarily introduced problem that happened to impact your build.

                  If you continue to see the problem, it implies there's something going on in your DataSource or component definitions that causes it since we're not seeing this in a simple test case.
                  Can you show us a standalone example that demonstrates it?

                  Thanks
                  Isomorphic Software

                  Comment

                  Working...
                  X