You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by gm...@apache.org on 2006/12/10 11:15:21 UTC

svn commit: r485151 - in /myfaces/tomahawk/trunk/sandbox: core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/ core/src/main/tld/ examples/src/main/webapp/

Author: gmuellan
Date: Sun Dec 10 02:15:18 2006
New Revision: 485151

URL: http://svn.apache.org/viewvc?view=rev&rev=485151
Log:
added new attribute autoComplete to InputSuggestAjax; fixed IE arrow bug (comboBox drop down arrow was not displayed)

Modified:
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/InputSuggestAjax.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/InputSuggestAjaxRenderer.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/InputSuggestAjaxTag.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld
    myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/inputSuggestAjax.jsp

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/InputSuggestAjax.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/InputSuggestAjax.java?view=diff&rev=485151&r1=485150&r2=485151
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/InputSuggestAjax.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/InputSuggestAjax.java Sun Dec 10 02:15:18 2006
@@ -22,6 +22,7 @@
 
 import javax.faces.context.FacesContext;
 import javax.faces.el.MethodBinding;
+import javax.faces.el.ValueBinding;
 import java.io.IOException;
 
 /**
@@ -38,6 +39,8 @@
 
     private MethodBinding _itemLabelMethod;
 
+    private Boolean _autoComplete = new Boolean(true);
+
     public InputSuggestAjax()
     {
         super();
@@ -47,9 +50,10 @@
 
     public Object saveState(FacesContext context)
     {
-        Object[] values = new Object[2];
+        Object[] values = new Object[3];
         values[0] = super.saveState(context);
         values[1] = saveAttachedState(context, _itemLabelMethod);
+        values[2] = _autoComplete;
 
         return values;
     }
@@ -59,11 +63,27 @@
         Object values[] = (Object[])state;
         super.restoreState(context, values[0]);
         _itemLabelMethod = (MethodBinding) restoreAttachedState(context, values[1]);
+        _autoComplete = (Boolean) values[2];
     }
 
     public void encodeChildren(FacesContext context) throws IOException
     {
         super.encodeChildren(context);
+    }
+
+    public Boolean getAutoComplete()
+    {
+         if (_autoComplete != null)
+        {
+            return _autoComplete;
+        }
+        ValueBinding vb = getValueBinding("autoComplete");
+        return vb != null ? (Boolean) vb.getValue(getFacesContext()) : null;
+    }
+
+    public void setAutoComplete(Boolean autoComplete)
+    {
+        _autoComplete = autoComplete;
     }
 
     public MethodBinding getItemLabelMethod()

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/InputSuggestAjaxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/InputSuggestAjaxRenderer.java?view=diff&rev=485151&r1=485150&r2=485151
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/InputSuggestAjaxRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/InputSuggestAjaxRenderer.java Sun Dec 10 02:15:18 2006
@@ -24,16 +24,20 @@
 import org.apache.myfaces.custom.dojo.DojoConfig;
 import org.apache.myfaces.custom.dojo.DojoUtils;
 import org.apache.myfaces.custom.suggestajax.SuggestAjaxRenderer;
+import org.apache.myfaces.custom.suggestajax.tablesuggestajax.TableSuggestAjaxRenderer;
 import org.apache.myfaces.shared_tomahawk.renderkit.JSFAttr;
 import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils;
 import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
 import org.apache.myfaces.shared_tomahawk.renderkit.html.util.UnicodeEncoder;
+import org.apache.myfaces.renderkit.html.util.AddResource;
+import org.apache.myfaces.renderkit.html.util.AddResourceFactory;
 
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;
 import javax.faces.convert.Converter;
 import javax.faces.el.MethodBinding;
+import javax.servlet.ServletResponse;
 import java.io.IOException;
 import java.util.Collection;
 import java.util.Iterator;
@@ -134,6 +138,7 @@
 
         attributes.put("dataUrl", ajaxUrl);
         attributes.put("mode", "remote");
+        attributes.put("autoComplete", inputSuggestAjax.getAutoComplete().booleanValue());
 
         if (label != null)
         {
@@ -152,21 +157,10 @@
         StringBuffer buffer = new StringBuffer();
 
         buffer.append("dojo.addOnLoad(function() {\n")
-                .append(inputSuggestComponentVar).append(".textInputNode.name=\"").append(idToRender).append("\";\n");
-
-        /** todo: cbTableNode doesn't exist anymore in dojo 0.4 - what to do?
-        if (inputSuggestAjax.getStyle() != null)
-        {
-            buffer.append(inputSuggestComponentVar).append(".cbTableNode.style.cssText=\"").append(inputSuggestAjax.getStyle()).append("\";\n");
-        }
-        if (inputSuggestAjax.getStyleClass() != null)
-        {
-            buffer.append(inputSuggestComponentVar).append(".cbTableNode.className=\"").append(inputSuggestAjax.getStyleClass()).append("\";\n");
-        }
-        */
-
-        buffer.append(inputSuggestComponentVar).append(".textInputNode.value = \"").append(valueToRender).append("\";\n")
+              .append(inputSuggestComponentVar).append(".textInputNode.name=\"").append(idToRender).append("\";\n")
+              .append(inputSuggestComponentVar).append(".textInputNode.value = \"").append(valueToRender).append("\";\n")
               .append(inputSuggestComponentVar).append(".comboBoxValue.value = \"").append(valueToRender).append("\";\n")
