A simpler API would be:

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

or even:

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

since you are calling this method with a specific List, and hence the
type of the List is known.

Scott


On Sun, Feb 13, 2011 at 11:32 AM, Jeremy Thomerson
<[email protected]> wrote:
> On Sat, Feb 12, 2011 at 8:49 AM, Willis Blackburn <[email protected]> wrote:
>
>> [email protected] wrote:
>> >
>> > On Sat, Feb 12, 2011 at 7:56 AM, Willis Blackburn <[email protected]>
>> > wrote:
>> >
>> > As a side note, rarely should you ever use Model class for a list of
>> > things,
>> > especially things loaded from a database.  If you then pass that model to
>> > a
>> > component, all the things in it will be serialized.
>> >
>> >
>>
>> I'm sorry that I said that I loaded the list from a database, since that
>> has
>> apparently created a distraction from my key point, which is that if you
>> start with a List<C> and pass it to Model.listOf, you get back something
>> that is not a List<C>, which is undesirable and perhaps unnecessary.
>>
>
> 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.
>
>
>> > So use the Model constructors instead.  The factory methods are just
>> there
>> > to help remove some verbosity related to generics.
>> >
>>
>> Have you tried this yourself?  Because it doesn't work.  You can only
>> instantiate Model with a Serializable instance, and java.util.List does not
>> implement Serializable.  The whole point of the ofList method is to
>> generate
>> serializable lists, and the documentation even says so: "This factory
>> method
>> will automatically rebuild a nonserializable list into a serializable one."
>> You're confusing Model.listOf with Model.of.
>>
>
> 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.
>
> --
> Jeremy Thomerson
> http://wickettraining.com
> *Need a CMS for Wicket?  Use Brix! http://brixcms.org*
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to