CompoundModel based on proxies

View: New views
20 Messages — Rating Filter:   Alert me  
< Prev | 1 - 2 - 3 - 4 - 5 | Next >

Re: CompoundModel based on proxies

by jwcarman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

If you're interested in using proxies, you could check out Apache
Commons Proxy.  It hasn't been released yet, but I would imagine we
could get a release out the door in short order if it was wanted.  The
cool thing about ACP is that you can swap out the proxying technology
easily (JDK proxies, CGLIB, and Javassist are currently supported).

On 2/6/08, Igor Vaynberg <igor.vaynberg@...> wrote:

> i support it in a non-core module
>
> -igor
>
>
> On Feb 6, 2008 5:41 PM, Jonathan Locke <jonathan.locke@...> wrote:
> >
> >
> > so you don't support this model then?
> >
> >
> >
> > igor.vaynberg wrote:
> > >
> > > i disagree. i dont think we should be doing more with cglib in core or
> > > any other bytecode magic. have you ever tried to walk code that uses
> > > bytecode generation? its a nightmare. one of my favorite things about
> > > wicket is that it is just java and its easy as hell to debug. im not
> > > really against putting something like this into extensions, or even
> > > having a new wicket-bytecode/codegen/whatever package that contains
> > > things like these...
> > >
> > > -igor
> > >
> > >
> > > On Feb 6, 2008 5:23 PM, Jonathan Locke <jonathan.locke@...> wrote:
> > >>
> > >> like BoundCompoundPropertyModel, but safer.  i think this almost might be
> > >> too
> > >> clever as it sacrifices some intuitiveness.  also, it's filling in for a
> > >> missing java feature.  this should really be:
> > >>
> > >> boundModel.bind(component, firstName.property)
> > >>
> > >> (where .property, .field and .method are long-missing declarative
> > >> reflections like .class)
> > >>
> > >> it does make me think we could be doing more with CGLIB in general. our
> > >> model classes ought to be able to detect model changes better using
> > >> proxies,
> > >> for example.
> > >>
> > >>
> > >>
> > >> 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@...
> > >> >
> > >> >
> > >> >
> > >>
> > >> --
> > >> View this message in context:
> > >> http://www.nabble.com/CompoundModel-based-on-proxies-tp15317807p15325663.html
> > >> Sent from the Wicket - User mailing list archive at Nabble.com.
> > >>
> > >>
> > >>
> > >> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: users-unsubscribe@...
> > >> For additional commands, e-mail: users-help@...
> > >>
> > >>
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@...
> > > For additional commands, e-mail: users-help@...
> > >
> > >
> > >
> >
> > --
> > View this message in context: http://www.nabble.com/CompoundModel-based-on-proxies-tp15317807p15325860.html
> >
> > Sent from the Wicket - User mailing list archive at Nabble.com.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@...
> > For additional commands, e-mail: users-help@...
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>

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


Re: CompoundModel based on proxies

by Jonathan Locke :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


makes sense to me.

igor.vaynberg wrote:
i support it in a non-core module

-igor


On Feb 6, 2008 5:41 PM, Jonathan Locke <jonathan.locke@gmail.com> wrote:
>
>
> so you don't support this model then?
>
>
>
> igor.vaynberg wrote:
> >
> > i disagree. i dont think we should be doing more with cglib in core or
> > any other bytecode magic. have you ever tried to walk code that uses
> > bytecode generation? its a nightmare. one of my favorite things about
> > wicket is that it is just java and its easy as hell to debug. im not
> > really against putting something like this into extensions, or even
> > having a new wicket-bytecode/codegen/whatever package that contains
> > things like these...
> >
> > -igor
> >
> >
> > On Feb 6, 2008 5:23 PM, Jonathan Locke <jonathan.locke@gmail.com> wrote:
> >>
> >> like BoundCompoundPropertyModel, but safer.  i think this almost might be
> >> too
> >> clever as it sacrifices some intuitiveness.  also, it's filling in for a
> >> missing java feature.  this should really be:
> >>
> >> boundModel.bind(component, firstName.property)
> >>
> >> (where .property, .field and .method are long-missing declarative
> >> reflections like .class)
> >>
> >> it does make me think we could be doing more with CGLIB in general. our
> >> model classes ought to be able to detect model changes better using
> >> proxies,
> >> for example.
> >>
> >>
> >>
> >> 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@wicket.apache.org
> >> > For additional commands, e-mail: users-help@wicket.apache.org
> >> >
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/CompoundModel-based-on-proxies-tp15317807p15325663.html
> >> Sent from the Wicket - User mailing list archive at Nabble.com.
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
> >
>
> --
> View this message in context: http://www.nabble.com/CompoundModel-based-on-proxies-tp15317807p15325860.html
>
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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

RE: CompoundModel based on proxies

by Thomas Maeder :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

+ 1 for what Igor says. I remember debugging Hibernate code: you debug
as far as your own code goes, and then you just guess. Oh, and yes:
Tapestry anyone?

Thomas

> -----Original Message-----
> From: Igor Vaynberg [mailto:igor.vaynberg@...]
> Sent: Donnerstag, 7. Februar 2008 02:34
> To: users@...
> Subject: Re: CompoundModel based on proxies
>
> i disagree. i dont think we should be doing more with cglib
> in core or any other bytecode magic. have you ever tried to
> walk code that uses bytecode generation? its a nightmare. one
> of my favorite things about wicket is that it is just java
> and its easy as hell to debug. im not really against putting
> something like this into extensions, or even having a new
> wicket-bytecode/codegen/whatever package that contains things
> like these...
>

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


Re: CompoundModel based on proxies

by Sam Barnum :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The big argument for this cglib is to introduce some type safety to  
what is currently string-based bindings.  This is a big plus.  I  
don't think it's worth giving up the "pure Java" aspect that so many  
of us obviously like about Wicket.

I'd rather see some IDE support that is smart about flagging bindings  
which refer to non-existent bean attributes.  That way there's no  
magic or performance hit happening at runtime.  IntelliJ does  
something similar for JPA query Strings.  If a query references a non-
existent property it appears as an error, even though they're just  
Strings.  Obviously things get really sticky when you're dealing with  
CompoundPropertyModels, etc.

Best case, of course, would be an addition to the java language that  
lets you refer to a property in a type-safe way.  Is there a JSR for  
this?

-Sam Barnum
360Works

On Feb 7, 2008, at 1:50 AM, Maeder Thomas wrote:

> + 1 for what Igor says. I remember debugging Hibernate code: you debug
> as far as your own code goes, and then you just guess. Oh, and yes:
> Tapestry anyone?
>
> Thomas
>
>> -----Original Message-----
>> From: Igor Vaynberg [mailto:igor.vaynberg@...]
>> Sent: Donnerstag, 7. Februar 2008 02:34
>> To: users@...
>> Subject: Re: CompoundModel based on proxies
>>
>> i disagree. i dont think we should be doing more with cglib
>> in core or any other bytecode magic. have you ever tried to
>> walk code that uses bytecode generation? its a nightmare. one
>> of my favorite things about wicket is that it is just java
>> and its easy as hell to debug. im not really against putting
>> something like this into extensions, or even having a new
>> wicket-bytecode/codegen/whatever package that contains things
>> like these...
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>


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


Re: CompoundModel based on proxies

by Johan Compagner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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 <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@...
>
>

Re: CompoundModel based on proxies

by Scott Swank :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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 <jcompagner@...> 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 <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@...
> >
> >
>



--
Scott Swank
reformed mathematician

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


Re: CompoundModel based on proxies

by Johan Compagner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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 <scott.swank@...> 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 <jcompagner@...> 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 <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@...
> > >
> > >
> >
>
>
>
> --
>  Scott Swank
> reformed mathematician
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>

Re: CompoundModel based on proxies

by Matej Knopp :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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 <jcompagner@...> 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 <scott.swank@...> 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 <jcompagner@...> 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 <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@...
>  > > >
>  > > >
>  > >
>  >
>  >
>  >
>  > --
>  >  Scott Swank
>  > reformed mathematician
>  >
>  > ---------------------------------------------------------------------
>  > To unsubscribe, e-mail: users-unsubscribe@...
>  > For additional commands, e-mail: users-help@...
>  >
>  >
>



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

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


Re: CompoundModel based on proxies

by Sebastiaan van Erk :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Matej Knopp wrote:

> 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
So proxy() returns a Customer proxy?

And model.bind() takes an Object argument (considering we don't know in
advance what type getCustomerName() returns)... What about primitive
types? Overload bind() for those as well?

And the call to getCustomerName() has the side effect of setting a model
  object somewhere (e.g., in an instance field of model) which
model.bind() can subsequently return?

Very interesting. I don't like the proxy() method name though. If you
call it something like property() it will look more like you're binding
to a property of Customer:

model.bind(model.property().getCustomerName())

VERY neat idea though... :-)

Regards,
Sebastiaan

