For authentication with services such as Facebook, we redirect to Facebook, they do their authentication stuff, then they redirect back. Once they've redirected back, our code runs which does some things, then displays a response page. Which response page gets displayed depends on any number of things.
What we are doing now is:
class RedirectTargetPage extends WebPage {
@Override public void onBeforeRender() {
String getParam = getRequest().getQueryParameters()
.getParamterValue("get-param");
......
if (...) setResponsePage(PageOne.class);
else if (...) setResposnePage(PageTwo.class);
else ... // etc
}
}
we then use urlFor(Class<Page>)
to find the URL to this page, pass it to Facebook, Facebook redirects back to us after authentication, everything works well.
However, this isn't really a page? I mean it's just a piece of code sitting behind a URL which, at the end, calls setResponsePage
. It seemed to me that what I was writing was just something that handled requests, it seemed I could create a IRequestHandler
instead and get a URL to it using urlFor(IRequestHandler)
with something like:
class RedirectTarget implements IRequestHandler {
@Override public void respond(IRequestCycle requestCycle) {
String getParam = requestCycle.getRequest().getQueryParameters()
.getParameterValue("get-param");
....
if (...) requestCycle.setResposnePage(..)
}
}
Alas, urlFor(new RedirectTarget())
delivers null
! What's going wrong? What can I do? Overriding onBeforeReder
works but it doesn't seem elegant....