本文介绍了如何基于后备bean条件有条件地显示p:dialog的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有任何方法(或正确的方法)有条件地显示基于后备豆条件的素面对话框?该代码如下所示:
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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!