RichFaces 4自动填充未显示建议 [英] RichFaces 4 autocomplete is not showing suggestions

查看:114
本文介绍了RichFaces 4自动填充未显示建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我花了很长时间才能制作一个自动完成的自定义建议演示. 该演示部分运行,因为我可以在f12调试器中看到建议响应,但未在下拉框中显示. 我正在做以下

I am trying for too long to make an autocomplete custom suggestion demo. The demo is partially working as I can see the suggestions response in f12 debugger, but it is not showing in the drop down box. I am doing the following

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>

我真的在网上搜索了无数小时,任何想法都会有所帮助.

I really search the web for hours getting nowhere, any idea will be helpful.

推荐答案

我解决了这个问题!它正在jsf 2.1.25上运行. RichFaces存在相同的问题,似乎两个实现都对jsf iml和api的同一问题/错误很敏感. 那是我项目中的pom:

I solved this issue! it is working on jsf 2.1.25. Same issue was with RichFaces, it appears both implementations are sensitive to the same issue/bug with jsf iml and api. That's the pom on my project:

    <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>

这篇关于RichFaces 4自动填充未显示建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