2012-03-22 81 views

回答

0

怎麼樣像(沒有測試過我自己)

客戶端唯一的解決辦法

<p:commandButton id="basic" onclick="jQuery('#IdOfThePanel').hide()"></p:commandButton> 

或客戶端+服務器端

JSF:

<p:commandButton value="Save" actionListener="#{myBean.doSomething}"/> 

的java :

public void doSomething(ActionEvent actionEvent) { 

    RequestContext context = RequestContext.getCurrentInstance(); 
    context.execute("jQuery('#IdOfThePanel').hide()"); 
} 

這裏看看上執行JS從Java

Executing Javascript from Server Side

PS的可能,而不是IdOfThePanel你必須添加一些前綴像formID:IdOfThePanel ......取決於你的情況...

編輯:不是的jQuery( '#IdOfThePanel')隱藏()只使用panelWidgetVar.hide()

+3

overlayPanelWidgetVar.hide()將更易於使用。 – 2012-03-22 22:17:40

+0

@Cagatay thx的小費, – Daniel 2012-03-22 22:34:48

0

將這個內部號碼:overlayPanel標籤,並設置號碼: '爲' ATTRIB效果與overlayPanel ID,使用appendToBody = true。

<p:commandLink styleClass="ui-icon ui-icon-triangle-1-e"> 
     <p:effect type="slide" for="idOverlayPanel" event="click"> 
      <f:param name="mode" value="'hide'"/> 
      <f:param name="direction" value="'right'"/> 
     </p:effect> 
    </p:commandLink> 

沒有效果參數

<p:commandLink styleClass="ui-icon ui-icon-close" > 
    <p:effect type="slide" for="idOverlayPanel" event="click"/> 
</p:commandLink> 

您可以更改幻燈片效果anotherone,圖標樣式類了。

對不起我的英文不好

3

您可以輕鬆添加一個按鈕,你overlaypanel到例如關閉

<p:overlayPanel widgetVar="myOverlayPanel" ... > 
    <p:commandButton ... onComplete="PF('myOverlayPanel').hide(); ... /> 
</p:overlayPanel> 

您也可以在Java中

private void doSomething() { 
    RequestContext ctx = RequestContext.getCurrentInstance(); 
    ctx.execute("PF('myOverlayPanel').hide();"); 
} 
0

做到這一點我與jQuery和CSS做到了這一點。請檢查以下代碼

<p:overlayPanel widgetVar="overlay" showEffect="blind" showCloseIcon="true" styleClass="lane-overlay" dynamic="true" dismissable="true" hideEffect="blind"> 
<script> 
$(document).ready(function(){ 
$(".closeIcon").click(function(){ 
$(".lane-overlay").hide(); 
}); 
}); 
</script> 
<p:commandButton value="close" styleClass="closeIcon"/> 
`enter code here`