Here I have something like a QuickStart.
In this reduced example I can verify this behavior. I checked that link but
it seems to work different.

In this case both submit button do the same. I'm using wicket 1.4.19.


package com.keepcon.web.administration.users;

import java.util.ArrayList;
import java.util.Collection;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.RequiredTextField;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.PropertyModel;


public class NestedForms extends WebPage {

@SuppressWarnings("unused")
private String name;
 private final Collection<String> values = new ArrayList<String>();

public NestedForms() {
 Form<Void> outerForm = new Form<Void>("outerForm");
PropertyModel<String> nameModel = new PropertyModel<String>(this, "name");
 outerForm.add(new RequiredTextField<String>("name", nameModel));

final IModel<String> valueModel = new Model<String>("");

Form<Void> innerForm = new Form<Void>("innerForm") {
@Override
 protected void onSubmit() {
values.add(valueModel.getObject());
valueModel.setObject("");
 }
};

innerForm.add(new RequiredTextField<String>("value", valueModel));

outerForm.add(innerForm);

outerForm.add(new Label("values", new AbstractReadOnlyModel<String>() {

@Override
public String getObject() {
return NestedForms.this.values.toString();
 }
}));
outerForm.add(new Label("nameSubmitted", nameModel));

add(outerForm);
add(new FeedbackPanel("feedback"));
 }
}



<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd";>
<html
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd
">
<head></head>
<body>
<div wicket:id="feedback"></div>
<form wicket:id="outerForm">
 <table>
<tr>
<td>Name:</td>
 <td><input type="text" wicket:id="name" /></td>
</tr>
 </table>
<form wicket:id="innerForm">
<table>
 <tr>
<td>Value:</td>
<td><input type="text" wicket:id="value" /></td>
 </tr>
<tr>
<td><input type="submit" value="Add" /></td>
 <td></td>
</tr>
</table>
 </form>
<table>
<tr>
 <td><input type="submit" value="Save" /></td>
<td></td>
 </tr>
<tr>
<td>Datos subidos:</td>
 <td></td>
</tr>
<tr>
 <td>Name:</td>
<td><span wicket:id="nameSubmitted"></span></td>
 </tr>
<tr>
<td>Values:</td>
 <td><span wicket:id="values"></span></td>
</tr>
 </table>
</form>
</body>
</html>



On Mon, Dec 19, 2011 at 11:10 AM, Andrea Del Bene <adelb...@ciseonweb.it>wrote:

> This is strange end should not happened: https://cwiki.apache.org/**
> WICKET/nested-forms.html<https://cwiki.apache.org/WICKET/nested-forms.html>.
> Maybe the problem is on code side. Can you show the initialization code for
> the two forms?
>
>  Yes, I have this layout. Is the first I tested.
>>
>> The problem with this is that when I click Add Item buttom information is
>> not submitted because general validations stops it. I mean, if I don't
>> complete name field i can't add items.
>>
>> It seems like inner form submit is submitting outer form.
>>
>> Thanks!
>>
>> On Mon, Dec 19, 2011 at 10:16 AM, Andrea Del Bene<adelb...@ciseonweb.it>*
>> *wrote:
>>
>>  Hi,
>>>
>>> nested form should work fine. I mean something like this:
>>>
>>> _________________________
>>> |<main form>
>>> | Name:..
>>> | Lastname:...
>>> |
>>> | ________________________
>>> | |<item (inner) form>
>>> | | item number:...
>>> | | item number:...
>>> | |<Add item button>
>>> | |______________________
>>> |
>>> |<save button>
>>> |_______________________
>>>
>>> Do you have this forms layout? 'Add item button' must be added to 'item
>>> form' and only to this form.
>>>
>>>  Hi, I'm creating a page with a form.
>>>
>>>> The form asks for personal information and also for information to add
>>>> some
>>>> items.
>>>>
>>>> For example
>>>>
>>>> General information
>>>> Name: _______
>>>> Lastname: _______
>>>>
>>>> Item information
>>>> Item number: _______
>>>> Item description: ______
>>>>
>>>> Add item (button)
>>>>
>>>> Item number | Description
>>>> 1                 |  something
>>>> 2                 |  a thing
>>>>
>>>> Save (button)
>>>>
>>>> I tryed with nested forms but when I click on "Add item" validations on
>>>> Name and LastName stop the submit. I thought on an ajax solution but i
>>>> don't know how to do it.
>>>>
>>>> I mean, I need validations of general information and validations of
>>>> item
>>>> information. Could you give an idea of how to do something like this?
>>>> I think it could be a standard problem.
>>>>
>>>> Thanks in advance.
>>>>
>>>> Tito
>>>>
>>>>
>>>>  ------------------------------****----------------------------**
>>> --**---------
>>> To unsubscribe, e-mail: 
>>> users-unsubscribe@wicket.**apa**che.org<http://apache.org>
>>> <users-unsubscribe@**wicket.apache.org<users-unsubscr...@wicket.apache.org>
>>> >
>>>
>>> For additional commands, e-mail: users-h...@wicket.apache.org
>>>
>>>
>>>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: 
> users-unsubscribe@wicket.**apache.org<users-unsubscr...@wicket.apache.org>
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

Reply via email to