Laban Okune Anunda
Laban Okune Anunda

Reputation: 96

Redirect to external non-Wicket page in Wicket 1.5

How do I do the following in Wicket 1.5?

page.getRequestCycle().setRequestTarget(new RedirectRequestTarget("http://www.facebook.com/login.php?api_key="+ _apiKey + "&v=1.0"));

I want to do a Facebook application using Wicket 1.5, and I want at some point to redirect the user to the Facebook login page. A lot has changed as highlighted in Migrating to Wicket 1.5.

Upvotes: 7

Views: 7564

Answers (2)

martin-g
martin-g

Reputation: 17503

See org.apache.wicket.request.cycle.RequestCycle.scheduleRequestHandlerAfterCurrent(IRequestHandler) and org.apache.wicket.request.http.handler.RedirectRequestHandler.RedirectRequestHandler(String)

Upvotes: 5

sother
sother

Reputation: 556

Using HTTP 302 ("Moved Temporarily"):

import org.apache.wicket.request.flow.RedirectToUrlException;
...
throw new RedirectToUrlException(
    "http://www.facebook.com/login.php?api_key="+ _apiKey + "&v=1.0");

Using HTTP 301 ("Moved Permanently", SEO friendly):

import org.apache.wicket.request.flow.RedirectToUrlException;
import javax.servlet.http.HttpServletResponse;
...
throw new RedirectToUrlException(
    "http://www.facebook.com/login.php?api_key="+ _apiKey + "&v=1.0", 
    HttpServletResponse.SC_MOVED_PERMANENTLY);

Upvotes: 9

Related Questions