我收到了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
)中添加一个或两个按钮,以使用我的数据做一些事情。但是如何?
但是,如果我把面板放在页面中,我需要将'CheckGroup'放入页面中。因为我必须将该检查组添加到表单中。这意味着我需要把我的列表放在那里。 所以我需要将我的表单,组和选定的列表传递给我的面板。我感觉不对。不知何故,我不能在我的'AjaxSubmitLink'中获得选定的List? – monti 2014-09-30 08:43:16
为什么?选择将与表格一起显示。唯一需要的是对表单的引用。你甚至可以在窗体上使用'getForm'方法并将结果传递给其他面板。 – RobAu 2014-09-30 09:51:18
我用表单包装了两个面板,并在页面内创建了表单,selectedList和我的检查组。 我只将我的selectedList传递给我的ButtonPanel,我可以使用它。 – monti 2014-09-30 09:51:44