You should be able to do
Form form = new Form("form", new CompoundPropertyModel(MyPojo));
page.add(form);
form.add(new MyFormComponent("myProperty"));
See
http://cwiki.apache.org/WICKET/working-with-wicket-models.html#WorkingwithWicketmodels-CompoundPropertyModels
dukehoops wrote:
>
> The following code works (have unit tests) but I would appreciate a code
> review from someone.
>
> Legend
> MyPojo - bean backing up form
> MyProperty - another POJO that is property of MyPojo (MyPojo has field
> 'myProperty' of type MyProperty)
> MyFormComponent - custom form component that displays/manipulates
> MyProperty (myProperty == myFormComponent.getModelObject())
>
> In particular, I want to ensure that when MyComponent's modelObject is
> updated, so is formBean's property (to be more precise, that the two
> reference the same object)
>
> //inside page:
>
> IModel formModel = new CompoundPropertyModel(MyPojo);
> Form form = new Form("form", formModel);
> page.add(form);
>
> MyFormComponent myComp = new MyFormComponent("myProperty", new
> PropertyModel(formModel, "myProperty"));
> form.add(myComp);
>
> and constructor:
> MyFormComponent(wicketId, model)
> {
> super(wicketId, model);
> }
>
--
View this message in context:
http://www.nabble.com/please-review-my-CompoundPropertyModel-use-tp19868935p19870462.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]