2013-01-10 54 views
0

我正在开发一个web应用程序,使用3.4.2版本的Primefaces。我有一个p:pickList就可以了。应用程序正在使用常规模板工作,每个页面将替换正在为每个请求重新加载的模板的general_content。我的问题是,选择列表不工作(不能与它交互),因为当我加载页面时发生一些JavaScript错误。这是我的XHTML:Primefaces 3.4.2 javascript错误

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

<ui:define name="metadata"> 
    <f:metadata> 
     <f:viewParam id="user" name="user" 
      value="#{navegableUserData._ParamUser}" /> 

     <f:viewParam id="NavIndex" name="NavIndex" 
      value="#{navegableUserData._QueueIndex}" /> 
     <f:event type="preRenderView" 
      listener="#{navegableUserData.initialize}" /> 
    </f:metadata> 
    <h:message for="user" /> 
</ui:define> 

<ui:define name="general_content"> 
    <h:form id="SystemUserForm"> 
     <p:pickList id="rolePickList" value="#{navegableUserData._ListRoles}" 
      var="role" itemValue="#{role}" converter="rolConverter"> 
      <f:facet name="sourceCaption"> 
       <h:outputText value="#{msg.AVAILABLE}" /> 
      </f:facet> 
      <f:facet name="targetCaption"> 
       <h:outputText value="#{msg.ASSIGNED}" /> 
      </f:facet> 

      <p:column> 
       <h:outputText value="#{role._Nombre}" /> 
      </p:column> 
     </p:pickList> 
    </h:form> 
</ui:define> 

这是JavaScript错误我:

Firefox中的Firebug

萤火虫告诉我该元素a,不能被发现第一行primefaces.js

"a is undefined" 
PrimeFaces={escapeClientId:function(a){return"#"+a.replace(/:/g,"\\:")}, 
... 

督察在Chrome

Uncaught TypeError: Cannot call method 'replace' of undefined primefaces.js.xhtml:1 
PrimeFaces.escapeHTML primefaces.js.xhtml:1 
(anonymous function) primefaces.js.xhtml:27 
bG.extend.each jquery.js.xhtml:14 
bG.fn.bG.each jquery.js.xhtml:14 
PrimeFaces.widget.PickList.PrimeFaces.widget.BaseWidget.extend.generateItems primefaces.js.xhtml:27 
PrimeFaces.widget.PickList.PrimeFaces.widget.BaseWidget.extend.init primefaces.js.xhtml:27 
e.(anonymous function) jquery.js.xhtml:373 
c jquery.js.xhtml:373 
PrimeFaces.createWidget primefaces.js.xhtml:1 
PrimeFaces.cw primefaces.js.xhtml:1 
(anonymous function) 

看起来有些jQuery是失败的。随着Prime的以前版本,3.4.1,一切工作正常。

+0

在萤火虫,尝试把一个breakmark在该行(脚本选项卡),当它停下看看它说的鼠标悬停提示这个'函数(a)'参数。它可以调用没有ID的元素上的函数,如果是这种情况,也许它是PF 3.4.2上的错误(你不能降级PF库吗?) – Mindwin

+0

我已经用Firebug进行了测试,它给了我未定义的值。使用JSF * 2.1.15-2.1.16 *进行测试。当然,我可以降级它,但我只是想知道它为什么会发生。 –

回答

3

p:pickList(primefaces v3.4.2)需要指定itemLabel。

只需添加

itemLabel="#{role}" 

到您的电话号码:PICKLIST

+0

问题解决。 PF文档根本不指定哪些属性是必需的。这种错误然后更难以调试。谢谢。 –