I got a Page with 2 Panels (panel a and panel b). I use one of those panels (panel b) for showing some data in a table. I added a form and some checkboxes to this table. My second panel (panal a) is used for showing buttons. I want to submit the form of panel b by pushing a button of panel a, so I can do some stuff with the checked ones.
I searched a little bit and I think I have to use an ajax submit link. But I dont get how I get my checked rows.
Page Markup:
<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>
this is how I add my checkboxes in panel 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
}
};
Markup:
<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>
I can actually check every row, and if I create a normal button inside the form I can use the list selectedCategorys
to do some stuff with the data.
Now I want to add one or two buttons in my second panel (categoryButtonPanel
) to do some things with my data. But how?
Just creating the AjaxSubmitLink
using this constructor should work:
AjaxSubmitLink(String id, Form<?> form)
So you need to somehow pass the form to the other panel to add it to the submitlink. Personally, I would add both the panels to a big form.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments