I use a ListView to populate a CheckGroup with Check objects. It works fine and all the check boxes are displayed properly. But when I try to add a new check box to the ones previously added, I keep getting the new one along with the previous ones in duplicate.
Here is my code. (I apologize for the format of the code) protected void addCheckGroup( List<SelectableValue> list) throws Exception { Object object = getDefaultModelObject(); checkGroupSelectableValues = new CheckGroup<SelectableValue>("selectedValues"); //checkGroupSelectableValues.add(new CheckGroupSelectors("groupSelector")); selectableValues = new ListView<SelectableValue>("selections", list) { /** * */ private static final long serialVersionUID = 1L; @Override protected void populateItem( ListItem<SelectableValue> item) { item.add(new Check<SelectableValue>("check", item.getModel())); item.add(new Label("value", new PropertyModel<SelectableValue>(item.getModel(), "value"))); } }; checkGroupSelectableValues.add(selectableValues); selectableValues.setOutputMarkupPlaceholderTag(true); checkGroupSelectableValues.setRenderBodyOnly(false); checkGroupSelectableValues.setOutputMarkupPlaceholderTag(true); add(checkGroupSelectableValues); } protected void addNewSelectableValue( AjaxRequestTarget target) throws Exception { List<SelectableValue> list; // new list with the new SelectableValue added selectableValues.removeAll(); // making sure to remove previous object selectableValues.setList(list); // Adding the new list to the ListView checkGroupSelectableValues.removeAll(); // making sure to remove previous check boxes. checkGroupSelectableValues.add(selectableValues); target.addComponent(checkGroupSelectableValues); } I have tried different other methods but either I get the previous values in duplicates or the new value does not show up. I will appreciate help in solving this issue. Thanks Mohammad