Tapestry 和 Wicket 的比较
2010-03-30 00:00:00 来源:WEB开发网清单 19. Tapestry HTML 标记
<span jwcid="table">
<table>
<tr><span jwcid="receivedItemsColumns" class="title"/></tr>
<tr jwcid="receivedItemsRows">
<td jwcid="receivedItemsValues"/>
</tr>
</table>
<span jwcid="receivedItemsPages"/>
</span>
Wicket 一同提供了一个 DataView 类和一个 IDataProvider 实现,如下所示:
清单 20. Wicket 的 DataView 类
public class ItemsDataProvider implements IdataProvider {
public Iterator iterator(int first, int count) {
return getActionItemManager().getActionItemsListByRecipient(uid, first, count);
}
public int size() {
return getActionItemManager().getActionItemsCountByRecipient(uid);
}
public IModel model(Object object) {
return new LoadableDetachableModel(object);
}
}
public ListActionItems extends WebPage {
public ListActionItems() {
DataView dataView = new DataView("receivedItemsView", new ItemsDataProvider()) {
protected void populateItem(final Item item) {
ActionItem todo = (ActionItem) item.getModelObject();
item.add(new Label("itemId", String.valueOf(todo.getItemId()));
item.add(new Label("subject", todo.getSubject()));
item.add(new Label("creator", todo.getCreator()));
item.add(new Label("recipient", todo.getRecipient()));
}
};
dataView.setItemsPerPage(10);
add(dataView);
add(new PagingNavigator("receivedItemsPages", dataView));
}
}
更多精彩
赞助商链接