rich:autocomplete example not working
ejb3workshop Aug 26, 2013 3:05 PMI am trying to run the autocomplete example (http://www.mastertheboss.com/richfaces/richfaces-4-quick-tutorial/page-2) on tomcat using JSF 2.2. However the pop-up showing me the options never appears.
Firebug reports the ajax response as following:
<partial-response id="j_id1"><changes> <update id="j_idt5:j_idt7"> <![CDATA[<span class="rf-msg " id="j_idt5:j_idt7"></span>]]> </update> <update id="j_idt5:j_idt10Items"><![CDATA[<div id="j_idt5:j_idt10Items"> <div class="rf-au-itm rf-au-opt rf-au-fnt rf-au-inp">England</div> <div class="rf-au-itm rf-au-opt rf-au-fnt rf-au-inp">France</div> <div class="rf-au-itm rf-au-opt rf-au-fnt rf-au-inp">Germany</div> <div class="rf-au-itm rf-au-opt rf-au-fnt rf-au-inp">Italy</div> <div class="rf-au-itm rf-au-opt rf-au-fnt rf-au-inp">Spain</div></div>]]> </update> <update id="javax.faces.ViewState"><![CDATA[1464693117226383287:-4493261262429297404]]></update> <extension id="org.richfaces.extension"> <complete>new RichFaces.ui.Message("j_idt5:j_idt7",{"forComponentId":"j_idt5:name","showSummary":false,"showDetail":true} );RichFaces.javascriptServiceComplete();;</complete> <render>j_idt5:j_idt10@items</render><componentData>{"j_idt5:j_idt10":["England","France","Germany","Italy","Spain"] } </componentData></extension></changes> </partial-response>
And there are no exceptions reported on the server side. I suspect the problem lies on the browser side not being able to interpret the response correctly.
Any suggestion on how I can debug this further ?
package com.j2anywhere.project013.web; import java.util.ArrayList; import java.util.List; import javax.enterprise.context.ApplicationScoped; import javax.inject.Named; import javax.validation.constraints.Size; @Named(value = "userBean") @ApplicationScoped public class UserBean { public List autocomplete(String prefix) { ArrayList result = new ArrayList(); result.add("England"); result.add("France"); result.add("Germany"); result.add("Italy"); result.add("Spain"); return result; } @Size(min=3, max=12,message="Must be between 3 and 12 chars") private String name; private String state; public String getState() { return state; } public String getName() { return name; } }
XHTML page
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <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:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich" template="./template.xhtml"> <f:view> <h:head></h:head> <h:body> <rich:panel header="Richfaces sample validation and auto-completion"> <h:form> <h:outputText value="Enter your name" /> <h:inputText id="name" value="#{userBean.name}"> <rich:validator /> </h:inputText> <rich:message for="name" /> <br /> <h:outputText value="Enter your state" /> <rich:autocomplete value="#{userBean.state}" minChars="1" autocompleteMethod="#{userBean.autocomplete}" /> </h:form> </rich:panel> </h:body> </f:view> </html>