You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Jürgen Lind <Ju...@iteratec.de> on 2012/04/26 11:05:28 UTC

setResponsePage in ajax call

Hi,

I have difficulties in using the setResponsePage in ajax call as Wicket seems to direct the
call to a relative URL. As a result, the request is made to the root context an that gives me
a 404.

The scenario is as follows: I have a login form and would like to provide user feedback on
submission errors as ajax responses. Upon success, the user should be redirected to a new
page.

I have already found a thread on a similar issue and there it said, that this was fixed in 1.4.7.
As I am using 1.5.3 this should presumably work. Am I doing something wrong here?

Cheers,

Jürgen

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


Re: setResponsePage in ajax call

Posted by Martin Grigorov <mg...@apache.org>.
It should work even with the Page variant.
Please create a quickstart and attach it to a ticket.

On Thu, Apr 26, 2012 at 1:58 PM, Jürgen Lind <Ju...@iteratec.de> wrote:
> Hi Martin,
>
> thnaks for your reply and the explanation, I have now switched to the
> class-based
> variant and it works like it should.
>
> J.
>
>
> On 26.04.2012 12:05, Martin Grigorov wrote:
>>
>> On Thu, Apr 26, 2012 at 12:50 PM, Jürgen Lind<Ju...@iteratec.de>
>>  wrote:
>>>
>>> Thanks for the quick responses... First of all the code sample: in my
>>> LoginPanel
>>> I have a method that is invoked if the user authentication succeeds:
>>>
>>>      protected void onSuccess(AuthenticatedUser user, AjaxRequestTarget
>>> target) {
>>>        EmobWebSession.get().setAuthenticatedUser(user);
>>>
>>>        if (!LoginPage.this.continueToOriginalDestination()) {
>>>          PageParameters pp = new PageParameters();
>>>          pp.add("page", "fleetlist");
>>>          setResponsePage(new DesktopPage(pp));
>>
>>
>> There is a small but important difference between
>> setResponsePage(Page) and setResponsePage(Class).
>> In most cases I'd recommend to use the Class variant because it
>> produces nicer urls if the page class is mounted.
>>
>> What should happen in your case:
>> by using the Page variant Wicket will render DesktopPage in the Ajax
>> request, will store a BufferedWebResponse for it in the Application
>> and will do a redirect to url like ../wicket/page?pageId. The redirect
>> will be done as I explained in my previous mail - by returning
>> <ajax-response<redirect>...</></>  and reload the page with:
>> document.location=.../wicket/page?pageId. This request will be handled
>> by BufferedResponseMapper because it will find stored response for
>> that url.
>>
>>>        }
>>>      }
>>>
>>> this code leads me to the root context of the server... Oddly enough, I
>>> do
>>> not see a
>>> redirect reponse neither in firebug nor in TamperData...
>>>
>>> If I replace the setResponsePage call with the following code, everything
>>> works just
>>> fine:
>>>          getRequestCycle().scheduleRequestHandlerAfterCurrent(
>>>              new RedirectRequestHandler("/desktop"));
>>>
>>> Is that a valid approach to achieving my goal or ist this just voodoo
>>> programming?
>>>
>>> J.
>>>
>>>
>>>
>>> On 26.04.2012 11:28, Martin Grigorov wrote:
>>>>
>>>>
>>>> Hi Juergen,
>>>>
>>>> This scenario should work just fine.
>>>> Wicket returns<redirect>./some/relative/url</redirect>    in the Ajax
>>>> response and uses window.location=url to do the "redirect"
>>>> Please try with 1.5.5 and create a ticket with a quickstart if it
>>>> still fails for you.
>>>>
>>>> On Thu, Apr 26, 2012 at 12:05 PM, Jürgen Lind<Ju...@iteratec.de>
>>>>  wrote:
>>>>>
>>>>>
>>>>> Hi,
>>>>>
>>>>> I have difficulties in using the setResponsePage in ajax call as Wicket
>>>>> seems to direct the
>>>>> call to a relative URL. As a result, the request is made to the root
>>>>> context
>>>>> an that gives me
>>>>> a 404.
>>>>>
>>>>> The scenario is as follows: I have a login form and would like to
>>>>> provide
>>>>> user feedback on
>>>>> submission errors as ajax responses. Upon success, the user should be
>>>>> redirected to a new
>>>>> page.
>>>>>
>>>>> I have already found a thread on a similar issue and there it said,
>>>>> that
>>>>> this was fixed in 1.4.7.
>>>>> As I am using 1.5.3 this should presumably work. Am I doing something
>>>>> wrong
>>>>> here?
>>>>>
>>>>> Cheers,
>>>>>
>>>>> Jürgen
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Mit freundlichen Grüßen,
>>>
>>> Jürgen Lind
>>>
>>> --
>>> Dr. Jürgen Lind
>>> iteratec GmbH                Fon: +49 (0)89 614551-44
>>> Inselkammerstrasse 4         Fax: +49 (0)89 614551-10
>>> 82008 Unterhaching           Web: www.iteratec.de
>>>
>>> Sitz und Registergericht der iteratec GmbH: München HRB 113 519
>>> Geschäftsführer: Klaus Eberhardt, Mark Goerke, Inge Hanschke, Ralf Menzel
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>
>>
>>
>
>
> --
> Mit freundlichen Grüßen,
>
> Jürgen Lind
>
> --
> Dr. Jürgen Lind
> iteratec GmbH                Fon: +49 (0)89 614551-44
> Inselkammerstrasse 4         Fax: +49 (0)89 614551-10
> 82008 Unterhaching           Web: www.iteratec.de
>
> Sitz und Registergericht der iteratec GmbH: München HRB 113 519
> Geschäftsführer: Klaus Eberhardt, Mark Goerke, Inge Hanschke, Ralf Menzel
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



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

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


