You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Chris <ch...@carlsoncentral.com> on 2009/05/08 04:54:34 UTC
Form that gets data form multiple models.
I have a form that combines data from multiple pojo's. Currently I am
creating two seperate IModels inside my form, something like this.
IModel model1 = new LoadableDetachableModel() {
@Override
protected Object load() { ... }
};
IModel model2 = new LoadableDetachableModel() {
@Override
protected Object load() { ... }
};
add(new TextField("foo", new PropertyModel(model1, "foo")));
add(new TextField("bar", new PropertyModel(model2, "bar")));
When the form is submitted, what's the best way to get the form
components back into their respected object models?
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Form that gets data form multiple models.
Posted by Jeremy Thomerson <je...@wickettraining.com>.
Make those models private fields within your form. Make sure that you
are overriding onDetach in the form and detaching them (even though
the PropertyModel should chain the detach down to it's nested model -
this is a good habit to get into so that you don't forget somewhere
else).
--
Jeremy Thomerson
http://www.wickettraining.com
On Thu, May 7, 2009 at 9:54 PM, Chris <ch...@carlsoncentral.com> wrote:
> I have a form that combines data from multiple pojo's. Currently I am
> creating two seperate IModels inside my form, something like this.
>
> IModel model1 = new LoadableDetachableModel() {
> @Override
> protected Object load() { ... }
> };
>
> IModel model2 = new LoadableDetachableModel() {
> @Override
> protected Object load() { ... }
> };
>
> add(new TextField("foo", new PropertyModel(model1, "foo")));
> add(new TextField("bar", new PropertyModel(model2, "bar")));
>
>
> When the form is submitted, what's the best way to get the form components
> back into their respected object models?
>
> ---------------------------------------------------------------------
> 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