You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "Emmanouil Batsis (Manos)" <ma...@abiss.gr> on 2012/04/11 15:08:12 UTC
Handling nested form submission on enter
I have a nested form that works as expected when it's submit button (an
IndicatingAjaxButton) is pressed but not when the user presses the enter
key when one of it's form fields is focused. Is it possible to capture
this enter key press to trigger the nested form's submit instead?
Manos
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Handling nested form submission on enter
Posted by jotaviotfs <jo...@gmail.com>.
Works perfect!!!
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Handling-nested-form-submission-on-enter-tp4548831p4666742.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: Handling nested form submission on enter
Posted by "Emmanouil Batsis (Manos)" <ma...@abiss.gr>.
On 04/11/2012 07:53 PM, Andrea Del Bene wrote:
> It's like if JavaScript can't tell apart a form from another. Can you
> check the HTML generated for your page and see if forms have an unique id?
Checked, the IDs are unique. I couldn't figure out what the actual
problem is so, to bypass it, I just added this to intercept the enter
key and explicitly use my nested form's submit:
final TextField<String> newValueField =
new TextField<String>("newValueField", new
PropertyModel(newSubFieldValues, "[" + index + "]")){
@Override
protected void onComponentTag(ComponentTag tag){
super.onComponentTag(tag);
tag.put("onkeypress", "if(event.keyCode == 13)
{document.getElementById('" + addButton.getMarkupId() +
"').click();return false;}");
}
};
Hope this helps someone else with nested forms and the enter key.
Manos
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Handling nested form submission on enter
Posted by Andrea Del Bene <ad...@ciseonweb.it>.
It's like if JavaScript can't tell apart a form from another. Can you
check the HTML generated for your page and see if forms have an unique id?
> On 04/11/2012 05:39 PM, Andrea Del Bene wrote:
>> Well, I couldn't say why it doesn't work. Can you post some code of your
>> nested forms?
>
> Sort of found what the problem is but have no clue on how to solve it.
> Pressing enter in one of the nested forms submits the last nested form
> in the page.
>
> Each form is within a custom FormComponentPanel I made to implement a
> widget, but it seems the nested forms are mixed up if more than one of
> these are used in the same page. Each of these FormComponentPanels is
> an instance of my MultipleValuesTextField:
>
> http://code.google.com/p/calipso/source/browse/trunk/calipso-war/src/main/java/gr/abiss/calipso/wicket/components/formfields/MultipleValuesTextField.java
>
>
> Manos
>
> ---------------------------------------------------------------------
> 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: Handling nested form submission on enter
Posted by "Emmanouil Batsis (Manos)" <ma...@abiss.gr>.
On 04/11/2012 05:39 PM, Andrea Del Bene wrote:
> Well, I couldn't say why it doesn't work. Can you post some code of your
> nested forms?
Sort of found what the problem is but have no clue on how to solve it.
Pressing enter in one of the nested forms submits the last nested form
in the page.
Each form is within a custom FormComponentPanel I made to implement a
widget, but it seems the nested forms are mixed up if more than one of
these are used in the same page. Each of these FormComponentPanels is an
instance of my MultipleValuesTextField:
http://code.google.com/p/calipso/source/browse/trunk/calipso-war/src/main/java/gr/abiss/calipso/wicket/components/formfields/MultipleValuesTextField.java
Manos
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Handling nested form submission on enter
Posted by Andrea Del Bene <ad...@ciseonweb.it>.
Well, I couldn't say why it doesn't work. Can you post some code of your
nested forms?
> Thanks, I just did and the flow is the one desired, but for some
> reason the nested form field models are not updated with the field
> inputs when the submit buttons onSubmit() is called. Is there
> something obvious I might be missing?
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Handling nested form submission on enter
Posted by "Emmanouil Batsis (Manos)" <ma...@abiss.gr>.
On 04/11/2012 04:14 PM, Andrea Del Bene wrote:
> already tried form setDefaultButton method (see JavaDoc)?
Thanks, I just did and the flow is the one desired, but for some reason
the nested form field models are not updated with the field inputs when
the submit buttons onSubmit() is called. Is there something obvious I
might be missing?
Manos
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Handling nested form submission on enter
Posted by Andrea Del Bene <ad...@ciseonweb.it>.
Hi,
already tried form setDefaultButton method (see JavaDoc)?
> I have a nested form that works as expected when it's submit button
> (an IndicatingAjaxButton) is pressed but not when the user presses the
> enter key when one of it's form fields is focused. Is it possible to
> capture this enter key press to trigger the nested form's submit instead?
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org