Conditional display of p:overlayPanel

别来无恙 提交于 2019-12-25 05:24:58

问题


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>

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


回答1:


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"

add oncomplete attr to you button, something like:

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


来源:https://stackoverflow.com/questions/18333219/conditional-display-of-poverlaypanel

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!