Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
OptionGroup unselect value?
I have an OptionGroup (in Single Select Mode). I have set "setNullSelectionAllowed(true)". If a user selects an option in the OptionGroup it cannot "unselect" it, leaving all options unselected.
Do you guys have any suggestion on how to address this issue?
Thank you all in advance!
For my understanding of your problem, if the user can leave the OptionGroup blank, the singleSelectMode is not the right mode.
set the optionGroup to multiselect ( setMultiSelect(true) ) and the user can select/unselect values one by one.
In the UI, the multiselect mode display checkBox instead of radioButton.
That doesn't actually solve my problem. Because I want the user to choose only one option (therefor the SingleSelectMode) or none!
Setting the Multi Select would require extra logic to enable only one option to be selected, disabling the remaining options. Is that the only available solution?
Thank you for your feedback,
Ricardo Pascoal: I have an OptionGroup (in Single Select Mode). I have set "setNullSelectionAllowed(true)". If a user selects an option in the OptionGroup it cannot "unselect" it, leaving all options unselected.
This is how the option group / radio buttons component works in most graphical environments - it is not possible to unselect after making a selection (if the component supports initial unselected state at all). You either need to add a "nothing" item or implement the custom logic in multiselect mode.
I understand and appreciate the answer. I suspected it would be this way. But I could be missing something :D I'll go with the custom logic then.
Thank you all :)