PrimeFaces selectBooleanCheckbox cheked on label click

1.2k views Asked by At

I am new to this Website. My issue is related to SelectBooleanCheckbox in primefaces. How to check Checkbox when user click on label?

Here is my xhtml

<h:panelGroup id="supplementaryProvision" layout="block">
            <h:panelGroup rendered="#{registrationHandler.showSupplProvisionsCheck}">
                <div class="row">
                    <div class="col-sm-offset-5 col-md-offset-3 col-sm-7 col-md-5">
                        <div class="checkbox">
                            <p:selectBooleanCheckbox id="provisionCheck" value="#{registrationHandler.registrationDto.supplProvisionCheck}"
                                label="#{msg.addtionalTerms}" />

                            <h:outputLabel for="provisionCheck" id="provisionCheckLabel">
                                <h:outputText value="#{msg.agreeForeignerTerms} *" />
                            </h:outputLabel>
                        </div>
                    </div>
                </div>
            </h:panelGroup>
        </h:panelGroup>
1

There are 1 answers

0
AudioBubble On

Use itemLabel, and remove the outputLabel with id provisionCheckLabel:

<p:selectBooleanCheckbox
    id="provisionCheck"
    itemLabel="#{msg.agreeForeignerTerms} *"
    value="#{registrationHa...}"
    label="#{msg.addtionalTerms}" />