igor.vaynberg wrote:
> 
> show us your code.
> 

Ok, I have a class 'Person' with an'Address-Property. My Form-object has a
simple Model wrapping a Person-object. The constructor creating the Panel
with the form contains these lines:

form = new Form<Person>("form", new Model<Person>());
personFormComponent = new
PersonFormComponent<Student>("personFormComponent", form.getModel());
addressFormComponent = new
AddressFormComponent<Address>("addressFormComponent", new
PropertyModel<Address>(this.form.getModel(), "address"));

form.add(personFormComponent);
form.add(addressFormComponent);

After creation of this Panel I call form.setModelObject(...). So the model
ist not empty. The PersonFormComponent works well as it only sets some
String-Properties of the Person-Object. But I have trouble with the
AddressFormComponent which looks like this:

public class AddressFormComponent<T extends Address> extends
FormComponentPanel<T> {
        protected TextField<String> cityField, postcodeField, streetField;
        protected IModel<T> model;

        public AddressFormComponent(String id, IModel<T> model) {
                super(id, model);

                // Model
                this.model = model;

                // Straße
                streetField = new TextField<String>("streetField", new
PropertyModel<String>(model, "street"));
                streetField.setRequired(true);
                streetField.add(StringValidator.lengthBetween(0, 100));

                // PLZ
                postcodeField = new TextField<String>("postcodeField", new
Model<String>(""));
                postcodeField.setRequired(true);

                // Stadt
                cityField = new TextField<String>("cityField", new 
Model<String>(""));
                cityField.setRequired(true);
                cityField.add(StringValidator.lengthBetween(0, 50));

                this.add(streetField);
                this.add(postcodeField);
                this.add(cityField);
        }
}

After submitting the whole form (with an AjaxButton) the Address-Property of
my Person-Object ist null. Perhaps I did not use the Models correctly ...?
-- 
View this message in context: 
http://www.nabble.com/Example-for-FormComponentPanel-best-practice-for-reusable-form-components-tp23391811p23393211.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to