View Full Version : Is there this kind of listener?

4 Jul 2010, 10:53 PM
Hello, all.

I've been adding a function to all components and elements to check session status.
Meanwhile, I've got a question : Is there a listener for all components' and elements' events?
Because I had to find all the components and elements' event to add the session check function.
It's too annoying work.

Any ideas?

Thanks in advance.

4 Jul 2010, 11:09 PM
Pass the session timeout value into your page..

<script type="text/javascript">
MyApp.timeoutValueSeconds = <%=session.getMaxInactiveInterval()%>;

Then you can start a timeout at app startup for that time.

And from then on use class level observability on the Ext.data.Connection class to refire the timeout on each Ajax request.

That way, you can time the client out in synch with the server.

4 Jul 2010, 11:15 PM
You could monitor mousedown/mousemove/keypress events on the body. Only stopped events would not bubble up to the body.

EventManager can't be monitored, because the essential methods are private, but you could also monitor Observable.fireEvent to catch any Observable event.

So you would end up with:

var endSession = function(){
// Do stuff
endSessionTask = new Ext.util.DelayedTask(endSession),
delayEndSession = function(){
mousedown: delayEndSession,
mousemove: delayEndSession,
keypress: delayEndSession
Ext.util.Observable.prototype.fireEvent = Ext.util.Observable.prototype.fireEvent.fireEvent.createInterceptor(delayEndSession);

4 Jul 2010, 11:52 PM
Mouse and key events should not interrupt and re-schedule a session timeout.

The server will timeout regardless of any keyboard or mouse interactions you might be doing, and your next Ajax transaction will fail.

The client and the server should timeout in sycnhrony.