Announcement

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

    Best place to transform a custom class into dsresponse

    Hi, i'm going to integrate with an existing rest service. It returns an object not totally different from DSResponse but not as advanced:

    Code:
    public class ApiDataResponse<T> extends ApiResponse {
    
    Integer startRow;
    Integer endRow;
    Integer totalRows;
    List<T> data;
    ...
    //various additional code
    So, i tried to read up on transformresponse and found the DataSource.transformresponse, but was unable to find something definitve. I am looking for a central override point where i can put code to move over these relevant rows into the DSResponse returned, either on the server side or client side (preferred)

    But since you get a DataSource in the client via DataSource.get(), i'm not sure how i could override those objects transformresponse?

    I'm sure this is doable, just hoping for pointers on where you suggest i put the code.

    Thanks in advance

    #2
    Please see the JavaDoc. DataSource.get() has a signature where you can pass in a request and response transformer, which is the equivalent of transformResponse.

    Comment


      #3
      Right. I did look at the docs prior to posting. The only stuff i could see was get(). See attached screenshot from the reference. Perhaps i was looking in the wrong place?

      Also, as i said i was hoping for a global config place so i wouldn't have to remember to include a custom call everywhere in the code. Surely i would miss it somewhere. It would have been great with something like DataSource.setCustomTransformer(String ID, CustomTransformer transformer), or the ability to set it on the ds.xml so that it would be used everywhere in the client that the datasource in question was used.
      Attached Files

      Comment


        #4
        That looks to be a screenshot from the SmartClient Reference. The additional signature of get() only exists in SmartGWT, because in SmartClient you could just use addMethods().

        Comment


          #5
          Right, see it now! Thanks.

          Comment

          Working...
          X