我使用Apache Wicket中的DefaultDataTable对象打印了一个表.
现在我想添加一个到每个表格单元格的链接.
我找到了解释其中一些内容的链接,但我对第一种方法有疑问.
columns[0] = new TextFilteredPropertyColumn(new Model("Id"), "id", "id") {
// add the LinkPanel to the cell item
public void populateItem(Item cellItem, String componentId, IModel model) {
final Transaction transaction = (Transaction) model.getObject(cellItem);
cellItem.add(new TransactionList.LinkPanel(componentId, transaction));
}
};
private class LinkPanel extends Panel {
public LinkPanel(String id, Transaction transaction) {
super(id);
final String name = transaction.getId();
PageParameters param = new PageParameters("id=" + name);
BookmarkablePageLink link = new BookmarkablePageLink("link", TransactionDetail.class, param);
link.add(new Label("label", name));
add(link);
}
Run Code Online (Sandbox Code Playgroud)
什么是交易以及交易的作用是什么?什么是LinkPanel类?如果有更简单的方法,我很乐意知道!