1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
| // 首先我们需要创建这个 action 对应的 Panel 容器。
private class ActionPanel extendsPanel
{
public ActionPanel(String id, finalIModel<ProductBean> model)
{
super(id, model);
/* 这个是给 Panel 里面添加各个 link 标签,在各自的 onclick 事件里来做自己的
逻辑处理,同时 model.getObject() 通过这个方法我们就可以拿到绑定到当
前 Panel 上的 Model 对象,一般我们会绑定当前行对应的 databean。*/
add(newLink<ProductBean>("Startup", model)
{
@Override
public void onClick()
{
ProductBean pb = model.getObject();
}
});
add(newLink<ProductBean>("Shutdown", model)
{
@Override
public
voidonClick()
{
ProductBean pb = model.getObject();
}
});
add(newLink<ProductBean>("Delete", model)
{
@Override
public void onClick()
{
ProductBean pb = model.getObject();
}
});
}
}
// 对于 column 的设定,同样的利用 column 的 populateItem 方法对 actions 设置 Panel。
columns.add(newAbstractColumn<ProductBean>(newModel<String>("Actions")){
public void populateItem(
Item<ICellPopulator<ProductBean>> cellItem, String componentId, IModel<ProductBean> model)
{
cellItem.add(newActionPanel(componentId, model));
}
});
|