繁体   English   中英

如何在commandButton单击时在primefaces / jsf2中有条件地隐藏/显示面板?

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

我想在某些情况下在commandButton单击上隐藏/显示<p:panel> ,我尝试了以下

<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

编辑方法仅执行sysout。

最终用户单击该按钮时我想要的是,该面板将显示为带有可编辑文本框的Bean数据。

我想通过单击按钮使此面板可见,该怎么做?

您还必须在按钮中使用update =“ <id>” ...因此,例如,您将需要<p:commandButton ... update =“ thepanelid” ... /> <p:panel id =“ thepanelid“ ...

我认为您可以在后备bean中使用布尔值属性。 在面板中,您输入了: visible="backingbean.yourAttribute"并在bean中使用一种方法通过onclick对其进行控制。

onclick="backingbean.theMethod"

在该方法中,如果您的条件得到验证,则可以将属性设置为“ true”。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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