Re: Ajax Requests and Session Timeouts
Re: Ajax Requests and Session Timeouts
- Subject: Re: Ajax Requests and Session Timeouts
- From: Kieran Kelleher <email@hidden>
- Date: Mon, 22 Nov 2010 14:42:53 -0500
This is copied/pasted directly from my generic Application subclass and demonstrates example logic. Modify it to suit your own needs.....
/**
* Checks Properties for the name of the default page to return upon Session timeout.
* If not defined, just returns the super implementation.
*
* If defined, then checks for Ajax request. If Ajax, returns a page that use javascript to redirect
* to a direct action that returns the session timeout page.
*
* If not Ajax, just returns the session timeout page.
*
* @property app.sessionTimeoutPageName Name of the page to redirect to when
* this method is called
* @see com.webobjects.appserver.WOApplication#handleSessionRestorationErrorInContext(com.webobjects.appserver.WOContext)
*/
@Override
public WOResponse handleSessionRestorationErrorInContext(WOContext context) {
String page = ERXProperties.stringForKey("app.sessionTimeoutPageName");
if (page == null) {
return super.handlePageRestorationErrorInContext(context);
} else {
if (AjaxUtils.isAjaxRequest(context.request())) {
WOResponse response = createResponseInContext(context);
String defaultUrl = ERXWOContext.directActionUrl(context, WKWODirectAction.class.getSimpleName() + "/sessionExpired", null,
false);
response.appendContentString("<script>document.location.href='" + defaultUrl + "';</script>");
return response;
} else {
return pageWithName(page, context).generateResponse();
}
}
}
On Nov 22, 2010, at 2:35 PM, Johnny Miller wrote:
> 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
_______________________________________________
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