How (not) to: IModel and Collections (and generics)

2009-03-04 Thread Johannes Schneider
Hi, the concept of IModel seems to be very obvious. It is simply some kind of reference and offers a getter and a setter. When used with ordinary object, everything works fine. An IModel that contains a String can easily be mapped to a TextField. The text field calls "getObject" to show the initi

Re: How (not) to: IModel and Collections (and generics)

2009-03-04 Thread Scott Swank
Does AbstractReadOnlyModel accomplish what you're talking about? Scott On Wed, Mar 4, 2009 at 4:50 AM, Johannes Schneider wrote: > Hi, > > the concept of IModel seems to be very obvious. It is simply some kind > of reference and offers a getter and a setter. > > When used with ordinary object, e

Re: How (not) to: IModel and Collections (and generics)

2009-03-04 Thread Igor Vaynberg
components that deal with collections in wicket always reuse the same instance of collection is one was provided where it makes sense. setobject is still called on the model, but is called with the same instance of collection. this is necessary so that if you have a model that translates a collect

Re: How (not) to: IModel and Collections (and generics)

2009-03-07 Thread Johannes Schneider
On Wed, 2009-03-04 at 08:27 -0800, Scott Swank wrote: > Does AbstractReadOnlyModel accomplish what you're talking about? Not really. I suggest a separate interface that does not extend IModel. Instead IModel should extend that one (since it adds the setter)... And of course that interface should

Re: How (not) to: IModel and Collections (and generics)

2009-03-07 Thread Johannes Schneider
On Wed, 2009-03-04 at 09:14 -0800, Igor Vaynberg wrote: > components that deal with collections in wicket always reuse the same > instance of collection is one was provided where it makes sense. Yes, and therefore a setter is not necessary. > setobject is still called on the model, but is called

Re: How (not) to: IModel and Collections (and generics)

2009-03-07 Thread Igor Vaynberg
On Sat, Mar 7, 2009 at 10:15 AM, Johannes Schneider wrote: > > > setobject is still called on the model, but is called with the same > > instance of collection. this is necessary so that if you have a model > > that translates a collection of one type to a collection of another > > can perform the

Re: How (not) to: IModel and Collections (and generics)

2009-03-07 Thread Johannes Schneider
> i think "misuse" is a pretty bold word considering you are talking to > people who designed and built imodel, dont you think? :) Well, I think you are right. Sorry for that. I just mean, that it has a bad smell here... > > if we do what you suggest then we would end up with: > > interface im

Re: How (not) to: IModel and Collections (and generics)

2009-03-07 Thread Igor Vaynberg
you are right, the components that just read a collection do just that, read it. they simply ignore the setter method in imodel. no big deal, just because you are given an interface doesnt mean you have to use all the methods in it. thus abstractreadonlymodel. however, a lot of components manipula

Re: How (not) to: IModel and Collections (and generics)

2009-03-10 Thread Johannes Schneider
Thanks for your reply. I think I can (at least partially) understand your position and think there aren't any new arguments here I can mention. So the discussions seems to be at an end here. Maybe it is a matter of taste... If I find any time, I will create a patch... Regards, Johannes On Sat,