On Feb 13, 2011, at 2:33 PM, jer...@wickettraining.com [via Apache Wicket] 
wrote:

> I understood your key point, which is why I said "as a side note".... but my 
> point still remains.  Loading a list and then sticking it into Model class 
> is in almost all cases a *bad* idea. 


I agree with you!  But nevertheless there are some cases in which a 
Model<List<C>> makes sense--even when a database is involved.  If, for example, 
the List is small, and is expensive to generate from the database, then 
serializing it and keeping it in the session could be the best approach.


> Sorry, yes, it was early and I wasn't paying attention.  Hadn't had my 
> Wheaties yet :)  Have you looked at the ListModel class?  It may help with 
> what you're looking for. 
> 
> Do you have a suggestion for a better method signature for that method?  The 
> problem you are describing, if I understand your description correctly, is a 
> problem with Java generics, not with Wicket's use of them. 


I hadn't seen ListModel, but thanks--it looks like a good solution.  Although 
it sort of makes Model.listOf even more mysterious, in that Model.listOf 
doesn't create a ListModel.

My suggestion for Model.listOf is simply:

    public static <C> IModel<List<C>> ofList(final List<C> list)

In other words it takes a List<C> and return an IModel<List<C>>, which is (I 
think) what you'd expect.

Maybe the thinking is that Model.listOf may need to return a list of some 
serializable subclass of C, if C is not serializable itself.

W





-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Unfriendly-Model-ofList-etc-methods-can-anything-be-done-tp3302712p3304062.html
Sent from the Users forum mailing list archive at Nabble.com.

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

Reply via email to