views:

21

answers:

1

Hi,

How to identify the sessiontime out issue while updating the value in the grid and redirect to login page..

my application (java spring hibernate with extjs)

i.e.. i am updating the extjs grid record and while submitting the changes, if the session is expired i need to identify that particular exception and redirect to the login page.

i am using // var proxy = new Ext.data.HttpProxy({ // var store = new Ext.data.Store({ proxy: proxy, reader: new Ext.data.JsonReader({

Thanks in advance

A: 

Not enough information to write the exact code, but what you want to do is the following:

  1. Ensure that your web service returns a response on timeout that the store's DataProxy or DataReader implementation recognizes is a failure. Either send an appropriate HTTP response code, something unique like 515, or set the response's successProperty to false. If you do the latter, you'll need to ensure that an error code of some kind is also returned in the response that you can detect to see why there was a failure.
  2. In your Javascript, add a listener on your store for the "exception" event. Do console.log(arguments) in the listener to see what the arguments look like; one of them is the raw HTTP response, I believe another is the JSON-decoded response data (if not you should be able to retrieve this through the jsonData property of the reader). If your web service sends an HTTP response code, check response.statusCode; if it's in the JSON data check there.
  3. Once you've successfully detected the session expired error in your exception listener, add code to set window.location.href to the login page when this condition is encountered.
divestoclimb