0

i try to show / hide inputText when user click on checkbox. When i used update=@form it works but if i give ids it doesn't

why ?

below i light exemple

primefaces 5.3 (tested with 6.0 same)

<h:form id="formId">

<p:outputPanel id="panel1" rendered="#{!param['checkb'].checked}">
<p:outputLabel value="input 1"/>
<p:inputText id="i1" value="#{employe.prenom}" />
</p:outputPanel>

<p:outputPanel id="panel2" rendered="#{param['checkb'].checked}">
<p:outputLabel value="input 2"/>
<p:inputText id="i2" value="#{employe.prenom}"/>
</p:outputPanel>

<p:selectBooleanCheckbox value="#{employe.mobileAsContact}" id="checkB">
    <p:ajax update="panel1 panel2"></p:ajax>
</p:selectBooleanCheckbox>

</h:form>
l4rnaud
  • 179
  • 9

1 Answers1

0

problem solved thanks to this post : https://forum.primefaces.org/viewtopic.php?t=33980

surround the inputs with a h:panelGroup and update this panel...job done

<h:panelGroup id="panelGroupGlobal">
            <p:outputPanel id="panel1" rendered="#{!employe.mobileAsContact}">
                <p:outputLabel value="input 1" for="i1" />
                <p:inputText id="i1" value="#{employe.prenom}" required="true"/>
            </p:outputPanel>

            <p:outputPanel id="panel2" rendered="#{employe.mobileAsContact}">
                <p:outputLabel value="input 2" for="i2"/>
                <p:inputText id="i2" value="#{employe.prenom}" />
            </p:outputPanel>
        </h:panelGroup>

        <p:selectBooleanCheckbox value="#{employe.mobileAsContact}"
            id="checkB">
            <p:ajax update="formId:panelGroupGlobal"></p:ajax>
        </p:selectBooleanCheckbox>
l4rnaud
  • 179
  • 9