I have a check box group in my page. After checking the inputs, if they are wrong, an error message will be shown to the user, but the status of check boxes are lost. This is part of my code that shows a group checkbox with three items (CONFIGURATION, TESTER, DEVELOPER):
group = new CheckGroup("group", user.getRoleNames());
group.add(new CheckGroupSelector("groupselector"));
// The list of possible roles
List<String> roleNames = new ArrayList<String>();
roleNames.add(Roles.CONFIGURATION.value());
roleNames.add(Roles.TESTER.value());
roleNames.add(Roles.DEVELOPER.value());
group.add(new ListView("roles", roleNames) {
protected void populateItem(ListItem item) {
item.add(new Check("checkbox", item.getModel()));
item.add(new Label("name", item.getModel()));
}
});
add(group);
Also I have two text boxes of username and password. If user enters a wrong password, she/he will get an error message, but after showing the error message, the checked items become unchecked, Do you know how I can keep the status of check boxes?
I changed my code as the following:
and now it works correctly. So, the only required thing is setting setReuseItems to true.