Re: Private Homepage Redirection

2008-05-07 Thread Johan Compagner
add this to the api...
Because this is the second question about this in a very short time..

johna


On Wed, May 7, 2008 at 7:47 AM, Martijn Dashorst [EMAIL PROTECTED]
wrote:

 Perhaps this one helps?

 public class RedirectToExternalException extends
 AbstractRestartResponseException
 {
   private static final long serialVersionUID = 1L;

   public RedirectToExternalException(String url)
   {

   RequestCycle rc = RequestCycle.get();
   if (rc == null)
   {
   throw new IllegalStateException(
   This exception can only be
 thrown from within request processing cycle);
   }
   else
   {
   Response r = rc.getResponse();
   if (!(r instanceof WebResponse))
   {
   throw new IllegalStateException(
   This exception can
 only be thrown when wicket is processing an
 http request);
   }

   // abort any further response processing
   rc.setRequestTarget(new RedirectRequestTarget(url));
}
   }
 }

 On 5/7/08, TH Lim [EMAIL PROTECTED] wrote:
 
   RestartResponseException worked but it doesn't accept external URL. As
 a
   result, I have to put the redirection in the dummy Page's HTML header.
 
   Someone in the forum mentioned using WebApplication.getHomePage() to
 get
   around but that too requires you to put up a dummy Page to redirect to
 the
   external site as mentioned in previous paragraph.
 
   Thanks for the replies. Now I have a choice to make after becoming more
   knowledgeable on this issue.
 
 
 
   Eelco Hillenius wrote:
   
 I tried both AbortException and RestartResponseException. They
 didn't
work.
 AbortException basically causes Wicket to show a blank page instead
 of
 redirecting to the external site while RestartResponseException
 caused
stack
 overflow error. The exceptions were thrown in
 onUnauthorizedInstantiation(...) method.
   
You should use the RestartResponseException, not AbortException
directly. The stack overflow error is something you can fix yourself;
make sure you redirect to a page that won't cause these redirects to
be triggered again.
   
Eelco
   
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
   
   
   
 
 
  --
   View this message in context:
 http://www.nabble.com/Private-Homepage-Redirection-tp17079231p17093829.html
 
  Sent from the Wicket - User mailing list archive at Nabble.com.
 
 
   -
 
  To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
 
 


 --
 Buy Wicket in Action: http://manning.com/dashorst
 Apache Wicket 1.3.3 is released
 Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.3

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




Re: Private Homepage Redirection

2008-05-07 Thread Alex Jacoby

+1

I did something similar but not nearly so elegant.  This would have  
been nice to have.


On May 7, 2008, at 3:22 AM, Johan Compagner wrote:


add this to the api...
Because this is the second question about this in a very short time..

johna


On Wed, May 7, 2008 at 7:47 AM, Martijn Dashorst [EMAIL PROTECTED] 


wrote:


Perhaps this one helps?

public class RedirectToExternalException extends
AbstractRestartResponseException
{
 private static final long serialVersionUID = 1L;

 public RedirectToExternalException(String url)
 {

 RequestCycle rc = RequestCycle.get();
 if (rc == null)
 {
 throw new IllegalStateException(
 This exception can only be
thrown from within request processing cycle);
 }
 else
 {
 Response r = rc.getResponse();
 if (!(r instanceof WebResponse))
 {
 throw new IllegalStateException(
 This exception can
only be thrown when wicket is processing an
http request);
 }

 // abort any further response processing
 rc.setRequestTarget(new  
RedirectRequestTarget(url));

  }
 }
}

On 5/7/08, TH Lim [EMAIL PROTECTED] wrote:


RestartResponseException worked but it doesn't accept external  
URL. As

a
result, I have to put the redirection in the dummy Page's HTML  
header.


Someone in the forum mentioned using WebApplication.getHomePage() to

get
around but that too requires you to put up a dummy Page to  
redirect to

the

external site as mentioned in previous paragraph.

