You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

This page applies to Wicket 1.3/2.0

Normally, you'd use one of the following to redirect to a Wicket page:

setResponsePage(new FooPage(arg0, arg1));
setResponsePage(BarPage.class);

If you're trying to integrate with JSPs or similar, you may need to redirect to a non-Wicket page. Do use then the RedirectRequestTarget where you can specify an url.

public void onSubmit()
{
    // The HTTP RFC says redirects should always be absolute, so we
    // make an absolute path by prefixing with the context path.
    String contextPath = getApplication().getApplicationSettings().getContextPath();
    
    // Make sure no output for the current cycle is ever sent.
    getRequestCycle().setRequestTarget(new RedirectRequestTarget(contextPath + "/path/to/legacyJspFile.jsp"));

}

Note that if you just want to make standard anchor tag links to other pages, don't create a Link and use this method in the onClick() handler; instead use the ExternalLink class.

  • No labels