PDA

View Full Version : How to do implement loadexception in Ext 4



rijkvanwel
12 Oct 2012, 1:31 AM
Hi all,

In my Ext 3 application, I have built a grid that does a periodic reload (a news feed), but only refreshes when there is new data on the back end. To accomplish this, I made use of the store's 'loadexception' event, that's triggered in the case of an empty response.

It works as following: on the initial request, a timestamp is added to the response and stored on the front end. This timestamp is then sent along with any subsequent requests to the backend, where it is used to determine if the client is still up to date. If so, the backend returns an empty repsonse, which triggers the loadexception event, and nothing happens (like I want).

In Ext 4, the I cannot find a way to replicate this behaviour. The loadexception event has been removed, and the load event is always triggered, and always considered successfull, even in case of an empty response! At that point, I could detect the response is empty by going into store.proxy.reader.jsonData.responseText, but at this point I can't stop the grid from being refreshed and thus becoming empty.

The only way I've found so far to trigger any exception event (or successfull:false), is to return a HTTP 500 code from the server, which is not what I want to do. I've tried using a 304 (not modified), but this also does nothing.

How can I reproduce this behaviour in the design of Ext 4?

mitchellsimoens
15 Oct 2012, 8:37 AM
Try using the exception event on the store

rijkvanwel
15 Oct 2012, 11:11 PM
Try using the exception event on the store

I've already tried. Neither the 'exception', nor 'loadexception' event is triggered in case of an empty request. This is a substantial backwards compatibility issue in my opinion; as Ext 3 really did trigger a load exception (and did not consider the request successfull)!

mitchellsimoens
16 Oct 2012, 4:08 AM
Say the server returns a 400 error, the exception event is firing for me on the store.

rijkvanwel
16 Oct 2012, 4:14 AM
Say the server returns a 400 error, the exception event is firing for me on the store.

That is true of course, but I don't want to do this as it would pollute the console and server logs, and more imporantly, as it doesn't feel right as this really isn't an error.

As said, a 304 status code (not modified) would suit the situation, but this also changes nothing to the way Ext responds.