Interesting. So model.getFirstName()
would return a PropetyModel based on the results of proxy.eval()? If I understand you correctly that creates many models (one per component) instead of reusing a single model, but that may well not be the end of the world. Or does getFirstName() return a CompoundModel that is properly bound this this component? Intriguing none the less. I hadn't considered this option, but I'm going to play with it a bit. I rather like that direction. On Feb 8, 2008 8:29 AM, Johan Compagner <[EMAIL PROTECTED]> wrote: > i try to look at this this weekend, but i have a quick question > I find it a bit verbose can't it be a bit shorter like this (just an > example) > > SharedPropertyModel<Customer> model = new > SharedPropertyModel<Customer>(customer); > this.setModel(model); > > FormComponent firstName = new CustomerNameField("firstName", > model.getFirstName()).setRequired(true); > add(firstName); > > where getFirstName() returns the model > > johan > > > > > > On Feb 6, 2008 6:57 PM, Scott Swank <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > -- Scott Swank reformed mathematician --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]