Re: Redirect to a component action
Re: Redirect to a component action
- Subject: Re: Redirect to a component action
- From: Hugi Thordarson <email@hidden>
- Date: Sat, 22 Aug 2009 12:32:05 +0000
Hi Francesco.
One option you have is to store a reference to the original page in
the Login page. Something like this (warning: uncompiled pseudocode):
/*----------------------------------------------*/
// in your shopping cart component:
/*----------------------------------------------*/
public WOActionResults saveCart() {
if( session().user() == null ) {
LoginPage nextPage = pageWithName( nextPage.class );
nextPage.componentToReturnToAfterLogin = context().page();
return nextPage;
}
else {
// Do your thing;
}
}
/*----------------------------------------------*/
In your login page
/*----------------------------------------------*/
public WOComponent componentToReturnToAfterLogin;
public WOActionResults login() {
// authenticate the user. Then, on successful login...
componentToReturnToAfterLogin.ensureAwakeInContext( context() );
return componentToReturnToAfterLogin;
}
/*----------------------------------------------*/
This way, your user will be returned to the original page after
logging in. Note, however, that this will of course not invoke your
saveCart() action when you return, you'll have to do that in a
different way.
Cheers,
- Hugi
// Hugi Thordarson
// http://hugi.karlmenn.is/
On 22.8.2009, at 08:40, Francesco Romano wrote:
Hi..
I have a component action that does a check if the user is logged in..
If the user is not logged in, I redirect to a login page.
Now... I would like that, after the successful login, the first
component action is called...
So.. something like this:
public WOActionResult saveCart() {
if (session().user == null)
->redirect to LoginPage
else
doSomething
The login action is a direct action..
How can I redirect from the login action to the saveCart action??
Thanks.
Francesco
_______________________________________________
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