model.getFirstName() can't really return IModel, if
Customer.getFirstName() returns string.

Anyway, I like the idea, but I don't like the syntax. instead of one
line [add(new TextField("id", model).setRequred(true)) ] you have now
three separate lines.

So I was thinking of something more like

SafePropertyModel<Customer> model = new SafePropertyModel<Customer>(customer);

add(new TextField("tf", model.bind(model.proxy().getCustomerName()
)).setRequired(true));

This way you can have it one one line.

-Matej

On Fri, Feb 8, 2008 at 6:17 PM, Johan Compagner <[EMAIL PROTECTED]> wrote:
> don't worry about creating the models
>  That will happen anyway in 1.3 (that needs to be done for example to get the
>  right object especially when we generify stuff)
>
>  see CompoundPropertyModel.wrapOnInheritance()
>
>  joan
>
>
>
>
>
>  On Feb 8, 2008 5:41 PM, Scott Swank <[EMAIL PROTECTED]> wrote:
>
>  > 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]
>  >
>  >
>



-- 
Resizable and reorderable grid components.
http://www.inmethod.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to