PDA

View Full Version : setSelectionRequired(true) for radiogroup doesn't work



APOLLO06
4 Jun 2012, 12:59 AM
Hello,

If we create a new RadioGroup with "setSelectionRequired(true)" we can validate it even if no value is selectionned.

Example :

RadioGroup saveTypeRadioGroup = new RadioGroup("saveTypeRadioGroup");
saveTypeRadioGroup.setId(RADIO);
saveTypeRadioGroup.setFieldLabel(Crm.crmConstants.filter_type());
saveTypeRadioGroup.setSelectionRequired(true);


saveTypeRadioGroup.add(presetRadio);
saveTypeRadioGroup.add(compoundRadio);

If there is no value for presetRadio neither for compoundRadio, we can however validate it.

Thank you for your response.

Corinne

APOLLO06
4 Jun 2012, 7:25 AM
Hello,

I have added a validator to my RadioGroup, now it is ok :

if (c instanceof RadioGroup) {
((RadioGroup) c).setValidator(new Validator() {
public String validate(Field<?> field, String value) {
if (!((RadioGroup) c).isValid(true)) {
return "";
}
return null;
}
});
((RadioGroup) c).setSelectionRequired(mandatory);

Bye
Corinne