Server side:

// The method that is called when the request completes
onComplete : function(transport) {
...
var redirect = (reply.redirect != undefined);
if(redirect)
location.href=reply.redirect;
}
----- Original Message -----

From: "François Facon" <francois.fa...@atos.net>
To: "Tapestry users" <users@tapestry.apache.org>
Sent: Thursday, 1 December, 2011 3:06:38 PM
Subject: Re: Tapestry 5 JQuery - redirect to other page when session has expired

Hi Ville,

Did you try to use Tynamo-security or to contribute your own access
control dispatcher

AppModule.java
.
.
.
public void contributeMasterDispatcher(
OrderedConfiguration<Dispatcher> configuration,
@InjectService("AccessControlDispatcher") Dispatcher
accessController)
{
configuration.add("AccessControlDispatcher",
accessController,
"before:ComponentEvent");
}

... and just have:

.
.
.
if (request.isXHR()) {
boolean noSession = (request.getSession(false)) ==
null ? true : false;
if (noSession){
OutputStream os =
response.getOutputStream("application/json;charset=UTF-8");

os.write("{\"script\":\"window.location.reload();\"}".getBytes());
os.flush();
return true;
}

as suggested in
http://tapestry.1045711.n5.nabble.com/redirecting-from-an-ajax-event-listener-td2438259.html

François

2011/12/1 Ville <ville.virta...@cerion.fi>:
> Hi,
>
> I googled around a bit, and have some thoughts how this could be done, but
> what are the options? We're using Tap5-JQuery library.
>
> The workaround I have currently in mind involves adding filter to serverside
> that catches redirects to login page and if request is xhr then a json
> response is generated instead. This involves wrapping the response etc.
>
> I also have to intercept the call in browser side to have it working
> correctly.
>
> Is this the best way to do it?
>
> - Ville
>
> --
> View this message in context: 
> http://tapestry.1045711.n5.nabble.com/Tapestry-5-JQuery-redirect-to-other-page-when-session-has-expired-tp5038408p5038408.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org


Reply via email to