Hi,

On Sun, Nov 6, 2011 at 3:53 PM, kamiseq <[email protected]> wrote:
> hej,
>
> I ve found this
> http://apache-wicket.1842946.n4.nabble.com/Wickettester-cookies-and-redirects-in-Wicket-1-4-15-td3250792.html
>
> but im developing on 1.5.2 and ticket is closed. I believe it is the same 
> case.
>
> this is description:
> I have a page ValidationPage that accepts request, checks parameters
> and sets cookie on response object
>
> ((WebResponse)getRequestCycle().getResponse()).addCookie(new
> Cookie("mycookie", VAL));
>
> then on certain condition I want to redirect to original destination
> or to some set page
>
> if (!continueToOriginalDestination())
> {
>     log.warning("redirect failed redirecting to original destination");
>     throw new RestartResponseException(new MyOtherPage());

RestartResponseException extends ResetResponseException which _resets_
the response, i.e. removes all the collected response body and headers
and starts from a clean state.

Use this instead:
public class NonResettingRestartException extends ReplaceHandlerException {

    public NonResettingRestartException(final Class<? extends Page<?>>
pageClass, final PageParameters params, final RequestCycle cycle) {
        super(createRequestHandler(pageClass, params), true);

        Response response = cycle.getResponse();
        if (response instanceof IMetaDataBufferingWebResponse) {
            IMetaDataBufferingWebResponse bufferingWebResponse =
(IMetaDataBufferingWebResponse) response;
            bufferingWebResponse.writeMetaData((WebResponse)
cycle.getOriginalResponse());
        }
    }

    private static IRequestHandler createRequestHandler(Class<?
extends Page<?>> pageClass, PageParameters params) {
        return new RenderPageRequestHandler(new
PageProvider(pageClass, params));
    }
}

> }
>
> so in test
>
> tester.startPage(ValidationPage.class, pageParameters);
> tester.assertRenderedPage(MyOtherPage.class);
> final Cookie[] cookies = tester.getRequest().getCookies();
> assertNotNull(cookies); - > fail
>
> and I get null, I tried Reponse object but no luck. I thought cookies
> should be resend in next request back to server right?
>
> pozdrawiam
> Paweł Kamiński
>
> [email protected]
> [email protected]
> ______________________
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>



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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to