For now I used the workaround (create a new UrlRenderer(webRequest)) in
ServletWebResponse#encodeRedirectURL().


On Mon, Nov 5, 2012 at 10:12 AM, Martin Grigorov <[email protected]>wrote:

> Hi,
>
> I wanted to improve ServletWebResponse#encodeRedirectUrl() for
> https://issues.apache.org/jira/browse/WICKET-4854 as we did for
> #encodeUrl() in https://issues.apache.org/jira/browse/WICKET-4645 but I
> face a problem that SWR#sendRedirect() is being called in a context where
> the RequestCycle is already detached (i.e. RequestCycle.get() returns null).
>
> The related code is:
> WicketFilter#process()
>
> RequestCycle requestCycle = application.createRequestCycle(webRequest,
> webResponse);
> if (!requestCycle.processRequestAndDetach())
>  {
> if (chain != null)
> {
> chain.doFilter(request, response);
>  }
> res = false;
> }
> else
>  {
> webResponse.flush();
> }
>
> The call to #flush() leads to #sendRedirect().
>
>
> I can workaround the problem by creating a new UrlRenderer to be able to
> render full and relative urls without using
> RequestCycle.get().getUrlRenderer() but I'm not sure whether this is the
> right way. Is it OK to use the WebResponse after detaching the RequestCycle
> as we do now ?
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com <http://jweekend.com/>
>
>


-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>

Reply via email to