Where are you redirecting from? You don't mention where you want to use it.
Nearly anywhere in your processing you can just do this:
throw new RestartResponseAtInterceptPageException(new RedirectPage("
http://www.example.com"));
Or if it's a link and you know the URL ahead of time, just use ExternalLink.
--
Jeremy Thomerson
http://www.wickettraining.com
On Thu, Jan 1, 2009 at 4:56 PM, Warren Bell <[email protected]>wrote:
> I need to redirect to an external page. I saw this solution, but was not
> sure how to use it. Where does this exception get thrown? I do not want to
> instantiate some kind of dummy page.
>
> 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));
> }
> }
> }
>
> Thanks,
>
> Warren
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>