p:commandButton rendered property not working after ajax update (Primefaces 3.5)

前端 未结 2 401
走了就别回头了
走了就别回头了 2021-02-08 13:38

I reviewed my code lot of times and didnt find questions about it.

I have a problem with p:commandButton rendered property. The p:commandButton is allways displayed even

相关标签:
2条回答
  • 2021-02-08 14:21

    You can only ajax-update a component which is always rendered (i.e. when it does not have a rendered attribute). JSF ajax engine does not support addition/removal of a HTML element. It only supports the change of a HTML element.

    So, wrap it in a component which is always rendered and ajax-update it instead.

    <p:selectOneMenu id="cmbPais" value="#{pessoaController.selected.endereco.pais}">
        <f:selectItems value="#{paisController.itemsSelectOne}"/>
        <p:ajax event="change" update="cmbEstado,btnBuscaPeloEndereco,test"/>
    </p:selectOneMenu>
    
    <h:panelGroup id="btnBuscaPeloEndereco">
        <p:commandButton icon="ui-icon-correios" type="button" onclick="dlgCEP.show();" rendered="#{pessoaController.selected.endereco.ok}"/>
    </h:panelGroup>
    

    See also:

    • Why do I need to nest a component with rendered="#{some}" in another component when I want to ajax-update it?
    0 讨论(0)
  • 2021-02-08 14:27

    If you don't want modify your code, you can use css instead rendered ej:

    <x:element style="#{condition ? 'visibility: hidden':' visibility: visible'}" />
    

    EDIT: this can be undo by some user so if you element need to be secure don't use. however if you want to hide/show only with visual purpose you can use it.

    0 讨论(0)
提交回复
热议问题