View Full Version : Handle JSON response before it loads in the store

15 Nov 2011, 8:07 AM
Hi all,

Is there a way to check what the response was from the server when the load() function is called for a store's Loader object?

The problem I'm having is that I have a store that is loaded using JSON data from the response, but if something goes wrong on the server side and I get a fata error message in the response, it isn't handled correctly, the store just hangs with the "Loading.." mask.

I tried listening for a LoadException but that isn't fireing.

Any help would be appreciated.


15 Nov 2011, 8:13 AM
If the reader throws an exception, normally the Loader should catch it and fire the LoadException event. On which object did you try to listen to that event? Do you have a testcase implementing EntryPoint?

Have you tried to step through the code?

15 Nov 2011, 10:34 AM
Hi Sven,

Sorry, I missed that I was reconfiguring the grid so I think that is why the listener was getting lost.

I managed to get the loadException to fire:

databaseGrid.getStore().getLoader().addLoadListener(new LoadListener(){
public void loaderLoadException(LoadEvent le) {
MessageBox.alert("ERROR", le.exception.getMessage(), null);

However, I still don't know how to get the responseText in the above listener to display the appropriate message to the user.
Where is the responseText located anyway?

16 Nov 2011, 3:04 AM
I guess you use a JSONReader too ?
post some code

16 Nov 2011, 7:51 AM
Yup, I use a JsonLoadResultReader.

This is where I create the store:

RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);

HttpProxy<String> proxy = new HttpProxy<String>(builder);

JsonLoadResultReader<ListLoadResult<ModelData>> reader = new JsonLoadResultReader<ListLoadResult<ModelData>>(type);

loader = new BaseListLoader<ListLoadResult<ModelData>>(proxy, reader);

ListStore<ModelData> store = new ListStore<ModelData>(loader);

return store;

This is inside a method that I use to create the store.
The store object is returned as a parameter when creating the databaseGrid object, on which I put the loadListener (as seen in the previous post).

16 Nov 2011, 7:58 AM
I had to handle a JSON response.getText() too. In order to do this, I extended JSONReader's read() method and handled there the response text.

I am not sure I understood your issue though.

16 Nov 2011, 8:03 AM
Yeah , I think you're right that overriding the read() method is the only way.