Page Redirection (Login)

2007-09-09 Thread Karl M. Davis




Hello all,

Maybe it's just late but I'm pretty confused by how the following code
snippets are supposed to work and the differences between them:

  redirectToInterceptPage(new Login(getPage()));
  throw new RestartResponseAtInterceptPageException(new
Login(getPage()));
  setResponsePage(previousPage);
  continueToOriginalDestination();

What I'm trying to do is create a Login link on every page that will
return the user back to their current page on a successful login. I've
tried various combinations of all of the above snippets, but can't seem
to get it to work correctly. My last best guess was this:

onClick() method of Link in LoginPanel:
  public void onClick()
  {
   redirectToInterceptPage(new Login(getPage()));
  }

onSubmit() method of SignInForm on LoginPage:
  protected final void onSubmit()
  {
   super.onSubmit();
 ...
   if ( ... /* login was successful */)
   {
if (previousPage != null)
 setResponsePage(previousPage);
if (!continueToOriginalDestination())
 setResponsePage(getApplication().getHomePage());
   }
   else
   {
error("Unable to login.");
   }
  }

This leaves the user on the LoginPage when they successfully login.
I'm stumped: can anyone offer some advice or point me to where the
intricacies of all of those code snippets is explained?

Thanks!
Karl




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Page Redirection (Login)

2007-09-09 Thread Maurice Marrink
What you are describing only makes sense if the loginpanel is located
on the loginpage.

Typically the redirectToInterceptPage works by storing the current
page in the session before going to the new page, the stored page is
retrieved and set as the new destination when
continueToOriginalDestination is called.

Well at least that is how the exception works :)

Maurice

On 9/9/07, Karl M. Davis [EMAIL PROTECTED] wrote:

  Hello all,

  Maybe it's just late but I'm pretty confused by how the following code
 snippets are supposed to work and the differences between them:


 redirectToInterceptPage(new Login(getPage()));
 throw new RestartResponseAtInterceptPageException(new
 Login(getPage()));
 setResponsePage(previousPage);
 continueToOriginalDestination(); What I'm trying to do is
 create a Login link on every page that will return the user back to their
 current page on a successful login.  I've tried various combinations of all
 of the above snippets, but can't seem to get it to work correctly.  My last
 best guess was this:

  onClick() method of Link in LoginPanel:
  public void onClick()
  {
  redirectToInterceptPage(new Login(getPage()));
  }

  onSubmit() method of SignInForm on LoginPage:
  protected final void onSubmit()
  {
  super.onSubmit();
  ...
  if ( ... /* login was successful */)
  {
  if (previousPage != null)
  setResponsePage(previousPage);
  if (!continueToOriginalDestination())

 setResponsePage(getApplication().getHomePage());
  }
  else
  {
  error(Unable to login.);
  }
  }

  This leaves the user on the LoginPage when they successfully login.  I'm
 stumped: can anyone offer some advice or point me to where the intricacies
 of all of those code snippets is explained?

  Thanks!
  Karl

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]