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