如何在单击命令按钮时有条件地 primefaces/jsf2 中的 hide/show 面板?

How to hide/show a panel conditionally in primefaces/jsf2 on commandButton click?

我想 hide/show <p:panel> commandButton click with some condition ,我试过以下

<h:form>
// some tag here
<p:commandButton value="EDIT" ajax="false"
                        onclick="if(#{bean.status == 'ACTIVE'}){editable.show();}"
                        actionListener="#{beanMgnt.edit}">
</h:form>

可编辑面板为

<p:panel widgetVar="editable" closable="true"
                toggleable="true" visible="false">
                // some tags here
            </p:panel

编辑方法只执行系统输出。

我想要的是当最终用户单击按钮时,此面板将可见,其中包含填充有可编辑文本框的 bean 数据。

我想使用按钮 click.How 使此面板可见吗?

我认为您可以在支持 bean 中使用布尔属性。在您放置的面板中:visible="backingbean.yourAttribute" 并在您的 bean 中使用一种方法通过 onclick 来控制它。

onclick="backingbean.theMethod"

在方法中,如果你的条件得到验证,你可以将属性设置为"true"。

您还必须在按钮中使用 update=""... 因此,例如,您需要