Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect to external non-Wicket page in Wicket 1.5

Tags:

wicket

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.

like image 662
Laban Okune Anunda Avatar asked Apr 27 '11 07:04

Laban Okune Anunda


2 Answers

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);
like image 149
sother Avatar answered Nov 16 '22 17:11

sother


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

like image 5
martin-g Avatar answered Nov 16 '22 17:11

martin-g