富自动完成功能不起作用

时间:2014-01-03 18:16:19

标签: jsf jsf-2 autocomplete richfaces

我确信我做的事情很蠢,所以我在前面道歉。我不能致富:自动完成以挽救我的生命。

当我加载页面时出现此错误“servlet FacesServlet的Servlet.service()抛出异常:java.lang.IllegalArgumentException:Width(2000)和height(0)不能是< = 0”

我已经看过几篇关于此的帖子,所以我检查了我们的web.xml,你可以看到我们有每个人建议的参数

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>Phizzle Platform</display-name>
<welcome-file-list>
    <welcome-file>index.jsf</welcome-file>
</welcome-file-list>
<context-param>
    <param-name>org.richfaces.skin</param-name>
    <param-value>plain</param-value>
</context-param>
<context-param>
    <param-name>org.richfaces.enableControlSkinning</param-name>
    <param-value>false</param-value>
</context-param>
<context-param>
    <param-name>org.richfaces.responsiveDesign</param-name>
    <param-value>true</param-value>
</context-param>
<context-param>
    <param-name>org.richfaces.clientSideStyle</param-name>
    <param-value>false</param-value>
</context-param>
<context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Production</param-value>
</context-param>
<context-param>
<param-name>javax.faces.SEPARATOR_CHAR</param-name>
<param-value>-</param-value>
</context-param>

<mime-mapping>
    <extension>less</extension>
    <mime-type>text/css</mime-type>
</mime-mapping>
<mime-mapping>
    <extension>woff</extension>
    <mime-type>application/x-font-woff</mime-type>
</mime-mapping>
<servlet>
    <servlet-name>ServletInitializer</servlet-name>
    <servlet-class>init.initializer</servlet-class>
    <load-on-startup>2</load-on-startup>
    <multipart-config>
        <location>/tmp</location>
        <max-file-size>20848820</max-file-size>
        <max-request-size>418018841</max-request-size>
        <file-size-threshold>1048576</file-size-threshold>

    </multipart-config>

</servlet>

<error-page>
    <exception-type>java.lang.IllegalStateException</exception-type>
    <location>/</location>
</error-page>

这是我验证的bean代码正确返回字符串列表

public List<String> tagAutoComplete(Object o){
    String searchString = (String) o; 
    List<String> results =    filter(Matchers.containsString(searchString.toUpperCase()), tagSuggestions);
    System.out.println("results:" + results);
    return results;

}

这是我的页面代码

<ui:define name="content">
<h:form id="formbox">
...
   <rich:autocomplete value="#{fanlist.tagInputs}" autocompleteMethod="#      {fanlist.tagAutoComplete}"  mode="ajax" tokens=", " minChars="3" autofill="false" style="width:200px; height:50px;"/>
...

     </h:form>
</ui:define>

即使bean显示结果,也不会为自动完成返回任何内容。请帮忙。

阅读@Andrey的评论如下。正如您所看到的,我使用bug中提到的Richfaces版本作为修复,所以不确定问题是什么?

image of the pom bug comment

3 个答案:

答案 0 :(得分:0)

RichFaces中存在一个错误:https://issues.jboss.org/browse/RF-11103。 尝试更新到最新版本。

答案 1 :(得分:0)

试试这段代码,它对我有用:

<a4j:outputPanel><rich:autocomplete value="#{fanlist.tagInputs}" autocompleteMethod="#fanlist.tagAutoComplete}" valueChangeListener="#fanlist.tagValueChanged}" mode="ajax" tokens=", " minChars="3" autofill="false" style="width:200px; height:50px;"><a4j:ajax event="selectitem" /></rich:autocomplete></a4j:outputPanel>                                                       

并将此方法添加到bean中以获取所选值:

public void tagValueChanged(ValueChangeEvent event) {   
    if (null != event.getNewValue()) {
        System.out.println(" event.getNewValue() "+event.getNewValue());
    }    
}

答案 2 :(得分:0)

为自动完成功能覆盖样式。默认的网址不存在。

input.rf-au-inp {
    background-image: none;
}