【发布时间】:2014-09-30 06:56:55
【问题描述】:
我有一个包含 2 个面板(面板 a 和面板 b)的页面。我使用其中一个面板(面板 b)在表格中显示一些数据。我在此表中添加了一个表单和一些复选框。我的第二个面板(panal a)用于显示按钮。 我想通过按下面板a的按钮来提交面板b的表单,这样我就可以对选中的那些做一些事情。
我搜索了一下,我想我必须使用 ajax 提交链接。但我不明白我是如何得到我选中的行的。
页面标记:
<wicket:extend xmlns:wicket="http://wicket.apache.org">
<div style="margin-top: 60px">
<h2><span wicket:id="header"></span></h2>
<div wicket:id="categoryButtonPanel"></div>
<div wicket:id="categoryTablePanel"></div>
</div>
</wicket:extend>
这就是我在面板 b (categoryTablePanel) 中添加复选框的方式:
Form form = new Form("form");
final List<Category> selectedCategorys = new ArrayList<Category>(); //my list where my selected rows are in
CheckGroup group = new CheckGroup("group", selectedCategorys);
DataView dv = new DataView("categoryList", dataProvider) {
@Override
protected void populateItem(Item item) {
final Category category = (Category) item.getModelObject();
final CompoundPropertyModel<Category> categoryModel = new CompoundPropertyModel<Category>(category);
item.add(new Check("checkBox", item.getModel()));
// some more binded rows
}
};
标记:
<wicket:panel xmlns:wicket="http://wicket.apache.org">
<form wicket:id="form">
<span wicket:id="group">
<div class="table table-striped table-hover table-condensed" style="overflow: auto !important;" wicket:id="categoryTable">
<table class="table table-striped">
<thead>
<th><input type="checkbox" wicket:id="selector">check/uncheck all</input></th>
</thead>
<tbody>
<tr wicket:id="categoryList">
<td>
<input type="checkbox" wicket:id="checkBox" />
</td>
</tr>
</tbody>
</table>
<div wicket:id="paginator"></div>
</div>
</span>
</form>
</wicket:panel>
我实际上可以检查每一行,如果我在表单中创建一个普通按钮,我可以使用列表selectedCategorys 来处理数据。
现在我想在第二个面板 (categoryButtonPanel) 中添加一两个按钮来处理我的数据。但是怎么做呢?
【问题讨论】: