You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Bram Vandoren <br...@bram.be> on 2009/03/18 15:49:26 UTC

custom formcomponent and multiple models

Hi,
I use a custom FormComponent on a form:
Form myForm = new Form("form");
CompoundPropertyModel myModel = new CompoundPropertyModel(myOrder)
myForm.setModel(myModel);

The formcomponent has to set two properties of the
CompoundPropertyModel of the form. At the moment I pass the complete
CompoundPropertyModel to the FormComponent:
myForm.add(new MyFormComponent("id", myModel));

It looks terrible but it was the only solution I found. The
FormComponent has access to the complete CompoundPropertyModel and I
can't reuse the same FormComponent with other models. Any suggestions
how to set 2 models in a FormComponent?

Thanks,
Bram.

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


Re: custom formcomponent and multiple models

Posted by Jeremy Thomerson <je...@wickettraining.com>.
Pass it two models.  Hold your models as private fields of the form
component.  Don't forget to override onDetach and detach the two models
yourself.

--
Jeremy Thomerson
http://www.wickettraining.com



On Wed, Mar 18, 2009 at 9:49 AM, Bram Vandoren <br...@bram.be> wrote:

> Hi,
> I use a custom FormComponent on a form:
> Form myForm = new Form("form");
> CompoundPropertyModel myModel = new CompoundPropertyModel(myOrder)
> myForm.setModel(myModel);
>
> The formcomponent has to set two properties of the
> CompoundPropertyModel of the form. At the moment I pass the complete
> CompoundPropertyModel to the FormComponent:
> myForm.add(new MyFormComponent("id", myModel));
>
> It looks terrible but it was the only solution I found. The
> FormComponent has access to the complete CompoundPropertyModel and I
> can't reuse the same FormComponent with other models. Any suggestions
> how to set 2 models in a FormComponent?
>
> Thanks,
> Bram.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>