hej,
maybe Im still confusing basics concepts but this is quite new stuff.

recently I had few problems with redirecting after setting cookies (my
application was setup to use render-to-buffer default strategy).
simple setResponsePage is not good enough as cookies are lost then I
was advised to use ReplaceHandlerException and rewrite response
actions (like setting cookies) from response to original response.
private void rewriteResponseActions()
{
    final RequestCycle cycle = RequestCycle.get();
    Response response = cycle.getResponse();
    Response originalResponse = cycle.getOriginalResponse();
    //it only makes sense for IMetaDataBufferingWebResponse
    //in tests originalResponse is same as response
    if (originalResponse != response && response instanceof
IMetaDataBufferingWebResponse)
    {
        IMetaDataBufferingWebResponse bufferingWebResponse =
(IMetaDataBufferingWebResponse) response;
        bufferingWebResponse.writeMetaData((WebResponse) originalResponse);
    }
}
this works fine, redirect is not scheduled and is immediately performed.

there is one but however!
setting my application to use one-pass-render strategy breaks url
rendering. the app is redirected correctly but url is as it was before
redirecting.
I was investigating that and it seems it is because in
WebPageRenderer#respond(RequestCycle requestCycle) currentUrl (the one
from before redirection) is used instead of targetUrl (the one where
we want redirect to)

if (isOnePassRender() && isAjax == false && getRedirectPolicy() !=
RedirectPolicy.ALWAYS_REDIRECT)
then
BufferedWebResponse response = renderPage(currentUrl, requestCycle);
// but new requestHandler (the one from replace handler exception) is
used

now probably I should pass ALWAYS_REDIRECT instead of AUTO_REDIRECT to
just created ReplaceHandlerException and it would fix all my problems
but I didnt.
I decided that I will go back to setResponsePage and reuse
rewiriteResponseActions just before redirection. And it all works fine
(yeah I really dont need immediate redirection), cookies are
persisted. So why this is not part of default behaviour?????

the other thing is that wicket tester uses totally different logic and
it always passes my redirect tests no matter which redirection method
I choose (setResponsePage or throw ReplaceHandlerException) as
cycle.getResponse() and cycle.getOriginalResponse() returns the same
object and cookies are already there.

If this is WAD then OK but maybe it could be described better somewhere.

pozdrawiam
Paweł Kamiński

kami...@gmail.com
pkaminski....@gmail.com
______________________

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to