RichFaces 4自动完成功能未显示建议

时间:2013-08-28 22:15:57

标签: jsf-2 richfaces client-side facelets

我试图制作自动完成的自定义建议演示时间太长。 该演示部分正常工作,因为我可以在f12调试器中看到建议响应,但它没有显示在下拉框中。 我正在做以下

POM:

 <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <org.richfaces.version>4.3.3.Final</org.richfaces.version>

</properties>

<repositories>
    <repository>
        <id>org.openfaces</id>
        <url>http://repository.openfaces.org/repository</url>
    </repository>
    <repository>
        <id>jfree</id>
        <url>http://www.ibiblio.org/maven/jfree/</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>org.richfaces</groupId>
        <artifactId>richfaces-bom</artifactId>
        <version>${org.richfaces.version}</version>
        <scope>import</scope>
        <type>pom</type>
    </dependency>
    <dependency>
        <groupId>org.richfaces.ui</groupId>
        <artifactId>richfaces-components-ui</artifactId>
        <version>${org.richfaces.version}</version>
    </dependency>
    <dependency>
        <groupId>org.richfaces.core</groupId>
        <artifactId>richfaces-core-impl</artifactId>
        <version>${org.richfaces.version}</version>
    </dependency>

豆子:

    @ManagedBean    
    @RequestScoped
    public class TagCollector  implements Serializable{

    private static final long serialVersionUID = 4930140495481611695L;
    String tagName;
    public Converter getTagNameConverter(){
        return new Converter() {

            @Override
            public String getAsString(FacesContext context, UIComponent converter, Object value) {
                System.out.println("getAsString=" +(String)value);
                return (String)value;
            }

            @Override
            public Object getAsObject(FacesContext context, UIComponent converter, String value) {
                System.out.println("getAsObject=" +value);
                return value;
            }
        };
    }

    public List<String> getSuggestedTags(){
        String searchString = Faces.var("searchString", String.class);
        System.out.println("getSuggestedTags searchString="+ searchString);
        List<String> suggestedTags = Arrays.asList(new String[]{"ford", "mazda", "fiat"});
        return suggestedTags;   
    }

    public String getTagName() {
        return tagName;
    }

    public void setTagName(String tagName) {
        this.tagName = tagName;
    }
   }

xhtml:

    <h:form>
        <h:outputText value="Enter state" />
        <rich:autocomplete mode="ajax" minChars="1" showButton="true"
            autocompleteMethod="#{userBean.autocomplete}">
</rich:autocomplete>
    </h:form>

面部配置:

<managed-bean>
    <managed-bean-name>tagCollector</managed-bean-name>
    <managed-bean-class>org.taagad.tag.model.TagCollector</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope> 
</managed-bean>

我真的在网上搜索了几个小时无处可去,任何想法都会有所帮助。

1 个答案:

答案 0 :(得分:2)

我解决了这个问题!它正在研究jsf 2.1.25。 同样的问题是RichFaces,看起来两个实现对jsf iml和api的相同问题/错误敏感。 这是我项目的主题:

    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-api</artifactId>
        <version>2.1.25</version>
    </dependency>
    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-impl</artifactId>
        <version>2.1.25</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.0.1</version>
    </dependency>
    <dependency>
        <groupId>javax.portlet</groupId>
        <artifactId>portlet-api</artifactId>
        <version>2.0</version>
        <scope>provided</scope>
    </dependency>