Thanks Martin,
that worked. Is this still the way to go in wicket 1.5?
Thanks
Mike
On Fri, Sep 2, 2011 at 11:24 AM, Mike Mander<wicket-m...@gmx.de> wrote:
Hi,
my usecase: Google caches page urls from our old shop. Because we changed
the url layout i have to redirect all page requests to the new page.
I did that this way
wicket-1.4.18
@Override
protected void onBeforeRender() {
super.onBeforeRender();
final String url = RequestCycle.get().urlFor(getRedirectPageClass(),
getRedirectPageParameters()).toString();
RedirectRequestTarget target = new RedirectRequestTarget(url) {
@Override
public void respond(RequestCycle requestCycle) {
WebResponse response = (WebResponse) requestCycle.getResponse();
response.reset();
response.getHttpServletResponse().setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
response.redirect(url);
}
};
getRequestCycle().setRequestTarget(target);
}
Until now my wicket 1.5 solution looks like this:
@Override
protected void onBeforeRender() {
super.onBeforeRender();
final String url = RequestCycle.get().urlFor(getRedirectPageClass(),
getRedirectPageParameters()).toString();
RedirectRequestHandler target = new RedirectRequestHandler(url) {
@Override
public void respond(IRequestCycle requestCycle) {
WebResponse response = (WebResponse) requestCycle.getResponse();
response.reset();
((HttpServletResponse)
response.getContainerResponse()).setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
response.redirect(url);
^^^^^^^^^^^^^^^^^^
org.apache.wicket.request.http.WebResponse.sendRedirect(String)
}
};
getRequestCycle().setRequestTarget(target);
^^^^^^^^^^^^^^^
org.apache.wicket.request.cycle.RequestCycle.scheduleRequestHandlerAfterCurrent(IRequestHandler)
}
It is not compiling because of the marked code pieces.
I've already checked the migration guide.
Thanks for helping me out.
Mike
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org