I have in CheesrPage the following:
private List<Cheese> getCheeses() {
return CheeseApplication.get().getCheeses();
}
If I change that to:
private IModel<List<Cheese>> getCheeses() {
return CheeseApplication.get().getCheeses();
}
I then just get the same warning here, and of course then I can go
back to the CheeseApplication class and change the getCheeses there,
but I get the same warning there.
It's just moving the problem around.
Andy
On Thu, Oct 15, 2009 at 4:00 PM, Jeremy Thomerson
<[email protected]> wrote:
> the key is in getCheeses...
>
> It should be something like private IModel<List<Cheese>> getCheeses()
>
> --
> Jeremy Thomerson
> http://www.wickettraining.com
>
>
>
> On Thu, Oct 15, 2009 at 4:55 PM, Andrig T. Miller <[email protected]
>> wrote:
>
>> I have been going through the Wicket in Action book, but using the
>> 1.4.2 release. I figured the changes where minimal enough I could get
>> through things. In the Cheese store example I have the following
>> code:
>>
>>
>> package org.miller.wicket.example;
>>
>> import org.apache.wicket.markup.html.basic.Label;
>> import org.apache.wicket.markup.html.link.Link;
>> import org.apache.wicket.markup.html.list.ListItem;
>> import org.apache.wicket.markup.html.list.ListView;
>> import org.apache.wicket.model.IModel;
>>
>> public class Index extends CheesrPage {
>>
>> public Index() {
>>
>> add(new ListView<Cheese>("cheeses", getCheeses()) {
>>
>> private static final long serialVersionUID =
>> -6160450216067455300L;
>>
>> @Override
>> protected void populateItem(ListItem<Cheese> item) {
>>
>> Cheese cheese = (Cheese) getDefaultModelObject();
>>
>> item.add(new Label("name", cheese.getName()));
>> item.add(new Label("description",
>> cheese.getDescription()));
>> item.add(new Label("price", "$" + cheese.getPrice()));
>> item.add(new Link<Cheese>("add", item.getDefaultModel()) {
>>
>> private static final long serialVersionUID =
>> 3724016761964076585L;
>>
>> @Override
>> public void onClick() {
>>
>> Cheese selected = (Cheese) getDefaultModelObject();
>> getCart().getCheeses().add(selected);
>>
>> }
>> });
>> }
>> });
>>
>> }
>>
>> }
>>
>> The line item.add(new Link<Cheese>("add", item.getDefaultModel()) {
>> ...
>>
>> Doesn't compile in Eclipse. It will compile if I remove the <Cheese>
>> from the Link, but warns about Link being a raw type that should be
>> parameterized.
>>
>> I can get it to compile if I cast the result of item.getDefaultModel
>> in this way (IModel<Cheese>), but then Eclipse gives me a warning
>> saying unchecked cast IModel<capture#1-of ?> to IModel<Cheese>.
>>
>> What's the right syntax? I'm sure I'm missing something obvious.
>>
>> Thanks for any help.
>>
>> Andy
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]