Announcement

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

    Missing in javadoc: DSResponse.addRelatedUpdate(DSResponse relatedUpdate)

    Hi Isomorphic,

    the following method is missing in
    http://www.smartclient.com/smartgwte...SResponse.html
    and (if it should be present there)
    http://www.smartclient.com/docs/8.2/...SResponse.html

    Could you please explain how to use it?

    Code:
    just
    ...
    dmlResponse1.addRelatedUpdate(dmlResponse2);
    or
    ...
    dmlResponse1 = dmlResponse1.addRelatedUpdate(dmlResponse2);
    I'm asking because the return type of addRelatedUpdate is "DSResponse" and not "void", as I'd expect.

    How is the following done best?
    "Person.ds.xml" with a field holding the most current person status
    "Person-to-Status.ds.xml" with fields person_id, status, date of statuschange

    If I insert/update/delete a row in "Person-to-Status", the row for the person might change (because the newest status changed).
    After the generated DML, I do a serverside fetch for the person in my Person-to-Status ServerObject, then added it via "addRelatedUpdate" to the 1st response. This does not work. Is this the preferred approach?

    Thanks,
    Blama
    Last edited by Blama; 5 Jun 2012, 05:46.

    #2
    Hi Isomorphic,

    one addidtion:
    getRowCount() is missing as well.
    I suppose it is the fetch-equivalent for add/update/remove's getAffectedRows(), but I'm not sure about it.


    Best regards,
    Blama

    Comment


      #3
      Follow-up to the addRelatedUpdate()-question:

      The Response reaches the Clientside, see log for RPC response:

      Code:
      [
          {
              data:[
                  {
                      MODIFIED_AT:new Date(1338904572000), 
                      DATUM:new Date(1341050400000), 
                      STATUS_ID:1, 
                      PERSON_ID:3, 
                      ID:26, 
                      MODIFIED_BY:1, 
                      STATUS_NAME:"F"
                  }
              ], 
              invalidateCache:false, 
              isDSResponse:true, 
              operationType:"add", 
              queueStatus:0, 
              relatedUpdates:[
                  {
                      endRow:1, 
                      dataSource:"T_PERSON", 
                      totalRows:1, 
                      isDSResponse:true, 
                      invalidateCache:false, 
                      status:0, 
                      operationType:"fetch", 
                      startRow:0, 
                      data:[
                          {
                              STATUS_SHORTNAME:"F", 
                              STATUS_ISAKTIV:true, 
                              ID:3, 
                              MODIFIED_BY:1, 
                              NAME:"Meyer", 
                              MODIFIED_AT:new Date(1338835134000), 
                              NAMEBERECHNET:"Meyer", 
                              STATUS_POSITION:1, 
                              GIVENNAME:"T.", 
                              ANREDE_GESCHLECHT:"M", 
                              STATUS_ISNOMEMBER:false, 
                              ANREDE_ID:1, 
                              ANREDE_NAME:"Herr"
                          }
                      ]
                  }
              ], 
              status:0
          }
      ]
      Do I have to do something that the Grid databound to "T_PERSON" and currently showing ID:3 displays the new data or is this handled automatically?

      Comment


        #4
        Thanks for pointing out the missing docs for addRelatedUpdate. The problem was that the comment started with /* instead of /**. Below are the docs for your reference (and they should answer your question).

        getRowCount() is intentionally not documented and is not a supported API.

        /**
        * Causes client-side components to react as though the provided DSResponse had just
        * successfully completed.
        * <P>
        * This API can be used to communicate additional changes that occur as a consequence of the
        * current DSResponse succeeding, such as changes to other records in the same DataSource or to
        * records from unrelated DataSources. For example, in CRM applications, Leads may be
        * converted to Accounts. In this case the "remove" operation on the Leads DataSource might
        * call <code>addRelatedUpdate()</code> with a DSResponse representing an "add" operation on
        * the Accounts DataSource. This would cause any client-side caches of Accounts (such as a
        * drop-down list for picking an Account) to automatically update.
        * <P>
        * If a DSResponse is passed with the DataSource or operationType unset, they will match the
        * current DSResponse.
        * <P>
        * This API can be called multiple times for multiple related updates. Each update is
        * processed by the client-side method DataSource.updateCaches().
        * <P>
        * This API should <b>NOT</b> be used simply to complete multiple requests in a single HTTP
        * turnaround, instead, use Queuing for this (see the client-side API
        * isc.RPCManager.startQueue()).
        *
        * @return the DSResponse that addRelatedUpdate() was called on
        * @param relatedUpdate <code>DSResponse</code> to add.
        * @visibility external
        */

        Comment


          #5
          Hi Isomorphic,

          thank you for the fast answer.
          I guess getTotalRows() is correct instead of getRowCount().

          Regarding the addRelatedUpdate() I'm not 100% sure? Use
          dmlResponse1.addRelatedUpdate(dmlResponse2);
          or
          dmlResponse1 = dmlResponse1.addRelatedUpdate(dmlResponse2);

          Best regards,
          Blama

          Comment


            #6
            Those two variations do the same thing?

            Like many other methods on dsResponse, addRelatedUpdate returns the dsResponse you call addRelatedUpdate() on, so you can "chain" methods. For example, dsResponse.setData(something).setStatus(SUCCESS).

            Comment


              #7
              Now I'm feeling stupid ;)

              Thanks again for the fast answer,
              Blama

              Comment

              Working...
              X