简体   繁体   中英

PrimeFaces selectBooleanCheckbox cheked on label click

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>

Use itemLabel, and remove the outputLabel with id provisionCheckLabel:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM