<p:autocomplete> Uncaught TypeError:无法读取属性&#39; keyCode&#39;未定义的</p:autocomplete>

时间:2015-04-10 02:06:14

标签: jsf-2 primefaces autocomplete

我尝试使用PrimeFaces 5.1的<p:autocomplete />,但出于某种原因,当我加载页面时,我会在浏览器控制台上收到以下消息:

  

未捕获的TypeError:无法读取属性&#39; keyCode&#39;未定义的

我的观点是这样的:

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

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

<ui:composition>
    <div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
        <div class="container-fluid">
            <div class="navbar-header">
                <p:link outcome="index" value="Chamada Parlamentar" styleClass="navbar-brand header-link" />
            </div>
            <div class="navbar-collapse collapse">
                <ul class="nav navbar-nav navbar-right">
                    <li>
                        <p:link href="https://github.com/Thiagokairala/reconstru-oChamadaParlametnar">
                            <h:outputText value="Código Fonte:" />
                            <p:graphicImage url="/images/github.png" />
                        </p:link>
                    </li>
                    <li>
                        <p:link href="http://dados.gov.br/dados-abertos/">
                            <h:outputText value="Lei dos Dados Abertos" />
                        </p:link>
                    </li>
                    <li>
                        <p:link outcome="about" value="Nós" />
                    </li>
                    <li>
                        <p:link outcome="help" value="Ajuda" />
                    </li>
                </ul>
                <h:form class="navbar-form navbar-right" onsubmit="#{deputyMB.statistics}">
                    <p:autoComplete value="#{deputyMB.deputyName}"
                        completeMethod="#{autoComplete.completeDeputies}" />

                </h:form>
            </div>
        </div>
    </div>
</ui:composition>

我的自动完成方法是这样的:

package jsfConnection;

import java.util.ArrayList;
import java.util.List;

import javax.faces.bean.ManagedBean;

@ManagedBean
public class AutoComplete {

    public List<String> completeDeputies(String prefix) {
        List<String> deputies = new ArrayList<String>();
        for (int i = 0; i < 10; i++) {
            deputies.add(Integer.toString(i));
        }

        return deputies;
    }
}

这是如何引起的?如何解决?

1 个答案:

答案 0 :(得分:0)

我修好了,这是一个简单的jquery conflit。