>
> On Fri, Feb 8, 2008 at 6:17 PM, Johan Compagner <jcompagner@...> 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 <scott.swank@...> 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 <jcompagner@...> 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 <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@...
>>  > > >
>>  > > >
>>  > >
>>  >
>>  >
>>  >
>>  > --
>>  >  Scott Swank
>>  > reformed mathematician
>>  >
>>  > ---------------------------------------------------------------------
>>  > To unsubscribe, e-mail: users-unsubscribe@...
>>  > For additional commands, e-mail: users-help@...
>>  >
>>  >
>>
>
>
>


smime.p7s (4K) Download Attachment

Re: CompoundModel based on proxies

by Matej Knopp :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

On Tue, Feb 26, 2008 at 11:13 AM, Sebastiaan van Erk
<sebster@...> wrote:

> Matej Knopp wrote:
>  > 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
>
>  So proxy() returns a Customer proxy?
>
>  And model.bind() takes an Object argument (considering we don't know in
>  advance what type getCustomerName() returns)... What about primitive
>  types? Overload bind() for those as well?
Well, the return object is not important at all. What is important is
the getCustomerName() call. That marks somewhere in the model that
last accessed property was called "customerName". and then immediately
after this model.bind takes this information.
>
>  And the call to getCustomerName() has the side effect of setting a model
>   object somewhere (e.g., in an instance field of model) which
>  model.bind() can subsequently return?
Model bind will return a model (variation of propertymodel probably).
It will take the information that getCustomerName call on proxy
provided.
>
>  Very interesting. I don't like the proxy() method name though. If you
>  call it something like property() it will look more like you're binding
>  to a property of Customer:
Well, the naming can certainly be improved. I'm not sure about
"property()" though. Well, we can discuss this more anyway.
>
>  model.bind(model.property().getCustomerName())
>
>  VERY neat idea though... :-)
Thanks.

-Matej

>
>  Regards,
>  Sebastiaan
>
>
>
>  >
>  > On Fri, Feb 8, 2008 at 6:17 PM, Johan Compagner <jcompagner@...> 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 <scott.swank@...> 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 <jcompagner@...> 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 <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@...
>  >>  > > >
>  >>  > > >
>  >>  > >
>  >>  >
>  >>  >
>  >>  >
>  >>  > --
>  >>  >  Scott Swank
>  >>  > reformed mathematician
>  >>  >
>  >>  > ---------------------------------------------------------------------
>  >>  > To unsubscribe, e-mail: users-unsubscribe@...
>  >>  > For additional commands, e-mail: users-help@...
>  >>  >
>  >>  >
>  >>
>  >
>  >
>  >
>



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

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


Re: CompoundModel based on proxies

by Sebastiaan van Erk :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Matej Knopp wrote:

> Hi,
>
> On Tue, Feb 26, 2008 at 11:13 AM, Sebastiaan van Erk
> <sebster@...> wrote:
>> Matej Knopp wrote:
>>  > 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
>>
>>  So proxy() returns a Customer proxy?
>>
>>  And model.bind() takes an Object argument (considering we don't know in
>>  advance what type getCustomerName() returns)... What about primitive
>>  types? Overload bind() for those as well?
> Well, the return object is not important at all. What is important is
> the getCustomerName() call. That marks somewhere in the model that
> last accessed property was called "customerName". and then immediately
> after this model.bind takes this information.
OK, that's what I described. :-) And I was being stupid with respect to
the overloading. If bind takes an object as argument, then overloading
will not be necessary due to autoboxing. :-)

>>  And the call to getCustomerName() has the side effect of setting a model
>>   object somewhere (e.g., in an instance field of model) which
>>  model.bind() can subsequently return?
> Model bind will return a model (variation of propertymodel probably).
> It will take the information that getCustomerName call on proxy
> provided.

Ok, so the proxy remembers which getter was called last, and you use
that to construct the model in bind(). Of course.

>>  Very interesting. I don't like the proxy() method name though. If you
>>  call it something like property() it will look more like you're binding
>>  to a property of Customer:
> Well, the naming can certainly be improved. I'm not sure about
> "property()" though. Well, we can discuss this more anyway.
>>  model.bind(model.property().getCustomerName())

Neither am I. :-) For one, it's quite long. But on the other hand, you
do bind to a model property, and so it reads ok. I think that proxies
should be "invisible" for general users, so they shouldn't have to
understand the magic going on here, nor that proxies are involved.

>>  VERY neat idea though... :-)
> Thanks.

What I really like about this solution is that it can be implemented
completely separately from wicket-core, so you can just put it in it's
own project. :-)

Regards,
Sebastiaan

> -Matej
>>  Regards,
>>  Sebastiaan
>>
>>
>>
>>  >
>>  > On Fri, Feb 8, 2008 at 6:17 PM, Johan Compagner <jcompagner@...> 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 <scott.swank@...> 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 <jcompagner@...> 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 <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@...
>>  >>  > > >
>>  >>  > > >
>>  >>  > >
>>  >>  >
>>  >>  >
>>  >>  >
>>  >>  > --
>>  >>  >  Scott Swank
>>  >>  > reformed mathematician
>>  >>  >
>>  >>  > ---------------------------------------------------------------------
>>  >>  > To unsubscribe, e-mail: users-unsubscribe@...
>>  >>  > For additional commands, e-mail: users-help@...
>>  >>  >
>>  >>  >
>>  >>
>>  >
>>  >
>>  >
>>
>
>
>


smime.p7s (4K) Download Attachment

Re: CompoundModel based on proxies

by Matej Knopp :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

We've reworked the implementation a bit,it works like this:


SafePropertyModel<Person> p = new SafePropertyModel<Person>(new Person());
TextField field = new TextField("name", p.bind(p.property().getFirstName()));

It's attached to the JIRA issue:
https://issues.apache.org/jira/browse/WICKET-1327

-Matej


On Tue, Feb 26, 2008 at 11:32 AM, Sebastiaan van Erk
<sebster@...> wrote:

> Matej Knopp wrote:
>  > Hi,
>  >
>  > On Tue, Feb 26, 2008 at 11:13 AM, Sebastiaan van Erk
>  > <sebster@...> wrote:
>  >> Matej Knopp wrote:
>  >>  > 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
>  >>
>  >>  So proxy() returns a Customer proxy?
>  >>
>  >>  And model.bind() takes an Object argument (considering we don't know in
>  >>  advance what type getCustomerName() returns)... What about primitive
>  >>  types? Overload bind() for those as well?
>  > Well, the return object is not important at all. What is important is
>  > the getCustomerName() call. That marks somewhere in the model that
>  > last accessed property was called "customerName". and then immediately
>  > after this model.bind takes this information.
>
>  OK, that's what I described. :-) And I was being stupid with respect to
>  the overloading. If bind takes an object as argument, then overloading
>  will not be necessary due to autoboxing. :-)
>
>
>  >>  And the call to getCustomerName() has the side effect of setting a model
>  >>   object somewhere (e.g., in an instance field of model) which
>  >>  model.bind() can subsequently return?
>  > Model bind will return a model (variation of propertymodel probably).
>  > It will take the information that getCustomerName call on proxy
>  > provided.
>
>  Ok, so the proxy remembers which getter was called last, and you use
>  that to construct the model in bind(). Of course.
>
>
>  >>  Very interesting. I don't like the proxy() method name though. If you
>  >>  call it something like property() it will look more like you're binding
>  >>  to a property of Customer:
>  > Well, the naming can certainly be improved. I'm not sure about
>  > "property()" though. Well, we can discuss this more anyway.
>  >>  model.bind(model.property().getCustomerName())
>
>  Neither am I. :-) For one, it's quite long. But on the other hand, you
>  do bind to a model property, and so it reads ok. I think that proxies
>  should be "invisible" for general users, so they shouldn't have to
>  understand the magic going on here, nor that proxies are involved.
>
>
>  >>  VERY neat idea though... :-)
>  > Thanks.
>
>  What I really like about this solution is that it can be implemented
>  completely separately from wicket-core, so you can just put it in it's
>  own project. :-)
>
>  Regards,
>  Sebastiaan
>
>
>
>  > -Matej
>  >>  Regards,
>  >>  Sebastiaan
>  >>
>  >>
>  >>
>  >>  >
>  >>  > On Fri, Feb 8, 2008 at 6:17 PM, Johan Compagner <jcompagner@...> 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 <scott.swank@...> 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 <jcompagner@...> 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 <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@...
>  >>  >>  > > >
>  >>  >>  > > >
>  >>  >>  > >
>  >>  >>  >
>  >>  >>  >
>  >>  >>  >
>  >>  >>  > --
>  >>  >>  >  Scott Swank
>  >>  >>  > reformed mathematician
>  >>  >>  >
>  >>  >>  > ---------------------------------------------------------------------
>  >>  >>  > To unsubscribe, e-mail: users-unsubscribe@...
>  >>  >>  > For additional commands, e-mail: users-help@...
>  >>  >>  >
>  >>  >>  >
>  >>  >>
>  >>  >
>  >>  >
>  >>  >
>  >>
>  >
>  >
>  >
>



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

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


