2015-02-06 35 views
0

我試圖使用<p:overlayPanel>作爲小部件,如PrimeFaces展示示例(http://www.primefaces.org/showcase/ui/overlay/overlayPanel.xhtml)中所述。PrimeFaces OverlayPanel導致JavaScript錯誤「TypeError:f未定義」

我建立一個簡單的應用程序,但在頁加載它直接導致了JavaScript錯誤TypeError: f is undefined在第3欄,行1457中的「/javax.faces.resource/primefaces.js.xhtml?ln=primefaces & V = 5.1」

的XHTML體的代碼是:

<h:form id="form"> 

    <p:commandButton update=":form:infoPanel" oncomplete="PF('testOverlayPanel').show('#{component.clientId}')" value="Test"/> 

    <p:overlayPanel widgetVar="testOverlayPanel" dismissable="false" showCloseIcon="true"> 
     <p:outputPanel id="infoPanel" style="text-align:center;"> 
      Hello OverlayPanel! 
     </p:outputPanel> 
    </p:overlayPanel> 

</h:form> 

當我刪除了overlayPanel時,JavaScript錯誤消失。

當我按命令按鈕,另外兩個JavaScript錯誤出現:

  1. NetworkError:403禁止 - https://localhost:8443/test/index.xhtml
  2. 類型錯誤:PF(...)是未定義

我使用PrimeFaces 5.1和JSF 2.2.8

+0

你有h:頭,h:身體等嗎? – 2015-02-06 15:07:44

+0

@Jaqen:很可能,否則'primefaces.js'不會首先加載。 – BalusC 2015-02-06 15:12:42

+0

也想過,但誰知道:-) – 2015-02-06 15:14:03

回答

1

你不是在展示中使用它;-)。

<p:commandButton update=":form:infoPanel" 
    oncomplete="PF('testOverlayPanel').show('#{component.clientId}')" 
    value="Test"/> 

是供在數據表中使用(可以在展示中看到)。通常情況下,你只需要做一個

<p:commandButton update=":form:infoPanel" 
    oncomplete="PF('testOverlayPanel').show()" value="Test"/> 

但是,如果overlayPanel被「綁定」到特定的按鈕,你還可以添加「爲」在overlayPanel屬性,如果你把一個id上的按鈕類似

<p:commandButton id="imageBtn" value="Basic" type="button" /> 
<p:overlayPanel id="imagePanel" for="imageBtn" hideEffect="fade"> 
    <p:graphicImage name="/demo/images/nature/nature1.jpg" width="300" /> 
</p:overlayPanel> 

(不知道後者如何去使用Ajax調用)

+0

是的,目標是在數據專家中使用它,我也嘗試過,但失敗了。你確定這只是一個數據表? – philsner 2015-02-09 08:36:29

+0

它至少是一個數據表,而不是你如何在上面使用它。如果它也適用於數據專家,我不知道。從來沒有嘗試過,沒有時間去嘗試未來的日子 – Kukeltje 2015-02-09 08:54:53

+0

看起來,datalist只適用於''。感謝您的提示! – philsner 2015-02-09 16:52:08

1

I am using PrimeFaces 5.1 with JSF 2.2.8

在Primefaces 5.1版,如果你讓號碼:覆蓋無爲= 「imageBtn」屬性,錯誤的是顯示瀏覽器的控制檯上:

遺漏的類型錯誤:未定義

的修補程序(實際上是重疊重構)無法讀取屬性「長」已經COMMITED 11月14日,2014年,作爲你可以看到下面:

https://code.google.com/p/primefaces/source/detail?r=12016

OverlayPanel除非你指定「爲」屬性,那就是不正常運行,我們指定的方式上Primefaces 5.1版本將無法正常工作數據表。

可能會在版本5.1.3和之後的工作。見https://code.google.com/p/primefaces/issues/detail?id=7615

0

我認爲@LeonardoHAlmeida發佈了正確的答案。 我找到了一個解決方法來避免這個錯誤。我剛剛創建了一個「假」按鈕,只是爲了能夠在overlayPanel設定目標的「for」屬性

<p:commandButton id="fakeButton" style="display: none"></p:commandButton> 

所以我覆蓋的樣子:

<p:overlayPanel widgetVar="wOverlay" appendToBody="true" for="fakeButton"> 
    <p:outputPanel id="display"> 
     ... 
    </p:outputPanel> 
</p:overlayPanel> 

而在我的DataTable中的按鈕是:

<p:commandButton update=":form:display" oncomplete="PF('wOverlay').show('#{component.clientId}')" icon="ui-icon-search"> 
相關問題