我正在将wicket从1.3.6迁移到1.4.0.我通过getModel()和getModelObject()方法得到语法错误.它说它们是未定义的,因此它们阻止了应用程序的编译.我应该使用哪种方法代替它们?
这是我的代码的一部分:
@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++;
}
}
Run Code Online (Sandbox Code Playgroud)
使用getDefaultModelObject()替代
Wicket通常提供迁移指南:https: //cwiki.apache.org/WICKET/migrating-to-wicket-14.html#MigratingtoWicket1.4-Component.getModel%2528%2529andfriendsrenamedtogetDefaultModel%2528%2529andfriends
BTW:wicket 1.5也已经出局了
| 归档时间: |
|
| 查看次数: |
331 次 |
| 最近记录: |