I have an keyFilter to my p:inputMask i want to disable and enable the keyFilter
<div class="col-sm-6 #{(newDesWeb eq '_')?'input-group' : ''} errorCible" >
<p:inputMask inputStyleClass="#{(newDesWeb eq '_')? 'selectfile' : 'form-control lg200 input-sm'} errorCible"
id="zoneResidenceAssure" styleClass="#{(newDesWeb eq '_')? 'ng-pristine ng-invalid ng-touched' : ''} errorCible"
style="width: 100%"
value="#{devisPresBean.currentAssureDevisBean.adresseActuelle.zipCode}" maxlength="#{msg['form.control.input.codepostal.maxlength']}">
<c:passThroughAttribute name="fieldId" value="LIBDEVzoneResidenceAssure" />
<c:ajax onevent="displayAjaxSatus" event="change" execute="@this" render="@this" />
</p:inputMask>
<p:keyFilter regEx="/[0-9_]/i" for="zoneResidenceAssure" />
<bpsi:message for="zoneResidenceAssure" />
</div>
I want with a condition disable the p:keyFilter
You can do this in 3 way:
use rendered on
<p:keyFilter regEx="/[0-9_]/i" for="zoneResidenceAssure" rendered="#{backing.condition()}"/>but then ypu need to update the container of keyFilter be it a form or a panel on the condition change.use a dynamic regex like
<p:keyFilter regEx="#{backing.regex()}" for="zoneResidenceAssure" />and update thekeyFilteron every condition change, returning actual pattern if you want it enabled or empty string to disable it.use
testFunctionon thekeyFilterinstead ofregExand implement the condition in JavaScript as a test function.