Re: CompoundModel based on proxies

by Scott Swank :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I just added a relevant note about serialization (learned the hard
way...) to the jira.

- Scott

On Tue, Feb 26, 2008 at 3:18 AM, Matej Knopp <matej.knopp@...> wrote:

> We've reworked the implementation a bit,it works like this:
>
>
>  SafePropertyModel<Person> p = new SafePropertyModel<Person>(new Person());
>  TextField field = new TextField("name", p.bind(p.property().getFirstName()));
>
>  It's attached to the JIRA issue:
>
> https://issues.apache.org/jira/browse/WICKET-1327
>
>  -Matej

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


Re: CompoundModel based on proxies

by atul singh-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I feel this approach does NOT solve a problem.....Its just an alternative ..

On Tue, Feb 26, 2008 at 4:48 PM, Matej Knopp <matej.knopp@...> wrote:

> We've reworked the implementation a bit,it works like this:
>
>
> SafePropertyModel<Person> p = new SafePropertyModel<Person>(new Person());
> TextField field = new TextField("name", p.bind(p.property
> ().getFirstName()));
>
> It's attached to the JIRA issue:
> https://issues.apache.org/jira/browse/WICKET-1327
>
> -Matej
>
>
> On Tue, Feb 26, 2008 at 11:32 AM, Sebastiaan van Erk
> <sebster@...> wrote:
> > Matej Knopp wrote:
> >  > Hi,
> >  >
> >  > On Tue, Feb 26, 2008 at 11:13 AM, Sebastiaan van Erk
> >  > <sebster@...> wrote:
> >  >> Matej Knopp wrote:
> >  >>  > 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
> >  >>
> >  >>  So proxy() returns a Customer proxy?
> >  >>
> >  >>  And model.bind() takes an Object argument (considering we don't
> know in
> >  >>  advance what type getCustomerName() returns)... What about
> primitive
> >  >>  types? Overload bind() for those as well?
> >  > Well, the return object is not important at all. What is important is
> >  > the getCustomerName() call. That marks somewhere in the model that
> >  > last accessed property was called "customerName". and then
> immediately
> >  > after this model.bind takes this information.
> >
> >  OK, that's what I described. :-) And I was being stupid with respect to
> >  the overloading. If bind takes an object as argument, then overloading
> >  will not be necessary due to autoboxing. :-)
> >
> >
> >  >>  And the call to getCustomerName() has the side effect of setting a
> model
> >  >>   object somewhere (e.g., in an instance field of model) which
> >  >>  model.bind() can subsequently return?
> >  > Model bind will return a model (variation of propertymodel probably).
> >  > It will take the information that getCustomerName call on proxy
> >  > provided.
> >
> >  Ok, so the proxy remembers which getter was called last, and you use
> >  that to construct the model in bind(). Of course.
> >
> >
> >  >>  Very interesting. I don't like the proxy() method name though. If
> you
> >  >>  call it something like property() it will look more like you're
> binding
> >  >>  to a property of Customer:
> >  > Well, the naming can certainly be improved. I'm not sure about
> >  > "property()" though. Well, we can discuss this more anyway.
> >  >>  model.bind(model.property().getCustomerName())
> >
> >  Neither am I. :-) For one, it's quite long. But on the other hand, you
> >  do bind to a model property, and so it reads ok. I think that proxies
> >  should be "invisible" for general users, so they shouldn't have to
> >  understand the magic going on here, nor that proxies are involved.
> >
> >
> >  >>  VERY neat idea though... :-)
> >  > Thanks.
> >
> >  What I really like about this solution is that it can be implemented
> >  completely separately from wicket-core, so you can just put it in it's
> >  own project. :-)
> >
> >  Regards,
> >  Sebastiaan
> >
> >
> >
> >  > -Matej
> >  >>  Regards,
> >  >>  Sebastiaan
> >  >>
> >  >>
> >  >>
> >  >>  >
> >  >>  > On Fri, Feb 8, 2008 at 6:17 PM, Johan Compagner <
> jcompagner@...> 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 <scott.swank@...>
> 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 <jcompagner@...>
> 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 <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@...
> >  >>  >>  > > >
> >  >>  >>  > > >
> >  >>  >>  > >
> >  >>  >>  >
> >  >>  >>  >
> >  >>  >>  >
> >  >>  >>  > --
> >  >>  >>  >  Scott Swank
> >  >>  >>  > reformed mathematician
> >  >>  >>  >
> >  >>  >>  >
> ---------------------------------------------------------------------
> >  >>  >>  > To unsubscribe, e-mail: users-unsubscribe@...
> >  >>  >>  > For additional commands, e-mail: users-help@...
> >  >>  >>  >
> >  >>  >>  >
> >  >>  >>
> >  >>  >
> >  >>  >
> >  >>  >
> >  >>
> >  >
> >  >
> >  >
> >
>
>
>
> --
> Resizable and reorderable grid components.
> http://www.inmethod.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>

Re: CompoundModel based on proxies

by Sebastiaan van Erk :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Well, there's a problem with normal PropertyModels (or
CompoundPropertyModels).

For example, if you have the following textfield:

TextField tf = new TextField("name", new PropertyModel(customer,
"customerName"));

Then a refactor of the customerName property (and the getCustomerName()
method) in an IDE such as Eclipse or NetBeans will *silently* break the
above code, which you will discover only at runtime...

The proxy based approach solves exactly this problem.

Regards,
Sebastiaan



atul singh wrote:

> I feel this approach does NOT solve a problem.....Its just an alternative ..
>
> On Tue, Feb 26, 2008 at 4:48 PM, Matej Knopp <matej.knopp@...> wrote:
>
>> We've reworked the implementation a bit,it works like this:
>>
>>
>> SafePropertyModel<Person> p = new SafePropertyModel<Person>(new Person());
>> TextField field = new TextField("name", p.bind(p.property
>> ().getFirstName()));
>>
>> It's attached to the JIRA issue:
>> https://issues.apache.org/jira/browse/WICKET-1327
>>
>> -Matej
>>
>>
>> On Tue, Feb 26, 2008 at 11:32 AM, Sebastiaan van Erk
>> <sebster@...> wrote:
>>> Matej Knopp wrote:
>>>  > Hi,
>>>  >
>>>  > On Tue, Feb 26, 2008 at 11:13 AM, Sebastiaan van Erk
>>>  > <sebster@...> wrote:
>>>  >> Matej Knopp wrote:
>>>  >>  > 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
>>>  >>
>>>  >>  So proxy() returns a Customer proxy?
>>>  >>
>>>  >>  And model.bind() takes an Object argument (considering we don't
>> know in
>>>  >>  advance what type getCustomerName() returns)... What about
>> primitive
>>>  >>  types? Overload bind() for those as well?
>>>  > Well, the return object is not important at all. What is important is
>>>  > the getCustomerName() call. That marks somewhere in the model that
>>>  > last accessed property was called "customerName". and then
>> immediately
>>>  > after this model.bind takes this information.
>>>
>>>  OK, that's what I described. :-) And I was being stupid with respect to
>>>  the overloading. If bind takes an object as argument, then overloading
>>>  will not be necessary due to autoboxing. :-)
>>>
>>>
>>>  >>  And the call to getCustomerName() has the side effect of setting a
>> model
>>>  >>   object somewhere (e.g., in an instance field of model) which
>>>  >>  model.bind() can subsequently return?
>>>  > Model bind will return a model (variation of propertymodel probably).
>>>  > It will take the information that getCustomerName call on proxy
>>>  > provided.
>>>
>>>  Ok, so the proxy remembers which getter was called last, and you use
>>>  that to construct the model in bind(). Of course.
>>>
>>>
>>>  >>  Very interesting. I don't like the proxy() method name though. If
>> you
>>>  >>  call it something like property() it will look more like you're
>> binding
>>>  >>  to a property of Customer:
>>>  > Well, the naming can certainly be improved. I'm not sure about
>>>  > "property()" though. Well, we can discuss this more anyway.
>>>  >>  model.bind(model.property().getCustomerName())
>>>
>>>  Neither am I. :-) For one, it's quite long. But on the other hand, you
>>>  do bind to a model property, and so it reads ok. I think that proxies
>>>  should be "invisible" for general users, so they shouldn't have to
>>>  understand the magic going on here, nor that proxies are involved.
>>>
>>>
>>>  >>  VERY neat idea though... :-)
>>>  > Thanks.
>>>
>>>  What I really like about this solution is that it can be implemented
>>>  completely separately from wicket-core, so you can just put it in it's
>>>  own project. :-)
>>>
>>>  Regards,
>>>  Sebastiaan
>>>
>>>
>>>
>>>  > -Matej
>>>  >>  Regards,
>>>  >>  Sebastiaan
>>>  >>
>>>  >>
>>>  >>
>>>  >>  >
>>>  >>  > On Fri, Feb 8, 2008 at 6:17 PM, Johan Compagner <
>> jcompagner@...> 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 <scott.swank@...>
>> 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 <jcompagner@...>
>> 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 <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@...
>>>  >>  >>  > > >
>>>  >>  >>  > > >
>>>  >>  >>  > >
>>>  >>  >>  >
>>>  >>  >>  >
>>>  >>  >>  >
>>>  >>  >>  > --
>>>  >>  >>  >  Scott Swank
>>>  >>  >>  > reformed mathematician
>>>  >>  >>  >
>>>  >>  >>  >
>> ---------------------------------------------------------------------
>>>  >>  >>  > To unsubscribe, e-mail: users-unsubscribe@...
>>>  >>  >>  > For additional commands, e-mail: users-help@...
>>>  >>  >>  >
>>>  >>  >>  >
>>>  >>  >>
>>>  >>  >
>>>  >>  >
>>>  >>  >
>>>  >>
>>>  >
>>>  >
>>>  >
>>>
>>
>>
>> --
>> Resizable and reorderable grid components.
>> http://www.inmethod.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@...
>> For additional commands, e-mail: users-help@...
>>
>>
>