Thanks for the replies. Now I have a choice to make after becoming  
more

knowledgeable on this issue.



Eelco Hillenius wrote:



I tried both AbortException and RestartResponseException. They

didn't

work.
AbortException basically causes Wicket to show a blank page  
instead

of

redirecting to the external site while RestartResponseException

caused

stack
overflow error. The exceptions were thrown in
onUnauthorizedInstantiation(...) method.


You should use the RestartResponseException, not AbortException
directly. The stack overflow error is something you can fix  
yourself;
make sure you redirect to a page that won't cause these redirects  
to

be triggered again.

Eelco

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






--
View this message in context:

http://www.nabble.com/Private-Homepage-Redirection-tp17079231p17093829.html


Sent from the Wicket - User mailing list archive at Nabble.com.


-

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





--
Buy Wicket in Action: http://manning.com/dashorst
Apache Wicket 1.3.3 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.3

-
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]



Re: Private Homepage Redirection

2008-05-07 Thread TH Lim

+1

It's a handy class and should be put in the API.


Alex Jacoby-2 wrote:
 
 +1
 
 I did something similar but not nearly so elegant.  This would have  
 been nice to have.
 
 On May 7, 2008, at 3:22 AM, Johan Compagner wrote:
 
 add this to the api...
 Because this is the second question about this in a very short time..

 johna


 On Wed, May 7, 2008 at 7:47 AM, Martijn Dashorst
 [EMAIL PROTECTED] 
 
 wrote:

 Perhaps this one helps?

 public class RedirectToExternalException extends
 AbstractRestartResponseException
 {
  private static final long serialVersionUID = 1L;

  public RedirectToExternalException(String url)
  {

  RequestCycle rc = RequestCycle.get();
  if (rc == null)
  {
  throw new IllegalStateException(
  This exception can only be
 thrown from within request processing cycle);
  }
  else
  {
  Response r = rc.getResponse();
  if (!(r instanceof WebResponse))
  {
  throw new IllegalStateException(
  This exception can
 only be thrown when wicket is processing an
 http request);
  }

  // abort any further response processing
  rc.setRequestTarget(new  
 RedirectRequestTarget(url));
   }
  }
 }

 On 5/7/08, TH Lim [EMAIL PROTECTED] wrote:

 RestartResponseException worked but it doesn't accept external  
 URL. As
 a
 result, I have to put the redirection in the dummy Page's HTML  
 header.

 Someone in the forum mentioned using WebApplication.getHomePage() to
 get
 around but that too requires you to put up a dummy Page to  
 redirect to
 the
 external site as mentioned in previous paragraph.

 Thanks for the replies. Now I have a choice to make after becoming  
 more
 knowledgeable on this issue.



 Eelco Hillenius wrote:

 I tried both AbortException and RestartResponseException. They
 didn't
 work.
 AbortException basically causes Wicket to show a blank page  
 instead
 of
 redirecting to the external site while RestartResponseException
 caused
 stack
 overflow error. The exceptions were thrown in
 onUnauthorizedInstantiation(...) method.

 You should use the RestartResponseException, not AbortException
 directly. The stack overflow error is something you can fix  
 yourself;
 make sure you redirect to a page that won't cause these redirects  
 to
 be triggered again.

 Eelco

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





 --
 View this message in context:
 http://www.nabble.com/Private-Homepage-Redirection-tp17079231p17093829.html

 Sent from the Wicket - User mailing list archive at Nabble.com.


 -

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




 --
 Buy Wicket in Action: http://manning.com/dashorst
 Apache Wicket 1.3.3 is released
 Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.3

 -
 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]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Private-Homepage-Redirection-tp17079231p17106174.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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



Re: Private Homepage Redirection

2008-05-06 Thread Maurice Marrink
No, The homepage class will be (at least partially) constructed.
Because it is the Component constructor that triggers the call to the
listeners.

Maurice

