• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Redirect to a component action
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Redirect to a component action


  • Subject: Re: Redirect to a component action
  • From: Francesco Romano <email@hidden>
  • Date: Sat, 22 Aug 2009 15:12:13 +0200


On 22/ago/2009, at 14.32, Hugi Thordarson <email@hidden> wrote:

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.


So it's impossible to call an action from another component?

Maybe I can set a flag in the cart component and manually call the action..
What do you think?


Francesco
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


  • Follow-Ups:
    • Re: Redirect to a component action
      • From: Hugi Thordarson <email@hidden>
References: 
 >Redirect to a component action (From: Francesco Romano <email@hidden>)
 >Re: Redirect to a component action (From: Hugi Thordarson <email@hidden>)

  • Prev by Date: Re: Redirect to a component action
  • Next by Date: Re: Redirect to a component action
  • Previous by thread: Re: Redirect to a component action
  • Next by thread: Re: Redirect to a component action
  • Index(es):
    • Date
    • Thread