smime.p7s (4K) Download Attachment

Re: CompoundModel based on proxies

by jwcarman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Have you tried this out using load testing?  You are creating a new
class every time you create a model.  Have you run out of permgen
space?

On 2/26/08, Sebastiaan van Erk <sebster@...> wrote:

> Well, there's a problem with normal PropertyModels (or
>  CompoundPropertyModels).
>
>  For example, if you have the following textfield:
>
>  TextField tf = new TextField("name", new PropertyModel(customer,
>  "customerName"));
>
>  Then a refactor of the customerName property (and the getCustomerName()
>  method) in an IDE such as Eclipse or NetBeans will *silently* break the
>  above code, which you will discover only at runtime...
>
>  The proxy based approach solves exactly this problem.
>
>  Regards,
>
> Sebastiaan
>
>
>
>
>  atul singh wrote:
>  > I feel this approach does NOT solve a problem.....Its just an alternative ..
>  >
>  > On Tue, Feb 26, 2008 at 4:48 PM, Matej Knopp <matej.knopp@...> wrote:
>  >
>  >> We've reworked the implementation a bit,it works like this:
>  >>
>  >>
>  >> SafePropertyModel<Person> p = new SafePropertyModel<Person>(new Person());
>  >> TextField field = new TextField("name", p.bind(p.property
>  >> ().getFirstName()));
>  >>
>  >> It's attached to the JIRA issue:
>  >> https://issues.apache.org/jira/browse/WICKET-1327
>  >>
>  >> -Matej
>  >>
>  >>
>  >> On Tue, Feb 26, 2008 at 11:32 AM, Sebastiaan van Erk
>  >> <sebster@...> wrote:
>  >>> Matej Knopp wrote:
>  >>>  > Hi,
>  >>>  >
>  >>>  > On Tue, Feb 26, 2008 at 11:13 AM, Sebastiaan van Erk
>  >>>  > <sebster@...> wrote:
>  >>>  >> Matej Knopp wrote:
>  >>>  >>  > 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
>  >>>  >>
>  >>>  >>  So proxy() returns a Customer proxy?
>  >>>  >>
>  >>>  >>  And model.bind() takes an Object argument (considering we don't
>  >> know in
>  >>>  >>  advance what type getCustomerName() returns)... What about
>  >> primitive
>  >>>  >>  types? Overload bind() for those as well?
>  >>>  > Well, the return object is not important at all. What is important is
>  >>>  > the getCustomerName() call. That marks somewhere in the model that
>  >>>  > last accessed property was called "customerName". and then
>  >> immediately
>  >>>  > after this model.bind takes this information.
>  >>>
>  >>>  OK, that's what I described. :-) And I was being stupid with respect to
>  >>>  the overloading. If bind takes an object as argument, then overloading
>  >>>  will not be necessary due to autoboxing. :-)
>  >>>
>  >>>
>  >>>  >>  And the call to getCustomerName() has the side effect of setting a
>  >> model
>  >>>  >>   object somewhere (e.g., in an instance field of model) which
>  >>>  >>  model.bind() can subsequently return?
>  >>>  > Model bind will return a model (variation of propertymodel probably).
>  >>>  > It will take the information that getCustomerName call on proxy
>  >>>  > provided.
>  >>>
>  >>>  Ok, so the proxy remembers which getter was called last, and you use
>  >>>  that to construct the model in bind(). Of course.
>  >>>
>  >>>
>  >>>  >>  Very interesting. I don't like the proxy() method name though. If
>  >> you
>  >>>  >>  call it something like property() it will look more like you're
>  >> binding
>  >>>  >>  to a property of Customer:
>  >>>  > Well, the naming can certainly be improved. I'm not sure about
>  >>>  > "property()" though. Well, we can discuss this more anyway.
>  >>>  >>  model.bind(model.property().getCustomerName())
>  >>>
>  >>>  Neither am I. :-) For one, it's quite long. But on the other hand, you
>  >>>  do bind to a model property, and so it reads ok. I think that proxies
>  >>>  should be "invisible" for general users, so they shouldn't have to
>  >>>  understand the magic going on here, nor that proxies are involved.
>  >>>
>  >>>
>  >>>  >>  VERY neat idea though... :-)
>  >>>  > Thanks.
>  >>>
>  >>>  What I really like about this solution is that it can be implemented
>  >>>  completely separately from wicket-core, so you can just put it in it's
>  >>>  own project. :-)
>  >>>
>  >>>  Regards,
>  >>>  Sebastiaan
>  >>>
>  >>>
>  >>>
>  >>>  > -Matej
>  >>>  >>  Regards,
>  >>>  >>  Sebastiaan
>  >>>  >>
>  >>>  >>
>  >>>  >>
>  >>>  >>  >
>  >>>  >>  > On Fri, Feb 8, 2008 at 6:17 PM, Johan Compagner <
>  >> jcompagner@...> 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 <scott.swank@...>
>  >> 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 <jcompagner@...>
>  >> 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 <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@...
>  >>>  >>  >>  > > >
>  >>>  >>  >>  > > >
>  >>>  >>  >>  > >
>  >>>  >>  >>  >
>  >>>  >>  >>  >
>  >>>  >>  >>  >
>  >>>  >>  >>  > --
>  >>>  >>  >>  >  Scott Swank
>  >>>  >>  >>  > reformed mathematician
>  >>>  >>  >>  >
>  >>>  >>  >>  >
>  >> ---------------------------------------------------------------------
>  >>>  >>  >>  > To unsubscribe, e-mail: users-unsubscribe@...
>  >>>  >>  >>  > For additional commands, e-mail: users-help@...
>  >>>  >>  >>  >
>  >>>  >>  >>  >
>  >>>  >>  >>
>  >>>  >>  >
>  >>>  >>  >
>  >>>  >>  >
>  >>>  >>
>  >>>  >
>  >>>  >
>  >>>  >
>  >>>
>  >>
>  >>
>  >> --
>  >> Resizable and reorderable grid components.
>  >> http://www.inmethod.com
>  >>
>  >> ---------------------------------------------------------------------
>  >> To unsubscribe, e-mail: users-unsubscribe@...
>  >> For additional commands, e-mail: users-help@...
>  >>
>  >>
>  >
>
>

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


Re: CompoundModel based on proxies

by igor.vaynberg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

we can cache the created proxy class and simply give each instance a
new handler...

-igor


On Tue, Feb 26, 2008 at 10:26 AM, James Carman
<james@...> wrote:

> Have you tried this out using load testing?  You are creating a new
>  class every time you create a model.  Have you run out of permgen
>  space?
>
>
>
>  On 2/26/08, Sebastiaan van Erk <sebster@...> wrote:
>  > Well, there's a problem with normal PropertyModels (or
>  >  CompoundPropertyModels).
>  >
>  >  For example, if you have the following textfield:
>  >
>  >  TextField tf = new TextField("name", new PropertyModel(customer,
>  >  "customerName"));
>  >
>  >  Then a refactor of the customerName property (and the getCustomerName()
>  >  method) in an IDE such as Eclipse or NetBeans will *silently* break the
>  >  above code, which you will discover only at runtime...
>  >
>  >  The proxy based approach solves exactly this problem.
>  >
>  >  Regards,
>  >
>  > Sebastiaan
>  >
>  >
>  >
>  >
>  >  atul singh wrote:
>  >  > I feel this approach does NOT solve a problem.....Its just an alternative ..
>  >  >
>  >  > On Tue, Feb 26, 2008 at 4:48 PM, Matej Knopp <matej.knopp@...> wrote:
>  >  >
>  >  >> We've reworked the implementation a bit,it works like this:
>  >  >>
>  >  >>
>  >  >> SafePropertyModel<Person> p = new SafePropertyModel<Person>(new Person());
>  >  >> TextField field = new TextField("name", p.bind(p.property
>  >  >> ().getFirstName()));
>  >  >>
>  >  >> It's attached to the JIRA issue:
>  >  >> https://issues.apache.org/jira/browse/WICKET-1327
>  >  >>
>  >  >> -Matej
>  >  >>
>  >  >>
>  >  >> On Tue, Feb 26, 2008 at 11:32 AM, Sebastiaan van Erk
>  >  >> <sebster@...> wrote:
>  >  >>> Matej Knopp wrote:
>  >  >>>  > Hi,
>  >  >>>  >
>  >  >>>  > On Tue, Feb 26, 2008 at 11:13 AM, Sebastiaan van Erk
>  >  >>>  > <sebster@...> wrote:
>  >  >>>  >> Matej Knopp wrote:
>  >  >>>  >>  > 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
>  >  >>>  >>
>  >  >>>  >>  So proxy() returns a Customer proxy?
>  >  >>>  >>
>  >  >>>  >>  And model.bind() takes an Object argument (considering we don't
>  >  >> know in
>  >  >>>  >>  advance what type getCustomerName() returns)... What about
>  >  >> primitive
>  >  >>>  >>  types? Overload bind() for those as well?
>  >  >>>  > Well, the return object is not important at all. What is important is
>  >  >>>  > the getCustomerName() call. That marks somewhere in the model that
>  >  >>>  > last accessed property was called "customerName". and then
>  >  >> immediately
>  >  >>>  > after this model.bind takes this information.
>  >  >>>
>  >  >>>  OK, that's what I described. :-) And I was being stupid with respect to
>  >  >>>  the overloading. If bind takes an object as argument, then overloading
>  >  >>>  will not be necessary due to autoboxing. :-)
>  >  >>>
>  >  >>>
>  >  >>>  >>  And the call to getCustomerName() has the side effect of setting a
>  >  >> model
>  >  >>>  >>   object somewhere (e.g., in an instance field of model) which
>  >  >>>  >>  model.bind() can subsequently return?
>  >  >>>  > Model bind will return a model (variation of propertymodel probably).
>  >  >>>  > It will take the information that getCustomerName call on proxy
>  >  >>>  > provided.
>  >  >>>
>  >  >>>  Ok, so the proxy remembers which getter was called last, and you use
>  >  >>>  that to construct the model in bind(). Of course.
>  >  >>>
>  >  >>>
>  >  >>>  >>  Very interesting. I don't like the proxy() method name though. If
>  >  >> you
>  >  >>>  >>  call it something like property() it will look more like you're
>  >  >> binding
>  >  >>>  >>  to a property of Customer:
>  >  >>>  > Well, the naming can certainly be improved. I'm not sure about
>  >  >>>  > "property()" though. Well, we can discuss this more anyway.
>  >  >>>  >>  model.bind(model.property().getCustomerName())
>  >  >>>
>  >  >>>  Neither am I. :-) For one, it's quite long. But on the other hand, you
>  >  >>>  do bind to a model property, and so it reads ok. I think that proxies
>  >  >>>  should be "invisible" for general users, so they shouldn't have to
>  >  >>>  understand the magic going on here, nor that proxies are involved.
>  >  >>>
>  >  >>>
>  >  >>>  >>  VERY neat idea though... :-)
>  >  >>>  > Thanks.
>  >  >>>
>  >  >>>  What I really like about this solution is that it can be implemented
>  >  >>>  completely separately from wicket-core, so you can just put it in it's
>  >  >>>  own project. :-)
>  >  >>>
>  >  >>>  Regards,
>  >  >>>  Sebastiaan
>  >  >>>
>  >  >>>
>  >  >>>
>  >  >>>  > -Matej
>  >  >>>  >>  Regards,
>  >  >>>  >>  Sebastiaan
>  >  >>>  >>
>  >  >>>  >>
>  >  >>>  >>
>  >  >>>  >>  >
>  >  >>>  >>  > On Fri, Feb 8, 2008 at 6:17 PM, Johan Compagner <
>  >  >> jcompagner@...> 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 <scott.swank@...>
>  >  >> 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 <jcompagner@...>
>  >  >> 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 <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@...
>  >  >>>  >>  >>  > > >
>  >  >>>  >>  >>  > > >
>  >  >>>  >>  >>  > >
>  >  >>>  >>  >>  >
>  >  >>>  >>  >>  >
>  >  >>>  >>  >>  >
>  >  >>>  >>  >>  > --
>  >  >>>  >>  >>  >  Scott Swank
>  >  >>>  >>  >>  > reformed mathematician
>  >  >>>  >>  >>  >
>  >  >>>  >>  >>  >
>  >  >> ---------------------------------------------------------------------
>  >  >>>  >>  >>  > To unsubscribe, e-mail: users-unsubscribe@...
>  >  >>>  >>  >>  > For additional commands, e-mail: users-help@...
>  >  >>>  >>  >>  >
>  >  >>>  >>  >>  >
>  >  >>>  >>  >>
>  >  >>>  >>  >
>  >  >>>  >>  >
>  >  >>>  >>  >
>  >  >>>  >>
>  >  >>>  >
>  >  >>>  >
>  >  >>>  >
>  >  >>>
>  >  >>
>  >  >>
>  >  >> --
>  >  >> Resizable and reorderable grid components.
>  >  >> http://www.inmethod.com
>  >  >>
>  >  >> ---------------------------------------------------------------------
>  >  >> To unsubscribe, e-mail: users-unsubscribe@...
>  >  >> For additional commands, e-mail: users-help@...
>  >  >>
>  >  >>
>  >  >
>  >
>  >
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: users-unsubscribe@...
>  For additional commands, e-mail: users-help@...
>
>

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


Re: CompoundModel based on proxies

by jwcarman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

So, you would cache the generated class (based on the type passed in)
and then have it generate a new object each time.  Then, cast that
object to Factory and set its callbacks?

On 2/26/08, Igor Vaynberg <igor.vaynberg@...> wrote:

> we can cache the created proxy class and simply give each instance a
>  new handler...
>
>
>  -igor
>
>
>
>  On Tue, Feb 26, 2008 at 10:26 AM, James Carman
>  <james@...> wrote:
>  > Have you tried this out using load testing?  You are creating a new
>  >  class every time you create a model.  Have you run out of permgen
>  >  space?
>  >
>  >
>  >
>  >  On 2/26/08, Sebastiaan van Erk <sebster@...> wrote:
>  >  > Well, there's a problem with normal PropertyModels (or
>  >  >  CompoundPropertyModels).
>  >  >
>  >  >  For example, if you have the following textfield:
>  >  >
>  >  >  TextField tf = new TextField("name", new PropertyModel(customer,
>  >  >  "customerName"));
>  >  >
>  >  >  Then a refactor of the customerName property (and the getCustomerName()
>  >  >  method) in an IDE such as Eclipse or NetBeans will *silently* break the
>  >  >  above code, which you will discover only at runtime...
>  >  >
>  >  >  The proxy based approach solves exactly this problem.
>  >  >
>  >  >  Regards,
>  >  >
>  >  > Sebastiaan
>  >  >
>  >  >
>  >  >
>  >  >
>  >  >  atul singh wrote:
>  >  >  > I feel this approach does NOT solve a problem.....Its just an alternative ..
>  >  >  >
>  >  >  > On Tue, Feb 26, 2008 at 4:48 PM, Matej Knopp <matej.knopp@...> wrote:
>  >  >  >
>  >  >  >> We've reworked the implementation a bit,it works like this:
>  >  >  >>
>  >  >  >>
>  >  >  >> SafePropertyModel<Person> p = new SafePropertyModel<Person>(new Person());
>  >  >  >> TextField field = new TextField("name", p.bind(p.property
>  >  >  >> ().getFirstName()));
>  >  >  >>
>  >  >  >> It's attached to the JIRA issue:
>  >  >  >> https://issues.apache.org/jira/browse/WICKET-1327
>  >  >  >>
>  >  >  >> -Matej
>  >  >  >>
>  >  >  >>
>  >  >  >> On Tue, Feb 26, 2008 at 11:32 AM, Sebastiaan van Erk
>  >  >  >> <sebster@...> wrote:
>  >  >  >>> Matej Knopp wrote:
>  >  >  >>>  > Hi,
>  >  >  >>>  >
>  >  >  >>>  > On Tue, Feb 26, 2008 at 11:13 AM, Sebastiaan van Erk
>  >  >  >>>  > <sebster@...> wrote:
>  >  >  >>>  >> Matej Knopp wrote:
>  >  >  >>>  >>  > 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
>  >  >  >>>  >>
>  >  >  >>>  >>  So proxy() returns a Customer proxy?
>  >  >  >>>  >>
>  >  >  >>>  >>  And model.bind() takes an Object argument (considering we don't
>  >  >  >> know in
>  >  >  >>>  >>  advance what type getCustomerName() returns)... What about
>  >  >  >> primitive
>  >  >  >>>  >>  types? Overload bind() for those as well?
>  >  >  >>>  > Well, the return object is not important at all. What is important is
>  >  >  >>>  > the getCustomerName() call. That marks somewhere in the model that
>  >  >  >>>  > last accessed property was called "customerName". and then
>  >  >  >> immediately
>  >  >  >>>  > after this model.bind takes this information.
>  >  >  >>>
>  >  >  >>>  OK, that's what I described. :-) And I was being stupid with respect to
>  >  >  >>>  the overloading. If bind takes an object as argument, then overloading
>  >  >  >>>  will not be necessary due to autoboxing. :-)
>  >  >  >>>
>  >  >  >>>
>  >  >  >>>  >>  And the call to getCustomerName() has the side effect of setting a
>  >  >  >> model
>  >  >  >>>  >>   object somewhere (e.g., in an instance field of model) which
>  >  >  >>>  >>  model.bind() can subsequently return?
>  >  >  >>>  > Model bind will return a model (variation of propertymodel probably).
>  >  >  >>>  > It will take the information that getCustomerName call on proxy
>  >  >  >>>  > provided.
>  >  >  >>>
>  >  >  >>>  Ok, so the proxy remembers which getter was called last, and you use
>  >  >  >>>  that to construct the model in bind(). Of course.
>  >  >  >>>
>  >  >  >>>
>  >  >  >>>  >>  Very interesting. I don't like the proxy() method name though. If
>  >  >  >> you
>  >  >  >>>  >>  call it something like property() it will look more like you're
>  >  >  >> binding
>  >  >  >>>  >>  to a property of Customer:
>  >  >  >>>  > Well, the naming can certainly be improved. I'm not sure about
>  >  >  >>>  > "property()" though. Well, we can discuss this more anyway.
>  >  >  >>>  >>  model.bind(model.property().getCustomerName())
>  >  >  >>>
>  >  >  >>>  Neither am I. :-) For one, it's quite long. But on the other hand, you
>  >  >  >>>  do bind to a model property, and so it reads ok. I think that proxies
>  >  >  >>>  should be "invisible" for general users, so they shouldn't have to
>  >  >  >>>  understand the magic going on here, nor that proxies are involved.
>  >  >  >>>
>  >  >  >>>
>  >  >  >>>  >>  VERY neat idea though... :-)
>  >  >  >>>  > Thanks.
>  >  >  >>>
>  >  >  >>>  What I really like about this solution is that it can be implemented
>  >  >  >>>  completely separately from wicket-core, so you can just put it in it's
>  >  >  >>>  own project. :-)
>  >  >  >>>
>  >  >  >>>  Regards,
>  >  >  >>>  Sebastiaan
>  >  >  >>>
>  >  >  >>>
>  >  >  >>>
>  >  >  >>>  > -Matej
>  >  >  >>>  >>  Regards,
>  >  >  >>>  >>  Sebastiaan
>  >  >  >>>  >>
>  >  >  >>>  >>
>  >  >  >>>  >>
>  >  >  >>>  >>  >
>  >  >  >>>  >>  > On Fri, Feb 8, 2008 at 6:17 PM, Johan Compagner <
>  >  >  >> jcompagner@...> 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 <scott.swank@...>
>  >  >  >> 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 <jcompagner@...>
>  >  >  >> 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 <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@...
>  >  >  >>>  >>  >>  > > >
>  >  >  >>>  >>  >>  > > >
>  >  >  >>>  >>  >>  > >
>  >  >  >>>  >>  >>  >
>  >  >  >>>  >>  >>  >
>  >  >  >>>  >>  >>  >
>  >  >  >>>  >>  >>  > --
>  >  >  >>>  >>  >>  >  Scott Swank
>  >  >  >>>  >>  >>  > reformed mathematician
>  >  >  >>>  >>  >>  >
>  >  >  >>>  >>  >>  >
>  >  >  >> ---------------------------------------------------------------------
>  >  >  >>>  >>  >>  > To unsubscribe, e-mail: users-unsubscribe@...
>  >  >  >>>  >>  >>  > For additional commands, e-mail: users-help@...
>  >  >  >>>  >>  >>  >
>  >  >  >>>  >>  >>  >
>  >  >  >>>  >>  >>
>  >  >  >>>  >>  >
>  >  >  >>>  >>  >
>  >  >  >>>  >>  >
>  >  >  >>>  >>
>  >  >  >>>  >
>  >  >  >>>  >
>  >  >  >>>  >
>  >  >  >>>
>  >  >  >>
>  >  >  >>
>  >  >  >> --
>  >  >  >> Resizable and reorderable grid components.
>  >  >  >> http://www.inmethod.com
>  >  >  >>
>  >  >  >> ---------------------------------------------------------------------
>  >  >  >> To unsubscribe, e-mail: users-unsubscribe@...
>  >  >  >> For additional commands, e-mail: users-help@...
>  >  >  >>
>  >  >  >>
>  >  >  >
>  >  >
>  >  >
>  >
>  >  ---------------------------------------------------------------------
>  >  To unsubscribe, e-mail: users-unsubscribe@...
>  >  For additional commands, e-mail: users-help@...
>  >
>  >
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: users-unsubscribe@...
>  For additional commands, e-mail: users-help@...
>
>

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


Re: CompoundModel based on proxies

by igor.vaynberg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

not really sure. but this is how it would work.

proxies in cglib take handlers. so you would do:

String key=modelclass.getname();
Class proxy=cache.get(key);
if (proxy==null) {
   proxy=cglib.createproxy(modelclass);
   cache.put(key,proxy);
}
proxyhandler handler=new proxyhandler(this);
Object instance=proxy.getconstructor(handler.class).newinstance(handler);

so we reuse the generated proxy class for all instances of the given
model class, and use a fresh handler to intercept all calls to proxy
and build the expression.

-igor



On Tue, Feb 26, 2008 at 10:36 AM, James Carman
<james@...> wrote:

