如何根据支持 bean 条件有条件地显示 p:dialog [英] How to conditionally show p:dialog based on backing bean condition
本文介绍了如何根据支持 bean 条件有条件地显示 p:dialog的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法(或正确的方式)有条件地根据支持 bean 条件在 primefaces 上显示对话框?代码如下所示:
Is there any way (or a correct way) to conditionally show a dialog on primefaces based on a backing bean condition? The code looks like the following:
<!-- dialog declaration -->
<p:dialog id="dialogTest" widgetVar="dialogTest" header="#{text['modal.header']}" modal="true" >
<h:outputText value="Test output" />
</p:dialog>
<!-- caller -->
<p:menuitem value="Check" actionListener="#{backingBean.performCheck}" oncomplete="PF('dialogTest').show()" icon="ui-icon-arrowthick-1-e"/>
我的支持 bean 如下所示:
My backing bean looks like the following:
private boolean conditionFlag; // ... +getter
public void performCheck() {
// ... access managers (database)
this.conditionFlag = dao.check();// some check;
}
我只想在 conditionFlag
为 true
的情况下显示对话框.performCheck
运行后,如何在 p:menuitem
上执行类似操作?
I just want to show the dialog in case the conditionFlag
is true
. How can I do something like this on p:menuitem
after performCheck
runs?
oncomplete="if (#{backingBean.conditionFlag}) { PF('dialogTest').show() }"
- JSF 2.0
- Primefaces 5
- Java 1.7
推荐答案
只需将 update="@this"
添加到 p:menuitem
即可.那么您的 oncomplete
块将按照您的预期工作.
just add update="@this"
to the p:menuitem
. then your oncomplete
block will work as you expect it to.
这篇关于如何根据支持 bean 条件有条件地显示 p:dialog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文