You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by karnowski <dk...@gmail.com> on 2007/11/20 18:33:40 UTC

setResponsePage in a WebPage constructor

Greetings,
In the constructor of my webpages I'm wanting to do a validity check and if
it fails redirect to a different page. So I'm doing something like this:

public class OriginalPage extends WebPage {

 public OriginalPage() {
  ...
  if(!validityCheck()) {
   setResponsePage(new DifferentPage());
  }
  ...
 }
 
 ...
}

But I'm getting inconsistent results for different web pages. When the
validity check fails it always appears to call the "setResponsePage()" but
sometimes will display the DifferentPage in the browser (i.e. what I want)
but sometimes continues to display the OriginalPage (not what I want).

Am I not supposed to be doing a setResponsePage() in a webpage's
constructor? Is setResponsePage() only for form/ajax submission? How can I
accomplish what I'm after here?

cheers,
David

-- 
View this message in context: http://www.nabble.com/setResponsePage-in-a-WebPage-constructor-tf4844887.html#a13861541
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: setResponsePage in a WebPage constructor

Posted by Al Maw <wi...@almaw.com>.
karnowski wrote:
> Greetings,
> In the constructor of my webpages I'm wanting to do a validity check and if
> it fails redirect to a different page. So I'm doing something like this:
> 
> public class OriginalPage extends WebPage {
> 
>  public OriginalPage() {
>   ...
>   if(!validityCheck()) {
>    setResponsePage(new DifferentPage());
>   }
>   ...
>  }
>  
>  ...
> }
> 
> But I'm getting inconsistent results for different web pages. When the
> validity check fails it always appears to call the "setResponsePage()" but
> sometimes will display the DifferentPage in the browser (i.e. what I want)
> but sometimes continues to display the OriginalPage (not what I want).
> 
> Am I not supposed to be doing a setResponsePage() in a webpage's
> constructor? Is setResponsePage() only for form/ajax submission? How can I
> accomplish what I'm after here?

throw new RestartResponseException(DifferentPage.class);

Regards,

Al

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: setResponsePage in a WebPage constructor

Posted by karnowski <dk...@gmail.com>.

Eelco Hillenius wrote:
> 
> You should always be able to use setResponsePage with Wicket 1.3 (in
> 1.2, this is not entirely supported). If you found a bug, please see
> if you can create a reproducible test case for it.
> 
I tried trimming down my app to reproduce it with code that developers could
run, but it seems I trimmed too much and the modified now-generic code no
longer produces the issue.



> Or do what Al said and throw a RestartResponseException.
> 
This worked fine.

-- 
View this message in context: http://www.nabble.com/setResponsePage-in-a-WebPage-constructor-tf4844887.html#a13913123
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: setResponsePage in a WebPage constructor

Posted by Eelco Hillenius <ee...@gmail.com>.
> But I'm getting inconsistent results for different web pages. When the
> validity check fails it always appears to call the "setResponsePage()" but
> sometimes will display the DifferentPage in the browser (i.e. what I want)
> but sometimes continues to display the OriginalPage (not what I want).
>
> Am I not supposed to be doing a setResponsePage() in a webpage's
> constructor? Is setResponsePage() only for form/ajax submission? How can I
> accomplish what I'm after here?

You should always be able to use setResponsePage with Wicket 1.3 (in
1.2, this is not entirely supported). If you found a bug, please see
if you can create a reproducible test case for it.

Or do what Al said and throw a RestartResponseException.

Eelco

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org