Hello, Thank you for the samples. But I will explain again what I have: I have two forms on my page. In the bottom form I have a RefreshingView component, with check all checkbox in the header, and check components for each items. In the top form there is a link, where I need to get the checked items from the second form (the bottom form);
This is what I have done: For checkAll and the individual checks I have used CheckGroup, CheckGroupSelector and Check. The issue is that because the refreshing view refreshes the model at every server roundtrip, when I check on item, the check doesn't maintain it's value, because it receives every time a new model. So this bit from the RefreshingView always returns a new model which makes the checks to dissapera: @Override protected Iterator<IModel<TestBean>> getItemModels() { List<TestBean> lst = SpringCtx.getAppDB(TestBeanDao.class).selectAll(); List<IModel<TestBean>> models = new ArrayList<IModel<TestBean>>(); for (TestBean tstSN:lst) { IModel<TestBean> modTst = new Model<TestBean>(tstSN); models.add(modTst); } return models.iterator(); } Isn;t there any way that I can still use the CheckGroup and Check components? As this comes easy when it is needed a CheckAll functionality. Thank you Here is the code: =Java code= private static final long serialVersionUID = 311508940740808005L; private static final Logger logger = LogManager.getLogger(TestPage.class); private TestForm tst; public TestPage(IModel<TestBean> model) { super(model); TestForm0 tst0 = new TestForm0("testForm0"); tst0.setOutputMarkupId(true); add(tst0); tst = new TestForm("testForm", model); tst.setOutputMarkupId(true); add(tst); } class TestForm0 extends Form<TestBean> { /** * */ private static final long serialVersionUID = 1L; public TestForm0(String id) { super(id); Link<TestadosSN> print = new Link<TestadosSN>("print") { private static final long serialVersionUID = 15L; @Override public void onClick() { System.out.println("size=" + tst.getCheckedTestBeans().size()); } }; add(print); } } class TestForm extends Form<TestBean> { /** * */ private static final long serialVersionUID = 1L; private List<TestBean> checkedTestBeans; public List<TestBean> getCheckedTestBeans() { return checkedTestBeans; } public void setCheckedTestBeans(List<TestBean> checkedTestBeans) { this.checkedTestBeans = checkedTestBeans; } public TestForm(String id, IModel<TestBean> model) { super(id, model); checkedTestBeans = new ArrayList<TestBean>(); TextField<String> txtName = new TextField<String>("txtName", new PropertyModel<String>(getModelObject(), "name")); add(txtName); txtName.setOutputMarkupId(true); txtName.add(new AjaxFormComponentUpdatingBehavior("change") { private static final long serialVersionUID = 1654345477970524731L; @Override protected void onUpdate(AjaxRequestTarget target) { target.add(txtName); } }); /// CheckGroup<TestBean> group = new CheckGroup<TestBean>("group1", checkedTestBeans); group.setOutputMarkupId(true); group.add(new AjaxFormChoiceComponentUpdatingBehavior() { private static final long serialVersionUID = 1654345477970524731L; @Override protected void onUpdate(AjaxRequestTarget target) { target.add(group); } }); CheckGroupSelector cgs = new CheckGroupSelector("allCheck1"); group.add(cgs); final WebMarkupContainer itemsContainer = new WebMarkupContainer("itemsContainer1"); itemsContainer.setOutputMarkupId(true); itemsContainer.add(new RefreshingView<TestBean>("forEachItem1") { /** * */ private static final long serialVersionUID = 1L; @Override protected Iterator<IModel<TestBean>> getItemModels() { List<TestBean> lst = SpringCtx.getAppDB(TestBeanDao.class).selectAll(); List<IModel<TestBean>> models = new ArrayList<IModel<TestBean>>(); for (TestBean tstSN:lst) { IModel<TestBean> modTst = new Model<TestBean>(tstSN); models.add(modTst); } return models.iterator(); } @Override protected void populateItem(Item<TestBean> item) { item.add(new Label("itemName", new PropertyModel<TestBean>(item.getModel(), "name"))); item.add(new Label("itemCode", new PropertyModel<TestBean>(item.getModel(), "code"))); item.add(new Label("itemId", new PropertyModel<TestBean>(item.getModel(), "id"))); Check<TestBean> chk = new Check<TestBean>("itemCheck", item.getModel(), group); item.add(chk); } }); group.add(itemsContainer); add(group); } @Override protected void onSubmit() { logger.info("OnSubmit"); System.out.println("size=" + checkedTestBeans.size()); } } =HTML= <form wicket:id="testForm0"> <table class="contenidoform" cellpadding=1 cellspacing=0 border="0" width="100%"> <tr> <th rowspan="3"> <a href="#" wicket:id="print"><img src="images/sprs/TAg-128.png" title="prints blue tags for selected elements" /></a> </th> </tr> </table> </form> <form wicket:id="testForm"> <span wicket:id="group1"> <table class="contenidoform" cellpadding=1 cellspacing=0 border="0" width="100%"> <thead> <tr> <th>Name</th> <th>Code</th> </tr> <tr> <th>Id</th> <th rowspan="3"><input type="checkbox" wicket:id="allCheck1" title="check all/uncheck all" /></th> </tr> </thead> <tbody wicket:id="itemsContainer1"> <wicket:container wicket:id="forEachItem1"> <tr > <td wicket:id="itemName"></td> <td wicket:id="itemCode"></td> </tr> <tr> <td wicket:id="itemId"></td> <td ><input type="checkbox" wicket:id="itemCheck" title="check to print" /></td> </tr> </wicket:container> <tr> <th align="left"> </th> <th align="left"> <div style="padding-left: 0%;display: inline;" /> <a><input type="image" src="images/Save.gif" class="submitButton" name="btnSave" value="OK" /></a> </th> </tr> </tbody> </table> </span> </form> On Wed, Oct 19, 2016 at 7:24 PM, Francois Meillet < francois.meil...@gmail.com> wrote: > Have a look at > > https://cwiki.apache.org/confluence/display/WICKET/ > Listview+with+checkboxes <https://cwiki.apache.org/ > confluence/display/WICKET/Listview+with+checkboxes> > > https://www.mkyong.com/wicket/wicket-multiple-checkboxes-example- > checkboxmultiplechoice/ <https://www.mkyong.com/wicket/wicket-multiple- > checkboxes-example-checkboxmultiplechoice/> > > > > François > > > > > Le 19 oct. 2016 à 16:11, ganea iulia <superbiss...@gmail.com> a écrit : > > > > Hello, > > > > I have actually made this to work by adding this behaviour to the > > checkgroup: > > > > group.add(new AjaxFormChoiceComponentUpdatingBehavior() { > > private static final long serialVersionUID = > > 1654345477970524731L; > > > > @Override > > protected void onUpdate(AjaxRequestTarget target) { > > target.add(group); > > } > > > > }); > > > > However, now I face following issue: > > If I replace my ListView component, with a RefreshingView, I cannot check > > any of the checks from the items. I check it, but then it gets unchecked > > right away. > > This is because the RefreshingView repaints its model at every roundtrip > to > > the server. > > > > I have tried this: > > http://stackoverflow.com/questions/12282492/add-row-to- > refreshingview-without-repainting-entire-refreshingview > > by setting: > > listOfItems.setItemReuseStrategy(new ReuseIfModelsEqualStrategy()); > > > > But it did not change a thing for me. > > > > Please guide on how to have a Check for every item of the RepeatingView, > > that can be checked. > > > > Thank you. > > > > > > > > On Tue, Oct 18, 2016 at 1:28 PM, ganea iulia <superbiss...@gmail.com> > wrote: > > > >> Hi, > >> I have 2 forms. > >> > >> Bottom form = testForm > >> - I have a listview with checkboxes. > >> As I needed a checkAll control also, I have uses CheckGroup, > >> CheckGroupSelector and Check wicket components. > >> > >> Top form = testForm0 > >> -I have only an link > >> > >> The use case is the following: > >> I check one item (or all) in bottom form, but then I need to get the > >> selected values when click on link in top form. > >> > >> The check doesn't do submit so the values are not retained. I alsways > get > >> the > >> size = 0 message. > >> > >> Could you tell me how I can manage this? > >> > >> Here is the code: > >> =HTML= > >> <form wicket:id="testForm0"> > >> <table class="contenidoform" cellpadding=1 cellspacing=0 border="0" > >> width="100%"> > >> <tr> > >> <th rowspan="3"> > >> <a href="#" wicket:id="print"><img src="images/Print.png" title="print" > >> /></a> > >> </th> > >> </tr> > >> </table> > >> </form> > >> <form wicket:id="testForm"> > >> <span wicket:id="group"> > >> <table class="contenidoform" cellpadding=1 cellspacing=0 border="0" > >> width="100%"> > >> <thead> > >> <tr> > >> <th>Name</th> > >> <th>Code</th> > >> </tr> > >> <tr> > >> <th>Id</th> > >> <th rowspan="3"><input type="checkbox" wicket:id="allCheck" title="check > >> all/uncheck all" /></th> > >> </tr> > >> </thead> > >> <tbody wicket:id="itemsContainer"> > >> <wicket:container wicket:id="forEachItem"> > >> <tr > > >> <td wicket:id="itemName"></td> > >> <td wicket:id="itemCode"></td> > >> </tr> > >> <tr> > >> <td wicket:id="itemId"></td> > >> <td ><input type="checkbox" wicket:id="itemCheck" title="check to print" > >> /></td> > >> </tr> > >> </wicket:container> > >> <tr> > >> <th align="left"> </th> > >> <th align="left"> > >> <div style="padding-left: 0%;display: inline;" /> > >> <a><input type="image" src="images/Save.gif" class="submitButton" > >> name="btnSave" value="OK" /></a> > >> </th> > >> </tr> > >> </tbody> > >> </table> > >> </span> > >> </form> > >> > >> > >> ==JAVA== > >> private static final long serialVersionUID = 311508940740808005L; > >> private static final Logger logger = LogManager.getLogger(TestPage. > class); > >> private TestForm tst; > >> > >> public TestPage(IModel<TestBean> model) { > >> super(model); > >> > >> TestForm0 tst0 = new TestForm0("testForm0"); > >> tst0.setOutputMarkupId(true); > >> add(tst0); > >> tst = new TestForm("testForm", model); > >> tst.setOutputMarkupId(true); > >> add(tst); > >> > >> } > >> > >> class TestForm0 extends Form<TestBean> { > >> > >> /** > >> * > >> */ > >> private static final long serialVersionUID = 1L; > >> > >> public TestForm0(String id) { > >> super(id); > >> > >> Link<TestadosSN> print = new Link<TestadosSN>("print") { > >> private static final long serialVersionUID = 15L; > >> > >> @Override > >> public void onClick() { > >> System.out.println("size=" + tst.getCheckedTestBeans().size()); > >> } > >> }; > >> add(print); > >> } > >> } > >> class TestForm extends Form<TestBean> { > >> /** > >> * > >> */ > >> private static final long serialVersionUID = 1L; > >> > >> private List<TestBean> checkedTestBeans; > >> public List<TestBean> getCheckedTestBeans() { > >> return checkedTestBeans; > >> } > >> > >> public void setCheckedTestBeans(List<TestBean> checkedTestBeans) { > >> this.checkedTestBeans = checkedTestBeans; > >> } > >> > >> public TestForm(String id, IModel<TestBean> model) { > >> super(id, model); > >> > >> checkedTestBeans = new ArrayList<TestBean>(); > >> TextField<String> txtName = new TextField<String>("txtName", new > >> PropertyModel<String>(getModelObject(), "name")); > >> add(txtName); > >> txtName.setOutputMarkupId(true); > >> txtName.add(new AjaxFormComponentUpdatingBehavior("change") { > >> private static final long serialVersionUID = 1654345477970524731L; > >> > >> @Override > >> protected void onUpdate(AjaxRequestTarget target) { > >> target.add(txtName); > >> } > >> > >> }); > >> > >> SubmitLink clearForm = new SubmitLink("clearForm", this){ > >> > >> /** > >> * > >> */ > >> private static final long serialVersionUID = 1L; > >> @Override > >> public void onSubmit() { > >> model.setObject(new TestBean()); > >> TestForm.this.clearInput(); > >> }; > >> }; > >> clearForm.setOutputMarkupId(true); > >> add(clearForm); > >> AjaxLink<TestBean> clearLink = new AjaxLink<TestBean>("clearLink", > model) > >> { > >> /** > >> * > >> */ > >> private static final long serialVersionUID = 1L; > >> > >> @Override > >> public void onClick(AjaxRequestTarget target) { > >> model.setObject(new TestBean()); > >> TestForm.this.clearInput(); > >> target.add(TestForm.this); > >> txtName.setConvertedInput(""); > >> > >> } > >> > >> }; > >> clearLink.setOutputMarkupId(true); > >> add(clearLink); > >> /// > >> CheckGroup<TestBean> group = new CheckGroup<TestBean>("group", > >> checkedTestBeans); > >> CheckGroupSelector cgs = new CheckGroupSelector("allCheck"); > >> group.add(cgs); > >> List<TestBean> beans = Arrays.asList(new TestBean("Name1", "Code1", 1), > >> new TestBean("Name2", "Code2", 2)); > >> final WebMarkupContainer itemsContainer = new WebMarkupContainer(" > >> itemsContainer"); > >> itemsContainer.setOutputMarkupId(true); > >> itemsContainer.add(new ListView<TestBean>("forEachItem", beans) { > >> /** > >> * > >> */ > >> private static final long serialVersionUID = 1L; > >> > >> @Override > >> protected void populateItem(ListItem<TestBean> item) { > >> item.add(new Label("itemName", new PropertyModel(item.getModel(), > >> "name"))); > >> item.add(new Label("itemCode", new PropertyModel(item.getModel(), > >> "code"))); > >> item.add(new Label("itemId", new PropertyModel(item.getModel(), > "id"))); > >> item.add(new Check<TestBean>("itemCheck", item.getModel(), group)); > >> } > >> }); > >> group.add(itemsContainer); > >> add(group); > >> //choice > >> List<String> lst = new ArrayList<String>(); > >> lst.add("C1"); > >> lst.add("C2"); > >> > >> > >> ChoiceRenderer<String> renderer = new ChoiceRenderer<String>("code") { > >> > >> private static final long serialVersionUID = 8875819661197521211L; > >> > >> @Override > >> public Object getDisplayValue(String arg0) { > >> return (arg0.equals("C1") ? "Code1" : "Code2"); > >> } > >> > >> @Override > >> public String getIdValue(String arg0, int arg1) { > >> return arg0; > >> } > >> > >> @Override > >> public String getObject(String paramString, IModel<? extends List<? > >> extends String>> paramIModel) { > >> // TODO Auto-generated method stub > >> return paramString; > >> } > >> > >> }; > >> DropDownChoice<String> code = new DropDownChoice<String>("code", lst, > >> renderer); > >> code.setOutputMarkupId(true); > >> code.setModel(new PropertyModel<String>(getModelObject(), "code")); > >> add(code); > >> } > >> > >> @Override > >> protected void onSubmit() { > >> > >> logger.info("OnSubmit"); > >> System.out.println("size=" + checkedTestBeans.size()); > >> > >> } > >> } > >> > >> > >