0

I use Primefaces 6.2.17 and I want to create a dialog where the user can set a boolean field, with no selection being a valid option. I tried to do it using selectOneRadio, like this:

<p:dialog id="dialogId" widgetVar="dialogId" dynamic="true" modal="true"
                closable="false" closeOnEscape="true" fitViewport="true" >
    <p:outputPanel id="panPersondata">
        <p:panelGrid>
            
            ...
            
            <p:row>
                <p:column style="width: 100px;">
                    <p:outputLabel value="Boolean choice"/>
                </p:column>
                <p:column colspan="2">
                    <p:selectOneRadio  id="booleanChoiceSelectone" widgetVar="booleanChoiceSelectone"
                                       layout="lineDirection"  value="#{backBean.choice}">
                        <f:selectItem itemLabel="Yes"  itemValue="#{true}" />
                        <f:selectItem itemLabel="No" itemValue="#{false}" />
                    </p:selectOneRadio>
                </p:column>
            </p:row>
            
            ... 
            
        </p:panelGrid>
    </p:outputPanel>        
</p:dialog>

backing bean has an attribute which I initialize with null, like this:

@Getter @Setter private Boolean choice= null;

When I then try to save while not selecting either option on the selectOneRadio it is automatically set to false (instead of remaining at null). What am I doing wrong here?

Christian O.
  • 468
  • 2
  • 12

0 Answers0