Page 1 of 7

Partial AJAX calls don't handle container session timeouts

Posted: 09 Aug 2011, 16:24
by nickw
Hi,
I'm using the following:

Glassfish 3.1
Mojarra 2.1.0 (included with Glassfish)
Primefaces 3.0M2

I'm using container security with form based login. I have a secured page that contains a p:commandButton that updates part of the page. All works fine whilst the user is logged in.

Once the session times out the application appears to lock up. What is happening is that the partial AJAX request from the button is expecting an XML response, but Glassfish sends it the HTML for the login page instead (as it should, the session has timed out). Would it be possible to get the partial request code to handle this situation, maybe refresh the whole page to allow the container redirect to work?

I've created a small war file/eclipse project to demonstrate the problem. I can provide that on request.
Regards,

Nick

Re: Partial AJAX calls don't handle container session timeou

Posted: 09 Aug 2011, 16:38
by tandraschko
Issue already exists: http://code.google.com/p/primefaces/iss ... il?id=1843

You could write an own exceptionhandler and redirect on session expiration (viewtopic.php?f=3&t=2631)

Re: Partial AJAX calls don't handle container session timeou

Posted: 09 Aug 2011, 16:51
by cagatay.civici
This is an important one, I'll take this into M3.

Re: Partial AJAX calls don't handle container session timeou

Posted: 09 Aug 2011, 16:57
by tandraschko
Great, thanks cagatay!

Re: Partial AJAX calls don't handle container session timeou

Posted: 09 Aug 2011, 17:19
by cagatay.civici
So how should we solve this case, any feedback is welcome. Probably we should implement it in onerror callback of ajax request.

Re: Partial AJAX calls don't handle container session timeou

Posted: 09 Aug 2011, 17:22
by cagatay.civici
This is what we get in case of error;

Code: Select all

<?xml version='1.0' encoding='UTF-8'?>
<partial-response><error><error-name>class javax.faces.application.ViewExpiredException</error-name><error-message><![CDATA[viewId:/ui/pprUpdate.jsf - View /ui/pprUpdate.jsf could not be restored.]]></error-message></error></partial-response>
So you catch the exceptin and send a redirect to login page right?

Re: Partial AJAX calls don't handle container session timeou

Posted: 09 Aug 2011, 18:19
by Oleg
Hi,

Maybe this can help you:

http://ovaraksin.blogspot.com/2010/10/j ... meout.html
http://ovaraksin.blogspot.com/2010/10/g ... ecked.html

I use that in all my web apps with success.

Re: Partial AJAX calls don't handle container session timeou

Posted: 09 Aug 2011, 18:27
by cagatay.civici
Will check, thx!

Re: Partial AJAX calls don't handle container session timeou

Posted: 09 Aug 2011, 18:30
by tandraschko
Hmm yep i think onerror with the error message and type should be ok and should also be flexible enough. What do you think?

Re: Partial AJAX calls don't handle container session timeou

Posted: 09 Aug 2011, 18:31
by tandraschko
Also then onerror should be possible on fileupload etc. too!