« Return to Thread: CompoundModel based on proxies

Re: CompoundModel based on proxies

by Martijn Dashorst :: Rate this Message:

Reply to Author | View in Thread

please share for Wicket 1.4, if cglib's license is permitting, I think
we should add this to core.

Martijn

On 2/6/08, Scott Swank <scott.swank@...> wrote:

> One of our more clever developers created a CompoundPropertyModel that
> uses a cglib proxy to strongly bind the mutators to the model.  It
> looks like this:
>
>                 SharedPropertyModel<Customer> model = new
> SharedPropertyModel<Customer>(customer);
>                 this.setModel(model);
>
>                 FormComponent firstName = new
> CustomerNameField("firstName").setRequired(true);
>                 model.bind(firstName).to().getFirstName();
>                 add(firstName);
>
>                 FormComponent lastName = new CustomerNameField("lastName").setRequired(true);
>                 model.bind(lastName).to().getLastName();
>                 add(lastName);
>
>                 FormComponent addr1 = new AddressField("address1").setRequired(true);
>                 model.bind(addr1).to().getAddress().getAddress1();
>                 add(addr1);
>
>                 FormComponent addr2 = new AddressField("address2");
>                 model.bind(addr2).to().getAddress().getAddress2();
>                 add(addr2);
>
>                 FormComponent city = new CityField("city");
>                 model.bind(city).to().getAddress().getCity();
>                 add(city);
>
> We're happy to share if folk like this approach.  N.B. that the .to()
> call is for readability rather than out of any necessity.
>
> Cheers,
> Scott
>
> --
> Scott Swank
> reformed mathematician
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>


--
Buy Wicket in Action: http://manning.com/dashorst
Apache Wicket 1.3.0 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.0

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

 « Return to Thread: CompoundModel based on proxies