You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2013/06/25 16:15:14 UTC

svn commit: r1496482 [1/2] - in /myfaces/tobago/trunk: tobago-core/src/main/java/org/apache/myfaces/tobago/component/ tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/ tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/extension/ ...

Author: lofwyr
Date: Tue Jun 25 14:15:13 2013
New Revision: 1496482

URL: http://svn.apache.org/r1496482
Log:
TOBAGO-1281: Reimplementation of the input suggest control

Added:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIIn.java
      - copied, changed from r1479803, myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIInput.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISuggest.java
      - copied, changed from r1479803, myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/UIMenuSelectOne.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SuggestTagDeclaration.java
      - copied, changed from r1479803, myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/InTagDeclaration.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/model/SuggestFilter.java
    myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/model/SuggestFilterUnitTest.java
      - copied, changed from r1492141, myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/layout/TextAlignUnitTest.java
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/Countries.java
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/55-suggest/
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/55-suggest/inputSuggest.xhtml
      - copied, changed from r1469744, myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/reference/inputSuggest.jsp
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SuggestRenderer.java
      - copied, changed from r1479803, myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-suggest.js
Modified:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/RendererTypes.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/SuggestMethodRule.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/extension/TobagoLabelExtensionHandler.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIDate.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIInput.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/InTagDeclaration.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/extension/InExtensionTag.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java
    myfaces/tobago/trunk/tobago-example/tobago-example-data/src/main/java/org/apache/myfaces/tobago/example/data/LocaleList.java
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/reference/InputSuggestController.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/tobago.css
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/pom.xml
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-in.js
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-menu.js
    myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/processor/TaglibGenerator.java
    myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component2.0.stg
    myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/tag1.2.stg

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/RendererTypes.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/RendererTypes.java?rev=1496482&r1=1496481&r2=1496482&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/RendererTypes.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/RendererTypes.java Tue Jun 25 14:15:13 2013
@@ -68,6 +68,7 @@ public final class RendererTypes {
   public static final String SHEET_PAGE_COMMAND = "SheetPageCommand";
   public static final String SHEET_LAYOUT = "SheetLayout";
   public static final String STYLE = "Style";
+  public static final String SUGGEST = "Suggest";
   public static final String TEXTAREA = "Textarea";
   public static final String TAB = "Tab";
   public static final String TAB_GROUP = "TabGroup";

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/SuggestMethodRule.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/SuggestMethodRule.java?rev=1496482&r1=1496481&r2=1496482&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/SuggestMethodRule.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/SuggestMethodRule.java Tue Jun 25 14:15:13 2013
@@ -19,8 +19,9 @@
 
 package org.apache.myfaces.tobago.facelets;
 
-import org.apache.myfaces.tobago.component.InputSuggest;
-import org.apache.myfaces.tobago.component.UIIn;
+import org.apache.myfaces.tobago.component.InputSuggest2;
+import org.apache.myfaces.tobago.internal.component.AbstractUISuggest;
+import org.apache.myfaces.tobago.model.SuggestFilter;
 
 import javax.faces.view.facelets.FaceletContext;
 import javax.faces.view.facelets.MetaRule;
@@ -29,16 +30,25 @@ import javax.faces.view.facelets.Metadat
 import javax.faces.view.facelets.TagAttribute;
 
 public class SuggestMethodRule extends MetaRule {
-  static final Class[] SUGGEST_METHOD = new Class[]{javax.faces.component.UIInput.class};
+
+  public static final Class[] SUGGEST_METHOD = new Class[]{javax.faces.component.UIInput.class};
+
   public static final SuggestMethodRule INSTANCE = new SuggestMethodRule();
 
-  public Metadata applyRule(String name, TagAttribute attribute,
-      MetadataTarget metadataTarget) {
-    if (metadataTarget.isTargetInstanceOf(InputSuggest.class)) {
+  public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget metadataTarget) {
+
+    if (metadataTarget.isTargetInstanceOf(InputSuggest2.class)) {
       if ("suggestMethod".equals(name)) {
         return new SuggestMethodMapper(attribute);
       }
     }
+    if (metadataTarget.isTargetInstanceOf(AbstractUISuggest.class)) {
+      if (attribute.isLiteral()) {
+        if ("filter".equals(name)) {
+          return new SuggestFilterMapper(attribute);
+        }
+      }
+    }
     return null;
   }
 
@@ -50,8 +60,21 @@ public class SuggestMethodRule extends M
     }
 
     public void applyMetadata(FaceletContext ctx, Object instance) {
-      ((UIIn) instance).setSuggestMethodExpression(
+      ((InputSuggest2) instance).setSuggestMethodExpression(
           attribute.getMethodExpression(ctx, null, SuggestMethodRule.SUGGEST_METHOD));
     }
   }
+
+  static final class SuggestFilterMapper extends Metadata {
+    private final TagAttribute attribute;
+
+    SuggestFilterMapper(TagAttribute attribute) {
+      this.attribute = attribute;
+    }
+
+    public void applyMetadata(FaceletContext ctx, Object instance) {
+      ((AbstractUISuggest) instance).setFilter(SuggestFilter.parse(attribute.getValue()));
+    }
+  }
+
 }

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/extension/TobagoLabelExtensionHandler.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/extension/TobagoLabelExtensionHandler.java?rev=1496482&r1=1496481&r2=1496482&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/extension/TobagoLabelExtensionHandler.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/extension/TobagoLabelExtensionHandler.java Tue Jun 25 14:15:13 2013
@@ -191,9 +191,15 @@ public abstract class TobagoLabelExtensi
 
   public void onComponentPopulated(FaceletContext faceletContext, UIComponent component, UIComponent parent) {
     super.onComponentPopulated(faceletContext, component, parent);
-    if (component.getChildren().size() > 1 && component.getChildren().get(1) instanceof EditableValueHolder) {
-      TobagoComponentHandler.addDefaultValidators(faceletContext.getFacesContext(),
-          (EditableValueHolder) component.getChildren().get(1));
+
+    if (component.getChildren().size() > 1) {
+      UIComponent input = component.getChildren().get(1);
+      if (input instanceof EditableValueHolder) {
+        TobagoComponentHandler.addDefaultValidators(faceletContext.getFacesContext(), (EditableValueHolder) input);
+      }
+      if (input instanceof OnComponentPopulated) {
+        ((OnComponentPopulated) input).onComponentPopulated(faceletContext.getFacesContext(), component);
+      }
     }
   }
 

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIDate.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIDate.java?rev=1496482&r1=1496481&r2=1496482&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIDate.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIDate.java Tue Jun 25 14:15:13 2013
@@ -20,8 +20,4 @@
 package org.apache.myfaces.tobago.internal.component;
 
 public abstract class AbstractUIDate extends AbstractUIInput {
-
-  public abstract boolean isDisabled();
-
-  public abstract boolean isReadonly();
 }

Copied: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIIn.java (from r1479803, myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIInput.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIIn.java?p2=myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIIn.java&p1=myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIInput.java&r1=1479803&r2=1496482&rev=1496482&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIInput.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIIn.java Tue Jun 25 14:15:13 2013
@@ -19,23 +19,36 @@
 
 package org.apache.myfaces.tobago.internal.component;
 
-import org.apache.myfaces.tobago.component.SupportsMarkup;
-import org.apache.myfaces.tobago.layout.LayoutComponent;
+import org.apache.myfaces.tobago.component.InputSuggest2;
+import org.apache.myfaces.tobago.component.OnComponentPopulated;
+import org.apache.myfaces.tobago.component.RendererTypes;
 import org.apache.myfaces.tobago.util.ComponentUtils;
+import org.apache.myfaces.tobago.util.CreateComponentUtils;
 
+import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
 
-public abstract class AbstractUIInput extends javax.faces.component.UIInput
-    implements SupportsMarkup, LayoutComponent {
+public abstract class AbstractUIIn extends AbstractUIInput implements OnComponentPopulated, InputSuggest2 {
 
-  // TODO can this removed?
-  public void updateModel(FacesContext facesContext) {
-    if (ComponentUtils.mayUpdateModel(this)) {
-      super.updateModel(facesContext);
+  public void onComponentPopulated(FacesContext facesContext, UIComponent parent) {
+    if (getSuggestMethodExpression() != null) {
+      if (getSuggest() == null) {
+        AbstractUISuggest suggest = (AbstractUISuggest) CreateComponentUtils.createComponent(
+            facesContext, AbstractUISuggest.COMPONENT_TYPE, RendererTypes.SUGGEST, null);
+        getChildren().add(suggest);
+        suggest.setSuggestMethodExpression(getSuggestMethodExpression());
+        suggest.setMinimumCharacters(getSuggestMinChars());
+        suggest.setDelay(getSuggestDelay());
+      }
     }
   }
 
-  public abstract Integer getTabIndex();
+  public AbstractUISuggest getSuggest() {
+    return ComponentUtils.findDescendant(this, AbstractUISuggest.class);
+  }
+
+  public abstract Integer getSuggestDelay();
+
+  public abstract Integer getSuggestMinChars();
 
-  public abstract boolean isFocus();
 }

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIInput.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIInput.java?rev=1496482&r1=1496481&r2=1496482&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIInput.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIInput.java Tue Jun 25 14:15:13 2013
@@ -38,4 +38,9 @@ public abstract class AbstractUIInput ex
   public abstract Integer getTabIndex();
 
   public abstract boolean isFocus();
+
+  public abstract boolean isDisabled();
+
+  public abstract boolean isReadonly();
+
 }

Copied: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISuggest.java (from r1479803, myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/UIMenuSelectOne.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISuggest.java?p2=myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISuggest.java&p1=myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/UIMenuSelectOne.java&r1=1479803&r2=1496482&rev=1496482&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/UIMenuSelectOne.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISuggest.java Tue Jun 25 14:15:13 2013
@@ -17,20 +17,28 @@
  * under the License.
  */
 
-package org.apache.myfaces.tobago.component;
+package org.apache.myfaces.tobago.internal.component;
 
-import javax.faces.component.UIComponent;
-import java.util.List;
+import org.apache.myfaces.tobago.component.InputSuggest2;
+import org.apache.myfaces.tobago.component.SupportsMarkup;
+import org.apache.myfaces.tobago.model.SuggestFilter;
 
-public class UIMenuSelectOne extends javax.faces.component.UISelectOne {
+import javax.faces.component.UIComponentBase;
 
-  public static final String COMPONENT_TYPE
-      = "org.apache.myfaces.tobago.MenuSelectOne";
+public abstract class AbstractUISuggest
+    extends UIComponentBase implements SupportsMarkup, InputSuggest2 {
 
-  // hack to made decoding of menuRadio work
-  // selectItems are located at parent component
-  public List<UIComponent> getChildren() {
-    return getParent().getChildren();
+  public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.Suggest";
+  public static final String COMPONENT_FAMILY = "org.apache.myfaces.tobago.Suggest";
+
+  @Override
+  public String getFamily() {
+    return COMPONENT_FAMILY;
   }
 
+  public abstract void setDelay(Integer delay);
+
+  public abstract void setMinimumCharacters(Integer minimumCharacters);
+
+  public abstract void setFilter(SuggestFilter filter);
 }

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/InTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/InTagDeclaration.java?rev=1496482&r1=1496481&r2=1496482&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/InTagDeclaration.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/InTagDeclaration.java Tue Jun 25 14:15:13 2013
@@ -49,12 +49,13 @@ import javax.faces.component.UIInput;
 @BodyContentDescription(anyTagOf = "facestag")
 @UIComponentTag(
     uiComponent = "org.apache.myfaces.tobago.component.UIIn",
-    uiComponentBaseClass = "org.apache.myfaces.tobago.internal.component.AbstractUIInput",
+    uiComponentBaseClass = "org.apache.myfaces.tobago.internal.component.AbstractUIIn",
     uiComponentFacesClass = "javax.faces.component.UIInput",
     componentFamily = UIInput.COMPONENT_FAMILY,
     rendererType = RendererTypes.IN,
-    allowedChildComponenents = "NONE",
-    interfaces =  {"org.apache.myfaces.tobago.component.InputSuggest2"},
+    allowedChildComponenents = {
+        "org.apache.myfaces.tobago.Suggest"
+    },
     facets = {
     @Facet(name = Facets.CHANGE,
         description =

Copied: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SuggestTagDeclaration.java (from r1479803, myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/InTagDeclaration.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SuggestTagDeclaration.java?p2=myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SuggestTagDeclaration.java&p1=myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/InTagDeclaration.java&r1=1479803&r2=1496482&rev=1496482&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/InTagDeclaration.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SuggestTagDeclaration.java Tue Jun 25 14:15:13 2013
@@ -19,50 +19,133 @@
 
 package org.apache.myfaces.tobago.internal.taglib.component;
 
-import org.apache.myfaces.tobago.apt.annotation.BodyContentDescription;
-import org.apache.myfaces.tobago.apt.annotation.Facet;
+import org.apache.myfaces.tobago.apt.annotation.DynamicExpression;
 import org.apache.myfaces.tobago.apt.annotation.Tag;
+import org.apache.myfaces.tobago.apt.annotation.TagAttribute;
 import org.apache.myfaces.tobago.apt.annotation.UIComponentTag;
-import org.apache.myfaces.tobago.component.Facets;
+import org.apache.myfaces.tobago.apt.annotation.UIComponentTagAttribute;
 import org.apache.myfaces.tobago.component.RendererTypes;
-import org.apache.myfaces.tobago.internal.taglib.declaration.HasAutocomplete;
-import org.apache.myfaces.tobago.internal.taglib.declaration.HasConverter;
 import org.apache.myfaces.tobago.internal.taglib.declaration.HasCurrentMarkup;
 import org.apache.myfaces.tobago.internal.taglib.declaration.HasIdBindingAndRendered;
-import org.apache.myfaces.tobago.internal.taglib.declaration.HasInputLabel;
 import org.apache.myfaces.tobago.internal.taglib.declaration.HasMarkup;
-import org.apache.myfaces.tobago.internal.taglib.declaration.HasSuggestMethod;
-import org.apache.myfaces.tobago.internal.taglib.declaration.HasTip;
-import org.apache.myfaces.tobago.internal.taglib.declaration.InputTagDeclaration;
-import org.apache.myfaces.tobago.internal.taglib.declaration.IsDeprecatedInline;
-import org.apache.myfaces.tobago.internal.taglib.declaration.IsDisabled;
-import org.apache.myfaces.tobago.internal.taglib.declaration.IsPassword;
-import org.apache.myfaces.tobago.internal.taglib.declaration.IsReadonly;
-import org.apache.myfaces.tobago.internal.taglib.declaration.IsRequired;
+import org.apache.myfaces.tobago.model.SuggestFilter;
 
 import javax.faces.component.UIInput;
 
 /**
- * Renders a text input field.
+ * Renders a list of suggested texts for a given input field.
+ *
+ * Basic features:
+ * <ul>
+ *   <li>provide a list directly while rendering (not AJAX needed) [todo]</li>
+ *   <li>update by typing (AJAX)</li>
+ *   <li>minimum number of typed characters (to avoid useless requests) [todo]</li>
+ *   <li>update delay (useful for optimization) [todo]</li>
+ *   <li>filter on client side (useful for optimization) [todo]</li>
+ * </ul>
+ *
+ * @since 2.0.0
  */
-@Tag(name = "in")
-@BodyContentDescription(anyTagOf = "facestag")
+@Tag(name = "suggest")
 @UIComponentTag(
-    uiComponent = "org.apache.myfaces.tobago.component.UIIn",
-    uiComponentBaseClass = "org.apache.myfaces.tobago.internal.component.AbstractUIInput",
-    uiComponentFacesClass = "javax.faces.component.UIInput",
+    uiComponent = "org.apache.myfaces.tobago.component.UISuggest",
+    uiComponentBaseClass = "org.apache.myfaces.tobago.internal.component.AbstractUISuggest",
+    uiComponentFacesClass = "javax.faces.component.UIComponentBase",
     componentFamily = UIInput.COMPONENT_FAMILY,
-    rendererType = RendererTypes.IN,
-    allowedChildComponenents = "NONE",
-    interfaces =  {"org.apache.myfaces.tobago.component.InputSuggest2"},
-    facets = {
-    @Facet(name = Facets.CHANGE,
-        description =
-            "This facet can contain a UICommand that is invoked in a case of a change event from the component")
-        })
-public interface InTagDeclaration
-    extends HasIdBindingAndRendered, HasConverter, IsReadonly, IsDisabled, IsRequired, HasTip, IsPassword,
-    HasSuggestMethod, HasMarkup, HasCurrentMarkup, InputTagDeclaration, HasInputLabel, IsDeprecatedInline,
-    HasAutocomplete {
+    rendererType = RendererTypes.SUGGEST,
+    isTransparentForLayout = true,
+    allowedChildComponenents = "NONE")
+public interface SuggestTagDeclaration extends HasIdBindingAndRendered, HasMarkup, HasCurrentMarkup {
+
+  /**
+   * MethodBinding which generates a list of suggested input values based on
+   * the currently entered text, which could be retrieved via getSubmittedValue() on the UIIn.
+   * The expression has to evaluate to a public method which has a javax.faces.component.UIInput parameter
+   * and returns a List&lt;String>, a List&lt;org.apache.myfaces.tobago.model.AutoSuggestItem>
+   * or a org.apache.myfaces.tobago.model.AutoSuggestItems.
+   *
+   * @deprecated Please use an <code>&lt;tc:selectItems></code> tag or a list of <code>&lt;tc:selectItem></code> tags
+   * (TODO: not implemented yet).
+   */
+  @Deprecated
+  @TagAttribute
+  @UIComponentTagAttribute(type = {},
+      expression = DynamicExpression.METHOD_EXPRESSION_REQUIRED,
+      methodSignature = "javax.faces.component.UIInput",
+      methodReturnType = "java.lang.Object")
+  void setSuggestMethod(String suggestMethod);
+
+  /**
+   * Minimum number of characters to type before the list will be requested.
+   * If the value is 0, there will be send an initial list to the client.
+   * So, if you set <pre>update="false"</pre> this value should be 0.
+   */
+  @TagAttribute
+  @UIComponentTagAttribute(type = "java.lang.Integer", defaultValue = "1")
+  void setMinimumCharacters(String minimumCharacters);
+
+  /**
+   * Time in milli seconds before the list will be requested (by AJAX).
+   */
+  @TagAttribute
+  @UIComponentTagAttribute(type = "java.lang.Integer", defaultValue = "300")
+  void setDelay(String delay);
+
+  /**
+   * The maximum number of item to display in the drop down list.
+   */
+  @TagAttribute
+  @UIComponentTagAttribute(type = "java.lang.Integer", defaultValue = "10")
+  void setMaximumItems(String maximumItems);
+
+  /**
+   * The real size of the result list.
+   * Typically the result list will be cropped (in the backend) to save memory.
+   * This value can be set, to show the user there are more results for the given string.
+   * If the value is -1, no hint will be displayed.
+   */
+  @TagAttribute
+  @UIComponentTagAttribute(type = "java.lang.Integer", defaultValue = "-1")
+  void setTotalCount(String totalCount);
+
+  /**
+   * TODO: not implemented yet
+   * <p/>
+   * Additional client side filtering of the result list.
+   * This is useful when sending the full list initially to the client and
+   * setting <code>update=false</code>.
+   * <p/>
+   * Possible values are:
+   * <dl>
+   *   <dt>all</dt>
+   *   <dd>no filtering</dd>
+   *   <dt>prefix</dt>
+   *   <dd>checks if the suggested string starts with the typed text</dd>
+   *   <dt>contains</dt>
+   *   <dd>checks if the typed text is inside of the suggested string</dd>
+   * </dl>
+   * <p/>
+   * The filter will only applied on the client side and
+   * only if server updated (by AJAX) are turned off (<code>update=false</code>);
+   */
+  @TagAttribute
+  @UIComponentTagAttribute(
+      type = "org.apache.myfaces.tobago.model.SuggestFilter",
+      defaultValue = "SuggestFilter.ALL",
+      allowedValues = {
+          SuggestFilter.STRING_ALL,
+          SuggestFilter.STRING_PREFIX,
+          SuggestFilter.STRING_CONTAINS})
+  void setFilter(String filter);
+
+  /**
+   * TODO: not implemented yet
+   * <p/>
+   * Should the list be updated while typing (via AJAX). This is the default behaviour.
+   * If you set this value to <code>false</code>, please set the <code>minimumCharacters="0"</pre>.
+   */
+  @TagAttribute
+  @UIComponentTagAttribute(type = "boolean", defaultValue = "true")
+  void setUpdate(String update);
 
 }

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/extension/InExtensionTag.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/extension/InExtensionTag.java?rev=1496482&r1=1496481&r2=1496482&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/extension/InExtensionTag.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/extension/InExtensionTag.java Tue Jun 25 14:15:13 2013
@@ -333,7 +333,7 @@ public class InExtensionTag extends Toba
   @TagAttribute
   @UIComponentTagAttribute(type = {},
       expression = DynamicExpression.METHOD_EXPRESSION_REQUIRED,
-      methodSignature = "java.lang.String")
+      methodSignature = "javax.faces.component.UIInput")
   public void setSuggestMethod(MethodExpression suggestMethod) {
     this.suggestMethod = suggestMethod;
   }

Added: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/model/SuggestFilter.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/model/SuggestFilter.java?rev=1496482&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/model/SuggestFilter.java (added)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/model/SuggestFilter.java Tue Jun 25 14:15:13 2013
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.myfaces.tobago.model;
+
+public enum SuggestFilter {
+
+  ALL,
+  PREFIX,
+  CONTAINS;
+
+  public static final String STRING_ALL = "all";
+  public static final String STRING_PREFIX = "prefix";
+  public static final String STRING_CONTAINS = "contains";
+
+  public String getValue() {
+    return name().toLowerCase();
+  }
+
+  public static SuggestFilter parse(String string) {
+    if (string == null) {
+      return null;
+    }
+    return valueOf(string.toUpperCase());
+  }
+}

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java?rev=1496482&r1=1496481&r2=1496482&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java Tue Jun 25 14:15:13 2013
@@ -199,13 +199,21 @@ public final class DataAttributes {
 
   /**
    * Custom suggest attribute. Used for input suggest.
+   * @deprecated Since Tobago 2.0.0. No longer needed.
    */
+  @Deprecated
   public static final String SUGGEST = "data-tobago-suggest";
 
   public static final String SUGGEST_DELAY = "data-tobago-suggest-delay";
 
+  public static final String SUGGEST_MAX_ITEMS = "data-tobago-suggest-max-items";
+
   public static final String SUGGEST_MIN_CHARS = "data-tobago-suggest-min-chars";
 
+  public static final String SUGGEST_TOTAL_COUNT = "data-tobago-suggest-total-count";
+
+  public static final String SUGGEST_UPDATE = "data-tobago-suggest-update";
+
   public static final String TRANSITION = "data-tobago-transition";
 
   /**

Copied: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/model/SuggestFilterUnitTest.java (from r1492141, myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/layout/TextAlignUnitTest.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/model/SuggestFilterUnitTest.java?p2=myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/model/SuggestFilterUnitTest.java&p1=myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/layout/TextAlignUnitTest.java&r1=1492141&r2=1496482&rev=1496482&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/layout/TextAlignUnitTest.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/model/SuggestFilterUnitTest.java Tue Jun 25 14:15:13 2013
@@ -17,18 +17,17 @@
  * under the License.
  */
 
-package org.apache.myfaces.tobago.layout;
+package org.apache.myfaces.tobago.model;
 
 import org.junit.Assert;
 import org.junit.Test;
 
-public class TextAlignUnitTest {
+public class SuggestFilterUnitTest {
 
   @Test
   public void testConstants() {
-    Assert.assertEquals(TextAlign.LEFT.getValue(), TextAlign.STRING_LEFT);
-    Assert.assertEquals(TextAlign.RIGHT.getValue(), TextAlign.STRING_RIGHT);
-    Assert.assertEquals(TextAlign.CENTER.getValue(), TextAlign.STRING_CENTER);
-    Assert.assertEquals(TextAlign.JUSTIFY.getValue(), TextAlign.STRING_JUSTIFY);
+    Assert.assertEquals(SuggestFilter.ALL.getValue(), SuggestFilter.STRING_ALL);
+    Assert.assertEquals(SuggestFilter.PREFIX.getValue(), SuggestFilter.STRING_PREFIX);
+    Assert.assertEquals(SuggestFilter.CONTAINS.getValue(), SuggestFilter.STRING_CONTAINS);
   }
 }

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-data/src/main/java/org/apache/myfaces/tobago/example/data/LocaleList.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-data/src/main/java/org/apache/myfaces/tobago/example/data/LocaleList.java?rev=1496482&r1=1496481&r2=1496482&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-data/src/main/java/org/apache/myfaces/tobago/example/data/LocaleList.java (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-data/src/main/java/org/apache/myfaces/tobago/example/data/LocaleList.java Tue Jun 25 14:15:13 2013
@@ -22,6 +22,7 @@ package org.apache.myfaces.tobago.exampl
 import org.apache.commons.lang.StringUtils;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
@@ -34,6 +35,10 @@ public class LocaleList {
 
   public static final List<String> COUNTRY_LANGUAGE;
 
+  public static final List<String> COUNTRY;
+
+  public static final List<String> HOLIDAY;
+
   static {
     List<LocaleEntry> init = new ArrayList<LocaleEntry>();
     for (Locale displayLocale : Locale.getAvailableLocales()) {
@@ -58,6 +63,34 @@ public class LocaleList {
     COUNTRY_LANGUAGE = Collections.unmodifiableList(list);
   }
 
+  static {
+    Set<String> init = new HashSet<String>();
+    for (LocaleEntry localeEntry : DATA) {
+      if (StringUtils.isNotBlank(localeEntry.getCountry())) {
+        init.add(localeEntry.getCountry());
+      }
+    }
+    final ArrayList<String> list = new ArrayList<String>(init);
+    Collections.sort(list);
+    COUNTRY = Collections.unmodifiableList(list);
+  }
+
+  static {
+    final List<String> list = Arrays.asList(
+        "Trinidad and Tobago",
+        "Portugal",
+        "Norway",
+        "New Zealand",
+        "Equador",
+        "Greece",
+        "Reunion",
+        "Mauritius",
+        "Dominica");
+    Collections.sort(list);
+    HOLIDAY = Collections.unmodifiableList(list);
+  }
+
+
   private LocaleList() {
     // do not call
   }

Added: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/Countries.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/Countries.java?rev=1496482&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/Countries.java (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/Countries.java Tue Jun 25 14:15:13 2013
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.myfaces.tobago.example.demo;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.myfaces.tobago.example.data.LocaleList;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.faces.component.UIInput;
+import javax.inject.Named;
+import java.util.ArrayList;
+import java.util.List;
+
+@ApplicationScoped
+@Named
+public class Countries {
+
+  private static final Logger LOG = LoggerFactory.getLogger(Countries.class);
+
+  public List<String> prefixed(UIInput input) {
+    String prefix = (String) input.getSubmittedValue();
+    LOG.info("Creating items for prefix: '" + prefix + "'");
+    List<String> result = new ArrayList<String>();
+    for (String name : LocaleList.COUNTRY) {
+      if (StringUtils.startsWithIgnoreCase(name, prefix)) {
+        result.add(name);
+      }
+      if (result.size() > 100) { // this value should be greater than the value of the input control
+        break;
+      }
+    }
+    return result;
+  }
+
+  public List<String> contains(UIInput input) {
+    String contain = (String) input.getSubmittedValue();
+    LOG.info("Creating items which contain: '" + contain + "'");
+    List<String> result = new ArrayList<String>();
+    for (String name : LocaleList.COUNTRY) {
+      if (StringUtils.containsIgnoreCase(name, contain)) {
+        result.add(name);
+      }
+      if (result.size() > 100) { // this value should be greater than the value of the input control
+        break;
+      }
+    }
+    return result;
+  }
+
+  public List<String> holiday(UIInput input) {
+    List<String> result = new ArrayList<String>();
+    for (String name : LocaleList.HOLIDAY) {
+      result.add(name);
+      if (result.size() > 100) { // this value should be greater than the value of the input control
+        break;
+      }
+    }
+    return result;
+  }
+
+}

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/reference/InputSuggestController.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/reference/InputSuggestController.java?rev=1496482&r1=1496481&r2=1496482&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/reference/InputSuggestController.java (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/reference/InputSuggestController.java Tue Jun 25 14:15:13 2013
@@ -19,18 +19,18 @@
 
 package org.apache.myfaces.tobago.example.reference;
 
+import org.apache.commons.lang.math.RandomUtils;
 import org.apache.myfaces.tobago.model.AutoSuggestExtensionItem;
 import org.apache.myfaces.tobago.model.AutoSuggestItem;
 import org.apache.myfaces.tobago.model.AutoSuggestItems;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import javax.faces.component.UIInput;
 import javax.faces.model.SelectItem;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 public class InputSuggestController {
 
   private static final Logger LOG = LoggerFactory.getLogger(InputSuggestController.class);
@@ -115,15 +115,16 @@ public class InputSuggestController {
 
   public List<String> getSimpleSuggestItems(UIInput component) {
     String prefix = (String) component.getSubmittedValue();
-    LOG.info("createing items for prefix :\"" + prefix + "\"");
-    List<String> li = new ArrayList<String>();
-    li.add(prefix+1);
-    li.add(prefix+2);
-    li.add(prefix+3);
-    li.add(prefix+4);
-    li.add(prefix+5);
-    li.add(prefix+6);
-    return li;
+    LOG.info("Creating items for prefix '" + prefix + "'");
+    if (prefix == null) {
+      prefix = "";
+    }
+    List<String> list = new ArrayList<String>();
+    int n = RandomUtils.nextInt(10);
+    for (int i = 0; i < n; i++) {
+      list.add(prefix + i);
+    }
+    return list;
   }
 
   public AutoSuggestItems getZipSuggestItems(UIInput component) {

Copied: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/55-suggest/inputSuggest.xhtml (from r1469744, myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/reference/inputSuggest.jsp)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/55-suggest/inputSuggest.xhtml?p2=myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/55-suggest/inputSuggest.xhtml&p1=myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/reference/inputSuggest.jsp&r1=1469744&r2=1496482&rev=1496482&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/reference/inputSuggest.jsp (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/55-suggest/inputSuggest.xhtml Tue Jun 25 14:15:13 2013
@@ -1,4 +1,4 @@
-<%--
+<!--
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
@@ -13,77 +13,140 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
---%>
-<%@ taglib uri="http://myfaces.apache.org/tobago/component" prefix="tc" %>
-<%@ taglib uri="http://myfaces.apache.org/tobago/extension" prefix="tx" %>
-<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
-<%@ taglib tagdir="/WEB-INF/tags/layout" prefix="layout" %>
-
-<layout:overview>
-  <jsp:body>
-    <tc:box label="InputSuggest">
+-->
+
+<ui:composition template="/WEB-INF/tags/layout/overview.xhtml"
+                xmlns:tc="http://myfaces.apache.org/tobago/component"
+                xmlns:ui="http://java.sun.com/jsf/facelets"
+                xmlns:f="http://java.sun.com/jsf/core"
+                xmlns:tx="http://myfaces.apache.org/tobago/extension">
+  <ui:param name="title" value="InputSuggest"/>
+  <tc:panel>
+
+    <!--
+        <f:facet name="contextMenu">
+          <tc:menu>
+            <tc:menuCommand onclick="alert('Main Menu 1')" label="Main Menu 1"/>
+            <tc:menuCommand onclick="alert('Main Menu 2')" label="Main Menu 2"/>
+            <tc:menu label="Main Submenu">
+              <tc:menuCommand onclick="alert('Main Menu 3')" label="Main Menu 3"/>
+              <tc:menuCommand onclick="alert('Main Menu 4')" label="Main Menu 4"/>
+            </tc:menu>
+          </tc:menu>
+        </f:facet>
+    -->
+
+    <f:facet name="layout">
+      <tc:gridLayout rows="auto;auto;auto;auto;auto"/>
+    </f:facet>
+
+    <tc:separator label="Simple"/>
+
+    <tc:panel>
       <f:facet name="layout">
-        <tc:gridLayout rows="auto;50px;auto;auto;50px;150px;auto;1*"/>
+        <tc:gridLayout columns="300px;*" rows="60px"/>
       </f:facet>
 
-      <tc:separator label="Simple"/>
+      <tx:in id="suggest"
+             value="#{inputSuggestController.simpleValue}"
+             label="Country"
+             tip="search for the given prefix">
+        <tc:suggest suggestMethod="#{countries.prefixed}"/>
+      </tx:in>
 
-      <tc:out value=" suggestion starts with the 2. character and just adds an index to the prefix"/>
+      <tc:out escape="false"
+          value="The backend implementation returns a list of countries which &lt;b>starts&lt;/b> with the given charaters."/>
 
-      <tc:panel >
-        <f:facet name="layout">
-          <tc:gridLayout columns="350px;1*"/>
-        </f:facet>
+    </tc:panel>
 
-        <tx:in value="#{inputSuggestController.simpleValue}"
-               label="Suggest test:"
-               tip="test"
-               suggestMethod="#{inputSuggestController.getSimpleSuggestItems}"/>
+    <tc:panel>
+      <f:facet name="layout">
+        <tc:gridLayout columns="300px;*" rows="60px"/>
+      </f:facet>
+
+      <tx:in value="#{inputSuggestController.simpleValue}"
+             label="Containing"
+             tip="search for containing the given string">
+        <tc:suggest suggestMethod="#{countries.contains}"/>
+      </tx:in>
 
-        <tc:cell/>
+      <tc:out escape="false"
+          value="The backend implementation returns a list of countries which &lt;b>contains&lt;/b> the given charaters."/>
 
-      </tc:panel>
+    </tc:panel>
 
-      <tc:separator label="Multi field suggest"/>
+    <tc:panel>
+      <f:facet name="layout">
+        <tc:gridLayout columns="300px;*" rows="60px"/>
+      </f:facet>
 
-      <tc:out value="Try \"26...\" in the ZIP, or \"ol...\" in the city field. On selection ZIP, City and State are updated, focus goes to textarea. "/>      
+      <tx:in value="#{inputSuggestController.simpleValue}"
+             label="Delay">
+        <tc:suggest suggestMethod="#{countries.prefixed}" delay="2000"/>
+      </tx:in>
 
-      <tc:panel >
-        <f:facet name="layout">
-          <tc:gridLayout rows="auto;auto;1*" columns="350px;1*"/>
-        </f:facet>
+      <tc:out escape="false"
+          value="Setting the &lt;b>delay='2000'&lt;/b> to wait 2 seconds before making an AJAX request."/>
+
+    </tc:panel>
+
+    <tc:panel>
+      <f:facet name="layout">
+        <tc:gridLayout columns="300px;*" rows="60px"/>
+      </f:facet>
+
+      <tx:in value="#{inputSuggestController.simpleValue}"
+             label="Minimum">
+        <tc:suggest suggestMethod="#{countries.prefixed}" minimumCharacters="3"/>
+      </tx:in>
+
+      <tc:out escape="false"
+          value="Defining the minimal number of charakers before the list will be requested, here with &lt;b>minimumCharacters='3'&lt;/b>."/>
+
+    </tc:panel>
+
+
+    <!--
+          <tc:separator label="Multi field suggest"/>
+
+          <tc:out value='Try "26..." in the ZIP, or "ol..." in the city field. On selection ZIP, City and State are updated, focus goes to textarea. '/>
+
+          <tc:panel >
+            <f:facet name="layout">
+              <tc:gridLayout rows="auto;auto;1*" columns="350px;1*"/>
+            </f:facet>
 
-        <tc:panel>
-          <f:facet name="layout">
-            <tc:gridLayout columns="200px;1*"/>
-          </f:facet>
-          <tx:in id="isZip" value="#{inputSuggestController.zipValue}"
-                 label="ZIP/City:"
-                 tip="test"
-                 suggestMethod="#{inputSuggestController.getZipSuggestItems}"/>
-          <tc:in id="isCity" value="#{inputSuggestController.cityValue}"
-                 tip="test"
-                 suggestMethod="#{inputSuggestController.getCitySuggestItems}"/>
-        </tc:panel>
+            <tc:panel>
+              <f:facet name="layout">
+                <tc:gridLayout columns="200px;1*"/>
+              </f:facet>
+              <tx:in id="isZip" value="#{inputSuggestController.zipValue}"
+                     label="ZIP/City:"
+                     tip="test"
+                     suggestMethod="#{inputSuggestController.getZipSuggestItems}"/>
+              <tc:in id="isCity" value="#{inputSuggestController.cityValue}"
+                     tip="test"
+                     suggestMethod="#{inputSuggestController.getCitySuggestItems}"/>
+            </tc:panel>
 
-        <tc:cell spanY="3"/>
+            <tc:cell spanY="3"/>
 
-        <tx:selectOneChoice label="State:"
-                            id="isState"
-            value="#{inputSuggestController.region}">
-          <f:selectItems value="#{inputSuggestController.regionItems}"/>
-        </tx:selectOneChoice>
+            <tx:selectOneChoice label="State:"
+                                id="isState"
+                value="#{inputSuggestController.region}">
+              <f:selectItems value="#{inputSuggestController.regionItems}"/>
+            </tx:selectOneChoice>
 
-        <tc:textarea id="txarea"/>
+            <tc:textarea id="txarea"/>
 
 
-      </tc:panel>
+          </tc:panel>
 
 
-      <tc:separator/>
+          <tc:separator/>
+    -->
 
-      <tc:cell/>
+    <tc:cell/>
 
-    </tc:box>
-  </jsp:body>
-</layout:overview>
+  </tc:panel>
+</ui:composition>

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java?rev=1496482&r1=1496481&r2=1496482&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java Tue Jun 25 14:15:13 2013
@@ -21,17 +21,12 @@ package org.apache.myfaces.tobago.render
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.myfaces.tobago.component.Attributes;
-import org.apache.myfaces.tobago.component.UIIn;
-import org.apache.myfaces.tobago.context.ResourceManagerUtils;
+import org.apache.myfaces.tobago.internal.component.AbstractUIIn;
 import org.apache.myfaces.tobago.internal.component.AbstractUIInput;
 import org.apache.myfaces.tobago.internal.util.FacesContextUtils;
-import org.apache.myfaces.tobago.model.AutoSuggestExtensionItem;
-import org.apache.myfaces.tobago.model.AutoSuggestItem;
-import org.apache.myfaces.tobago.model.AutoSuggestItems;
 import org.apache.myfaces.tobago.renderkit.InputRendererBase;
 import org.apache.myfaces.tobago.renderkit.css.Classes;
 import org.apache.myfaces.tobago.renderkit.css.Style;
-import org.apache.myfaces.tobago.renderkit.html.DataAttributes;
 import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
 import org.apache.myfaces.tobago.renderkit.html.HtmlElements;
 import org.apache.myfaces.tobago.renderkit.html.HtmlInputTypes;
@@ -43,13 +38,9 @@ import org.slf4j.LoggerFactory;
 
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
-import javax.faces.el.MethodBinding;
 import javax.faces.validator.LengthValidator;
 import javax.faces.validator.Validator;
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
 
 public class InRenderer extends InputRendererBase {
 
@@ -67,81 +58,64 @@ public class InRenderer extends InputRen
 
   @Override
   public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {
-    if (!(component instanceof AbstractUIInput)) {
-      LOG.error("Wrong type: Need " + AbstractUIInput.class.getName() + ", but was " + component.getClass().getName());
-      return;
-    }
 
-    String clientId = component.getClientId(facesContext);
-    if (clientId.equals(FacesContextUtils.getActionId(facesContext))) {
-      // this is a inputSuggest
-      encodeAjax(facesContext, component);
-    } else {
-
-      AbstractUIInput input = (AbstractUIInput) component;
-
-      String title = HtmlRendererUtils.getTitleFromTipAndMessages(facesContext, input);
-
-      final String currentValue = getCurrentValue(facesContext, input);
-      final boolean password = ComponentUtils.getBooleanAttribute(input, Attributes.PASSWORD);
-      if (LOG.isDebugEnabled()) {
-        LOG.debug("currentValue = '"
-            + (password && currentValue != null ? StringUtils.leftPad("", currentValue.length(), '*') : currentValue)
-            + "'");
-      }
-      final String type = password ? HtmlInputTypes.PASSWORD : HtmlInputTypes.TEXT;
+    final AbstractUIInput input = (AbstractUIInput) component;
+    final String title = HtmlRendererUtils.getTitleFromTipAndMessages(facesContext, input);
+    final String currentValue = getCurrentValue(facesContext, input);
+    final boolean password = ComponentUtils.getBooleanAttribute(input, Attributes.PASSWORD);
+    if (LOG.isDebugEnabled()) {
+      LOG.debug("currentValue = '"
+          + (password && currentValue != null ? StringUtils.leftPad("", currentValue.length(), '*') : currentValue)
+          + "'");
+    }
+    final String type = password ? HtmlInputTypes.PASSWORD : HtmlInputTypes.TEXT;
 
-      // Todo: check for valid binding
-      boolean renderAjaxSuggest = false;
-      if (input instanceof UIIn) {
-        renderAjaxSuggest = ((UIIn) input).getSuggestMethod() != null;
-      }
-      String id = input.getClientId(facesContext);
-      TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
-      writer.startElement(HtmlElements.INPUT, input);
-      writer.writeAttribute(HtmlAttributes.TYPE, type, false);
-      writer.writeNameAttribute(id);
-      writer.writeIdAttribute(id);
-      HtmlRendererUtils.writeDataAttributes(facesContext, writer, input);
-      if (currentValue != null) {
-        writer.writeAttribute(HtmlAttributes.VALUE, currentValue, true);
-      }
-      if (title != null) {
-        writer.writeAttribute(HtmlAttributes.TITLE, title, true);
+    final String id = input.getClientId(facesContext);
+    final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
+    writer.startElement(HtmlElements.INPUT, input);
+    writer.writeAttribute(HtmlAttributes.TYPE, type, false);
+    writer.writeNameAttribute(id);
+    writer.writeIdAttribute(id);
+    HtmlRendererUtils.writeDataAttributes(facesContext, writer, input);
+    if (currentValue != null) {
+      writer.writeAttribute(HtmlAttributes.VALUE, currentValue, true);
+    }
+    if (title != null) {
+      writer.writeAttribute(HtmlAttributes.TITLE, title, true);
+    }
+    int maxLength = 0;
+    String pattern = null;
+    for (Validator validator : input.getValidators()) {
+      if (validator instanceof LengthValidator) {
+        LengthValidator lengthValidator = (LengthValidator) validator;
+        maxLength = lengthValidator.getMaximum();
       }
-      int maxLength = 0;
-      String pattern = null;
-      for (Validator validator : input.getValidators()) {
-        if (validator instanceof LengthValidator) {
-          LengthValidator lengthValidator = (LengthValidator) validator;
-          maxLength = lengthValidator.getMaximum();
-        }
         /*if (validator instanceof RegexValidator) {
           RegexValidator regexValidator = (RegexValidator) validator;
           pattern = regexValidator.getPattern();
         }*/
-      }
-      if (maxLength > 0) {
-        writer.writeAttribute(HtmlAttributes.MAXLENGTH, maxLength);
-      }
-      if (pattern != null) {
-        writer.writeAttribute(HtmlAttributes.PATTERN, pattern, false);
-      }
-      writer.writeAttribute(HtmlAttributes.READONLY, ComponentUtils.getBooleanAttribute(input, Attributes.READONLY));
-      writer.writeAttribute(HtmlAttributes.DISABLED, ComponentUtils.getBooleanAttribute(input, Attributes.DISABLED));
-      Integer tabIndex = input.getTabIndex();
-      if (tabIndex != null) {
-        writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
-      }
-      Style style = new Style(facesContext, input);
-      writer.writeStyleAttribute(style);
+    }
+    if (maxLength > 0) {
+      writer.writeAttribute(HtmlAttributes.MAXLENGTH, maxLength);
+    }
+    if (pattern != null) {
+      writer.writeAttribute(HtmlAttributes.PATTERN, pattern, false);
+    }
+    writer.writeAttribute(HtmlAttributes.READONLY, input.isReadonly());
+    writer.writeAttribute(HtmlAttributes.DISABLED, input.isDisabled());
+    Integer tabIndex = input.getTabIndex();
+    if (tabIndex != null) {
+      writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
+    }
+    Style style = new Style(facesContext, input);
+    writer.writeStyleAttribute(style);
 
-      if (renderAjaxSuggest || (input instanceof UIIn && !((UIIn) input).isAutocomplete())) {
-        writer.writeAttribute(HtmlAttributes.AUTOCOMPLETE, "off", false);
-      }
+    if (input instanceof AbstractUIIn && ((AbstractUIIn) input).getSuggest() != null) {
+      writer.writeAttribute(HtmlAttributes.AUTOCOMPLETE, "off", false);
+    }
 
-      HtmlRendererUtils.renderDojoDndItem(component, writer, true);
-      writer.writeClassAttribute(Classes.create(input));
+    HtmlRendererUtils.renderDojoDndItem(component, writer, true);
+    writer.writeClassAttribute(Classes.create(input));
       /*if (component instanceof AbstractUIInput) {
        String onchange = HtmlUtils.generateOnchange((AbstractUIInput) component, facesContext);
        if (onchange != null) {
@@ -149,129 +123,15 @@ public class InRenderer extends InputRen
      //      writer.writeAttribute(HtmlAttributes.ONCHANGE, onchange, null);
        }
      } */
-      boolean required = ComponentUtils.getBooleanAttribute(input, Attributes.REQUIRED);
-      writer.writeAttribute(HtmlAttributes.REQUIRED, required);
-      writer.writeAttribute(DataAttributes.SUGGEST, renderAjaxSuggest);
-      if (renderAjaxSuggest) {
-        UIIn in = (UIIn) input;
-        writer.writeAttribute(DataAttributes.SUGGEST_MIN_CHARS, in.getSuggestMinChars());
-        writer.writeAttribute(DataAttributes.SUGGEST_DELAY, in.getSuggestDelay());
-      }
-
-      HtmlRendererUtils.renderFocus(id, input.isFocus(), ComponentUtils.isError(input), facesContext, writer);
-      writeAdditionalAttributes(facesContext, writer, input);
-      HtmlRendererUtils.renderCommandFacet(input, facesContext, writer);
-      writer.endElement(HtmlElements.INPUT);
-    }
+    boolean required = ComponentUtils.getBooleanAttribute(input, Attributes.REQUIRED);
+    writer.writeAttribute(HtmlAttributes.REQUIRED, required);
+    HtmlRendererUtils.renderFocus(id, input.isFocus(), ComponentUtils.isError(input), facesContext, writer);
+    writeAdditionalAttributes(facesContext, writer, input);
+    HtmlRendererUtils.renderCommandFacet(input, facesContext, writer);
+    writer.endElement(HtmlElements.INPUT);
   }
 
   protected void writeAdditionalAttributes(
       FacesContext facesContext, TobagoResponseWriter writer, AbstractUIInput input) throws IOException {
   }
-
-  private void encodeAjax(FacesContext facesContext, UIComponent component) throws IOException {
-    if (!(component instanceof UIIn)) {
-      LOG.error("Wrong type: Need " + UIIn.class.getName() + ", but was " + component.getClass().getName());
-      return;
-    }
-
-    final UIIn input = (UIIn) component;
-    final MethodBinding methodBinding = input.getSuggestMethod();
-    final AutoSuggestItems items
-            = createAutoSuggestItems(methodBinding.invoke(facesContext, new Object[]{input}));
-    final List<AutoSuggestItem> suggestItems = items.getItems();
-    final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
-
-    writer.startJavascript();
-
-    writer.write("Tobago.ajaxComponents['");
-    writer.write(component.getClientId(facesContext));
-    writer.write("'].suggestions = {items: [");
-
-    for (int i = 0; i < suggestItems.size() && i < items.getMaxSuggestedCount(); i++) {
-      AutoSuggestItem suggestItem = suggestItems.get(i);
-      if (i > 0) {
-        writer.write(", ");
-      }
-      writer.write("{label: '");
-      String label = suggestItem.getLabel();
-      label = StringUtils.replace(label, "\\", "\\\\");
-      label = StringUtils.replace(label, "\"", "\\\"");
-      writer.write(label);
-      writer.write("', value: '");
-      String value = suggestItem.getLabel();
-      value = StringUtils.replace(value, "\\", "\\\\");
-      value = StringUtils.replace(value, "\"", "\\\"");
-      writer.write(value);
-      writer.write("'");
-      if (suggestItem.getExtensionItems() != null) {
-        writer.write(", values: [");
-        for (int j = 0; j < suggestItem.getExtensionItems().size(); j++) {
-          AutoSuggestExtensionItem item = suggestItem.getExtensionItems().get(j);
-          if (j > 0) {
-            writer.write(", ");
-          }
-          writer.write("{id: '");
-          writer.write(item.getId());
-          writer.write("', value: '");
-          writer.write(item.getValue());
-          writer.write("'}");
-        }
-        writer.write("]");
-      }
-      if (suggestItem.getNextFocusId() != null) {
-        writer.write(", nextFocusId: '");
-        writer.write(suggestItem.getNextFocusId());
-        writer.write("'");
-      }
-
-      writer.write("}");
-
-    }
-
-    writer.write("]");
-    if (items.getNextFocusId() != null) {
-      writer.write(", nextFocusId: \"");
-      writer.write(items.getNextFocusId());
-      writer.write("\"");
-    }
-
-    if (suggestItems.size() > items.getMaxSuggestedCount()) {
-      writer.write(", moreElements: \"");
-      writer.write(
-          ResourceManagerUtils.getPropertyNotNull(facesContext, "tobago", "tobago.in.inputSuggest.moreElements"));
-      writer.write("\"");
-    }
-
-    writer.write("};");
-    writer.endJavascript();
-  }
-
-  private AutoSuggestItems createAutoSuggestItems(Object object) {
-    if (object instanceof AutoSuggestItems) {
-      return (AutoSuggestItems) object;
-    }
-    AutoSuggestItems autoSuggestItems = new AutoSuggestItems();
-    if (object instanceof List && !((List) object).isEmpty()) {
-      if (((List) object).get(0) instanceof AutoSuggestItem) {
-        //noinspection unchecked
-        autoSuggestItems.setItems((List<AutoSuggestItem>) object);
-      } else if (((List) object).get(0) instanceof String) {
-        List<AutoSuggestItem> items = new ArrayList<AutoSuggestItem>(((List) object).size());
-        for (int i = 0; i < ((List) object).size(); i++) {
-          AutoSuggestItem item = new AutoSuggestItem();
-          item.setLabel((String) ((List) object).get(i));
-          item.setValue((String) ((List) object).get(i));
-          items.add(item);
-        }
-        autoSuggestItems.setItems(items);
-      } else {
-        throw new ClassCastException("Cant create AutoSuggestItems from '" + object + "'. "
-            + "Elements needs to be " + String.class.getName() + " or " + AutoSuggestItem.class.getName());
-      }
-    } else {
-      autoSuggestItems.setItems(Collections.<AutoSuggestItem>emptyList());
-    }
-    return autoSuggestItems;
-  }
 }

Copied: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SuggestRenderer.java (from r1479803, myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SuggestRenderer.java?p2=myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SuggestRenderer.java&p1=myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java&r1=1479803&r2=1496482&rev=1496482&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SuggestRenderer.java Tue Jun 25 14:15:13 2013
@@ -19,232 +19,90 @@
 
 package org.apache.myfaces.tobago.renderkit.html.scarborough.standard.tag;
 
-import org.apache.commons.lang.StringUtils;
-import org.apache.myfaces.tobago.component.Attributes;
 import org.apache.myfaces.tobago.component.UIIn;
+import org.apache.myfaces.tobago.component.UISuggest;
 import org.apache.myfaces.tobago.context.ResourceManagerUtils;
-import org.apache.myfaces.tobago.internal.component.AbstractUIInput;
-import org.apache.myfaces.tobago.internal.util.FacesContextUtils;
-import org.apache.myfaces.tobago.model.AutoSuggestExtensionItem;
 import org.apache.myfaces.tobago.model.AutoSuggestItem;
 import org.apache.myfaces.tobago.model.AutoSuggestItems;
 import org.apache.myfaces.tobago.renderkit.InputRendererBase;
 import org.apache.myfaces.tobago.renderkit.css.Classes;
-import org.apache.myfaces.tobago.renderkit.css.Style;
 import org.apache.myfaces.tobago.renderkit.html.DataAttributes;
 import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
 import org.apache.myfaces.tobago.renderkit.html.HtmlElements;
-import org.apache.myfaces.tobago.renderkit.html.HtmlInputTypes;
 import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtils;
-import org.apache.myfaces.tobago.util.ComponentUtils;
 import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
+import javax.el.MethodExpression;
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
-import javax.faces.el.MethodBinding;
-import javax.faces.validator.LengthValidator;
-import javax.faces.validator.Validator;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
-public class InRenderer extends InputRendererBase {
-
-  private static final Logger LOG = LoggerFactory.getLogger(InRenderer.class);
-
-  @Override
-  public void decode(FacesContext facesContext, UIComponent component) {
-    super.decode(facesContext, component);
-    String clientId = component.getClientId(facesContext);
-    if (clientId.equals(FacesContextUtils.getActionId(facesContext))) {
-      // this is a inputSuggest request -> render response
-      facesContext.renderResponse();
-    }
-  }
+public class SuggestRenderer extends InputRendererBase {
 
   @Override
   public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {
-    if (!(component instanceof AbstractUIInput)) {
-      LOG.error("Wrong type: Need " + AbstractUIInput.class.getName() + ", but was " + component.getClass().getName());
-      return;
-    }
-
-    String clientId = component.getClientId(facesContext);
-    if (clientId.equals(FacesContextUtils.getActionId(facesContext))) {
-      // this is a inputSuggest
-      encodeAjax(facesContext, component);
-    } else {
-
-      AbstractUIInput input = (AbstractUIInput) component;
-
-      String title = HtmlRendererUtils.getTitleFromTipAndMessages(facesContext, input);
-
-      final String currentValue = getCurrentValue(facesContext, input);
-      final boolean password = ComponentUtils.getBooleanAttribute(input, Attributes.PASSWORD);
-      if (LOG.isDebugEnabled()) {
-        LOG.debug("currentValue = '"
-            + (password && currentValue != null ? StringUtils.leftPad("", currentValue.length(), '*') : currentValue)
-            + "'");
-      }
-      final String type = password ? HtmlInputTypes.PASSWORD : HtmlInputTypes.TEXT;
-
-      // Todo: check for valid binding
-      boolean renderAjaxSuggest = false;
-      if (input instanceof UIIn) {
-        renderAjaxSuggest = ((UIIn) input).getSuggestMethod() != null;
-      }
-      String id = input.getClientId(facesContext);
-      TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
-      writer.startElement(HtmlElements.INPUT, input);
-      writer.writeAttribute(HtmlAttributes.TYPE, type, false);
-      writer.writeNameAttribute(id);
-      writer.writeIdAttribute(id);
-      HtmlRendererUtils.writeDataAttributes(facesContext, writer, input);
-      if (currentValue != null) {
-        writer.writeAttribute(HtmlAttributes.VALUE, currentValue, true);
-      }
-      if (title != null) {
-        writer.writeAttribute(HtmlAttributes.TITLE, title, true);
-      }
-      int maxLength = 0;
-      String pattern = null;
-      for (Validator validator : input.getValidators()) {
-        if (validator instanceof LengthValidator) {
-          LengthValidator lengthValidator = (LengthValidator) validator;
-          maxLength = lengthValidator.getMaximum();
-        }
-        /*if (validator instanceof RegexValidator) {
-          RegexValidator regexValidator = (RegexValidator) validator;
-          pattern = regexValidator.getPattern();
-        }*/
-      }
-      if (maxLength > 0) {
-        writer.writeAttribute(HtmlAttributes.MAXLENGTH, maxLength);
-      }
-      if (pattern != null) {
-        writer.writeAttribute(HtmlAttributes.PATTERN, pattern, false);
-      }
-      writer.writeAttribute(HtmlAttributes.READONLY, ComponentUtils.getBooleanAttribute(input, Attributes.READONLY));
-      writer.writeAttribute(HtmlAttributes.DISABLED, ComponentUtils.getBooleanAttribute(input, Attributes.DISABLED));
-      Integer tabIndex = input.getTabIndex();
-      if (tabIndex != null) {
-        writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
-      }
-      Style style = new Style(facesContext, input);
-      writer.writeStyleAttribute(style);
-
-      if (renderAjaxSuggest || (input instanceof UIIn && !((UIIn) input).isAutocomplete())) {
-        writer.writeAttribute(HtmlAttributes.AUTOCOMPLETE, "off", false);
-      }
 
-      HtmlRendererUtils.renderDojoDndItem(component, writer, true);
-      writer.writeClassAttribute(Classes.create(input));
-      /*if (component instanceof AbstractUIInput) {
-       String onchange = HtmlUtils.generateOnchange((AbstractUIInput) component, facesContext);
-       if (onchange != null) {
-         // TODO: create and use utility method to write attributes without quoting
-     //      writer.writeAttribute(HtmlAttributes.ONCHANGE, onchange, null);
-       }
-     } */
-      boolean required = ComponentUtils.getBooleanAttribute(input, Attributes.REQUIRED);
-      writer.writeAttribute(HtmlAttributes.REQUIRED, required);
-      writer.writeAttribute(DataAttributes.SUGGEST, renderAjaxSuggest);
-      if (renderAjaxSuggest) {
-        UIIn in = (UIIn) input;
-        writer.writeAttribute(DataAttributes.SUGGEST_MIN_CHARS, in.getSuggestMinChars());
-        writer.writeAttribute(DataAttributes.SUGGEST_DELAY, in.getSuggestDelay());
-      }
-
-      HtmlRendererUtils.renderFocus(id, input.isFocus(), ComponentUtils.isError(input), facesContext, writer);
-      writeAdditionalAttributes(facesContext, writer, input);
-      HtmlRendererUtils.renderCommandFacet(input, facesContext, writer);
-      writer.endElement(HtmlElements.INPUT);
-    }
-  }
-
-  protected void writeAdditionalAttributes(
-      FacesContext facesContext, TobagoResponseWriter writer, AbstractUIInput input) throws IOException {
-  }
-
-  private void encodeAjax(FacesContext facesContext, UIComponent component) throws IOException {
-    if (!(component instanceof UIIn)) {
-      LOG.error("Wrong type: Need " + UIIn.class.getName() + ", but was " + component.getClass().getName());
-      return;
-    }
-
-    final UIIn input = (UIIn) component;
-    final MethodBinding methodBinding = input.getSuggestMethod();
-    final AutoSuggestItems items
-            = createAutoSuggestItems(methodBinding.invoke(facesContext, new Object[]{input}));
-    final List<AutoSuggestItem> suggestItems = items.getItems();
+    final UISuggest suggest = (UISuggest) component;
     final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
+    final String id  = suggest.getClientId(facesContext);
+    final UIIn in = (UIIn) suggest.getParent();
+    final MethodExpression suggestMethodExpression = suggest.getSuggestMethodExpression();
+    final AutoSuggestItems items
+        = createAutoSuggestItems(suggestMethodExpression.invoke(facesContext.getELContext(), new Object[]{in}));
+    // todo: declare unused/unsupported stuff deprecated
 
-    writer.startJavascript();
-
-    writer.write("Tobago.ajaxComponents['");
-    writer.write(component.getClientId(facesContext));
-    writer.write("'].suggestions = {items: [");
-
-    for (int i = 0; i < suggestItems.size() && i < items.getMaxSuggestedCount(); i++) {
-      AutoSuggestItem suggestItem = suggestItems.get(i);
-      if (i > 0) {
-        writer.write(", ");
-      }
-      writer.write("{label: '");
-      String label = suggestItem.getLabel();
-      label = StringUtils.replace(label, "\\", "\\\\");
-      label = StringUtils.replace(label, "\"", "\\\"");
-      writer.write(label);
-      writer.write("', value: '");
-      String value = suggestItem.getLabel();
-      value = StringUtils.replace(value, "\\", "\\\\");
-      value = StringUtils.replace(value, "\"", "\\\"");
-      writer.write(value);
-      writer.write("'");
-      if (suggestItem.getExtensionItems() != null) {
-        writer.write(", values: [");
-        for (int j = 0; j < suggestItem.getExtensionItems().size(); j++) {
-          AutoSuggestExtensionItem item = suggestItem.getExtensionItems().get(j);
-          if (j > 0) {
-            writer.write(", ");
-          }
-          writer.write("{id: '");
-          writer.write(item.getId());
-          writer.write("', value: '");
-          writer.write(item.getValue());
-          writer.write("'}");
-        }
-        writer.write("]");
-      }
-      if (suggestItem.getNextFocusId() != null) {
-        writer.write(", nextFocusId: '");
-        writer.write(suggestItem.getNextFocusId());
-        writer.write("'");
-      }
-
-      writer.write("}");
-
-    }
+    writer.startElement(HtmlElements.DIV, null);
+    writer.writeClassAttribute(Classes.create(suggest));
+    writer.writeIdAttribute(id);
+    writer.writeAttribute(DataAttributes.FOR, in.getClientId(facesContext), false);
+    writer.writeAttribute(DataAttributes.SUGGEST_MIN_CHARS, suggest.getMinimumCharacters());
+    writer.writeAttribute(DataAttributes.SUGGEST_DELAY, suggest.getDelay());
+    writer.writeAttribute(DataAttributes.SUGGEST_MAX_ITEMS, suggest.getMaximumItems());
+    writer.writeAttribute(DataAttributes.SUGGEST_UPDATE, Boolean.toString(suggest.isUpdate()), false);
+    int totalCount = suggest.getTotalCount();
+    if (totalCount == -1) {
+      totalCount = items.getItems().size();
+    }
+    writer.writeAttribute(DataAttributes.SUGGEST_TOTAL_COUNT, totalCount);
+
+    writer.startElement(HtmlElements.OL, null);
+    writer.writeClassAttribute("tobago-menuBar");
+    writer.startElement(HtmlElements.LI, null);
+    writer.writeClassAttribute("tobago-menu tobago-menu-markup-top");
+    writer.startElement(HtmlElements.A, null);
+    writer.writeAttribute(HtmlAttributes.HREF, "#", false);
+    writer.writeAttribute(HtmlAttributes.TABINDEX, -1);
+    writer.endElement(HtmlElements.A);
+
+    writer.startElement(HtmlElements.OL, null);
+    for (AutoSuggestItem item : items.getItems()) {
+      writer.startElement(HtmlElements.LI, null);
+      writer.startElement(HtmlElements.A, null);
+      writer.writeAttribute(HtmlAttributes.HREF, "#", false);
+      writer.writeText(item.getLabel());
+      writer.endElement(HtmlElements.A);
+      writer.endElement(HtmlElements.LI);
+    }
+    writer.startElement(HtmlElements.LI, null);
+    writer.writeAttribute(HtmlAttributes.DISABLED, true);
+    final String title
+        = ResourceManagerUtils.getPropertyNotNull(facesContext, "tobago", "tobago.in.inputSuggest.moreElements");
+    writer.writeAttribute(HtmlAttributes.TITLE, title, true);
+    writer.startElement(HtmlElements.A, null);
+    writer.writeAttribute(HtmlAttributes.HREF, "#", false);
+    writer.writeText("...");
+    writer.endElement(HtmlElements.A);
+    writer.endElement(HtmlElements.LI);
 
-    writer.write("]");
-    if (items.getNextFocusId() != null) {
-      writer.write(", nextFocusId: \"");
-      writer.write(items.getNextFocusId());
-      writer.write("\"");
-    }
+    writer.endElement(HtmlElements.OL);
 
-    if (suggestItems.size() > items.getMaxSuggestedCount()) {
-      writer.write(", moreElements: \"");
-      writer.write(
-          ResourceManagerUtils.getPropertyNotNull(facesContext, "tobago", "tobago.in.inputSuggest.moreElements"));
-      writer.write("\"");
-    }
+    writer.endElement(HtmlElements.LI);
+    writer.endElement(HtmlElements.OL);
 
-    writer.write("};");
-    writer.endJavascript();
+    writer.endElement(HtmlElements.DIV);
   }
 
   private AutoSuggestItems createAutoSuggestItems(Object object) {
@@ -266,7 +124,7 @@ public class InRenderer extends InputRen
         }
         autoSuggestItems.setItems(items);
       } else {
-        throw new ClassCastException("Cant create AutoSuggestItems from '" + object + "'. "
+        throw new ClassCastException("Can't create AutoSuggestItems from '" + object + "'. "
             + "Elements needs to be " + String.class.getName() + " or " + AutoSuggestItem.class.getName());
       }
     } else {
@@ -274,4 +132,5 @@ public class InRenderer extends InputRen
     }
     return autoSuggestItems;
   }
+
 }

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/tobago.css
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/tobago.css?rev=1496482&r1=1496481&r2=1496482&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/tobago.css (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/tobago.css Tue Jun 25 14:15:13 2013
@@ -1124,6 +1124,12 @@ a:active.tobago-sheet-pagingLink {
   margin-left: 1px;
 }
 
+/* suggest ---------------------------------------------------------------------- */
+
+.tobago-suggest {
+  position: absolute;
+}
+
 /* richTextEditor ---------------------------------------------------------- */
 
 .tobago-richTextEditor-container {

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/pom.xml?rev=1496482&r1=1496481&r2=1496482&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/pom.xml (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/pom.xml Tue Jun 25 14:15:13 2013
@@ -60,7 +60,7 @@
             <configuration>
               <target>
                 <concat destfile="${project.build.directory}/javascript-min/standard/script/tobago.min.js">
-                  <filelist dir="${basedir}/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script" files="tobago.js,tobago-calendar.js,tobago-converter.js,tobago-in.js,tobago-menu.js,tobago-overlay.js,tobago-popup.js,tobago-sheet.js,tobago-tree.js,tobago-utils.js" />
+                  <filelist dir="${basedir}/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script" files="tobago.js,tobago-calendar.js,tobago-converter.js,tobago-in.js,tobago-menu.js,tobago-overlay.js,tobago-popup.js,tobago-sheet.js,tobago-suggest.js,tobago-tree.js,tobago-utils.js" />
                 </concat>
                 <concat destfile="${project.build.directory}/javascript-min/msie_6_0/script/tobago.min.js">
                   <filelist dir="${basedir}/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/msie_6_0/script" files="tobago.js" />

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml?rev=1496482&r1=1496481&r2=1496482&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml Tue Jun 25 14:15:13 2013
@@ -382,6 +382,7 @@
         <script name="script/tobago-overlay.js"/>
         <script name="script/tobago-popup.js"/>
         <script name="script/tobago-sheet.js"/>
+        <script name="script/tobago-suggest.js"/>
         <script name="script/tobago-tree.js"/>
         <script name="script/tobago-utils.js"/>
         <script name="script/tobago-logging.js"/>