我收到了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