I have a p:selectOneRadio setup as follows :
<p:selectOneRadio id="positionRadio" value="#{employeeBean.empPosition}" converter="#{empPositionConverter}" layout="custom"
required="true" requiredMessage="Please select a position">
<f:selectItems value="#{employeeBean.positionList}" var="pos"
itemLabel="#{pos.name}" itemValue="#{pos}" />
<p:ajax process="@this" update="@this"/>
</p:selectOneRadio>
<ui:repeat id="iterator" value="#{employeeBean.positionList}" var="template" varStatus="iterStat">
<div class="form-group" onclick="document.getElementById('employeeForm:positionRadio:#{iterStat.index}').click();">
<h:outputText styleClass="form-control" value="#{pos.name}"/>
<p:radioButton for=":employeeForm:positionRadio" itemIndex="#{iterStat.index}" />
<div style="display: inline">
<p style="display: inline">
<h:outputText value="#{pos.description}"/>
</p>
</div>
</div>
</ui:repeat>
I need to check the corresponding radio button if anything in the div containing it is clicked. I am attempting to do this using
onclick="document.getElementById('employeeForm:positionRadio:#{iterStat.index}').click();"
This is only half working. When I click on the div I do see the POST request fire, however the styles aren't updated so none of my radio buttons are checked client side.
This is of course because p:radioButton is rendered as a div with a hidden input radio element and a visible span that is styled accordingly. Why is the span style not updated when clicked via javascript and is there a way to fix it?
Using JSF 2.1.7, PrimeFaces 5.0 and Java 1.7