I am trying to put all the checkboxes in a CheckboxGroup into an
unselected state, but Checkbox.setState(false) does not
automatically unselect the checkbox once a checkbox has been selected
within a CheckboxGroup. How can this be done?
At least one Checkbox in a CheckboxGroup must be selected at all
times. A CheckboxGroup mimics a set of radio buttons, where the
pressing of a button results in the ejection of all of other buttons.
In general, if you require all of your checkboxes to be unselected, it
is possible that they really should not be in a CheckboxGroup.
However, if the options represented by the checkboxes are indeed
mutually exclusive, and you really would like to be able to deselect
all of them, you can use the following trick:
Add an extra Checkbox
to the CheckboxGroup, but don't add it to a container component and do
not display it. When you want to deselect all the visible checkboxes,
just set the invisible Checkbox's state to true. From a user
interface standpoint, it may be better to make this extra button
visible and give it a label like "None" so that it is clear to the
user that it is possible not to choose any of the other options.