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?
Announcement
Collapse
No announcement yet.
X
-
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().
-
Originally posted by IsomorphicSince 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
-
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
-
Originally posted by IsomorphicAh, 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
-
Originally posted by IsomorphicSince 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
-
Originally posted by IsomorphicYes - although to clarify, no need to call setData() client-side of course.
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");
Comment
-
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
Comment