Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSF 2 selectOneRadio Dependend Validation

i have a pretty simple jsf page with three selectOneRadio components. two of them within a panelGroup.

<t:selectOneRadio id="first" value="#{myBean.first}" required="true" requiredMessage="Please make a choice!">
<f:selectItem itemLabel="yeah" itemValue="true"/>
<f:selectItem itemLabel="no!" itemValue="false"/>
<f:ajax render="myform" execute="myform" />
</t:selectOneRadio>

<h:panelGroup rendered="#{not myBean.first}">
  <t:selectOneRadio id="second" value="#{myBean.second}" required="true" requiredMessage="Please make a choice!">
  <f:selectItem itemLabel="yeah" itemValue="true"/>
  <f:selectItem itemLabel="no!" itemValue="false"/>
  <f:ajax render="myform" execute="myform" />
  </t:selectOneRadio>


  <t:selectOneRadio id="third" value="#{myBean.third}" required="true" requiredMessage="Please make a choice!">
  <f:selectItem itemLabel="yeah" itemValue="true"/>
  <f:selectItem itemLabel="no!" itemValue="false"/>
  <f:ajax render="myform" execute="myform" />
  </t:selectOneRadio>
</h:panelGroup>

My problem is, that dependent on value of the first button, the panel should be shown or not. if it shows up, the two other radio selections shall be validated.

the current behaviour is that if i choose someting in the first selectOneRadio, the required messages for the other two ones are displayed.

does anyone how to avoid that and validate two and three dependent on value one?

kind regards and thanks in advance :-)

like image 314
el.paso Avatar asked Jul 18 '26 22:07

el.paso


1 Answers

found the answer...sometimes i am blind :-)

setting the execute attribute to the current radio buttons solved it:

<t:selectOneRadio id="first" value="#{myBean.first}" required="true" requiredMessage="Please make a choice!">
<f:selectItem itemLabel="yeah" itemValue="true"/>
<f:selectItem itemLabel="no!" itemValue="false"/>

<f:ajax render="myform" execute="first" />

</t:selectOneRadio>
like image 119
el.paso Avatar answered Jul 25 '26 17:07

el.paso



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!