Code: Select all
<pe:dynaForm id="dynaForm" value="#{prospectController.model}" var="field" widgetVar="dynaFormWidget" openExtended="${prospectController.extended}">
<pe:dynaFormControl type="ynToggleExtended" for="yn" >
<p:selectOneRadio id="yn" value="#{field.value}" required="${field.required}" onchange="PF('dynaFormWidget').toggleExtended()" >
<f:selectItems value="#{field.selectItems}"/>
</p:selectOneRadio>
</pe:dynaFormControl>
<! -- additional control definitions -->
</pe:dynaForm>
Code: Select all
SelectItem no = new SelectItem(Boolean.FALSE, "No");
SelectItem yes = new SelectItem(Boolean.TRUE, "Yes");
this.extended = value != null && !value.isEmpty();
FormField questionField = new FormField(this.extended, false, Arrays.asList(no, yes));
DynaFormRow questionRow = this.model.createRegularRow();
DynaFormLabel questionLabel = questionRow.addLabel(question, 1, 1);
DynaFormControl questionControl = questionRow.addControl(questionField, "ynToggleExtended", 1, 1);
questionLabel.setForControl(questionControl);
Problem is, when the form is later submitted, field.value is always set to null regardless of which radio button is selected. That is, neither Boolean.FALSE nor Boolean.TRUE appears to be recognised by the selectOneRadio. However, downgrade to Extensions v4.0.0 without any other changes and it all works smoothly again.
I might also add that setting field.required to true apparently makes validation fail, as both radio buttons are immediately unselected on submit.