4 Replies Latest reply on Jun 26, 2007 10:07 AM by tuxzilla

    help with r:suggestionbox

    tuxzilla

      I virtually copied the suggestionbox example code in demo to my app but the suggestion box didn't show up. The inputText field was fine but when I typed in something nothing showed up. I used debugging and confirmed that suggestionBox.autocompletion method was not invoked. I am using richfaces 3.0.1. Here is the view code (inside an xhtml file):

      <h:form>
      ...
      
       <h:panelGroup rendered="#{businessHome.definedInstance == null}">
       <h:inputText id="businessTitle" required="true"
       size="36"
       maxlength="128"
       value="#{suggestionBox.property}"/>
       <rich:suggestionbox id="suggestionBoxId" for="businessTitle" tokens=",["
       rules="#{suggestionBox.rules}"
       suggestionAction="#{suggestionBox.autocomplete}" var="result"
       fetchValue="#{result.title}" 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.title}"/>
       </h:column>
       </rich:suggestionbox>
       </h:panelGroup>
      ...
      </h:form>
      


      Here is the java bean suggestionBox:
      
      import java.io.Serializable;
      import java.util.List;
      import java.util.ArrayList;
      
      import org.richfaces.renderkit.html.SuggestionBoxRenderer;
      import org.jboss.seam.annotations.Name;
      
      /**
       * Created by IntelliJ IDEA.
       * To change this template use File | Settings | File Templates.
       */
      @Name("suggestionBox")
      public class SuggestionBox implements Serializable {
       /**
       *
       */
      
       private String property;
      
       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 = "300";
       private String height = "200";
       private String shadowOpacity = "4";
      
       private AllowSuggestion allowSuggestion;
      
       public SuggestionBox() {
       this.rows = "0";
       this.first = "0";
       this.cellspacing = "2";
       this.cellpadding = "2";
       this.minchars = "1";
       this.frequency = "0";
       this.rules = "none";
       }
      
       public List autocomplete(Object suggest) {
       return allowSuggestion.autocomplete(suggest);
       }
      
       public ArrayList getData() {
       return data;
       }
      
       public void setData(ArrayList data) {
       this.data = data;
       }
      
       public String getProperty() {
       return property;
       }
      
       public void setProperty(String property) {
       this.property = property;
       }
      
       public String getCellpadding() {
       return cellpadding;
       }
      
       public void setCellpadding(String cellpadding) {
       this.cellpadding = cellpadding;
       }
      
       public String getCellspacing() {
       return cellspacing;
       }
      
       public void setCellspacing(String cellspacing) {
       this.cellspacing = cellspacing;
       }
      
       public boolean isCheck() {
       return check;
       }
      
       public void setCheck(boolean check) {
       this.check = check;
       }
      
       public String getFirst() {
       return first;
       }
      
       public int getIntFirst() {
       return Integer.parseInt(getFirst());
       }
      
       public void setFirst(String first) {
       this.first = first;
       }
      
       public String getFrequency() {
       return frequency;
       }
      
       public double getDoubleFrequency() {
       return Double.parseDouble(getFrequency());
       }
      
       public void setFrequency(String frequency) {
       this.frequency = frequency;
       }
      
       public String getMinchars() {
       return minchars;
       }
      
       public void setMinchars(String minchars) {
       this.minchars = minchars;
       }
      
       public String getRows() {
       return rows;
       }
      
       public int getIntRows() {
       return Integer.parseInt(getRows());
       }
      
       public void setRows(String rows) {
       this.rows = rows;
       }
      
       public String getRules() {
       return rules;
       }
      
       public void setRules(String rules) {
       this.rules = rules;
       }
      
       public ArrayList getTokens() {
       return tokens;
       }
      
       public void setTokens(ArrayList tokens) {
       this.tokens = tokens;
       }
      
       public void OnSelect() {
       System.out.print("Onselect works!!!");
      
       }
      
       public String getShadowDepth() {
       return shadowDepth;
       }
      
       public void setShadowDepth(String shadowDepth) {
       this.shadowDepth = shadowDepth;
       }
      
       public String getBorder() {
       return border;
       }
      
       public void setBorder(String border) {
       this.border = border;
       }
      
       public String getWidth() {
       return width;
       }
      
       public void setWidth(String width) {
       this.width = width;
       }
      
       public String getHeight() {
       return height;
       }
      
       public void setHeight(String height) {
       this.height = height;
       }
      
       public String getShadowOpacity() {
       return shadowOpacity;
       }
      
       public void setShadowOpacity(String shadowOpacity) {
       this.shadowOpacity = shadowOpacity;
       }
      
       public void setAllowSuggestion(AllowSuggestion allowSuggestion) {
       this.allowSuggestion = allowSuggestion;
       }
      }
      
      


      Any help? Thanks.

        • 1. Re: help with r:suggestionbox
          hbarca

          Suggestionbox also does not work for me with RichFaces 3.0.1.

          It used to work with RichFaces 3.0.0, but there was a known bug which misplaced the suggestion box when contained in a relative-positioned div. The bug should have been fixed for version 3.0.1., but now it does not work at all. Are there any compatibiliy issues between RichFaces 3.0.1. and MyFaces implementation versions, Facelets etc.?

          • 2. Re: help with r:suggestionbox
            hbarca

            When I passed from RichFaces 3.0.0 to RichFaces 3.0.1, I only changed the library versions in the WEB-INF/lib to richFaces3.0.1, ajax4jsf1.0.1. and os-cache2.3.2. Then it didn't work any more. I use MyFaces1.1.4, Tomahawk 1.1.5 and Facelets.

            Thanks for any advice.

            • 3. Re: help with r:suggestionbox
              hbarca

              It works now! It was a stupid browser cache problem.. the cache must be cleaned up after changing between versions. I found this here:

              http://jboss.com/index.html?module=bb&op=viewtopic&t=111485

              • 4. Re: help with r:suggestionbox
                tuxzilla

                Unfortunately it is still not working for me. I use myfaces 1.1.4 and facelet, along with Seam 1.2.1. Could you post your suggestion box code snippet? Thanks.