2013-06-28 28 views
0

當我單擊p:commandButton以顯示p:對話框時,出現javacript錯誤。使用p:commandButton和p:對話框時出現Javascript錯誤

請看以下錯誤:

Message: Object doesn't support this property or method 
Line: 1 
Char: 169 
Code: 0 
URI: http://localhost:8080/idm/javax.faces.resource/dialog/dialog.js.xhtml?  ln=primefaces&v=2.2.1 

Message: Object doesn't support this property or method 
Line: 1 
Char: 133 
Code: 0 
URI: http://localhost:8080/idm/javax.faces.resource/button/button.js.xhtml?ln=primefaces&v=2.2.1 

這裏是代碼塊:

 <ui:composition xmlns="http://www.w3.org/1999/xhtml" 
xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" 
xmlns:p="http://primefaces.prime.com.tr/ui" 
xmlns:f="http://java.sun.com/jsf/core" 
xmlns:c="http://java.sun.com/jsp/jstl/core"> 

<p:commandButton value="save" onclick="dlg1.show();" ></p:commandButton> 
    <p:dialog id="basicDialog" header="Basic Dialog" widgetVar="dlg1"> 
    <h:outputText value="Resistance to PrimeFaces is futile!" /> 
</p:dialog> 
     </ui:composition> 

所有其他primefaces部件工作正常。

任何幫助,將不勝感激。

+0

這是一箇舊的和現有的Web應用程序,或者你剛開始PrimeFaces? 2.2.1是一個非常古老的版本,不建議開始使用過時的庫。至於這個問題,你是否手動包含jQuery的另一個副本? – BalusC

+0

是的,我們正在使用PrimeFaces 2.2.1版本。我們必須使用這個版本來開發我們的應用程序。是的,我們正在使用jQuery的另一個副本,但我們想知道在哪個文件中我們需要更改以顯示primefaces對話框......您可以幫我解決這個問題。 –

回答

2

是我們使用jQuery

的另一個副本刪除它。 PrimeFaces作爲基於jQuery/jQuery UI之上的JSF組件庫已經自動包含了捆綁的jQuery文件,用於其他對話框組件。 jQuery的多個副本只會相互衝突,導致類似你所面臨的那種JS錯誤。

如果您打算在不一定使用自動包含PrimeFaces捆綁jQuery文件的PrimeFaces組件的頁面上使用jQuery,請將此行添加到<h:head>

<h:outputScript library="primefaces" name="jquery/jquery.js" /> 

這樣PrimeFaces捆綁jQuery的文件總是包含和PrimeFaces不會自動包括重複jQuery的文件,如果有的PrimeFaces組件碰巧需要它。

相關問題