有条件地显示p:overlayPanel [英] Conditional display of p:overlayPanel

查看:78
本文介绍了有条件地显示p:overlayPanel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何根据某些结果从@ManagedBean有条件地显示/隐藏覆盖面板.
在下面的代码中:p:overlayPanel用于p:commandButton.我想从Action方法中有条件地显示覆盖面板.
现在,每当我单击命令按钮时,它就会显示出来.

How can I show/hide the overlay panel conditionally from @ManagedBean based on some result.
In the below code: p:overlayPanel is for p:commandButton. I want to show overlay panel conditionally from Action method.
Right now it is showing every time I click the commandbutton.

<h:form id="form">
    <h:outputLabel value="Town Name:"/>
    <h:inputText value="#{myBean.town}"/>
    <p:commandButton id="checkBtn" value="Check" action="#{myBean.action}"/>

    <p:overlayPanel  widgetVar="overL" id="over" for="checkBtn">
       <h:outputText value="This town is not Listed in our records"/>
    </p:overlayPanel>
</h:form>

注意:我正在使用 ** Primefaces 3.5 **

Note : I'm using **Primefaces 3.5**

推荐答案

为覆盖面板提供小部件名称,并将showEvent设置为none(这会杀死默认行为,并为面板分配一个javascript句柄):

Give the overlay panel a widget name and set showEvent to none (this kills the default behavior and assign a javascript handle to the panel):

widgetVar="myOverlay" showEvent="none"

向您的按钮添加oncomplete属性,例如:

add oncomplete attr to you button, something like:

oncomplete="if(args && !args.validationFailed) myOverlay.show();"

这篇关于有条件地显示p:overlayPanel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