Re: setResponsePage in ajax call

Posted by Jürgen Lind <Ju...@iteratec.de>.
Hi Martin,

thnaks for your reply and the explanation, I have now switched to the class-based
variant and it works like it should.

J.

On 26.04.2012 12:05, Martin Grigorov wrote:
> On Thu, Apr 26, 2012 at 12:50 PM, Jürgen Lind<Ju...@iteratec.de>  wrote:
>> Thanks for the quick responses... First of all the code sample: in my
>> LoginPanel
>> I have a method that is invoked if the user authentication succeeds:
>>
>>       protected void onSuccess(AuthenticatedUser user, AjaxRequestTarget
>> target) {
>>         EmobWebSession.get().setAuthenticatedUser(user);
>>
>>         if (!LoginPage.this.continueToOriginalDestination()) {
>>           PageParameters pp = new PageParameters();
>>           pp.add("page", "fleetlist");
>>           setResponsePage(new DesktopPage(pp));
>
> There is a small but important difference between
> setResponsePage(Page) and setResponsePage(Class).
> In most cases I'd recommend to use the Class variant because it
> produces nicer urls if the page class is mounted.
>
> What should happen in your case:
> by using the Page variant Wicket will render DesktopPage in the Ajax
> request, will store a BufferedWebResponse for it in the Application
> and will do a redirect to url like ../wicket/page?pageId. The redirect
> will be done as I explained in my previous mail - by returning
> <ajax-response<redirect>...</></>  and reload the page with:
> document.location=.../wicket/page?pageId. This request will be handled
> by BufferedResponseMapper because it will find stored response for
> that url.
>
>>         }
>>       }
>>
>> this code leads me to the root context of the server... Oddly enough, I do
>> not see a
>> redirect reponse neither in firebug nor in TamperData...
>>
>> If I replace the setResponsePage call with the following code, everything
>> works just
>> fine:
>>           getRequestCycle().scheduleRequestHandlerAfterCurrent(
>>               new RedirectRequestHandler("/desktop"));
>>
>> Is that a valid approach to achieving my goal or ist this just voodoo
>> programming?
>>
>> J.
>>
>>
>>
>> On 26.04.2012 11:28, Martin Grigorov wrote:
>>>
>>> Hi Juergen,
>>>
>>> This scenario should work just fine.
>>> Wicket returns<redirect>./some/relative/url</redirect>    in the Ajax
>>> response and uses window.location=url to do the "redirect"
>>> Please try with 1.5.5 and create a ticket with a quickstart if it
>>> still fails for you.
>>>
>>> On Thu, Apr 26, 2012 at 12:05 PM, Jürgen Lind<Ju...@iteratec.de>
>>>   wrote:
>>>>
>>>> Hi,
>>>>
>>>> I have difficulties in using the setResponsePage in ajax call as Wicket
>>>> seems to direct the
>>>> call to a relative URL. As a result, the request is made to the root
>>>> context
>>>> an that gives me
>>>> a 404.
>>>>
>>>> The scenario is as follows: I have a login form and would like to provide
>>>> user feedback on
>>>> submission errors as ajax responses. Upon success, the user should be
>>>> redirected to a new
>>>> page.
>>>>
>>>> I have already found a thread on a similar issue and there it said, that
>>>> this was fixed in 1.4.7.
>>>> As I am using 1.5.3 this should presumably work. Am I doing something
>>>> wrong
>>>> here?
>>>>
>>>> Cheers,
>>>>
>>>> Jürgen
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>
>>>
>>>
>>
>>
>> --
>> Mit freundlichen Grüßen,
>>
>> Jürgen Lind
>>
>> --
>> Dr. Jürgen Lind
>> iteratec GmbH                Fon: +49 (0)89 614551-44
>> Inselkammerstrasse 4         Fax: +49 (0)89 614551-10
>> 82008 Unterhaching           Web: www.iteratec.de
>>
>> Sitz und Registergericht der iteratec GmbH: München HRB 113 519
>> Geschäftsführer: Klaus Eberhardt, Mark Goerke, Inge Hanschke, Ralf Menzel
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>
>


-- 
Mit freundlichen Grüßen,

Jürgen Lind

--
Dr. Jürgen Lind
iteratec GmbH                Fon: +49 (0)89 614551-44
Inselkammerstrasse 4         Fax: +49 (0)89 614551-10
82008 Unterhaching           Web: www.iteratec.de

Sitz und Registergericht der iteratec GmbH: München HRB 113 519
Geschäftsführer: Klaus Eberhardt, Mark Goerke, Inge Hanschke, Ralf Menzel

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


Re: setResponsePage in ajax call

Posted by Martin Grigorov <mg...@apache.org>.
On Thu, Apr 26, 2012 at 12:50 PM, Jürgen Lind <Ju...@iteratec.de> wrote:
> Thanks for the quick responses... First of all the code sample: in my
> LoginPanel
> I have a method that is invoked if the user authentication succeeds:
>
>      protected void onSuccess(AuthenticatedUser user, AjaxRequestTarget
> target) {
>        EmobWebSession.get().setAuthenticatedUser(user);
>
>        if (!LoginPage.this.continueToOriginalDestination()) {
>          PageParameters pp = new PageParameters();
>          pp.add("page", "fleetlist");
>          setResponsePage(new DesktopPage(pp));

There is a small but important difference between
setResponsePage(Page) and setResponsePage(Class).
In most cases I'd recommend to use the Class variant because it
produces nicer urls if the page class is mounted.

What should happen in your case:
by using the Page variant Wicket will render DesktopPage in the Ajax
request, will store a BufferedWebResponse for it in the Application
and will do a redirect to url like ../wicket/page?pageId. The redirect
will be done as I explained in my previous mail - by returning
<ajax-response<redirect>...</></> and reload the page with:
document.location=.../wicket/page?pageId. This request will be handled
by BufferedResponseMapper because it will find stored response for
that url.

>        }
>      }
>
> this code leads me to the root context of the server... Oddly enough, I do
> not see a
> redirect reponse neither in firebug nor in TamperData...
>
> If I replace the setResponsePage call with the following code, everything
> works just
> fine:
>          getRequestCycle().scheduleRequestHandlerAfterCurrent(
>              new RedirectRequestHandler("/desktop"));
>
> Is that a valid approach to achieving my goal or ist this just voodoo
> programming?
>
> J.
>
>
>
> On 26.04.2012 11:28, Martin Grigorov wrote:
>>
>> Hi Juergen,
>>
>> This scenario should work just fine.
>> Wicket returns<redirect>./some/relative/url</redirect>  in the Ajax
>> response and uses window.location=url to do the "redirect"
>> Please try with 1.5.5 and create a ticket with a quickstart if it
>> still fails for you.
>>
>> On Thu, Apr 26, 2012 at 12:05 PM, Jürgen Lind<Ju...@iteratec.de>
>>  wrote:
>>>
>>> Hi,
>>>
>>> I have difficulties in using the setResponsePage in ajax call as Wicket
>>> seems to direct the
>>> call to a relative URL. As a result, the request is made to the root
>>> context
>>> an that gives me
>>> a 404.
>>>
>>> The scenario is as follows: I have a login form and would like to provide
>>> user feedback on
>>> submission errors as ajax responses. Upon success, the user should be
>>> redirected to a new
>>> page.
>>>
>>> I have already found a thread on a similar issue and there it said, that
>>> this was fixed in 1.4.7.
>>> As I am using 1.5.3 this should presumably work. Am I doing something
>>> wrong
>>> here?
>>>
>>> Cheers,
>>>
>>> Jürgen
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>
>>
>>
>
>
> --
> Mit freundlichen Grüßen,
>
> Jürgen Lind
>
> --
> Dr. Jürgen Lind
> iteratec GmbH                Fon: +49 (0)89 614551-44
> Inselkammerstrasse 4         Fax: +49 (0)89 614551-10
> 82008 Unterhaching           Web: www.iteratec.de
>
> Sitz und Registergericht der iteratec GmbH: München HRB 113 519
> Geschäftsführer: Klaus Eberhardt, Mark Goerke, Inge Hanschke, Ralf Menzel
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



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

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