> So, you would cache the generated class (based on the type passed in)
>  and then have it generate a new object each time.  Then, cast that
>  object to Factory and set its callbacks?
>
>
>
>  On 2/26/08, Igor Vaynberg <igor.vaynberg@...> wrote:
>  > we can cache the created proxy class and simply give each instance a
>  >  new handler...
>  >
>  >
>  >  -igor
>  >
>  >
>  >
>  >  On Tue, Feb 26, 2008 at 10:26 AM, James Carman
>  >  <james@...> wrote:
>  >  > Have you tried this out using load testing?  You are creating a new
>  >  >  class every time you create a model.  Have you run out of permgen
>  >  >  space?
>  >  >
>  >  >
>  >  >
>  >  >  On 2/26/08, Sebastiaan van Erk <sebster@...> wrote:
>  >  >  > Well, there's a problem with normal PropertyModels (or
>  >  >  >  CompoundPropertyModels).
>  >  >  >
>  >  >  >  For example, if you have the following textfield:
>  >  >  >
>  >  >  >  TextField tf = new TextField("name", new PropertyModel(customer,
>  >  >  >  "customerName"));
>  >  >  >
>  >  >  >  Then a refactor of the customerName property (and the getCustomerName()
>  >  >  >  method) in an IDE such as Eclipse or NetBeans will *silently* break the
>  >  >  >  above code, which you will discover only at runtime...
>  >  >  >
>  >  >  >  The proxy based approach solves exactly this problem.
>  >  >  >
>  >  >  >  Regards,
>  >  >  >
>  >  >  > Sebastiaan
>  >  >  >
>  >  >  >
>  >  >  >
>  >  >  >
>  >  >  >  atul singh wrote:
>  >  >  >  > I feel this approach does NOT solve a problem.....Its just an alternative ..
>  >  >  >  >
>  >  >  >  > On Tue, Feb 26, 2008 at 4:48 PM, Matej Knopp <matej.knopp@...> wrote:
>  >  >  >  >
>  >  >  >  >> We've reworked the implementation a bit,it works like this:
>  >  >  >  >>
>  >  >  >  >>
>  >  >  >  >> SafePropertyModel<Person> p = new SafePropertyModel<Person>(new Person());
>  >  >  >  >> TextField field = new TextField("name", p.bind(p.property
>  >  >  >  >> ().getFirstName()));
>  >  >  >  >>
>  >  >  >  >> It's attached to the JIRA issue:
>  >  >  >  >> https://issues.apache.org/jira/browse/WICKET-1327
>  >  >  >  >>
>  >  >  >  >> -Matej
>  >  >  >  >>
>  >  >  >  >>
>  >  >  >  >> On Tue, Feb 26, 2008 at 11:32 AM, Sebastiaan van Erk
>  >  >  >  >> <sebster@...> wrote:
>  >  >  >  >>> Matej Knopp wrote:
>  >  >  >  >>>  > Hi,
>  >  >  >  >>>  >
>  >  >  >  >>>  > On Tue, Feb 26, 2008 at 11:13 AM, Sebastiaan van Erk
>  >  >  >  >>>  > <sebster@...> wrote:
>  >  >  >  >>>  >> Matej Knopp wrote:
>  >  >  >  >>>  >>  > 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
>  >  >  >  >>>  >>
>  >  >  >  >>>  >>  So proxy() returns a Customer proxy?
>  >  >  >  >>>  >>
>  >  >  >  >>>  >>  And model.bind() takes an Object argument (considering we don't
>  >  >  >  >> know in
>  >  >  >  >>>  >>  advance what type getCustomerName() returns)... What about
>  >  >  >  >> primitive
>  >  >  >  >>>  >>  types? Overload bind() for those as well?
>  >  >  >  >>>  > Well, the return object is not important at all. What is important is
>  >  >  >  >>>  > the getCustomerName() call. That marks somewhere in the model that
>  >  >  >  >>>  > last accessed property was called "customerName". and then
>  >  >  >  >> immediately
>  >  >  >  >>>  > after this model.bind takes this information.
>  >  >  >  >>>
>  >  >  >  >>>  OK, that's what I described. :-) And I was being stupid with respect to
>  >  >  >  >>>  the overloading. If bind takes an object as argument, then overloading
>  >  >  >  >>>  will not be necessary due to autoboxing. :-)
>  >  >  >  >>>
>  >  >  >  >>>
>  >  >  >  >>>  >>  And the call to getCustomerName() has the side effect of setting a
>  >  >  >  >> model
>  >  >  >  >>>  >>   object somewhere (e.g., in an instance field of model) which
>  >  >  >  >>>  >>  model.bind() can subsequently return?
>  >  >  >  >>>  > Model bind will return a model (variation of propertymodel probably).
>  >  >  >  >>>  > It will take the information that getCustomerName call on proxy
>  >  >  >  >>>  > provided.
>  >  >  >  >>>
>  >  >  >  >>>  Ok, so the proxy remembers which getter was called last, and you use
>  >  >  >  >>>  that to construct the model in bind(). Of course.
>  >  >  >  >>>
>  >  >  >  >>>
>  >  >  >  >>>  >>  Very interesting. I don't like the proxy() method name though. If
>  >  >  >  >> you
>  >  >  >  >>>  >>  call it something like property() it will look more like you're
>  >  >  >  >> binding
>  >  >  >  >>>  >>  to a property of Customer:
>  >  >  >  >>>  > Well, the naming can certainly be improved. I'm not sure about
>  >  >  >  >>>  > "property()" though. Well, we can discuss this more anyway.
>  >  >  >  >>>  >>  model.bind(model.property().getCustomerName())
>  >  >  >  >>>
>  >  >  >  >>>  Neither am I. :-) For one, it's quite long. But on the other hand, you
>  >  >  >  >>>  do bind to a model property, and so it reads ok. I think that proxies
>  >  >  >  >>>  should be "invisible" for general users, so they shouldn't have to
>  >  >  >  >>>  understand the magic going on here, nor that proxies are involved.
>  >  >  >  >>>
>  >  >  >  >>>
>  >  >  >  >>>  >>  VERY neat idea though... :-)
>  >  >  >  >>>  > Thanks.
>  >  >  >  >>>
>  >  >  >  >>>  What I really like about this solution is that it can be implemented
>  >  >  >  >>>  completely separately from wicket-core, so you can just put it in it's
>  >  >  >  >>>  own project. :-)
>  >  >  >  >>>
>  >  >  >  >>>  Regards,
>  >  >  >  >>>  Sebastiaan
>  >  >  >  >>>
>  >  >  >  >>>
>  >  >  >  >>>
>  >  >  >  >>>  > -Matej
>  >  >  >  >>>  >>  Regards,
>  >  >  >  >>>  >>  Sebastiaan
>  >  >  >  >>>  >>
>  >  >  >  >>>  >>
>  >  >  >  >>>  >>
>  >  >  >  >>>  >>  >
>  >  >  >  >>>  >>  > On Fri, Feb 8, 2008 at 6:17 PM, Johan Compagner <
>  >  >  >  >> jcompagner@...> 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 <scott.swank@...>
>  >  >  >  >> 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 <jcompagner@...>
>  >  >  >  >> 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 <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@...
>  >  >  >  >>>  >>  >>  > > >
>  >  >  >  >>>  >>  >>  > > >
>  >  >  >  >>>  >>  >>  > >
>  >  >  >  >>>  >>  >>  >
>  >  >  >  >>>  >>  >>  >
>  >  >  >  >>>  >>  >>  >
>  >  >  >  >>>  >>  >>  > --
>  >  >  >  >>>  >>  >>  >  Scott Swank
>  >  >  >  >>>  >>  >>  > reformed mathematician
>  >  >  >  >>>  >>  >>  >
>  >  >  >  >>>  >>  >>  >
>  >  >  >  >> ---------------------------------------------------------------------
>  >  >  >  >>>  >>  >>  > To unsubscribe, e-mail: users-unsubscribe@...
>  >  >  >  >>>  >>  >>  > For additional commands, e-mail: users-help@...
>  >  >  >  >>>  >>  >>  >
>  >  >  >  >>>  >>  >>  >
>  >  >  >  >>>  >>  >>
>  >  >  >  >>>  >>  >
>  >  >  >  >>>  >>  >
>  >  >  >  >>>  >>  >
>  >  >  >  >>>  >>
>  >  >  >  >>>  >
>  >  >  >  >>>  >
>  >  >  >  >>>  >
>  >  >  >  >>>
>  >  >  >  >>
>  >  >  >  >>
>  >  >  >  >> --
>  >  >  >  >> Resizable and reorderable grid components.
>  >  >  >  >> http://www.inmethod.com
>  >  >  >  >>
>  >  >  >  >> ---------------------------------------------------------------------
>  >  >  >  >> To unsubscribe, e-mail: users-unsubscribe@...
>  >  >  >  >> For additional commands, e-mail: users-help@...
>  >  >  >  >>
>  >  >  >  >>
>  >  >  >  >
>  >  >  >
>  >  >  >
>  >  >
>  >  >  ---------------------------------------------------------------------
>  >  >  To unsubscribe, e-mail: users-unsubscribe@...
>  >  >  For additional commands, e-mail: users-help@...
>  >  >
>  >  >
>  >
>  >  ---------------------------------------------------------------------
>  >  To unsubscribe, e-mail: users-unsubscribe@...
>  >  For additional commands, e-mail: users-help@...
>  >
>  >
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: users-unsubscribe@...
>  For additional commands, e-mail: users-help@...
>
>

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


Re: CompoundModel based on proxies

by jwcarman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Well, if you wait a bit until I do another release of Commons Proxy,
it'll have that feature built in.  Also, you could use Javassist if
you wanted to very easily.

On 2/26/08, Igor Vaynberg <igor.vaynberg@...> wrote:

