You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Alexandros Karypidis <ak...@yahoo.gr> on 2012/12/26 19:11:07 UTC
Cookies and RestartResponseException
Hi,
I am using CookieUtils to store a cookie. Here's the catch though: after
setting the cookie, I want to redirect the user to a new page, so that
is followed immediately by a RestartResponseException:
new CookieUtils().save("some-key", "some-value")
throw new RestartResponseException(AnotherPage.class);
The net result seems to be that Wicket uses an HTTP 3xx to get the user
agent to go to the new page (which is what I want, since the URL
changes), but the cookie does NOT get set.
If instead of RestartResponseException the I use:
RequestCycle.get().setResponsePage(AnotherPage.class);
...the cookie gets set properly and the redirect occurs as desired, but
I need to perform the redirect in "library code", which should prevent
the calling thread from proceeding beyond the redirect point (which
RestartResponseException nicely addresses).
Is there some way to use RestartResponseException without discarding
cookies?
Cheers,
Alex
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Cookies and RestartResponseException
Posted by Alexandros Karypidis <ak...@yahoo.gr>.
So simple...
I spent the last 8 minutes (i.e. till I received your reply) playing
with a custom PageProvider, trying to set the cookie in
getPageInstance(), (only to find that it doesn't matter since the 3xx
redirect ends up retrieving the page from the default page provider anyway).
Thx!
On 26/12/12 18:19, Sven Meier wrote:
> Use NonResettingRestartException
>
> Sven
>
> On 12/26/2012 07:11 PM, Alexandros Karypidis wrote:
>> Hi,
>>
>> I am using CookieUtils to store a cookie. Here's the catch though:
>> after setting the cookie, I want to redirect the user to a new page,
>> so that is followed immediately by a RestartResponseException:
>>
>> new CookieUtils().save("some-key", "some-value")
>> throw new RestartResponseException(AnotherPage.class);
>>
>> The net result seems to be that Wicket uses an HTTP 3xx to get the
>> user agent to go to the new page (which is what I want, since the URL
>> changes), but the cookie does NOT get set.
>>
>> If instead of RestartResponseException the I use:
>>
>> RequestCycle.get().setResponsePage(AnotherPage.class);
>>
>> ...the cookie gets set properly and the redirect occurs as desired,
>> but I need to perform the redirect in "library code", which should
>> prevent the calling thread from proceeding beyond the redirect point
>> (which RestartResponseException nicely addresses).
>>
>> Is there some way to use RestartResponseException without discarding
>> cookies?
>>
>> Cheers,
>> Alex
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Cookies and RestartResponseException
Posted by Sven Meier <sv...@meiers.net>.
Use NonResettingRestartException
Sven
On 12/26/2012 07:11 PM, Alexandros Karypidis wrote:
> Hi,
>
> I am using CookieUtils to store a cookie. Here's the catch though:
> after setting the cookie, I want to redirect the user to a new page,
> so that is followed immediately by a RestartResponseException:
>
> new CookieUtils().save("some-key", "some-value")
> throw new RestartResponseException(AnotherPage.class);
>
> The net result seems to be that Wicket uses an HTTP 3xx to get the
> user agent to go to the new page (which is what I want, since the URL
> changes), but the cookie does NOT get set.
>
> If instead of RestartResponseException the I use:
>
> RequestCycle.get().setResponsePage(AnotherPage.class);
>
> ...the cookie gets set properly and the redirect occurs as desired,
> but I need to perform the redirect in "library code", which should
> prevent the calling thread from proceeding beyond the redirect point
> (which RestartResponseException nicely addresses).
>
> Is there some way to use RestartResponseException without discarding
> cookies?
>
> Cheers,
> Alex
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org