You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Daniel Bartl <d....@comsysto.com> on 2011/01/20 13:14:13 UTC
Question regarding AjaxFormSubmitBehavior
Have a small question regarding using AjaxFormSubmitBehavoir with nested
forms.
Would like to use it to submit a smaller nested form within a bigger parent
form.
Even though I passed a nested form as a "*form that will be submitted*"
while calling the following constructor of AjaxFormSubmitBehavoir :
/**
* Construct.
*
* @param form
* * form that will be submitted*
* @param event
* javascript event this behavior is attached to, like
onclick
*/
public AjaxFormSubmitBehavior(Form<?> form, String
event) <- passing nested form here
{
super(event);
__form = form;
if (form != null)
{
form.setOutputMarkupId(true);
}
}
I noticed that the AjaxFormSubmitBehavior#onEvent(AjaxRequestTarget target)
executes the following line first:
"getForm().getRootForm().onFormSubmitted();"
Why does it still delegate to the root form?
Shouldn't the line be "getForm().onFormSubmitted();" so that the nested form
and possibly its children get processed only.
Many thanks!
Daniel
Re: Question regarding AjaxFormSubmitBehavior
Posted by Igor Vaynberg <ig...@gmail.com>.
you are welcome to submit a jira issue with a unit test/quickstart
that demonstrates the problem.
-igor
On Fri, Jan 21, 2011 at 5:42 AM, Daniel Bartl <d....@comsysto.com> wrote:
> Many thanks for your feedback!
>
> I am well aware of the fact that HTML spec actually does not allow nested
> forms and that wicket is already doing great job while transforming those
> nested forms into divs.
>
> I also expected that the bigger form gets submitted as well but only the
> nested one processed and the rest ignored, but that's not exactly what's
> happening in our case.
>
> The reason for this is that AjaxFormSubmitBehavior always delegates to the
> #onFormSubmitted() of the root form
>
> AjaxFormSubmitBehavior, line 135:
>
> getForm().getRootForm().onFormSubmitted();
>
> which then looks up if there is any enabled, visible
> IFormSubmittingComponent in the hierarchy that has been triggered. Only in
> case that one such IFormSubmittingComponent gets identified, it sets
> *formToProcess* to the form of the identified submittingComponent and then
> finally invokes
>
> Form, line 920: formToProcess.process(submittingComponent);
>
> The problem with our crazy liitle nested form ;) is that it does not have
> any IFormSubmittingComponent but rather a TextField with
> AjaxFormSubmitBehavior attached to its "onchange" event that should then
> submit the nested form accordingly. This leads to formToProcess being left
> assigned to the parentForm that then gets processed at the end:
>
> - from Form#onFormSubmitted():
>
> // this is the root form
> Form<?> formToProcess = this;
>
> // find out whether it was a nested form that was
> submitted
> if (submittingComponent != null)
> {
> formToProcess = submittingComponent.getForm();
> }
>
> // process the form for this request
> formToProcess.process(submittingComponent);
>
>
> We have in the meantime subclassed AjaxFormSubmitBehavior with our own
> implementation of AjaxFormSubmitBehavior#onEvent(AjaxRequestTarget target)
> method the only difference being the line 135 that was changed from
>
> getForm().getRootForm().onFormSubmitted();
>
> to
>
> getForm().onFormSubmitted();
>
> and did not experience any problems with it, at least so far ;)
>
> Daniel
>
>
>
> On Fri, Jan 21, 2011 at 12:25 AM, jcgarciam <jc...@gmail.com> wrote:
>
>>
>> Adding to Igor's comment, remember that nested form is not allow in HTML
>> spec per se, so what wicket is doing a trick where the root form is submit
>> but only elements of nested form (which get transform in DIV tag) are
>> processed
>>
>> On Thu, Jan 20, 2011 at 4:47 PM, Igor Vaynberg-2 [via Apache Wicket] <
>> ml-node+3228304-1818027643-65838@n4.nabble.com<ml...@n4.nabble.com>
>> <ml...@n4.nabble.com>
>> >
>> > wrote:
>>
>> > the bigger form needs to be processed because what is submitted is the
>> > root form's formtag. however, validation, etc, will probably be
>> > delegated only to the inner form.
>> >
>> > -igor
>> >
>> > On Thu, Jan 20, 2011 at 4:14 AM, Daniel Bartl <[hidden email]<
>> http://user/SendEmail.jtp?type=node&node=3228304&i=0>>
>> > wrote:
>> >
>> > > Have a small question regarding using AjaxFormSubmitBehavoir with
>> nested
>> > > forms.
>> > >
>> > > Would like to use it to submit a smaller nested form within a bigger
>> > parent
>> > > form.
>> > >
>> > > Even though I passed a nested form as a "*form that will be submitted*"
>> > > while calling the following constructor of AjaxFormSubmitBehavoir :
>> > > /**
>> > > * Construct.
>> > > *
>> > > * @param form
>> > > * * form that will be submitted*
>> > > * @param event
>> > > * javascript event this behavior is attached to, like
>> > > onclick
>> > > */
>> > > public AjaxFormSubmitBehavior(Form<?> form, String
>> > > event) <- passing nested form here
>> > > {
>> > > super(event);
>> > > __form = form;
>> > >
>> > > if (form != null)
>> > > {
>> > > form.setOutputMarkupId(true);
>> > > }
>> > > }
>> > >
>> > >
>> > > I noticed that the AjaxFormSubmitBehavior#onEvent(AjaxRequestTarget
>> > target)
>> > > executes the following line first:
>> > > "getForm().getRootForm().onFormSubmitted();"
>> > > Why does it still delegate to the root form?
>> > >
>> > > Shouldn't the line be "getForm().onFormSubmitted();" so that the nested
>> > form
>> > > and possibly its children get processed only.
>> > >
>> > >
>> > > Many thanks!
>> > > Daniel
>> > >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [hidden email]<
>> http://user/SendEmail.jtp?type=node&node=3228304&i=1>
>> > For additional commands, e-mail: [hidden email]<
>> http://user/SendEmail.jtp?type=node&node=3228304&i=2>
>> >
>> >
>> >
>> > ------------------------------
>> > If you reply to this email, your message will be added to the discussion
>> > below:
>> >
>> >
>> http://apache-wicket.1842946.n4.nabble.com/Question-regarding-AjaxFormSubmitBehavior-tp3227451p3228304.html
>> > To start a new topic under Apache Wicket, email
>> > ml-node+1842946-398011874-65838@n4.nabble.com<ml...@n4.nabble.com>
>> <ml...@n4.nabble.com>
>> >
>> > To unsubscribe from Apache Wicket, click here<
>> http://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxODQyOTQ2fDEyNTYxMzc3ODY=
>> >.
>> >
>> >
>>
>>
>>
>> --
>> Sincerely,
>> JC (http://www.linkedin.com/in/jcgarciam)
>> --Anyone who has never made a mistake has never tried anything new.--
>>
>> --
>> View this message in context:
>> http://apache-wicket.1842946.n4.nabble.com/Question-regarding-AjaxFormSubmitBehavior-tp3227451p3228728.html
>> Sent from the Users forum mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> 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: Question regarding AjaxFormSubmitBehavior
Posted by Daniel Bartl <d....@comsysto.com>.
Many thanks for your feedback!
I am well aware of the fact that HTML spec actually does not allow nested
forms and that wicket is already doing great job while transforming those
nested forms into divs.
I also expected that the bigger form gets submitted as well but only the
nested one processed and the rest ignored, but that's not exactly what's
happening in our case.
The reason for this is that AjaxFormSubmitBehavior always delegates to the
#onFormSubmitted() of the root form
AjaxFormSubmitBehavior, line 135:
getForm().getRootForm().onFormSubmitted();
which then looks up if there is any enabled, visible
IFormSubmittingComponent in the hierarchy that has been triggered. Only in
case that one such IFormSubmittingComponent gets identified, it sets
*formToProcess* to the form of the identified submittingComponent and then
finally invokes
Form, line 920: formToProcess.process(submittingComponent);
The problem with our crazy liitle nested form ;) is that it does not have
any IFormSubmittingComponent but rather a TextField with
AjaxFormSubmitBehavior attached to its "onchange" event that should then
submit the nested form accordingly. This leads to formToProcess being left
assigned to the parentForm that then gets processed at the end:
- from Form#onFormSubmitted():
// this is the root form
Form<?> formToProcess = this;
// find out whether it was a nested form that was
submitted
if (submittingComponent != null)
{
formToProcess = submittingComponent.getForm();
}
// process the form for this request
formToProcess.process(submittingComponent);
We have in the meantime subclassed AjaxFormSubmitBehavior with our own
implementation of AjaxFormSubmitBehavior#onEvent(AjaxRequestTarget target)
method the only difference being the line 135 that was changed from
getForm().getRootForm().onFormSubmitted();
to
getForm().onFormSubmitted();
and did not experience any problems with it, at least so far ;)
Daniel
On Fri, Jan 21, 2011 at 12:25 AM, jcgarciam <jc...@gmail.com> wrote:
>
> Adding to Igor's comment, remember that nested form is not allow in HTML
> spec per se, so what wicket is doing a trick where the root form is submit
> but only elements of nested form (which get transform in DIV tag) are
> processed
>
> On Thu, Jan 20, 2011 at 4:47 PM, Igor Vaynberg-2 [via Apache Wicket] <
> ml-node+3228304-1818027643-65838@n4.nabble.com<ml...@n4.nabble.com>
> <ml...@n4.nabble.com>
> >
> > wrote:
>
> > the bigger form needs to be processed because what is submitted is the
> > root form's formtag. however, validation, etc, will probably be
> > delegated only to the inner form.
> >
> > -igor
> >
> > On Thu, Jan 20, 2011 at 4:14 AM, Daniel Bartl <[hidden email]<
> http://user/SendEmail.jtp?type=node&node=3228304&i=0>>
> > wrote:
> >
> > > Have a small question regarding using AjaxFormSubmitBehavoir with
> nested
> > > forms.
> > >
> > > Would like to use it to submit a smaller nested form within a bigger
> > parent
> > > form.
> > >
> > > Even though I passed a nested form as a "*form that will be submitted*"
> > > while calling the following constructor of AjaxFormSubmitBehavoir :
> > > /**
> > > * Construct.
> > > *
> > > * @param form
> > > * * form that will be submitted*
> > > * @param event
> > > * javascript event this behavior is attached to, like
> > > onclick
> > > */
> > > public AjaxFormSubmitBehavior(Form<?> form, String
> > > event) <- passing nested form here
> > > {
> > > super(event);
> > > __form = form;
> > >
> > > if (form != null)
> > > {
> > > form.setOutputMarkupId(true);
> > > }
> > > }
> > >
> > >
> > > I noticed that the AjaxFormSubmitBehavior#onEvent(AjaxRequestTarget
> > target)
> > > executes the following line first:
> > > "getForm().getRootForm().onFormSubmitted();"
> > > Why does it still delegate to the root form?
> > >
> > > Shouldn't the line be "getForm().onFormSubmitted();" so that the nested
> > form
> > > and possibly its children get processed only.
> > >
> > >
> > > Many thanks!
> > > Daniel
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]<
> http://user/SendEmail.jtp?type=node&node=3228304&i=1>
> > For additional commands, e-mail: [hidden email]<
> http://user/SendEmail.jtp?type=node&node=3228304&i=2>
> >
> >
> >
> > ------------------------------
> > If you reply to this email, your message will be added to the discussion
> > below:
> >
> >
> http://apache-wicket.1842946.n4.nabble.com/Question-regarding-AjaxFormSubmitBehavior-tp3227451p3228304.html
> > To start a new topic under Apache Wicket, email
> > ml-node+1842946-398011874-65838@n4.nabble.com<ml...@n4.nabble.com>
> <ml...@n4.nabble.com>
> >
> > To unsubscribe from Apache Wicket, click here<
> http://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxODQyOTQ2fDEyNTYxMzc3ODY=
> >.
> >
> >
>
>
>
> --
> Sincerely,
> JC (http://www.linkedin.com/in/jcgarciam)
> --Anyone who has never made a mistake has never tried anything new.--
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Question-regarding-AjaxFormSubmitBehavior-tp3227451p3228728.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Re: Question regarding AjaxFormSubmitBehavior
Posted by jcgarciam <jc...@gmail.com>.
Adding to Igor's comment, remember that nested form is not allow in HTML
spec per se, so what wicket is doing a trick where the root form is submit
but only elements of nested form (which get transform in DIV tag) are
processed
On Thu, Jan 20, 2011 at 4:47 PM, Igor Vaynberg-2 [via Apache Wicket] <
ml-node+3228304-1818027643-65838@n4.nabble.com<ml...@n4.nabble.com>
> wrote:
> the bigger form needs to be processed because what is submitted is the
> root form's formtag. however, validation, etc, will probably be
> delegated only to the inner form.
>
> -igor
>
> On Thu, Jan 20, 2011 at 4:14 AM, Daniel Bartl <[hidden email]<http://user/SendEmail.jtp?type=node&node=3228304&i=0>>
> wrote:
>
> > Have a small question regarding using AjaxFormSubmitBehavoir with nested
> > forms.
> >
> > Would like to use it to submit a smaller nested form within a bigger
> parent
> > form.
> >
> > Even though I passed a nested form as a "*form that will be submitted*"
> > while calling the following constructor of AjaxFormSubmitBehavoir :
> > /**
> > * Construct.
> > *
> > * @param form
> > * * form that will be submitted*
> > * @param event
> > * javascript event this behavior is attached to, like
> > onclick
> > */
> > public AjaxFormSubmitBehavior(Form<?> form, String
> > event) <- passing nested form here
> > {
> > super(event);
> > __form = form;
> >
> > if (form != null)
> > {
> > form.setOutputMarkupId(true);
> > }
> > }
> >
> >
> > I noticed that the AjaxFormSubmitBehavior#onEvent(AjaxRequestTarget
> target)
> > executes the following line first:
> > "getForm().getRootForm().onFormSubmitted();"
> > Why does it still delegate to the root form?
> >
> > Shouldn't the line be "getForm().onFormSubmitted();" so that the nested
> form
> > and possibly its children get processed only.
> >
> >
> > Many thanks!
> > Daniel
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=3228304&i=1>
> For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=3228304&i=2>
>
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://apache-wicket.1842946.n4.nabble.com/Question-regarding-AjaxFormSubmitBehavior-tp3227451p3228304.html
> To start a new topic under Apache Wicket, email
> ml-node+1842946-398011874-65838@n4.nabble.com<ml...@n4.nabble.com>
> To unsubscribe from Apache Wicket, click here<http://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxODQyOTQ2fDEyNTYxMzc3ODY=>.
>
>
--
Sincerely,
JC (http://www.linkedin.com/in/jcgarciam)
--Anyone who has never made a mistake has never tried anything new.--
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Question-regarding-AjaxFormSubmitBehavior-tp3227451p3228728.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Question regarding AjaxFormSubmitBehavior
Posted by Igor Vaynberg <ig...@gmail.com>.
the bigger form needs to be processed because what is submitted is the
root form's formtag. however, validation, etc, will probably be
delegated only to the inner form.
-igor
On Thu, Jan 20, 2011 at 4:14 AM, Daniel Bartl <d....@comsysto.com> wrote:
> Have a small question regarding using AjaxFormSubmitBehavoir with nested
> forms.
>
> Would like to use it to submit a smaller nested form within a bigger parent
> form.
>
> Even though I passed a nested form as a "*form that will be submitted*"
> while calling the following constructor of AjaxFormSubmitBehavoir :
> /**
> * Construct.
> *
> * @param form
> * * form that will be submitted*
> * @param event
> * javascript event this behavior is attached to, like
> onclick
> */
> public AjaxFormSubmitBehavior(Form<?> form, String
> event) <- passing nested form here
> {
> super(event);
> __form = form;
>
> if (form != null)
> {
> form.setOutputMarkupId(true);
> }
> }
>
>
> I noticed that the AjaxFormSubmitBehavior#onEvent(AjaxRequestTarget target)
> executes the following line first:
> "getForm().getRootForm().onFormSubmitted();"
> Why does it still delegate to the root form?
>
> Shouldn't the line be "getForm().onFormSubmitted();" so that the nested form
> and possibly its children get processed only.
>
>
> Many thanks!
> Daniel
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org