Announcement

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

    Return a string along with DSResponse

    I am currently running smartgwtpower 3.0 and gwt 2.3. On the server side I am extending SQLDataSource and intercepting the executeFetch method, doing something, then just returning super.executeFetch(request); I would like to return a simple string to the client for the client to store. What is the correct way to do this? Is this something I can put in the DSResponse object and then intercept it on the client?

    #2
    Since it's a "fetch" operation, a List of Records is the expected response unless an error has occurred. So you could deliver the String as an attribute on the first Record.

    However, consider DataSource.performCustomOperation() as an alternative since it sounds like the method you are implementing is not really fetch (it could never be used with a grid, for example). Instead, it merely *performs a fetch* as part of it's work, which can be done server-side via new DSRequest(...).execute().

    Comment


      #3
      Originally posted by Isomorphic
      Since it's a "fetch" operation, a List of Records is the expected response unless an error has occurred. So you could deliver the String as an attribute on the first Record.

      However, consider DataSource.performCustomOperation() as an alternative since it sounds like the method you are implementing is not really fetch (it could never be used with a grid, for example). Instead, it merely *performs a fetch* as part of it's work, which can be done server-side via new DSRequest(...).execute().
      The fetch is for a listgrid. I'll look into setting the string as an attribute of the first record

      Comment


        #4
        Ah, so the String is something to return *in addition to* the fetch. In this case also consider representing the code that returns the String as a separate DSRequest / RPCRequest, and using queuing to get both results at once. Creating it as a separate operation means you'd be able to call it without also fetching records for the grid.

        Comment


          #5
          Originally posted by Isomorphic
          Ah, so the String is something to return *in addition to* the fetch. In this case also consider representing the code that returns the String as a separate DSRequest / RPCRequest, and using queuing to get both results at once. Creating it as a separate operation means you'd be able to call it without also fetching records for the grid.
          Is there an example of how to do the queuing? I'll never actually need to call it without fetching records though.

          Comment


            #6
            Under the "Transactions" folder there are several examples of queuing (both automatic and manual).

            Comment


              #7
              Originally posted by Isomorphic
              Since it's a "fetch" operation, a List of Records is the expected response unless an error has occurred. So you could deliver the String as an attribute on the first Record.

              However, consider DataSource.performCustomOperation() as an alternative since it sounds like the method you are implementing is not really fetch (it could never be used with a grid, for example). Instead, it merely *performs a fetch* as part of it's work, which can be done server-side via new DSRequest(...).execute().
              Is there an example of setting the string as an attribute of the first record? Would I have to call getData() on the server side, then edit the first record and call setData(Record[]), and then on the client side do the same?

              Comment


                #8
                Yes - although to clarify, no need to call setData() client-side of course.

                Comment


                  #9
                  Originally posted by Isomorphic
                  Yes - although to clarify, no need to call setData() client-side of course.
                  eb
                  So on the client side, how do I intercept the DSResponse? Do I have to extend the DataSource class? At the moment this is the code I have.
                  Code:
                  this.ListGridDataSource = DataSource.get("MyDataSource");
                  What would I have to do to override the transformResponse only, and leave everything as default?

                  Comment


                    #10
                    The way I solved the problem was by adding a property to the DSResponse on the server side. On the client side, I called DataSource.get(String, RequestTransformer, ResponseTransformer) and made my own ResponseTransformer and overrode the transformResponse method. I grabbed the string in that method.

                    Comment

                    Working...
                    X