简体   繁体   English

使用p:commandButton和p:dialog时出现Javascript错误

[英]Getting Javascript error while using p:commandButton and p:dialog

I am getting a javacript error when I click on the p:commandButton to display ap:dialog. 当我点击p:commandButton来显示ap:dialog时,我收到一个javacript错误。

Please find the errors below: 请找到以下错误:

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

Here is the code block: 这是代码块:

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

All the other primefaces components are working fine. 所有其他primefaces组件工作正常。

Any help would be appreciated. 任何帮助,将不胜感激。

Yes we are using another copy of jQuery 是的,我们正在使用另一个jQuery副本

Remove it. 去掉它。 PrimeFaces as being a JSF component library based on top of jQuery/jQuery UI already auto-includes its bundled jQuery file for among others the dialog component. PrimeFaces作为一个基于jQuery / jQuery UI的JSF组件库已经自动包含其捆绑的jQuery文件以及其他对话框组件。 Multiple copies of jQuery would only conflict with each other, resulting in the kind of JS errors like the one you're facing. jQuery的多个副本只会相互冲突,导致像你所面临的JS错误。

If you intend to use jQuery on pages which do not necessarily use PrimeFaces components which auto-include the PrimeFaces-bundled jQuery file, then add this line to <h:head> . 如果您打算在不一定使用自动包含PrimeFaces捆绑的jQuery文件的PrimeFaces组件的页面上使用jQuery,那么将此行添加到<h:head>

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

This way PrimeFaces-bundled jQuery file is always included and PrimeFaces won't auto-include duplicate jQuery files if some PrimeFaces component happen to require it. 这样,PrimeFaces捆绑的jQuery文件总是包含在内,如果某些PrimeFaces组件碰巧需要它,PrimeFaces将不会自动包含重复的jQuery文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM