0

如何根据某些结果从@ManagedBean 有条件地显示/隐藏覆盖面板。
在下面的代码中:p:overlayPanel是 for p:commandButton。我想从 Action 方法有条件地显示覆盖面板。
现在每次我单击命令按钮时它都会显示。

<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 **

4

1 回答 1

0

给覆盖面板一个小部件名称并将 showEvent 设置为 none(这会终止默认行为并为面板分配一个 javascript 句柄):

widgetVar="myOverlay" showEvent="none"

将 oncomplete attr 添加到您的按钮,例如:

oncomplete="if(args && !args.validationFailed) myOverlay.show();"
于 2013-10-29T17:53:32.703 回答