Thanx,
This is satisfying solution, though I don't know if Link implementation not
being Serializable makes any problem when persisting in HttpSession in some
cases.
-Vjeran
----- Original Message -----
From: "Josh Canfield" <j...@thedailytube.com>
To: "Tapestry users" <users@tapestry.apache.org>
Sent: Sunday, August 09, 2009 7:48 PM
Subject: Re: [T5] Log in directly to requested page (not just home page)
I've found that the easiest thing to do is just remember the url that your
user was trying to load in the first place.
In my base page I have this:
@InjectPage
private Login _loginPage;
public Object onActivate(Object[] context) {
// Only let the request through if the user has logged in
if (!_loginStateExists || !_loginState.isValid()) {
_loginState = null;
final Link link =
_linkSource.createPageRenderLinkWithContext(_resources.getPageName(),
context);
_loginPage.setSuccessLink(link);
return _loginPage;
}
return null;
}
Then when the form is submitted to the login page I have this:
/**
* Where to go after a successful login.
*/
@Persist
private Link _successLink;
Object onSuccess() {
if (_successLink != null) {
final Link link = _successLink;
_successLink = null; // we only use the link once.
return link;
}
return Index.class; // no link set, just go to home page.
}
Josh
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org