Re: Ajax Requests and Session Timeouts
Re: Ajax Requests and Session Timeouts
- Subject: Re: Ajax Requests and Session Timeouts
- From: Johnny Miller <email@hidden>
- Date: Mon, 22 Nov 2010 10:13:10 -1000
Thank you Timo, Chuck and Kieran!
On Nov 22, 2010, at 10:00 AM, Timo Hoepfner wrote:
> Hy Johnny,
>
> this is what I'm using in some of our apps in the WOApplication subclass:
>
> @Override
> public WOResponse handleSessionRestorationErrorInContext(WOContext context) {
> try {
> WOResponse response;
> if (context != null) {
> response = _redirect(context, "sessionExpired"); // -> DirectAction
> } else {
> response = super.handleSessionRestorationErrorInContext(context);
> }
> return response;
> } catch (Throwable t) {
> log.fatal(t.getMessage(), t);
> return super.handleSessionRestorationErrorInContext(context);
> }
> }
>
> private WOResponse _redirect(WOContext context, String directActionName) {
> WOResponse response;
> NSDictionary<String, ?> params = new NSDictionary<String, Object>(Boolean.FALSE, "wosid");
> // String url = context.directActionURLForActionNamed(directActionName, params);
> String url = ERXWOContext._directActionURL(context, directActionName, params, false);
> if (AjaxUtils.isAjaxRequest(context.request())) {
> response = createResponseInContext(context);
> response.appendContentString("<script>document.location.href='" + url + "';</script>");
> } else {
> WORedirect page = pageWithName(WORedirect.class);
> page.setUrl(url);
> response = page.generateResponse();
> }
> return response;
> }
>
>
> HTH,
>
> Timo
>
> Am 22.11.2010 um 20:35 schrieb Johnny Miller:
>
>> Hi,
>>
>> I'm sure this is discussed somewhere but I'm unable to find it.
>>
>> If a session timeouts between ajax requests how do you handle the response? I assume it is a combination of WOApplication's handleSessionRestorationErrorInContext and AjaxUtil.isAjaxRequest methods.
>>
>> Do you just return a javascript method in the response that redirects to a direct action? I can also see from wocontext that you may be able to triangulate which page the request originated from.
>>
>> Anyway, any advice would be greatly appreciated!
>>
>> Johnny Miller
>> Kahalawai Media Corp
>> http://www.kahalawai.com
>>
>>
>>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Webobjects-dev mailing list (email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
>
Johnny Miller
Kahalawai Media Corp
http://www.kahalawai.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden