I’m migrating wicket from 1.3.6 to 1.4.0. I get syntax error by getModel() and getModelObject() methods. It says they are undefined, so they prevent application from compiling. Which methods should I use instead of them?
This is part of my code:
@SuppressWarnings("unchecked")
public BreadCrumbTrail(String id, IModel model) {
super(id, model);
// Keep a count of the crumbs
int count = 1;
// Get the crumbs
List<Crumb> crumbs = (List<Crumb>) getModelObject();
// Create a repeating view to render the crumbs within
RepeatingView repeating = new RepeatingView("crumbs");
add(repeating);
// Add each crumb
for (final Crumb crumb : crumbs) {
WebMarkupContainer item = new WebMarkupContainer(repeating
.newChildId());
repeating.add(item);
// Create a link from the page held in the crumb
@SuppressWarnings("serial")
Link link = new Link("link", item.getModel()) {
public void onClick() {
setResponsePage(crumb.getPage());
}
};
// Add a title/label to the link
link.add(new Label("title", crumb.getTitle()));
item.add(link);
// Is this the last crumb?
if (count == crumbs.size()) {
// Don't add the normal separator
item.add(new Label("separator", " "));
// Disable the link as this is the current page
link.setEnabled(false);
} else {
// Add the separator
item.add(new Label("separator", " > "));
}
// Up the count of crumbs
count++;
}
}
use
getDefaultModelObject()insteadWicket usually provides a migration guide:
https://cwiki.apache.org/WICKET/migrating-to-wicket-14.html#MigratingtoWicket1.4-Component.getModel%2528%2529andfriendsrenamedtogetDefaultModel%2528%2529andfriends
BTW: wicket 1.5 is also already out