簡體   English   中英

豐富的自動填充功能不起作用

[英]rich autocomplete does not work

我確定我做的事很愚蠢,所以我在前面道歉。 我無法致富:自動完成可以挽救生命。

當加載頁面“ Servlet FacesServlet的Servlet.service()引發異常:java.lang.IllegalArgumentException:寬度(2000)和高度(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的評論。 如您所見,我正在使用該錯誤中提到的Richfaces版本作為修復程序,所以不確定是什么問題嗎?

pom的形象錯誤評論

RichFaces中存在一個錯誤: https : //issues.jboss.org/browse/RF-11103 嘗試更新到最新版本。

試試下面的代碼,它對我有用:

<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());
    }    
}

覆蓋樣式以實現自動完成。 默認具有不存在的URL。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM