You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Adam Koch <ad...@dogtired.org> on 2007/10/15 19:50:05 UTC

feedback message not shown from ajax button when setting new response page

I'm having a problem with the feedback panel in conjunction with the
AjaxButton and setResponsePage(). There are two pages, a home page and a sub
page. When the user submits a form successfully on the sub page, I would
like the home page to display with an informational message.

Here is some code:
// my form
add(new AjaxButton("submitButton", this) {
    protected void onSubmit(AjaxRequestTarget target, Form form) {
      // nothing, want the form submit to do the work
    }
    protected void onError(...) {
      // refresh the feedback panel without refreshing any page
});

protected void onSubmit() {
    info("successful!");
    setRedirect(false);
    setResponsePage(HomePage.class);
}

What happens is the new page is displayed, but the info message isn't.

If I use a regular Button, this works, but then I don't get the Ajax
validation of the form.
And if I don't set the response page to another page, then this also works.
(Well, maybe not _that_ code, but the feedback can be refreshed with an info
message.)

Can anybody help me? I'm not sure what else I can do to debug this.

Thanks,
Adam

Re: feedback message not shown from ajax button when setting new response page

Posted by Igor Vaynberg <ig...@gmail.com>.
if you want to display an entirely new page from an ajax request then yes,
you have to redirect. whether that is done via a window.location or another
method doesnt matter...

-igor


On 10/15/07, Adam Koch <ad...@dogtired.org> wrote:
>
> That seems easy enough. Thanks!
>
> Tell me if this is right. If we send an Ajax request from the browser,
> then
> the only way to get it to refresh the page is to tell it to redirect.
> That's
> why all Ajax calls that have render a new page have to redirect.
>
> Thanks,
> Adam
>
> On 10/15/07, Igor Vaynberg <ig...@gmail.com> wrote:
> >
> > if you have feedback messages that need to last across requests/pages
> you
> > need to use getsession().info() instead
> >
> > -igor
> >
> >
> > On 10/15/07, Adam Koch <ad...@dogtired.org> wrote:
> > >
> > > I'm having a problem with the feedback panel in conjunction with the
> > > AjaxButton and setResponsePage(). There are two pages, a home page and
> a
> > > sub
> > > page. When the user submits a form successfully on the sub page, I
> would
> > > like the home page to display with an informational message.
> > >
> > > Here is some code:
> > > // my form
> > > add(new AjaxButton("submitButton", this) {
> > >     protected void onSubmit(AjaxRequestTarget target, Form form) {
> > >       // nothing, want the form submit to do the work
> > >     }
> > >     protected void onError(...) {
> > >       // refresh the feedback panel without refreshing any page
> > > });
> > >
> > > protected void onSubmit() {
> > >     info("successful!");
> > >     setRedirect(false);
> > >     setResponsePage(HomePage.class);
> > > }
> > >
> > > What happens is the new page is displayed, but the info message isn't.
> > >
> > > If I use a regular Button, this works, but then I don't get the Ajax
> > > validation of the form.
> > > And if I don't set the response page to another page, then this also
> > > works.
> > > (Well, maybe not _that_ code, but the feedback can be refreshed with
> an
> > > info
> > > message.)
> > >
> > > Can anybody help me? I'm not sure what else I can do to debug this.
> > >
> > > Thanks,
> > > Adam
> > >
> >
>
>
>
> --
> Adam A. Koch
> http://www.outofthemold.com/
>

Re: feedback message not shown from ajax button when setting new response page

Posted by Adam Koch <ad...@dogtired.org>.
That seems easy enough. Thanks!

Tell me if this is right. If we send an Ajax request from the browser, then
the only way to get it to refresh the page is to tell it to redirect. That's
why all Ajax calls that have render a new page have to redirect.

Thanks,
Adam

On 10/15/07, Igor Vaynberg <ig...@gmail.com> wrote:
>
> if you have feedback messages that need to last across requests/pages you
> need to use getsession().info() instead
>
> -igor
>
>
> On 10/15/07, Adam Koch <ad...@dogtired.org> wrote:
> >
> > I'm having a problem with the feedback panel in conjunction with the
> > AjaxButton and setResponsePage(). There are two pages, a home page and a
> > sub
> > page. When the user submits a form successfully on the sub page, I would
> > like the home page to display with an informational message.
> >
> > Here is some code:
> > // my form
> > add(new AjaxButton("submitButton", this) {
> >     protected void onSubmit(AjaxRequestTarget target, Form form) {
> >       // nothing, want the form submit to do the work
> >     }
> >     protected void onError(...) {
> >       // refresh the feedback panel without refreshing any page
> > });
> >
> > protected void onSubmit() {
> >     info("successful!");
> >     setRedirect(false);
> >     setResponsePage(HomePage.class);
> > }
> >
> > What happens is the new page is displayed, but the info message isn't.
> >
> > If I use a regular Button, this works, but then I don't get the Ajax
> > validation of the form.
> > And if I don't set the response page to another page, then this also
> > works.
> > (Well, maybe not _that_ code, but the feedback can be refreshed with an
> > info
> > message.)
> >
> > Can anybody help me? I'm not sure what else I can do to debug this.
> >
> > Thanks,
> > Adam
> >
>



-- 
Adam A. Koch
http://www.outofthemold.com/

Re: feedback message not shown from ajax button when setting new response page

Posted by Igor Vaynberg <ig...@gmail.com>.
if you have feedback messages that need to last across requests/pages you
need to use getsession().info() instead

-igor


On 10/15/07, Adam Koch <ad...@dogtired.org> wrote:
>
> I'm having a problem with the feedback panel in conjunction with the
> AjaxButton and setResponsePage(). There are two pages, a home page and a
> sub
> page. When the user submits a form successfully on the sub page, I would
> like the home page to display with an informational message.
>
> Here is some code:
> // my form
> add(new AjaxButton("submitButton", this) {
>     protected void onSubmit(AjaxRequestTarget target, Form form) {
>       // nothing, want the form submit to do the work
>     }
>     protected void onError(...) {
>       // refresh the feedback panel without refreshing any page
> });
>
> protected void onSubmit() {
>     info("successful!");
>     setRedirect(false);
>     setResponsePage(HomePage.class);
> }
>
> What happens is the new page is displayed, but the info message isn't.
>
> If I use a regular Button, this works, but then I don't get the Ajax
> validation of the form.
> And if I don't set the response page to another page, then this also
> works.
> (Well, maybe not _that_ code, but the feedback can be refreshed with an
> info
> message.)
>
> Can anybody help me? I'm not sure what else I can do to debug this.
>
> Thanks,
> Adam
>

Re: feedback message not shown from ajax button when setting new response page

Posted by Adam Koch <ad...@dogtired.org>.
I think I found the reason:
    /**
     * If it's an ajax request we always redirect.
     *
     * @see org.apache.wicket.RequestCycle#isRedirect()
     */
    public final boolean isRedirect()
    {
        if (getWebRequest().isAjax())
        {
            return true;
        }
        else
        {
            return super.isRedirect();
        }
    }

This is inside WebRequestCycle.  Can someone explain why if it's an ajax
request it's always a redirect?

On 10/15/07, Adam Koch <ad...@dogtired.org> wrote:
>
> I'm having a problem with the feedback panel in conjunction with the
> AjaxButton and setResponsePage(). There are two pages, a home page and a sub
> page. When the user submits a form successfully on the sub page, I would
> like the home page to display with an informational message.
>
> Here is some code:
> // my form
> add(new AjaxButton("submitButton", this) {
>     protected void onSubmit(AjaxRequestTarget target, Form form) {
>       // nothing, want the form submit to do the work
>     }
>     protected void onError(...) {
>       // refresh the feedback panel without refreshing any page
> });
>
> protected void onSubmit() {
>     info("successful!");
>     setRedirect(false);
>     setResponsePage(HomePage.class);
> }
>
> What happens is the new page is displayed, but the info message isn't.
>
> If I use a regular Button, this works, but then I don't get the Ajax
> validation of the form.
> And if I don't set the response page to another page, then this also
> works. (Well, maybe not _that_ code, but the feedback can be refreshed with
> an info message.)
>
> Can anybody help me? I'm not sure what else I can do to debug this.
>
> Thanks,
> Adam




-- 
Adam A. Koch
http://www.outofthemold.com/