> not really sure. but this is how it would work.
>
>  proxies in cglib take handlers. so you would do:
>
>  String key=modelclass.getname();
>  Class proxy=cache.get(key);
>  if (proxy==null) {
>    proxy=cglib.createproxy(modelclass);
>    cache.put(key,proxy);
>  }
>  proxyhandler handler=new proxyhandler(this);
>  Object instance=proxy.getconstructor(handler.class).newinstance(handler);
>
>  so we reuse the generated proxy class for all instances of the given
>  model class, and use a fresh handler to intercept all calls to proxy
>  and build the expression.
>
>  -igor
>
>
>
>  On Tue, Feb 26, 2008 at 10:36 AM, James Carman
>
> <james@...> wrote:
>  > So, you would cache the generated class (based on the type passed in)
>  >  and then have it generate a new object each time.  Then, cast that
>  >  object to Factory and set its callbacks?
>  >
>  >
>  >
>  >  On 2/26/08, Igor Vaynberg <igor.vaynberg@...> wrote:
>  >  > we can cache the created proxy class and simply give each instance a
>  >  >  new handler...
>  >  >
>  >  >
>  >  >  -igor
>  >  >
>  >  >
>  >  >
>  >  >  On Tue, Feb 26, 2008 at 10:26 AM, James Carman
>  >  >  <james@...> wrote:
>  >  >  > Have you tried this out using load testing?  You are creating a new
>  >  >  >  class every time you create a model.  Have you run out of permgen
>  >  >  >  space?
>  >  >  >
>  >  >  >
>  >  >  >
>  >  >  >  On 2/26/08, Sebastiaan van Erk <sebster@...> wrote:
>  >  >  >  > Well, there's a problem with normal PropertyModels (or
>  >  >  >  >  CompoundPropertyModels).
>  >  >  >  >
>  >  >  >  >  For example, if you have the following textfield:
>  >  >  >  >
>  >  >  >  >  TextField tf = new TextField("name", new PropertyModel(customer,
>  >  >  >  >  "customerName"));
>  >  >  >  >
>  >  >  >  >  Then a refactor of the customerName property (and the getCustomerName()
>  >  >  >  >  method) in an IDE such as Eclipse or NetBeans will *silently* break the
>  >  >  >  >  above code, which you will discover only at runtime...
>  >  >  >  >
>  >  >  >  >  The proxy based approach solves exactly this problem.
>  >  >  >  >
>  >  >  >  >  Regards,
>  >  >  >  >
>  >  >  >  > Sebastiaan
>  >  >  >  >
>  >  >  >  >
>  >  >  >  >
>  >  >  >  >
>  >  >  >  >  atul singh wrote:
>  >  >  >  >  > I feel this approach does NOT solve a problem.....Its just an alternative ..
>  >  >  >  >  >
>  >  >  >  >  > On Tue, Feb 26, 2008 at 4:48 PM, Matej Knopp <matej.knopp@...> wrote:
>  >  >  >  >  >
>  >  >  >  >  >> We've reworked the implementation a bit,it works like this:
>  >  >  >  >  >>
>  >  >  >  >  >>
>  >  >  >  >  >> SafePropertyModel<Person> p = new SafePropertyModel<Person>(new Person());
>  >  >  >  >  >> TextField field = new TextField("name", p.bind(p.property
>  >  >  >  >  >> ().getFirstName()));
>  >  >  >  >  >>
>  >  >  >  >  >> It's attached to the JIRA issue:
>  >  >  >  >  >> https://issues.apache.org/jira/browse/WICKET-1327
>  >  >  >  >  >>
>  >  >  >  >  >> -Matej
>  >  >  >  >  >>
>  >  >  >  >  >>
>  >  >  >  >  >> On Tue, Feb 26, 2008 at 11:32 AM, Sebastiaan van Erk
>  >  >  >  >  >> <sebster@...> wrote:
>  >  >  >  >  >>> Matej Knopp wrote:
>  >  >  >  >  >>>  > Hi,
>  >  >  >  >  >>>  >
>  >  >  >  >  >>>  > On Tue, Feb 26, 2008 at 11:13 AM, Sebastiaan van Erk
>  >  >  >  >  >>>  > <sebster@...> wrote:
>  >  >  >  >  >>>  >> Matej Knopp wrote:
>  >  >  >  >  >>>  >>  > 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
>  >  >  >  >  >>>  >>
>  >  >  >  >  >>>  >>  So proxy() returns a Customer proxy?
>  >  >  >  >  >>>  >>
>  >  >  >  >  >>>  >>  And model.bind() takes an Object argument (considering we don't
>  >  >  >  >  >> know in
>  >  >  >  >  >>>  >>  advance what type getCustomerName() returns)... What about
>  >  >  >  >  >> primitive
>  >  >  >  >  >>>  >>  types? Overload bind() for those as well?
>  >  >  >  >  >>>  > Well, the return object is not important at all. What is important is
>  >  >  >  >  >>>  > the getCustomerName() call. That marks somewhere in the model that
>  >  >  >  >  >>>  > last accessed property was called "customerName". and then
>  >  >  >  >  >> immediately
>  >  >  >  >  >>>  > after this model.bind takes this information.
>  >  >  >  >  >>>
>  >  >  >  >  >>>  OK, that's what I described. :-) And I was being stupid with respect to
>  >  >  >  >  >>>  the overloading. If bind takes an object as argument, then overloading
>  >  >  >  >  >>>  will not be necessary due to autoboxing. :-)
>  >  >  >  >  >>>
>  >  >  >  >  >>>
>  >  >  >  >  >>>  >>  And the call to getCustomerName() has the side effect of setting a
>  >  >  >  >  >> model
>  >  >  >  >  >>>  >>   object somewhere (e.g., in an instance field of model) which
>  >  >  >  >  >>>  >>  model.bind() can subsequently return?
>  >  >  >  >  >>>  > Model bind will return a model (variation of propertymodel probably).
>  >  >  >  >  >>>  > It will take the information that getCustomerName call on proxy
>  >  >  >  >  >>>  > provided.
>  >  >  >  >  >>>
>  >  >  >  >  >>>  Ok, so the proxy remembers which getter was called last, and you use
>  >  >  >  >  >>>  that to construct the model in bind(). Of course.
>  >  >  >  >  >>>
>  >  >  >  >  >>>
>  >  >  >  >  >>>  >>  Very interesting. I don't like the proxy() method name though. If
>  >  >  >  >  >> you
>  >  >  >  >  >>>  >>  call it something like property() it will look more like you're
>  >  >  >  >  >> binding
>  >  >  >  >  >>>  >>  to a property of Customer:
>  >  >  >  >  >>>  > Well, the naming can certainly be improved. I'm not sure about
>  >  >  >  >  >>>  > "property()" though. Well, we can discuss this more anyway.
>  >  >  >  >  >>>  >>  model.bind(model.property().getCustomerName())
>  >  >  >  >  >>>
>  >  >  >  >  >>>  Neither am I. :-) For one, it's quite long. But on the other hand, you
>  >  >  >  >  >>>  do bind to a model property, and so it reads ok. I think that proxies
>  >  >  >  >  >>>  should be "invisible" for general users, so they shouldn't have to
>  >  >  >  >  >>>  understand the magic going on here, nor that proxies are involved.
>  >  >  >  >  >>>
>  >  >  >  >  >>>
>  >  >  >  >  >>>  >>  VERY neat idea though... :-)
>  >  >  >  >  >>>  > Thanks.
>  >  >  >  >  >>>
>  >  >  >  >  >>>  What I really like about this solution is that it can be implemented
>  >  >  >  >  >>>  completely separately from wicket-core, so you can just put it in it's
>  >  >  >  >  >>>  own project. :-)
>  >  >  >  >  >>>
>  >  >  >  >  >>>  Regards,
>  >  >  >  >  >>>  Sebastiaan
>  >  >  >  >  >>>
>  >  >  >  >  >>>
>  >  >  >  >  >>>
>  >  >  >  >  >>>  > -Matej
>  >  >  >  >  >>>  >>  Regards,
>  >  >  >  >  >>>  >>  Sebastiaan
>  >  >  >  >  >>>  >>
>  >  >  >  >  >>>  >>
>  >  >  >  >  >>>  >>
>  >  >  >  >  >>>  >>  >
>  >  >  >  >  >>>  >>  > On Fri, Feb 8, 2008 at 6:17 PM, Johan Compagner <
>  >  >  >  >  >> jcompagner@...> 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 <scott.swank@...>
>  >  >  >  >  >> 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 <jcompagner@...>
>  >  >  >  >  >> 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 <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@...
>  >  >  >  >  >>>  >>  >>  > > >
>  >  >  >  >  >>>  >>  >>  > > >
>  >  >  >  >  >>>  >>  >>  > >
>  >  >  >  >  >>>  >>  >>  >
>  >  >  >  >  >>>  >>  >>  >
>  >  >  >  >  >>>  >>  >>  >
>  >  >  >  >  >>>  >>  >>  > --
>  >  >  >  >  >>>  >>  >>  >  Scott Swank
>  >  >  >  >  >>>  >>  >>  > reformed mathematician
>  >  >  >  >  >>>  >>  >>  >
>  >  >  >  >  >>>  >>  >>  >
>  >  >  >  >  >> ---------------------------------------------------------------------
>  >  >  >  >  >>>  >>  >>  > To unsubscribe, e-mail: users-unsubscribe@...
>  >  >  >  >  >>>  >>  >>  > For additional commands, e-mail: users-help@...
>  >  >  >  >  >>>  >>  >>  >
>  >  >  >  >  >>>  >>  >>  >
>  >  >  >  >  >>>  >>  >>
>  >  >  >  >  >>>  >>  >
>  >  >  >  >  >>>  >>  >
>  >  >  >  >  >>>  >>  >
>  >  >  >  >  >>>  >>
>  >  >  >  >  >>>  >
>  >  >  >  >  >>>  >
>  >  >  >  >  >>>  >
>  >  >  >  >  >>>
>  >  >  >  >  >>
>  >  >  >  >  >>
>  >  >  >  >  >> --
>  >  >  >  >  >> Resizable and reorderable grid components.
>  >  >  >  >  >> http://www.inmethod.com
>  >  >  >  >  >>
>  >  >  >  >  >> ---------------------------------------------------------------------
>  >  >  >  >  >> To unsubscribe, e-mail: users-unsubscribe@...
>  >  >  >  >  >> For additional commands, e-mail: users-help@...
>  >  >  >  >  >>
>  >  >  >  >  >>
>  >  >  >  >  >
>  >  >  >  >
>  >  >  >  >
>  >  >  >
>  >  >  >  ---------------------------------------------------------------------
>  >  >  >  To unsubscribe, e-mail: users-unsubscribe@...
>  >  >  >  For additional commands, e-mail: users-help@...
>  >  >  >
>  >  >  >
>  >  >
>  >  >  ---------------------------------------------------------------------
>  >  >  To unsubscribe, e-mail: users-unsubscribe@...
>  >  >  For additional commands, e-mail: users-help@...
>  >  >
>  >  >
>  >
>  >  ---------------------------------------------------------------------
>  >  To unsubscribe, e-mail: users-unsubscribe@...
>  >  For additional commands, e-mail: users-help@...
>  >
>  >
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: users-unsubscribe@...
>  For additional commands, e-mail: users-help@...
>
>

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

< Prev | 1 - 2 - 3 - 4 - 5 | Next >