+              .append(inputSuggestComponentVar).append(".onResize();\n")
               .append("});\n");
 
         out.write(buffer.toString());

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/InputSuggestAjaxTag.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/InputSuggestAjaxTag.java?view=diff&rev=485151&r1=485150&r2=485151
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/InputSuggestAjaxTag.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/InputSuggestAjaxTag.java Sun Dec 10 02:15:18 2006
@@ -34,6 +34,7 @@
 public class InputSuggestAjaxTag extends SuggestAjaxTag
 {
     private String _itemLabelMethod;
+    private String _autoComplete;
 
     public String getComponentType() {
         return InputSuggestAjax.COMPONENT_TYPE;
@@ -46,6 +47,7 @@
     public void release() {
         super.release();
         _itemLabelMethod = null;
+        _autoComplete = null;
     }
 
     protected void setProperties(UIComponent component) {
@@ -65,10 +67,16 @@
                 throw new IllegalStateException("Invalid expression " + _itemLabelMethod);
             }
         }
+        setBooleanProperty(component, "autoComplete", _autoComplete);
     }
 
     public void setItemLabelMethod(String itemLabelMethod)
     {
         _itemLabelMethod = itemLabelMethod;
+    }
+
+    public void setAutoComplete(String autoComplete)
+    {
+        _autoComplete = autoComplete;
     }
 }

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld?view=diff&rev=485151&r1=485150&r2=485151
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld Sun Dec 10 02:15:18 2006
@@ -242,6 +242,15 @@
                          to achieve the same mechanism as it can be found at select menues with the label/value pair.
             </description>
         </attribute>
+        <attribute>
+            <name>autoComplete</name>
+            <required>false</required>
+            <rtexprvalue>false</rtexprvalue>
+            <type>java.lang.Boolean</type>
+            <description>If false, the input field is not automatically populated with the first suggested value.
+                         Default: true
+            </description>
+        </attribute>
     </tag>
 
     <!-- Ajax child combobox  -->

Modified: myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/inputSuggestAjax.jsp
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/inputSuggestAjax.jsp?view=diff&rev=485151&r1=485150&r2=485151
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/inputSuggestAjax.jsp (original)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/inputSuggestAjax.jsp Sun Dec 10 02:15:18 2006
@@ -37,17 +37,23 @@
 
      <f:verbatim><br/><br/></f:verbatim>
 
-     <h:panelGrid columns="7">
+     <t:dojoInitializer bindEncoding="utf-8"/>
+
+     <h:panelGrid columns="9">
          <h:outputText value="default suggest"/>
-         <s:inputSuggestAjax suggestedItemsMethod="#{inputSuggestAjax.getItems}"  style="width:100px;"
+         <s:inputSuggestAjax suggestedItemsMethod="#{inputSuggestAjax.getItems}"
                              value="#{inputSuggestAjax.suggestValue}"  charset="utf-8"/>
 
+         <h:outputText value="suggest without autoComplete"/>
+         <s:inputSuggestAjax suggestedItemsMethod="#{inputSuggestAjax.getItems}"
+                             value="#{inputSuggestAjax.suggestValue}" autoComplete="false"/>
+
          <h:outputText value="suggest with limited suggested items"/>
-         <s:inputSuggestAjax suggestedItemsMethod="#{inputSuggestAjax.getItems}" style="width:100px;"
+         <s:inputSuggestAjax suggestedItemsMethod="#{inputSuggestAjax.getItems}"
                              maxSuggestedItems="2" value="#{inputSuggestAjax.suggestValueMaxItems}"/>
 
          <h:outputText value="suggest with label/value functionality"/>
-         <s:inputSuggestAjax suggestedItemsMethod="#{inputSuggestAjax.getAddresses}" style="width:250px;"
+         <s:inputSuggestAjax suggestedItemsMethod="#{inputSuggestAjax.getAddresses}" 
                              itemLabelMethod="#{inputSuggestAjax.getAddressLabel}"
                              value="#{inputSuggestAjax.choosenAddress}">
              <f:converter converterId="inputSuggestAjaxConverter" />