You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by RalfButler <ra...@web.de> on 2013/04/02 12:40:29 UTC
Nested forms ...
Hi there,
to my understanding the forms in the bottom code are nested. But why is the
value of the outer textbox submitted when I click the inner submit button
only? According to this page
<https://cwiki.apache.org/WICKET/nested-forms.html> only the value of the
inner textbox should be submitted when the inner submit button is pressed.
Would be great if someone could explain this. Most likely I do something
wrong here.
Thanks.
Ralf
public class HomePage extends WebPage {
private static final long serialVersionUID = 1L;
private Model innerModel= new Model("Inner");
private Model outerModel= new Model("Outer");
public HomePage() {
add(new Label("labelOuter", outerModel));
add(new Label("labelInner", innerModel));
Form formA = new Form("outerForm"){
@Override
protected void onSubmit() {
System.out.println("Outer form submitted");
}
};
add(formA);
formA.add(new TextField("outerFormTF", outerModel));
Form formB = new Form("innerForm"){
@Override
protected void onSubmit() {
System.out.println("Inner form submitted");
}
};
formA.add(formB);
formB.add(new TextField("innerFormTF", innerModel));
}
}
HTML:
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<head>
<meta charset="utf-8" />
<title>Apache Wicket Quickstart</title>
<link
href='http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz:regular,bold'
rel='stylesheet' type='text/css' />
<link rel="stylesheet" href="style.css" type="text/css"
media="screen" title="Stylesheet" />
</head>
<body>
Outer value <br/>
Inner value
<form wicket:id="outerForm">
<input wicket:id="outerFormTF" type="text"/>
<input type="submit" value="Outer Form" />
<form wicket:id="innerForm">
<input wicket:id="innerFormTF" type="text"/>
<input type="submit" value="Inner Form" />
</form>
</form>
</body>
</html>
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Nested-forms-tp4657683.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: Nested forms ...
Posted by RalfButler <ra...@web.de>.
Ah! Thank you very much Sven. Yes, that makes sense!!
In case anyone is interested:
JAVA:
HTML:
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Nested-forms-tp4657683p4657689.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: Nested forms ...
Posted by Sven Meier <sv...@meiers.net>.
Ah, you're not using any button components, so there's no way for Wicket
to know which form was submitted.
Sven
On 04/02/2013 01:48 PM, RalfButler wrote:
> Thanks for the quick reply Sven! Still confusing to me; for
> wantSubmitOnNestedFormSubmit() it says "By default, this is false, so when a
> nested form is submitted, this form will not be submitted." And since I did
> not overwrite wantSubmitOnNestedFormSubmit of the OuterForm to return true,
> I'd expect that OuterForm is not submitted when the inner form submit button
> is pressed.
>
> Could it be that 'submit' and 'process' got a bit confused in the JavaDoc?
>
> I reckon it has something to do with the code I wrote. I slightly modified
> it ... same result. But it would be great if you could skim through it. May
> aim is that outerModel does not get assigned a value of the outerTextField
> when the innser submit button is pressed.
>
> Thanks,
> Ralf
>
>
> JAVA:
>
> HTML:
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Nested-forms-tp4657683p4657687.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: Nested forms ...
Posted by RalfButler <ra...@web.de>.
Thanks for the quick reply Sven! Still confusing to me; for
wantSubmitOnNestedFormSubmit() it says "By default, this is false, so when a
nested form is submitted, this form will not be submitted." And since I did
not overwrite wantSubmitOnNestedFormSubmit of the OuterForm to return true,
I'd expect that OuterForm is not submitted when the inner form submit button
is pressed.
Could it be that 'submit' and 'process' got a bit confused in the JavaDoc?
I reckon it has something to do with the code I wrote. I slightly modified
it ... same result. But it would be great if you could skim through it. May
aim is that outerModel does not get assigned a value of the outerTextField
when the innser submit button is pressed.
Thanks,
Ralf
JAVA:
HTML:
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Nested-forms-tp4657683p4657687.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: Nested forms ...
Posted by Sven Meier <sv...@meiers.net>.
Hi,
the values of all form components are submitted, but only the ones from
the submitted nested form are processed.
See Form#wantSubmitOnNestedFormSubmit() and the tests in
NestedFormSubmitTest.
Sven
On 04/02/2013 12:40 PM, RalfButler wrote:
> Hi there,
>
> to my understanding the forms in the bottom code are nested. But why is the
> value of the outer textbox submitted when I click the inner submit button
> only? According to this page
> <https://cwiki.apache.org/WICKET/nested-forms.html> only the value of the
> inner textbox should be submitted when the inner submit button is pressed.
>
> Would be great if someone could explain this. Most likely I do something
> wrong here.
>
> Thanks.
> Ralf
>
>
> public class HomePage extends WebPage {
>
> private static final long serialVersionUID = 1L;
> private Model innerModel= new Model("Inner");
> private Model outerModel= new Model("Outer");
>
> public HomePage() {
>
> add(new Label("labelOuter", outerModel));
> add(new Label("labelInner", innerModel));
> Form formA = new Form("outerForm"){
>
> @Override
> protected void onSubmit() {
> System.out.println("Outer form submitted");
> }
>
> };
> add(formA);
> formA.add(new TextField("outerFormTF", outerModel));
> Form formB = new Form("innerForm"){
>
> @Override
> protected void onSubmit() {
> System.out.println("Inner form submitted");
> }
>
> };
> formA.add(formB);
> formB.add(new TextField("innerFormTF", innerModel));
>
> }
> }
>
> HTML:
> <!DOCTYPE html>
> <html xmlns:wicket="http://wicket.apache.org">
> <head>
> <meta charset="utf-8" />
> <title>Apache Wicket Quickstart</title>
> <link
> href='http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz:regular,bold'
> rel='stylesheet' type='text/css' />
> <link rel="stylesheet" href="style.css" type="text/css"
> media="screen" title="Stylesheet" />
> </head>
> <body>
> Outer value <br/>
> Inner value
> <form wicket:id="outerForm">
> <input wicket:id="outerFormTF" type="text"/>
> <input type="submit" value="Outer Form" />
> <form wicket:id="innerForm">
> <input wicket:id="innerFormTF" type="text"/>
> <input type="submit" value="Inner Form" />
> </form>
> </form>
> </body>
> </html>
>
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Nested-forms-tp4657683.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