On Tue, May 6, 2008 at 11:37 AM, TH Lim [EMAIL PROTECTED] wrote:

  Hi,

  I have setup a private homepage in org.apache.wicket.WebApplication. My
  intention is to redirect the user, if he not logged in, to an external site.
  Once he has successfully logon using the external site, he will be
  redirected back to the private homepage.  I use setRequestTarget(new
  RedirectRequestTarget(...)  inside
  IUnauthorizedComponentInstantiationListener.onUnauthorizedInstantiation(...)
  to achieve my objective. It works and at the same time my homepage class was
  instantiated in the background. My question is, is it possible to redirect
  the request to the external site and avoid instantiating the homepage class
  altogether.

  TQ

  /lim/

  --
  View this message in context: 
 http://www.nabble.com/Private-Homepage-Redirection-tp17079231p17079231.html
  Sent from the Wicket - User mailing list archive at Nabble.com.


  -
  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]



Re: Private Homepage Redirection

2008-05-06 Thread Johan Compagner
But if the right abort/restart exception is thrown then it should work
without a complete page being created.

johan


On Tue, May 6, 2008 at 12:05 PM, Maurice Marrink [EMAIL PROTECTED] wrote:

 No, The homepage class will be (at least partially) constructed.
 Because it is the Component constructor that triggers the call to the
 listeners.

 Maurice

 On Tue, May 6, 2008 at 11:37 AM, TH Lim [EMAIL PROTECTED] wrote:
 
   Hi,
 
   I have setup a private homepage in org.apache.wicket.WebApplication. My
   intention is to redirect the user, if he not logged in, to an external
 site.
   Once he has successfully logon using the external site, he will be
   redirected back to the private homepage.  I use setRequestTarget(new
   RedirectRequestTarget(...)  inside
 
  IUnauthorizedComponentInstantiationListener.onUnauthorizedInstantiation(...)
   to achieve my objective. It works and at the same time my homepage
 class was
   instantiated in the background. My question is, is it possible to
 redirect
   the request to the external site and avoid instantiating the homepage
 class
   altogether.
 
   TQ
 
   /lim/
 
   --
   View this message in context:
 http://www.nabble.com/Private-Homepage-Redirection-tp17079231p17079231.html
   Sent from the Wicket - User mailing list archive at Nabble.com.
 
 
   -
   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]




Re: Private Homepage Redirection

2008-05-06 Thread TH Lim

I tried both AbortException and RestartResponseException. They didn't work.
AbortException basically causes Wicket to show a blank page instead of
redirecting to the external site while RestartResponseException caused stack
overflow error. The exceptions were thrown in
onUnauthorizedInstantiation(...) method. 


Johan Compagner wrote:
 
 But if the right abort/restart exception is thrown then it should work
 without a complete page being created.
 
 johan
 
 
 On Tue, May 6, 2008 at 12:05 PM, Maurice Marrink [EMAIL PROTECTED]
 wrote:
 
 No, The homepage class will be (at least partially) constructed.
 Because it is the Component constructor that triggers the call to the
 listeners.

 Maurice

 On Tue, May 6, 2008 at 11:37 AM, TH Lim [EMAIL PROTECTED] wrote:
 
   Hi,
 
   I have setup a private homepage in org.apache.wicket.WebApplication.
 My
   intention is to redirect the user, if he not logged in, to an external
 site.
   Once he has successfully logon using the external site, he will be
   redirected back to the private homepage.  I use setRequestTarget(new
   RedirectRequestTarget(...)  inside
 
 
 IUnauthorizedComponentInstantiationListener.onUnauthorizedInstantiation(...)
   to achieve my objective. It works and at the same time my homepage
 class was
   instantiated in the background. My question is, is it possible to
 redirect
   the request to the external site and avoid instantiating the homepage
 class
   altogether.
 
   TQ
 
   /lim/
 
   --
   View this message in context:
 http://www.nabble.com/Private-Homepage-Redirection-tp17079231p17079231.html
   Sent from the Wicket - User mailing list archive at Nabble.com.
 
 
   -
   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]


 
 

