2013-08-20 36 views
0

如何根據某些結果從@ManagedBean有條件地顯示/隱藏覆蓋面板。
在下面的代碼中:p:overlayPanel用於p:commandButton。我想從Action方法中有條件地顯示覆蓋面板。
現在它顯示每次我點擊commandbutton。p:overlayPanel的條件顯示

<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爲overlayPanel

<p:overlayPanel rendered="{myBean.condition}" ...>... 

3.5 **

回答

0

給的重疊頁ANEL窗口小部件名稱,並設置showEvent爲none(這個殺死默認行爲,並分配一個javascript手柄面板):

widgetVar="myOverlay" showEvent="none" 

ATTR添加的onComplete你按鈕,這樣的:

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

有同樣的問題,增加widgetVar爲我工作,但我不得不做'PF('myOverlay')。show();' –