Announcement

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

    Duplicate rows on create from processResponse and updateCaches

    Hi ...
    I've searched the forums and can't seem to see any example of this so I think I'll just ask. We've updated to latest nightly build of 2.5 from smartgwt 2.2.

    We were using events from the server to update datasources on any CUD events using updateCaches in the DataSource.

    Code:
    public void onNotification(String event, DomainObject object) {
       if((event != null) && (object != null))
       {
          GWT.log("received "+event+" event for "+
                       object.getClassName()+" with name" +object.getName());
          DSResponse response = createDSResponse(event, object);
          updateCaches(response);
       }
    }
    To stop duplicate rows appearing the ListGrid during creates, in the DataSource I was setting the status of the dsResponse to failure and then calling processResponse. This seem to work although I admit its a bit of a hack ...

    Code:
    DSResponse dsResponse = new DSResponse();
    dsResponse.setStatus(RPCResponse.STATUS_FAILURE);//(-1);
    processResponse(requestId, dsResponse);
    The problem is, in the latest build smartClient displays a warning, that the server returned an error ... which is great but it means my little hack doesn't work anymore :-)

    So .... whats the correct way to do this ? if I set it success, I get a row from the create response and I get a row from the updateCaches. If I don't call processResponse the dialog just sits there. The dataSource does have a primaryKey set. I've looked at setPreventDuplicates but that seems to be for drag and drop.

    Any help would be really appreciated ...

    Mike.

    #2
    Ok ... blinded by the enums ... :-)

    Setting the status to "0" results in success and a record added to an attached ListGrid.
    Setting the status to a negative number results in an error.
    Setting the status to a positive number results in success with no update to any attached ListGrid.

    I assume this is documented somewhere any I missed it ... I hope this is the correct way to implement this. I do get this warning from the DataSource code

    Code:
    [ERROR] [main] - 17:25:37.117:WARN:DataSource:Customer:Empty results returned on 'add' on dataSource 'Customer', unable to update resultSet(s) on DataSource Customer.  Return affected records to ensure cache consistency.
    Please let me know if I'm wrong.

    Seems to work for now anyway.

    Thanks,
    Mike
    Last edited by mike_mac; 8 Dec 2011, 09:27.

    Comment


      #3
      There are various error codes documented on RPCManager, however, it sounds like what you may actually want is resultSet.neverDropUpdatedRows.

      Comment


        #4
        Thanks for the quick response Isomorphic ... I appreciate it as I realise you get a high volume of requests on this forum.

        From the javadoc neverDropUpdatedRows seems to be a flag to turn off client side filtering, this is on by default right ?. I don't think thats what I need but maybe I confused you with my last post, sorry about that, maybe if I'm a little bit verbose.

        I have a DataSource with an attached ListGrid and a Create Dialog.

        When the user clicks create in the dialog, it calls create in the DataSource which sends a create request to the server. On success, the DataSource calls processResponse with a success code.

        To allow for a multi user environment, our DataSource subscribes for updates with our server for the object its interested in. When an update event is received for its object type, it calls updateCaches with the updated object.

        The issue is, the user that created the object has two of these objects added to the cache and so two in the listing screen, one from processResponse (from the create invoked on the DataSource) and one from the update caches (invoked from the AJAX server event).

        My solution above is to return a number greater then zero in the status, which seems to work as it doesn't add the created object to the cache. My question is, is this correct.

        Comment


          #5
          Ah. No that's a bit of a hack. We would recommend instead finding a way to avoid sending duplicate updates - track updates this client made and ignore such updates from the server, for instance.

          Comment

          Working...
          X