You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Sumit Raja <su...@gmail.com> on 2010/01/13 16:13:27 UTC

Help with Form submission and Ajax buttons

Hi,

Beginner question with Form handling: I have a panel that accepts name value
pairs in text fields.On the form there is an ajax button to add a value, an
ajax button to remove a value and an actual form submit button. I  have a
onSubmit handler for the form that actually processes the NV pairs once the
user has finished. When either the plus or minus button are pressed I update
the form's model and have the form rerenderd. For this to work correctly I
need the form's model updated but not have the form's onSubmit handler
called.  Setting default form processing to false on the twoajx  buttons did
not work as the model was not updated correctly (NPEs thrown)

I have overridden the two buttons' onSubmit() handler to set a flag (as
these seem to be called before the form's onSubmit()) and check for this
flag in the form's onSubmit and save or ignore the submit accordingly. Is
this the right way to do this?

I don't want to use another button to do the 'true' form submission as I
need to have this panel embedded in a wizard as well as an ordinary page.

Thanks

Sumit

Re: Help with Form submission and Ajax buttons

Posted by Sumit Raja <su...@gmail.com>.
Excellent thanks, exactly what I needed.

2010/1/13 Stijn Maller <st...@gmail.com>

> In the form's onSubmit() handler you can use findSubmittingButton() for
> your
> check instead.
>
> 2010/1/13 Sumit Raja <su...@gmail.com>
>
> > Hi,
> >
> > Beginner question with Form handling: I have a panel that accepts name
> > value
> > pairs in text fields.On the form there is an ajax button to add a value,
> an
> > ajax button to remove a value and an actual form submit button. I  have a
> > onSubmit handler for the form that actually processes the NV pairs once
> the
> > user has finished. When either the plus or minus button are pressed I
> > update
> > the form's model and have the form rerenderd. For this to work correctly
> I
> > need the form's model updated but not have the form's onSubmit handler
> > called.  Setting default form processing to false on the twoajx  buttons
> > did
> > not work as the model was not updated correctly (NPEs thrown)
> >
> > I have overridden the two buttons' onSubmit() handler to set a flag (as
> > these seem to be called before the form's onSubmit()) and check for this
> > flag in the form's onSubmit and save or ignore the submit accordingly. Is
> > this the right way to do this?
> >
> > I don't want to use another button to do the 'true' form submission as I
> > need to have this panel embedded in a wizard as well as an ordinary page.
> >
> > Thanks
> >
> > Sumit
> >
>

Re: Help with Form submission and Ajax buttons

Posted by Stijn Maller <st...@gmail.com>.
In the form's onSubmit() handler you can use findSubmittingButton() for your
check instead.

2010/1/13 Sumit Raja <su...@gmail.com>

> Hi,
>
> Beginner question with Form handling: I have a panel that accepts name
> value
> pairs in text fields.On the form there is an ajax button to add a value, an
> ajax button to remove a value and an actual form submit button. I  have a
> onSubmit handler for the form that actually processes the NV pairs once the
> user has finished. When either the plus or minus button are pressed I
> update
> the form's model and have the form rerenderd. For this to work correctly I
> need the form's model updated but not have the form's onSubmit handler
> called.  Setting default form processing to false on the twoajx  buttons
> did
> not work as the model was not updated correctly (NPEs thrown)
>
> I have overridden the two buttons' onSubmit() handler to set a flag (as
> these seem to be called before the form's onSubmit()) and check for this
> flag in the form's onSubmit and save or ignore the submit accordingly. Is
> this the right way to do this?
>
> I don't want to use another button to do the 'true' form submission as I
> need to have this panel embedded in a wizard as well as an ordinary page.
>
> Thanks
>
> Sumit
>