Re: setResponsePage in ajax call

Posted by Jürgen Lind <Ju...@iteratec.de>.
Thanks for the quick responses... First of all the code sample: in my LoginPanel
I have a method that is invoked if the user authentication succeeds:

       protected void onSuccess(AuthenticatedUser user, AjaxRequestTarget target) {
         EmobWebSession.get().setAuthenticatedUser(user);

         if (!LoginPage.this.continueToOriginalDestination()) {
           PageParameters pp = new PageParameters();
           pp.add("page", "fleetlist");
           setResponsePage(new DesktopPage(pp));
         }
       }

this code leads me to the root context of the server... Oddly enough, I do not see a
redirect reponse neither in firebug nor in TamperData...

If I replace the setResponsePage call with the following code, everything works just
fine:
           getRequestCycle().scheduleRequestHandlerAfterCurrent(
               new RedirectRequestHandler("/desktop"));

Is that a valid approach to achieving my goal or ist this just voodoo programming?

J.


On 26.04.2012 11:28, Martin Grigorov wrote:
> Hi Juergen,
>
> This scenario should work just fine.
> Wicket returns<redirect>./some/relative/url</redirect>  in the Ajax
> response and uses window.location=url to do the "redirect"
> Please try with 1.5.5 and create a ticket with a quickstart if it
> still fails for you.
>
> On Thu, Apr 26, 2012 at 12:05 PM, Jürgen Lind<Ju...@iteratec.de>  wrote:
>> Hi,
>>
>> I have difficulties in using the setResponsePage in ajax call as Wicket
>> seems to direct the
>> call to a relative URL. As a result, the request is made to the root context
>> an that gives me
>> a 404.
>>
>> The scenario is as follows: I have a login form and would like to provide
>> user feedback on
>> submission errors as ajax responses. Upon success, the user should be
>> redirected to a new
>> page.
>>
>> I have already found a thread on a similar issue and there it said, that
>> this was fixed in 1.4.7.
>> As I am using 1.5.3 this should presumably work. Am I doing something wrong
>> here?
>>
>> Cheers,
>>
>> Jürgen
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>
>


-- 
Mit freundlichen Grüßen,

Jürgen Lind

--
Dr. Jürgen Lind
iteratec GmbH                Fon: +49 (0)89 614551-44
Inselkammerstrasse 4         Fax: +49 (0)89 614551-10
82008 Unterhaching           Web: www.iteratec.de

Sitz und Registergericht der iteratec GmbH: München HRB 113 519
Geschäftsführer: Klaus Eberhardt, Mark Goerke, Inge Hanschke, Ralf Menzel

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


Re: setResponsePage in ajax call

Posted by Martin Grigorov <mg...@apache.org>.
Hi Juergen,

This scenario should work just fine.
Wicket returns <redirect>./some/relative/url</redirect> in the Ajax
response and uses window.location=url to do the "redirect"
Please try with 1.5.5 and create a ticket with a quickstart if it
still fails for you.

On Thu, Apr 26, 2012 at 12:05 PM, Jürgen Lind <Ju...@iteratec.de> wrote:
> Hi,
>
> I have difficulties in using the setResponsePage in ajax call as Wicket
> seems to direct the
> call to a relative URL. As a result, the request is made to the root context
> an that gives me
> a 404.
>
> The scenario is as follows: I have a login form and would like to provide
> user feedback on
> submission errors as ajax responses. Upon success, the user should be
> redirected to a new
> page.
>
> I have already found a thread on a similar issue and there it said, that
> this was fixed in 1.4.7.
> As I am using 1.5.3 this should presumably work. Am I doing something wrong
> here?
>
> Cheers,
>
> Jürgen
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



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

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


Re: setResponsePage in ajax call

Posted by Jochen Mader <pf...@gmail.com>.
Please provide some code-samples to show us what you are doing.
If it's related to an older issue it would be great if you could give more
details (link to the issue).

Am 26.04.12 11:05 schrieb "Jürgen Lind" unter <Ju...@iteratec.de>:

>Hi,
>
>I have difficulties in using the setResponsePage in ajax call as Wicket
>seems to direct the
>call to a relative URL. As a result, the request is made to the root
>context an that gives me
>a 404.
>
>The scenario is as follows: I have a login form and would like to provide
>user feedback on
>submission errors as ajax responses. Upon success, the user should be
>redirected to a new
>page.
>
>I have already found a thread on a similar issue and there it said, that
>this was fixed in 1.4.7.
>As I am using 1.5.3 this should presumably work. Am I doing something
>wrong here?
>
>Cheers,
>
>Jürgen
>
>---------------------------------------------------------------------
>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