Listviews with Links in them, sometimes fail to retrieve the object in the
onClick() method the first time around. When I reload the page, the code
works fine.
Here is a test. In the listview below, I load the page and in the listview
loop code, I correctly retrieve the item. Note that in the onClick() the
modelobject is null.
TEMPLATE NAME IN listview: first
TEMPLATE NAME IN onClick(): null
Reloading the page, and the problem goes away.
TEMPLATE NAME IN listview: first
TEMPLATE NAME IN onClick(): first
This is using wicket 1.3.5. and db4o 7.8. This problem is normally there
when I restart my application.
Any ideas?
Example code:
ListView templateList = new ListView("listview", ModelConverter
.getModelList(templates, TemplateWebModel.class)) {
@Override
protected void populateItem(ListItem item) {
final TemplateWebModel templatewebmodel = (TemplateWebModel)
item
.getModelObject();
System.out.println("TEMPLATE NAME IN listview: "
+ templatewebmodel.getEntity().getName());
item.setModel(new CompoundPropertyModel(templatewebmodel));
...
item.add(new Link("edit") {
@Override
public void onClick() {
System.out.println("TEMPLATE NAME IN onClick(): "
+ templatewebmodel.getEntity().getName());
setResponsePage(new
TemplateEditPage(templatewebmodel));
}
});
...