检票口中的可分页列表视图中的复选框
checkbox in pageablelistview in wicket
private ArrayList<MFRList> list;
private ArrayList<STUList> list1 = new ArrayList<STUList>();
public ResultPage(PageParameters params) throws APIException {
Form form = new Form("form");
PageableListView view = new PageableListView("view", list, 10) {
@Override
public void onConfigure() {
super.onConfigure();
setVisible(list.size() > 0);
}
@Override
protected void populateItem(ListItem item) {
final StuList stu= (StuList) item.getModelObject();
item.add(new CheckBox("check", item.getModel()));
item.add(new Label("name", stu.getName()));
item.add(new Label("num", stu.getNumber()));
item.add(new Label("age", stu.getAge()));
item.add(new Label("sex", stu.getSex()));
}
};
Button backtosearchbutton = new Button("backtosearchbutton") {
@Override
public void onSubmit() {
setResponsePage(SearchPage.class);
}
}.setDefaultFormProcessing(false);
Button groupcheckbutton = new Button("groupcheckbutton") {
@Override
public void onSubmit() {
}
}.setDefaultFormProcessing(false);
Button groupuncheckbutton = new Button("groupuncheckbutton") {
@Override
public void onSubmit() {
}
}.setDefaultFormProcessing(false);
Button submitselectionbutton = new Button("submitselectionbutton") {
@Override
public void onSubmit() {
}
}.setDefaultFormProcessing(true);
form.add(view);
form.add(backtosearchbutton);
form.add(submitselectionbutton);
form.add(groupuncheckbutton);
form.add(groupcheckbutton);
add(form);
add(new CustomPagingNavigator("navigator", view));
如何存储所选记录以及如何使用它。我知道在提交表格时会提交这些记录,但我不清楚如何以及在何处提交。
我的 pojo 是
public class MFRList implements Serializable {
private String name;
private String num;
private String age;
private String sex;
private Boolean selected = Boolean.FALSE;
public String getName() {
return Name;
}
public void setName(String Name) {
this.Name = Name;
}
public String getnum() {
return num;
}
public void setnum(String num) {
this.num = num;
}
public String getAge() {
return age;
}
public void setsex(String sex) {
this.sex= sex;
}
public String getsex() {
return sex;
}
public void setage(String age) {
this.age = age;
}
public Boolean getSelected() {
return selected;
}
public void setSelected(Boolean selected) {
this.selected = selected;
}
}
所选行保存在哪里,如何检索和使用它。
提前致谢
我得到了我想要实现的目标,但如果它是最佳解决方案,我不满意。
我创建了自己的模型,并在选中复选框后将对象添加到列表中。
class SelectedCheckBoxModel 扩展了 AbstractCheckBoxModel {
private final STUList info;
private ArrayList<STUList> list1;
public SelectedCheckBoxModel(STUList info, ArrayList<STUList> list1) {
super();
this.info = info;
this.list1 = list1;
}
@Override
public boolean isSelected() {
// TODO Auto-generated method stub
return list1.contains(info);
}
@Override
public void select() {
// TODO Auto-generated method stub
list1.add(info);
}
@Override
public void unselect() {
// TODO Auto-generated method stub
list1.remove(info);
}
我在列表视图中调用了它
check = new CheckBox("check", new SelectedCheckBoxModel(stu, list1));
item.add(check);
如果这不是最优的请提出建议
谢谢
您应该改用带有 Checks 的 CheckGroup:
public ResultPage(PageParameters 参数) 抛出 APIException {
Form form = new Form("form");
CheckGroup selection = new CheckGroup("selection", new ArrayList());
selection.setRenderBodyOnly(false);
form.add(selection);
PageableListView view = new PageableListView("view", list, 10) {
@Override
public void onConfigure() {
super.onConfigure();
setVisible(list.size() > 0);
}
@Override
protected void populateItem(ListItem item) {
final StuList stu= (StuList) item.getModelObject();
item.add(new Check("check", item.getModel()));
item.add(new Label("name", stu.getName()));
item.add(new Label("num", stu.getNumber()));
item.add(new Label("age", stu.getAge()));
item.add(new Label("sex", stu.getSex()));
}
};
selection.add(view);
这样传递给 CheckGroup 构造函数的 arrayList 将始终包含选定的对象。
private ArrayList<MFRList> list;
private ArrayList<STUList> list1 = new ArrayList<STUList>();
public ResultPage(PageParameters params) throws APIException {
Form form = new Form("form");
PageableListView view = new PageableListView("view", list, 10) {
@Override
public void onConfigure() {
super.onConfigure();
setVisible(list.size() > 0);
}
@Override
protected void populateItem(ListItem item) {
final StuList stu= (StuList) item.getModelObject();
item.add(new CheckBox("check", item.getModel()));
item.add(new Label("name", stu.getName()));
item.add(new Label("num", stu.getNumber()));
item.add(new Label("age", stu.getAge()));
item.add(new Label("sex", stu.getSex()));
}
};
Button backtosearchbutton = new Button("backtosearchbutton") {
@Override
public void onSubmit() {
setResponsePage(SearchPage.class);
}
}.setDefaultFormProcessing(false);
Button groupcheckbutton = new Button("groupcheckbutton") {
@Override
public void onSubmit() {
}
}.setDefaultFormProcessing(false);
Button groupuncheckbutton = new Button("groupuncheckbutton") {
@Override
public void onSubmit() {
}
}.setDefaultFormProcessing(false);
Button submitselectionbutton = new Button("submitselectionbutton") {
@Override
public void onSubmit() {
}
}.setDefaultFormProcessing(true);
form.add(view);
form.add(backtosearchbutton);
form.add(submitselectionbutton);
form.add(groupuncheckbutton);
form.add(groupcheckbutton);
add(form);
add(new CustomPagingNavigator("navigator", view));
如何存储所选记录以及如何使用它。我知道在提交表格时会提交这些记录,但我不清楚如何以及在何处提交。
我的 pojo 是
public class MFRList implements Serializable {
private String name;
private String num;
private String age;
private String sex;
private Boolean selected = Boolean.FALSE;
public String getName() {
return Name;
}
public void setName(String Name) {
this.Name = Name;
}
public String getnum() {
return num;
}
public void setnum(String num) {
this.num = num;
}
public String getAge() {
return age;
}
public void setsex(String sex) {
this.sex= sex;
}
public String getsex() {
return sex;
}
public void setage(String age) {
this.age = age;
}
public Boolean getSelected() {
return selected;
}
public void setSelected(Boolean selected) {
this.selected = selected;
}
}
所选行保存在哪里,如何检索和使用它。
提前致谢
我得到了我想要实现的目标,但如果它是最佳解决方案,我不满意。
我创建了自己的模型,并在选中复选框后将对象添加到列表中。 class SelectedCheckBoxModel 扩展了 AbstractCheckBoxModel {
private final STUList info;
private ArrayList<STUList> list1;
public SelectedCheckBoxModel(STUList info, ArrayList<STUList> list1) {
super();
this.info = info;
this.list1 = list1;
}
@Override
public boolean isSelected() {
// TODO Auto-generated method stub
return list1.contains(info);
}
@Override
public void select() {
// TODO Auto-generated method stub
list1.add(info);
}
@Override
public void unselect() {
// TODO Auto-generated method stub
list1.remove(info);
}
我在列表视图中调用了它
check = new CheckBox("check", new SelectedCheckBoxModel(stu, list1));
item.add(check);
如果这不是最优的请提出建议
谢谢
您应该改用带有 Checks 的 CheckGroup:
public ResultPage(PageParameters 参数) 抛出 APIException {
Form form = new Form("form");
CheckGroup selection = new CheckGroup("selection", new ArrayList());
selection.setRenderBodyOnly(false);
form.add(selection);
PageableListView view = new PageableListView("view", list, 10) {
@Override
public void onConfigure() {
super.onConfigure();
setVisible(list.size() > 0);
}
@Override
protected void populateItem(ListItem item) {
final StuList stu= (StuList) item.getModelObject();
item.add(new Check("check", item.getModel()));
item.add(new Label("name", stu.getName()));
item.add(new Label("num", stu.getNumber()));
item.add(new Label("age", stu.getAge()));
item.add(new Label("sex", stu.getSex()));
}
};
selection.add(view);
这样传递给 CheckGroup 构造函数的 arrayList 将始终包含选定的对象。