Nested Forms in 1.4.x - order of calling onSubmit

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Nested Forms in 1.4.x - order of calling onSubmit

Bruno Borges
After playing with Nested Forms in WIcket 1.4.18, I found out that the
onSubmit method of these forms is called at the end of the process.

If a parent form has a button and this button is submited, its onSubmit
method is called before anything.
Then, parent form's onSubmit method is called.
Then, it will navigate through all nested forms calling their onSubmit
method.
The problem is that I have a nested forms that changes a value in the model
that is associated with the parent form.

My usecase has an AddressPanel with a form inside that manipulates the
"person.address" object. This panel is created by informing two
IModel<Address> objects.
One is to be used as the Person's address. The other one is to be used as
copy of, because of a CheckBox that states "Use the same address as of
account holder".

On its onSubmit method, is where I clone the account holder address to the
actual person.address.

But because of the order of how Wicket calls onSubmit methods, this
implementation fails.

Any suggestion?

Should Wicket call all nested forms' onSubmit methods before calling the
Button's onSubmit (or the parent form onSubmit) ?

Thanks,

*Bruno Borges*
(21) 7672-7099
*www.brunoborges.com*
Reply | Threaded
Open this post in threaded view
|

Re: Nested Forms in 1.4.x - order of calling onSubmit

Martin Grigorov-4
On Tue, Oct 18, 2011 at 3:11 PM, Bruno Borges <[hidden email]> wrote:

> After playing with Nested Forms in WIcket 1.4.18, I found out that the
> onSubmit method of these forms is called at the end of the process.
>
> If a parent form has a button and this button is submited, its onSubmit
> method is called before anything.
> Then, parent form's onSubmit method is called.
> Then, it will navigate through all nested forms calling their onSubmit
> method.
> The problem is that I have a nested forms that changes a value in the model
> that is associated with the parent form.
>
> My usecase has an AddressPanel with a form inside that manipulates the
> "person.address" object. This panel is created by informing two
> IModel<Address> objects.
> One is to be used as the Person's address. The other one is to be used as
> copy of, because of a CheckBox that states "Use the same address as of
> account holder".
>
> On its onSubmit method, is where I clone the account holder address to the
> actual person.address.
>
> But because of the order of how Wicket calls onSubmit methods, this
> implementation fails.
>
> Any suggestion?
>
> Should Wicket call all nested forms' onSubmit methods before calling the
> Button's onSubmit (or the parent form onSubmit) ?
This is how it behaves in Wicket 1.5.
See org.apache.wicket.markup.html.form.Form.delegateSubmit(IFormSubmitter)

You are recommended to upgrade! ;-)
>
> Thanks,
>
> *Bruno Borges*
> (21) 7672-7099
> *www.brunoborges.com*
>



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

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

Reply | Threaded
Open this post in threaded view
|

Re: Nested Forms in 1.4.x - order of calling onSubmit

Bruno Borges
Can't upgrade... :-(

Political issues (read: conservative corporation with terrible decision
makers)

*Bruno Borges*
(21) 7672-7099
*www.brunoborges.com*



On Thu, Oct 20, 2011 at 9:28 AM, Martin Grigorov <[hidden email]>wrote:

> On Tue, Oct 18, 2011 at 3:11 PM, Bruno Borges <[hidden email]>
> wrote:
> > After playing with Nested Forms in WIcket 1.4.18, I found out that the
> > onSubmit method of these forms is called at the end of the process.
> >
> > If a parent form has a button and this button is submited, its onSubmit
> > method is called before anything.
> > Then, parent form's onSubmit method is called.
> > Then, it will navigate through all nested forms calling their onSubmit
> > method.
> > The problem is that I have a nested forms that changes a value in the
> model
> > that is associated with the parent form.
> >
> > My usecase has an AddressPanel with a form inside that manipulates the
> > "person.address" object. This panel is created by informing two
> > IModel<Address> objects.
> > One is to be used as the Person's address. The other one is to be used as
> > copy of, because of a CheckBox that states "Use the same address as of
> > account holder".
> >
> > On its onSubmit method, is where I clone the account holder address to
> the
> > actual person.address.
> >
> > But because of the order of how Wicket calls onSubmit methods, this
> > implementation fails.
> >
> > Any suggestion?
> >
> > Should Wicket call all nested forms' onSubmit methods before calling the
> > Button's onSubmit (or the parent form onSubmit) ?
> This is how it behaves in Wicket 1.5.
> See org.apache.wicket.markup.html.form.Form.delegateSubmit(IFormSubmitter)
>
> You are recommended to upgrade! ;-)
> >
> > Thanks,
> >
> > *Bruno Borges*
> > (21) 7672-7099
> > *www.brunoborges.com*
> >
>
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Nested Forms in 1.4.x - order of calling onSubmit

Martijn Dashorst
Administrator
On Thu, Oct 20, 2011 at 3:07 PM, Bruno Borges <[hidden email]> wrote:
> Can't upgrade... :-(
>
> Political issues (read: conservative corporation with terrible decision
> makers)

They let you use wicket, so they can't be too bad :)

Martijn

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