-- 
View this message in context: 
http://www.nabble.com/Private-Homepage-Redirection-tp17079231p17080212.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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



Re: Private Homepage Redirection

2008-05-06 Thread Eelco Hillenius
  I tried both AbortException and RestartResponseException. They didn't work.
  AbortException basically causes Wicket to show a blank page instead of
  redirecting to the external site while RestartResponseException caused stack
  overflow error. The exceptions were thrown in
  onUnauthorizedInstantiation(...) method.

You should use the RestartResponseException, not AbortException
directly. The stack overflow error is something you can fix yourself;
make sure you redirect to a page that won't cause these redirects to
be triggered again.

Eelco

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



Re: Private Homepage Redirection

2008-05-06 Thread TH Lim

RestartResponseException worked but it doesn't accept external URL. As a
result, I have to put the redirection in the dummy Page's HTML header.

Someone in the forum mentioned using WebApplication.getHomePage() to get
around but that too requires you to put up a dummy Page to redirect to the
external site as mentioned in previous paragraph.

Thanks for the replies. Now I have a choice to make after becoming more
knowledgeable on this issue.


Eelco Hillenius wrote:
 
  I tried both AbortException and RestartResponseException. They didn't
 work.
  AbortException basically causes Wicket to show a blank page instead of
  redirecting to the external site while RestartResponseException caused
 stack
  overflow error. The exceptions were thrown in
  onUnauthorizedInstantiation(...) method.
 
 You should use the RestartResponseException, not AbortException
 directly. The stack overflow error is something you can fix yourself;
 make sure you redirect to a page that won't cause these redirects to
 be triggered again.
 
 Eelco
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Private-Homepage-Redirection-tp17079231p17093829.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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



Re: Private Homepage Redirection

2008-05-06 Thread Martijn Dashorst
Perhaps this one helps?

public class RedirectToExternalException extends
AbstractRestartResponseException
{
   private static final long serialVersionUID = 1L;

   public RedirectToExternalException(String url)
   {

   RequestCycle rc = RequestCycle.get();
   if (rc == null)
   {
   throw new IllegalStateException(
   This exception can only be
thrown from within request processing cycle);
   }
   else
   {
   Response r = rc.getResponse();
   if (!(r instanceof WebResponse))
   {
   throw new IllegalStateException(
   This exception can
only be thrown when wicket is processing an
http request);
   }

   // abort any further response processing
   rc.setRequestTarget(new RedirectRequestTarget(url));
   }
   }
}

On 5/7/08, TH Lim [EMAIL PROTECTED] wrote:

  RestartResponseException worked but it doesn't accept external URL. As a
  result, I have to put the redirection in the dummy Page's HTML header.

  Someone in the forum mentioned using WebApplication.getHomePage() to get
  around but that too requires you to put up a dummy Page to redirect to the
  external site as mentioned in previous paragraph.

  Thanks for the replies. Now I have a choice to make after becoming more
  knowledgeable on this issue.



  Eelco Hillenius wrote:
  
I tried both AbortException and RestartResponseException. They didn't
   work.
AbortException basically causes Wicket to show a blank page instead of
redirecting to the external site while RestartResponseException caused
   stack
overflow error. The exceptions were thrown in
onUnauthorizedInstantiation(...) method.
  
   You should use the RestartResponseException, not AbortException
   directly. The stack overflow error is something you can fix yourself;
   make sure you redirect to a page that won't cause these redirects to
   be triggered again.
  
   Eelco
  
   -
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  
  


 --
  View this message in context: 
 http://www.nabble.com/Private-Homepage-Redirection-tp17079231p17093829.html

 Sent from the Wicket - User mailing list archive at Nabble.com.


  -

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




-- 
Buy Wicket in Action: http://manning.com/dashorst
Apache Wicket 1.3.3 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.3

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