8 Replies Latest reply on Mar 14, 2007 4:43 PM by ecauduro

    suggestion box example not work

    ecauduro

      Hi, im new in RichFaces and try to do the suggestion box example retired from RichFacesLiveDemo, but not work for me, i used exadel studio pro 4 in eclipse ide.
      I create de the bean SuggestionBox.java same on described in richfaceslivedemo, then i create a jsf page :

      <%@ taglib uri="http://richfaces.ajax4jsf.org/rich" prefix="rich"%>
      <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
      
      <html>
       <head>
       <title></title>
       </head>
       <body>
       <f:view>
       <h:form id="suggestionbox_form">
      
      
       <h:outputText
       value="Simple richfaces Suggestion Box test web application."
       style="font: 18px;font-weight: bold;" />
       <br />
       <br />
      
       <h:panelGrid columns="3" border="0" style="border: 1px solid black;">
       <f:verbatim>Suggestion Box will suggest you town names if it's started with the "a" or
       "A" letter</f:verbatim>
      
       <f:facet name="header">
       <f:verbatim>Input With Suggestion Feature</f:verbatim>
       </f:facet>
      
      
       <f:verbatim> </f:verbatim>
      
       <h:inputText value="#{suggestionBox.property}" id="text" />
       <rich:suggestionbox id="suggestionBoxId" for="text" tokens=",["
       rules="#{suggestionBox.rules}"
       suggestionAction="#{suggestionBox.autocomplete}" var="result"
       fetchValue="#{result.text}" rows="#{suggestionBox.intRows}"
       first="#{suggestionBox.intFirst}"
       minChars="#{suggestionBox.minchars}"
       shadowOpacity="#{suggestionBox.shadowOpacity}"
       border="#{suggestionBox.border}" width="#{suggestionBox.width}"
       height="#{suggestionBox.height}"
       shadowDepth="#{suggestionBox.shadowDepth}"
       cellpadding="#{suggestionBox.cellpadding}">
       <h:column>
       <h:outputText value="#{result.text}" />
       </h:column>
       </rich:suggestionbox>
       </h:panelGrid>
      
       <br />
       <br />
      
       </h:form>
       </f:view>
       </body>
      </html>
      


      when i access the page and input some letter on input box i receive an alert error:
      request error: 500 internal server error
      message undefined

      So looking in a tomcat log:
      14/03/2007 14:09:20 com.sun.faces.lifecycle.InvokeApplicationPhase execute
      SEVERE: autocomplete
      javax.faces.el.MethodNotFoundException: autocomplete
      at com.sun.faces.el.MethodBindingImpl.method(MethodBindingImpl.java:199)
      at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:124)
      at org.richfaces.component.UISuggestionBox.broadcast(UISuggestionBox.java:144)
      at javax.faces.component.UIData.broadcast(UIData.java:657)
      at org.richfaces.component.UISuggestionBox.broadcast(UISuggestionBox.java:137)
      at org.ajax4jsf.framework.ajax.AjaxViewRoot.processEvents(AjaxViewRoot.java:180)
      at org.ajax4jsf.framework.ajax.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:158)
      at org.ajax4jsf.framework.ajax.AjaxViewRoot.processApplication(AjaxViewRoot.java:329)
      at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
      at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:96)
      at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:220)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
      at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
      at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
      at java.lang.Thread.run(Thread.java:595)
      14/03/2007 14:09:20 org.apache.catalina.core.StandardWrapperValve invoke
      SEVERE: Servlet.service() for servlet Faces Servlet threw exception
      javax.faces.el.MethodNotFoundException: autocomplete
      at com.sun.faces.el.MethodBindingImpl.method(MethodBindingImpl.java:199)
      at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:124)
      at org.richfaces.component.UISuggestionBox.broadcast(UISuggestionBox.java:144)
      at javax.faces.component.UIData.broadcast(UIData.java:657)
      at org.richfaces.component.UISuggestionBox.broadcast(UISuggestionBox.java:137)
      at org.ajax4jsf.framework.ajax.AjaxViewRoot.processEvents(AjaxViewRoot.java:180)
      at org.ajax4jsf.framework.ajax.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:158)
      at org.ajax4jsf.framework.ajax.AjaxViewRoot.processApplication(AjaxViewRoot.java:329)
      at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)

      Makes me think he dont find autocomplete metod, but this method exists in SuggestionBox class. Whats the problem? Please help...


        • 1. Re: suggestion box example not work

          So, how the #{suggestionBox.autocomplete} method looks like in java code ?

          • 2. Re: suggestion box example not work
            ecauduro

            thx for respond....fyi:

            package org.richfaces.demo.sb;
            
            import org.richfaces.renderkit.html.SuggestionBoxRenderer;
            
            import java.util.ArrayList;
            import java.util.Iterator;
            import java.util.List;
            import java.io.Serializable;
            import org.richfaces.demo.sb.Data;
            
            public class SuggestionBox implements Serializable {
            
            
             /**
             *
             */
             private static final long serialVersionUID = 1L;
            
             private String property;
            
             private ArrayList cities;
            
             private ArrayList data;
             private ArrayList tokens;
            
             private String rows;
             private String first;
             private String cellspacing;
             private String cellpadding;
             private String minchars;
             private String frequency;
             private String rules;
             private boolean check;
             private String shadowDepth = Integer.toString(SuggestionBoxRenderer.SHADOW_DEPTH);
             private String border = "1";
             private String width = "200";
             private String height = "150";
             private String shadowOpacity = "4";
            
             private static final String [] cit = {"Abba", "Abbeville", "Acworth", "Adairsville", "Adel", "Adrian", "Ailey", "Alamo", "Alapaha", "Albany", "Allenhurst", "Alma", "Alpharetta", "Alston", "Amboy", "Ambrose", "Americus", "Appling", "Arlington", "Ashburn", "Athens", "Athens-Clarke County", "Atkinson", "Atlanta", "Attapulgus", "Auburn", "Augusta", "Augusta-Richmond County", "Austell", "Avondale Estates", "Axson"};
            
             public SuggestionBox() {
             this.rows = "0";
             this.first = "0";
             this.cellspacing = "2";
             this.cellpadding = "2";
             this.minchars = "1";
             this.frequency = "0";
             this.rules = "none";
            
             setCities(getAllData());
             }
            
             public List autocomplete(Object suggest) {
             String pref = (String)suggest;
             ArrayList result = new ArrayList();
            
             Iterator iterator = getAllData().iterator();
             while (iterator.hasNext()) {
             Data elem = (Data) iterator.next();
             if ((elem != null && elem.getText().toLowerCase().indexOf(pref.toLowerCase()) == 0) || "".equals(pref))
             {
             result.add(elem);
             }
             }
             return result;
             }
            
            


            • 3. Re: suggestion box example not work

              What is in your run-time environment ? (jsf version, facelets or not and so on)

              • 4. Re: suggestion box example not work
                ecauduro

                SUN RI jsf 1.2, no facelets, jdk 1.5:
                my web.xml:
                <?xml version="1.0"?>
                <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
                <context-param>
                <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
                <param-value>server</param-value>
                </context-param>
                <context-param>
                <param-name>org.ajax4jsf.SKIN</param-name>
                <param-value>classic</param-value>
                </context-param>
                <context-param>
                <param-name>com.exadel.vcp.trialKey</param-name>
                <param-value>trial_key_goes_here</param-value>
                </context-param>

                <display-name>Ajax4jsf Filter</display-name>
                <filter-name>ajax4jsf</filter-name>
                <filter-class>org.ajax4jsf.Filter</filter-class>

                <filter-mapping>
                <filter-name>ajax4jsf</filter-name>
                <servlet-name>Faces Servlet</servlet-name>
                REQUEST
                FORWARD
                INCLUDE
                </filter-mapping>

                <listener-class>com.sun.faces.config.ConfigureListener</listener-class>

                <!-- Faces Servlet -->

                <servlet-name>Faces Servlet</servlet-name>
                <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
                <load-on-startup>1</load-on-startup>

                <!-- Faces Servlet Mapping -->
                <servlet-mapping>
                <servlet-name>Faces Servlet</servlet-name>
                <url-pattern>*.jsf</url-pattern>
                </servlet-mapping>
                <login-config>
                <auth-method>BASIC</auth-method>
                </login-config>
                </web-app>

                • 5. Re: suggestion box example not work

                  So, change the signature of the method.

                  public List autocomplete(SuggestionEvent event) {
                  
                   String pref = event.getSubmittedValue();
                  
                   //collecting some data that begins with "pref" letters.
                  
                   ...
                  
                   return result;
                  
                   }

                  Source:

                  http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone/docs/devguide/suggestionbox.html

                  • 6. Re: suggestion box example not work
                    ecauduro

                    I register the SuggestionBox class like managed bean then it works... :)

                    • 7. Re: suggestion box example not work

                      Oh, yes. It was a brilliant idea :-)

                      • 8. Re: suggestion box example not work
                        ecauduro

                        sry...im new :(