You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by mm...@apache.org on 2006/02/25 17:33:05 UTC

svn commit: r380943 - in /myfaces/tomahawk/trunk/sandbox: core/src/main/java/org/apache/myfaces/custom/dojo/ core/src/main/java/org/apache/myfaces/custom/inputsuggestajax/ core/src/main/resources/org/apache/myfaces/custom/inputsuggestajax/resource/ cor...

Author: mmarinschek
Date: Sat Feb 25 08:33:02 2006
New Revision: 380943

URL: http://svn.apache.org/viewcvs?rev=380943&view=rev
Log:
some fixes,enhancements to inputSuggestAjax

Added:
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/inputsuggestajax/resource/tableSuggest.js
Modified:
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoUtils.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputsuggestajax/HtmlOutputText.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputsuggestajax/HtmlOutputTextTag.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputsuggestajax/InputSuggestAjax.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputsuggestajax/InputSuggestAjaxRenderer.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputsuggestajax/InputSuggestAjaxTag.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/inputsuggestajax/resource/default/ajax_suggest.css
    myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld
    myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/inputSuggestAjax/Address.java
    myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/inputSuggestAjax/InputSuggestAjaxBean.java
    myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/inputSuggestAjax.jsp

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoUtils.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoUtils.java?rev=380943&r1=380942&r2=380943&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoUtils.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoUtils.java Sat Feb 25 08:33:02 2006
@@ -315,7 +315,7 @@
      * a debug:true is required for this to work properly
      * it will not be set by this method (due to the avoidance
      * of unwanted automatisms causing sideefects)
-     * 
+     *
      * @param facesContext
      * @param component
      * @return
@@ -357,6 +357,16 @@
     public static String createDebugStatement(String stmnt)
     {
         return "dojo.debug(\"" + stmnt + "\");\n";
+    }
+
+    /**
+     * creates a debug statement and a corresponding value for the debug console
+     * @param stmnt the debug message displayed and given value by the debug console
+     * @return javaScriptcode String
+     */
+    public static String createDebugStatement(String stmnt, String value)
+    {
+        return "dojo.debug(\"" + stmnt + ":\");dojo.debug("+value+");\n";
     }
 
     /**

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputsuggestajax/HtmlOutputText.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputsuggestajax/HtmlOutputText.java?rev=380943&r1=380942&r2=380943&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputsuggestajax/HtmlOutputText.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputsuggestajax/HtmlOutputText.java Sat Feb 25 08:33:02 2006
@@ -14,6 +14,7 @@
     public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlOutputTextFor";
 
     private String _for;
+    private String _label;
 
     public HtmlOutputText()
     {
@@ -21,9 +22,10 @@
 
      public Object saveState(FacesContext context)
     {
-        Object values[] = new Object[2];
+        Object values[] = new Object[3];
         values[0] = super.saveState(context);
         values[1] = _for;
+        values[2] = _label;
 
         return ((Object) (values));
     }
@@ -33,6 +35,7 @@
         Object values[] = (Object[]) state;
         super.restoreState(context, values[0]);
         _for = (String) values[1];
+        _label = (String) values[2];
     }
 
     public String getFor()
@@ -46,5 +49,18 @@
     public void setFor(String aFor)
     {
         _for = aFor;
+    }
+
+    public String getLabel()
+    {
+        if (_label != null)
+            return _label;
+        ValueBinding vb = getValueBinding("label");
+        return vb != null ? vb.getValue(getFacesContext()).toString() : null;
+    }
+
+    public void setLabel(String label)
+    {
+        _label = label;
     }
 }

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputsuggestajax/HtmlOutputTextTag.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputsuggestajax/HtmlOutputTextTag.java?rev=380943&r1=380942&r2=380943&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputsuggestajax/HtmlOutputTextTag.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputsuggestajax/HtmlOutputTextTag.java Sat Feb 25 08:33:02 2006
@@ -11,6 +11,7 @@
 public class HtmlOutputTextTag extends org.apache.myfaces.taglib.html.HtmlOutputTextTag
 {
     private String _for;
+    private String _label;
 
     public String getComponentType() {
         return HtmlOutputText.COMPONENT_TYPE;
@@ -21,6 +22,7 @@
         super.release();
 
         _for = null;
+        _label = null;
     }
 
     protected void setProperties(UIComponent component) {
@@ -28,10 +30,16 @@
         super.setProperties(component);
 
         setStringProperty(component, JSFAttr.FOR_ATTR, _for);
+        setStringProperty(component, "label", _label);
     }
 
     public void setFor(String aFor)
     {
         _for = aFor;
+    }
+
+    public void setLabel(String label)
+    {
+        _label = label;
     }
 }

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputsuggestajax/InputSuggestAjax.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputsuggestajax/InputSuggestAjax.java?rev=380943&r1=380942&r2=380943&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputsuggestajax/InputSuggestAjax.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputsuggestajax/InputSuggestAjax.java Sat Feb 25 08:33:02 2006
@@ -56,6 +56,8 @@
     private String _layout;
 
     private Integer _maxSuggestedItems;
+    private Integer _delay;
+    private Integer _startRequest;
 
     private String _var;
 
@@ -68,7 +70,7 @@
 
     public Object saveState(FacesContext context)
     {
-        Object[] values = new Object[15];
+        Object[] values = new Object[17];
         values[0] = super.saveState(context);
         values[1] = saveAttachedState(context, _suggestedItemsMethod);
         values[2] = _popupId;
@@ -84,6 +86,8 @@
         values[12] = _var;
         values[13] = _columnHoverClass;
         values[14] = _columnOutClass;
+        values[15] = _delay;
+        values[16] = _startRequest;
 
         return values;
     }
@@ -106,6 +110,8 @@
         _var = (String) values[12];
         _columnHoverClass = (String) values[13];
         _columnOutClass = (String) values[14];
+        _delay = (Integer) values[15];
+        _startRequest = (Integer) values[16];
     }
 
     public void encodeAjax(FacesContext context)
@@ -275,6 +281,32 @@
 	public void setMaxSuggestedItems(Integer suggestedItems) {
 		_maxSuggestedItems = suggestedItems;
 	}
+
+    public Integer getDelay()
+    {
+        if (_delay != null)
+            return _delay;
+        ValueBinding vb = getValueBinding("delay");
+        return vb != null ? (Integer) vb.getValue(getFacesContext()) : null;
+    }
+
+    public void setDelay(Integer delay)
+    {
+        _delay = delay;
+    }
+
+    public Integer getStartRequest()
+    {
+        if (_startRequest != null)
+            return _startRequest;
+        ValueBinding vb = getValueBinding("startRequest");
+        return vb != null ? (Integer) vb.getValue(getFacesContext()) : null;
+    }
+
+    public void setStartRequest(Integer startRequest)
+    {
+        _startRequest = startRequest;
+    }
 
     public void setVar(String var)
     {

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputsuggestajax/InputSuggestAjaxRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputsuggestajax/InputSuggestAjaxRenderer.java?rev=380943&r1=380942&r2=380943&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputsuggestajax/InputSuggestAjaxRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputsuggestajax/InputSuggestAjaxRenderer.java Sat Feb 25 08:33:02 2006
@@ -20,6 +20,7 @@
 import org.apache.myfaces.custom.ajax.api.AjaxRenderer;
 import org.apache.myfaces.custom.dojo.DojoUtils;
 import org.apache.myfaces.custom.dojo.DojoConfig;
+import org.apache.myfaces.custom.dojo.DojoResourceLoader;
 import org.apache.myfaces.renderkit.JSFAttr;
 import org.apache.myfaces.renderkit.RendererUtils;
 import org.apache.myfaces.renderkit.html.ext.HtmlTextRenderer;
@@ -39,6 +40,7 @@
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
+import java.util.ArrayList;
 
 /**
  * @author Gerald Müllan
@@ -68,20 +70,37 @@
         DojoUtils.addRequire(context, "dojo.widget.*");
         DojoUtils.addRequire(context, "dojo.widget.ComboBox");
         DojoUtils.addRequire(context, "dojo.widget.html.ComboBox");
-        DojoUtils.addRequire(context, "dojo.event.topic");
+        DojoUtils.addRequire(context, "dojo.event.*");
+        DojoUtils.addRequire(context, "dojo.string");
+        DojoUtils.addRequire(context, "dojo.fx.html");
+        DojoUtils.addRequire(context, "dojo.lang");
 
         AddResource addResource = AddResourceFactory.getInstance(context);
 
-        if( StringUtils.isNotBlank( styleLocation ) )
+        if(javascriptLocation != null)
         {
-            addResource.addStyleSheet(context, AddResource.HEADER_BEGIN, styleLocation + "/ajax_suggest.css");
+            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, javascriptLocation + "/tableSuggest.js");
         }
         else
         {
-            String theme = ((InputSuggestAjax)component).getLayout();
-            if(theme == null)
-                theme = "default";
-            addResource.addStyleSheet(context, AddResource.HEADER_BEGIN, InputSuggestAjaxRenderer.class, theme + "/ajax_suggest.css");
+            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, InputSuggestAjaxRenderer.class, "tableSuggest.js");
+        }
+
+        InputSuggestAjax inputSuggestAjax = (InputSuggestAjax) component;
+
+        if (inputSuggestAjax.getPopupStyleClass() == null)
+        {
+            if( StringUtils.isNotBlank( styleLocation ) )
+            {
+                addResource.addStyleSheet(context, AddResource.HEADER_BEGIN, styleLocation + "/ajax_suggest.css");
+            }
+            else
+            {
+                String theme = ((InputSuggestAjax)component).getLayout();
+                if(theme == null)
+                    theme = "default";
+                addResource.addStyleSheet(context, AddResource.HEADER_BEGIN, InputSuggestAjaxRenderer.class, theme + "/ajax_suggest.css");
+            }
         }
     }
 
@@ -93,13 +112,13 @@
 
         encodeJavascript(context,component);
 
-        inputSuggestAjax.getAttributes().put("autocomplete","off");
-        
-        String oldStyleClass = inputSuggestAjax.getStyleClass();
-        inputSuggestAjax.setStyleClass(
-        		(oldStyleClass!=null && oldStyleClass.length()>=0 ? oldStyleClass : "")+" myFacesInputSuggestAjax");
+       inputSuggestAjax.getAttributes().put("autocomplete","off");
+
+    /*     String oldStyleClass = inputSuggestAjax.getStyleClass();
+    inputSuggestAjax.setStyleClass(
+            (oldStyleClass!=null && oldStyleClass.length()>=0 ? oldStyleClass : "")+" myFacesInputSuggestAjax");
 
-        inputSuggestAjax.setStyleClass(oldStyleClass);
+    inputSuggestAjax.setStyleClass(oldStyleClass);*/
 
         String clientId = component.getClientId(context);
         String actionURL = getActionUrl(context);
@@ -120,6 +139,7 @@
             out.startElement(HTML.TD_ELEM, null);
 
             super.encodeEnd(context, inputSuggestAjax);
+            //out.write("<input dojoType=\"subcombobox\" value=\"\" style=\"width:150px;\">");
 
             out.endElement(HTML.TR_ELEM);
             out.endElement(HTML.TD_ELEM);
@@ -128,14 +148,14 @@
             out.startElement(HTML.TD_ELEM, null);
 
             out.startElement(HTML.DIV_ELEM, null);
-            if(inputSuggestAjax.getLayout().equals("default"))
-            {
-                out.writeAttribute(HTML.CLASS_ATTR, "ajaxTablePopup", null);
-            }
             if(inputSuggestAjax.getPopupStyleClass()!= null)
             {
                 out.writeAttribute(HTML.CLASS_ATTR, inputSuggestAjax.getPopupStyleClass(), null);
             }
+            else if(inputSuggestAjax.getLayout().equals("default"))
+            {
+                out.writeAttribute(HTML.CLASS_ATTR, "ajaxTablePopup", null);
+            }
             if (inputSuggestAjax.getPopupId() != null)
             {
                 out.writeAttribute(HTML.ID_ATTR,inputSuggestAjax.getPopupId(), null);
@@ -161,14 +181,53 @@
 
             out.startElement(HTML.SCRIPT_ELEM, null);
             out.writeAttribute(HTML.TYPE_ATTR, HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT, null);
-            out.write(getAJAXHandlingCode(urlWithValue, clientId).toString());
+            out.write(getAJAXHandlingCode(urlWithValue, clientId, inputSuggestAjax).toString());
             out.endElement(HTML.SCRIPT_ELEM);
+
+          /*  out.write("<script type=\"text/javascript\">\n                    "
+                    + "\tdojo.widget.SubComboBox = function(){\n"
+                    + "\t\tdojo.widget.html.ComboBox.call(this);\n"
+                    + "\t\tthis.widgetType = \"SubComboBox\";\n"
+                    + "\t}\n"
+                    + "\n"
+                    + "\tdojo.inherits(dojo.widget.SubComboBox, dojo.widget.html.ComboBox);\n"
+                    + "\n"
+                    + "\tdojo.lang.extend(dojo.widget.SubComboBox, {\n"
+                    + "\t\tfillInTemplate: function(args, frag){\n"
+                    + "\t\t\tthis.dataProvider = {\n"
+                    + "\t\t\t\tstartSearch: function(searchStr, type, ignoreLimit){\n"
+                    +DojoUtils.createDebugStatement("starting request")
+                     + "       dojo.io.bind ({\n"
+                    + "             url: \""+ urlWithValue +"\"+searchStr,\n"
+                    + "             handle: function(type, data, evt)"
+                    + "             {\n"
+                    +                   DojoUtils.createDebugStatement("after response")
+                    + "                 if(type == \"load\")\n"
+                    + "                 {\n"
+                    +                       DojoUtils.createDebugStatement("response successful")
+                    +" var popUp = document.getElementById(\"" + clientId+"_auto_complete"+"\");\n"
+                    + "                     popUp.innerHTML = data;\n"
+                    + "                 }\n"
+                    + "                 else if(type == \"error\")\n"
+                    + "                 {\n"
+                    +                       DojoUtils.createDebugStatement("error during response")
+                    + "                     // here, \"data\" is our error object\n"
+                    + "                 }\n"
+                    + "             },\n"
+                    + "             mimetype: \"text/plain\"\n"
+                    + "       });\n"
+                    + "\t\t\t\t}\n"
+                    + "\t\t\t};\n"
+                    + "\t\t}\n"
+                    + "\t});\n"
+                    + "dojo.widget.tags.addParseTreeHandler(\"dojo:subcombobox\");\n"
+                    + "</script>");*/
         }
         else
         {
             //simple suggest stuff
             out.write("<input dojoType=\"combobox\" "
-                + "value=\"\" width=\"50px;\" "
+                + "value=\"\" style=\"width:150px;\" "
                 + "dataUrl=\""+ urlWithValue + "%{searchString}\"\n"
                 + "mode=\"remote\">");
         }
@@ -195,31 +254,29 @@
 
     }
 
-    private StringBuffer getAJAXHandlingCode(String urlWithValue, String clientId)
+    private StringBuffer getAJAXHandlingCode(String urlWithValue, String clientId, InputSuggestAjax inputSuggestAjax)
     {
         StringBuffer buf = new StringBuffer();
 
         //doing ajax request and handling the response
-        buf.append("var handlerNode = document.getElementById(\"" + clientId + "\");\n"
-                 + "dojo.event.connect(handlerNode, \"onkeyup\", function(evt)\n"
+        buf.append(   "dojo.event.connect(document.getElementById(\"" + clientId + "\"), \"onkeyup\", function(evt)\n"
                     + "{\n"
-                    + "    dojo.io.bind({\n"
-                    + "    url: \""+ urlWithValue +"\"+handlerNode.value,\n"
-                    + "    handle: function(type, data, evt){\n"
-                    + DojoUtils.createDebugStatement("after response")
-                    + "        if(type == \"load\"){\n"
-                    + "            var popUp = document.getElementById(\"" + clientId+"_auto_complete"+"\");\n"
-                    + "            popUp.innerHTML = data;\n"
-                    + "        }else if(type == \"error\"){\n"
-                    + "            // here, \"data\" is our error object\n"
-                    + "            // respond to the error here\n"
-                    + "        }else{\n"
-                    + "            // other types of events might get passed, handle them here\n"
-                    + "        }\n"
-                    + "    },\n"
-                    + "    mimetype: \"text/plain\"\n"
-                    + "});\n"
-                + "});\n");
+                    + "   var handlerNode = document.getElementById(\"" + clientId + "\");\n"
+                    + "   var popUp = document.getElementById(\"" + clientId+"_auto_complete"+"\");\n"
+                    + "   var inputValue = handlerNode.value;\n"
+                    + "   var url = \""+ urlWithValue +"\"+inputValue;\n"
+                    +     DojoUtils.createDebugStatement("onkeyup event occured, length is","inputValue.length")
+                    +     DojoUtils.createDebugStatement("value is","inputValue")
+                    + "   if(inputValue != \"\" ");
+                    if(inputSuggestAjax.getStartRequest()!=null)
+                        buf.append("&& inputValue.length >= "+inputSuggestAjax.getStartRequest()+")\n");
+                    else buf.append(")");
+                    if(inputSuggestAjax.getDelay()!=null)
+                        buf.append("window.setTimeout(handleRequestResponse(url, handlerNode, popUp),"+inputSuggestAjax.getDelay()+");\n");
+                    else
+                        buf.append("handleRequestResponse(url, handlerNode, popUp);\n");
+       buf.append("   else document.onclick();\n"
+                    + "});\n");
 
         //if setting the focus outside the input field, popup should not be displayed
         buf.append("dojo.event.connect(document, \"onclick\", function(evt)\n"
@@ -228,17 +285,6 @@
                     + "     popUp.innerHTML = \"\";\n"
                     + "});\n");
 
-        //puting the values from the choosen row into the fields
-        buf.append("function putValueToField(trElem)\n"
-                + "{\n"
-                + "   for(i=0;i<trElem.childNodes.length;i++)\n"
-                + "   {\n"
-                + "      var idToPutValue = trElem.childNodes[i].id.substr(11); \n"
-                + "      var elemToPutValue = document.getElementById(idToPutValue);\n"
-                + "      elemToPutValue.value = trElem.childNodes[i].innerHTML;\n "
-                + "   }\n"
-                + "}\n");
-
         return buf;
     }
 
@@ -256,41 +302,55 @@
         MethodBinding mb = inputSuggestAjax.getSuggestedItemsMethod();
         Collection suggesteds = null;
         int maxSuggestedCount = inputSuggestAjax.getMaxSuggestedItems()!=null
-        							? inputSuggestAjax.getMaxSuggestedItems().intValue()
-        							: DEFAULT_MAX_SUGGESTED_ITEMS;
+                                    ? inputSuggestAjax.getMaxSuggestedItems().intValue()
+                                    : DEFAULT_MAX_SUGGESTED_ITEMS;
         if (inputSuggestAjax.getMaxSuggestedItems()!=null) {
-        	try{
-	        	suggesteds = (Collection) mb.invoke(context,new Object[]{
-	                    AjaxPhaseListener.getValueForComponent(context, uiComponent),
-	                    new Integer(maxSuggestedCount)});
-        	}catch(MethodNotFoundException dummy){
-        		suggesteds = (List) mb.invoke(context,new Object[]{
-	                    AjaxPhaseListener.getValueForComponent(context, uiComponent)});
-        	}
+            try{
+                suggesteds = (Collection) mb.invoke(context,new Object[]{
+                        AjaxPhaseListener.getValueForComponent(context, uiComponent),
+                        new Integer(maxSuggestedCount)});
+            }catch(MethodNotFoundException dummy){
+                suggesteds = (List) mb.invoke(context,new Object[]{
+                        AjaxPhaseListener.getValueForComponent(context, uiComponent)});
+            }
         } else {
-        	try{
-	        	suggesteds = (List) mb.invoke(context,new Object[]{
-	                    AjaxPhaseListener.getValueForComponent(context, uiComponent)});
-        	}catch(MethodNotFoundException dummy){
-        		suggesteds = (Collection) mb.invoke(context,new Object[]{
+            try{
+                suggesteds = (List) mb.invoke(context,new Object[]{
+                        AjaxPhaseListener.getValueForComponent(context, uiComponent)});
+            }catch(MethodNotFoundException dummy){
+                suggesteds = (Collection) mb.invoke(context,new Object[]{
                         AjaxPhaseListener.getValueForComponent(context, uiComponent),
                         new Integer( DEFAULT_MAX_SUGGESTED_ITEMS )});
-        	}
+            }
         }
-        
+
         StringBuffer buf = new StringBuffer();
 
         if (getChildren(inputSuggestAjax)!=null
                 && !getChildren(inputSuggestAjax).isEmpty())
         {
-            buf.append("<table>");
+            /*if (inputSuggestAjax.getMaxSuggestedItems() != null)
+            {
+                List oneSuggestedTable = new ArrayList();
+                List wholeList = new ArrayList();
+                wholeList.addAll(suggesteds);
 
-            buf.append(renderTableHeader(inputSuggestAjax.getChildren()));
-            buf.append(renderTableBody(inputSuggestAjax.getChildren(), suggesteds,
-                                       context, inputSuggestAjax));
-            //todo:render footer as well
+                int j = 0;
+
+                while (j < wholeList.size())
+                {
+                    for (int i = 0; i < inputSuggestAjax.getMaxSuggestedItems().intValue(); i++)
+                    {
+                        Object entry = wholeList.get(j);
+                        oneSuggestedTable.add(entry);
+                        j++;
+                    }
+
+                    writeOneSuggestList(buf, inputSuggestAjax, suggesteds, context);
+                }
+            }*/
 
-            buf.append("</table>");
+            writeSuggestList(buf, inputSuggestAjax, suggesteds, context);
         }
         else
         {
@@ -315,6 +375,28 @@
         context.getResponseWriter().write(buf.toString());
     }
 
+    private void writeSuggestList(StringBuffer buf,
+                                  InputSuggestAjax inputSuggestAjax,
+                                  Collection suggesteds,
+                                  FacesContext context)
+    {
+        writeOneSuggestList(buf, inputSuggestAjax, suggesteds, context);
+    }
+
+    private void writeOneSuggestList(StringBuffer buf,
+                                     InputSuggestAjax inputSuggestAjax,
+                                     Collection suggesteds,
+                                     FacesContext context)
+    {
+        buf.append("<table>");
+
+        buf.append(renderTableHeader(inputSuggestAjax.getChildren()));
+        buf.append(renderTableBody(inputSuggestAjax.getChildren(), suggesteds,context, inputSuggestAjax));
+        //todo:render footer as well
+
+        buf.append("</table>");
+    }
+
     private StringBuffer renderTableBody(List columns,
                                          Collection suggesteds,
                                          FacesContext context,
@@ -325,7 +407,7 @@
 
         for (Iterator suggestedEntry = suggesteds.iterator(); suggestedEntry.hasNext();)
         {
-            Object addressEntryObject = suggestedEntry.next();
+           Object addressEntryObject = suggestedEntry.next();
 
            bodyContent.append("<tr onmouseover=");
             if(inputSuggestAjax.getColumnHoverClass()!=null)
@@ -351,17 +433,28 @@
 
                 for (Iterator iterComps = column.getChildren().iterator(); iterComps.hasNext();)
                 {
-                    UIComponent comp =  (UIComponent) iterComps.next();
+                    Object comp =  iterComps.next();
 
                     if (comp instanceof HtmlOutputText)
                     {
                         HtmlOutputText htmlOutputText = (HtmlOutputText) comp;
 
-                           bodyContent.append("<td id=\"putValueTo_")
-                                   .append(RendererUtils.getClientId(context,inputSuggestAjax,htmlOutputText.getFor())+"\">")
-                                   .append(htmlOutputText.getValue())
-                                   .append("</td>");
-                        break;
+                        if (htmlOutputText.getValue()!=null)
+                        {
+                            bodyContent.append("<td id=\"putValueTo_")
+                                       .append(RendererUtils.getClientId(context, inputSuggestAjax, htmlOutputText.getFor()) + "\">");
+
+                            if (htmlOutputText.getLabel()!=null)
+                            {
+                                bodyContent.append("<span>" + htmlOutputText.getValue() + "</span>")
+                                           .append("<span style=\"display:none;\">" + htmlOutputText.getLabel() + "</span>").append("</td>");
+                            }
+                            else
+                            {
+                                bodyContent.append("<span>" + htmlOutputText.getValue() + "</span>").append("</td>");
+                                break;
+                            }
+                        }
                     }
                 }
             }

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputsuggestajax/InputSuggestAjaxTag.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputsuggestajax/InputSuggestAjaxTag.java?rev=380943&r1=380942&r2=380943&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputsuggestajax/InputSuggestAjaxTag.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputsuggestajax/InputSuggestAjaxTag.java Sat Feb 25 08:33:02 2006
@@ -58,6 +58,8 @@
     private String _listItemStyle;
 
     private String _layout;
+    private String _delay;
+    private String _startRequest;
 
     private String _var;
 
@@ -87,6 +89,8 @@
        _var = null;
        _columnHoverClass = null;
        _columnOutClass = null;
+       _delay = null;
+       _startRequest = null;
 
     }
 
@@ -95,7 +99,10 @@
         super.setProperties(component);
 
         setIntegerProperty(component,"maxSuggestedItems", _maxSuggestedItems);
-         setSuggestedItemsMethodProperty(getFacesContext(),component,_suggestedItemsMethod);
+        setIntegerProperty(component,"delay",_delay);
+        setIntegerProperty(component,"startRequest", _startRequest);
+
+        setSuggestedItemsMethodProperty(getFacesContext(),component,_suggestedItemsMethod);
         setStringProperty(component,"popupId",_popupId);
         setStringProperty(component,"popupStyleClass",_popupStyleClass);
         setStringProperty(component,"popupStyle",_popupStyle);
@@ -141,6 +148,16 @@
     }
 
     // setter methodes to populate the components properites
+
+    public void setDelay(String delay)
+    {
+        _delay = delay;
+    }
+
+    public void setStartRequest(String startRequest)
+    {
+        _startRequest = startRequest;
+    }
 
     public void setLayout(String layout)
     {

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/inputsuggestajax/resource/default/ajax_suggest.css
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/inputsuggestajax/resource/default/ajax_suggest.css?rev=380943&r1=380942&r2=380943&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/inputsuggestajax/resource/default/ajax_suggest.css (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/inputsuggestajax/resource/default/ajax_suggest.css Sat Feb 25 08:33:02 2006
@@ -35,7 +35,7 @@
   background-color:rgb(171, 202, 219);
 }
 
-.ajaxTablePopup table thead{
+.ajaxTablePopup table thead tr th{
 text-align:center;
 }
 

Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/inputsuggestajax/resource/tableSuggest.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/inputsuggestajax/resource/tableSuggest.js?rev=380943&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/inputsuggestajax/resource/tableSuggest.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/inputsuggestajax/resource/tableSuggest.js Sat Feb 25 08:33:02 2006
@@ -0,0 +1,64 @@
+/**
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+//puting the values from the choosen row into the fields
+function putValueToField(trElem)
+{
+    var j = 0;
+
+    for(;j<trElem.childNodes.length;j++)
+    {
+        var idToPutValue = trElem.childNodes[j].id.substr(11);
+        var elemToPutValue = document.getElementById(idToPutValue);
+
+        if(trElem.childNodes[j].childNodes[1] == null)
+            elemToPutValue.value = trElem.childNodes[j].childNodes[0].innerHTML;
+        else
+        {   //quick fix to put the value in a selectOneMenu; todo: more generic and embedding in dojo 
+            for(i=0;i<elemToPutValue.options.length;i++)
+            {
+                if(elemToPutValue.options[i].value == trElem.childNodes[j].childNodes[1].innerHTML)
+                    elemToPutValue.options[i].selected = true;
+            }
+       }
+    }
+}
+
+function handleRequestResponse(url, handlerNode, popUp)
+{
+    dojo.io.bind
+    ({
+       url:  url+handlerNode.value,
+       handle: function(type, data, evt)
+               {
+                  dojo.debug("after response");
+                  //if(data) dojo.debug(data.substr(0,7));
+
+                  if(type == "load")  //&& data?
+                  {
+                      dojo.debug("response successful");
+                      if(dojo.string.startsWithAny(data, "<table>")) popUp.innerHTML = data;
+                  }
+                  else if(type == "error")
+                  {
+                      dojo.debug("error during response");
+                      //dojo.debug(data);
+                      // here, data is our error object
+                  }
+              },
+         mimetype: "text/plain"
+    });
+}

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld?rev=380943&r1=380942&r2=380943&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld Sat Feb 25 08:33:02 2006
@@ -15,7 +15,6 @@
 	* See the License for the specific language governing permissions and
 	* limitations under the License.
 -->
-
 <!DOCTYPE taglib
   PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
   "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd" [
@@ -221,7 +220,25 @@
 			<description>optional attribute to identify the max size of suggested Values</description>
 		</attribute>
 
-		<attribute>
+        <attribute>
+			<name>delay</name>
+			<required>false</required>
+			<rtexprvalue>false</rtexprvalue>
+			<type>java.lang.String</type>
+			<description>The AJAX Request is triggered after a given delay. In milliseconds.</description>
+		</attribute>
+
+        <attribute>
+			<name>startRequest</name>
+			<required>false</required>
+			<rtexprvalue>false</rtexprvalue>
+			<type>java.lang.String</type>
+			<description>The AJAX Request is only triggered if the number of chars typed in is
+                         equal or greater than this given value.
+            </description>
+		</attribute>
+
+        <attribute>
 			<name>layout</name>
 			<required>false</required>
 			<rtexprvalue>false</rtexprvalue>
@@ -1042,6 +1059,15 @@
 			<rtexprvalue>false</rtexprvalue>
 			<type>java.lang.String</type>
             <description></description>
+        </attribute>
+        <attribute>
+			<name>label</name>
+			<required>false</required>
+			<rtexprvalue>false</rtexprvalue>
+			<type>java.lang.String</type>
+            <description>To provide a second value in form of a label. Usage like SelectItem.
+                         Label is brought to client in a hidden span element near the value.            
+            </description>
         </attribute>
     </tag>
 

Modified: myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/inputSuggestAjax/Address.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/inputSuggestAjax/Address.java?rev=380943&r1=380942&r2=380943&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/inputSuggestAjax/Address.java (original)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/inputSuggestAjax/Address.java Sat Feb 25 08:33:02 2006
@@ -1,5 +1,7 @@
 package org.apache.myfaces.examples.inputSuggestAjax;
 
+import javax.faces.model.SelectItem;
+
 /**
  * @author Gerald Muellan
  *         Date: 12.02.2006
@@ -10,16 +12,19 @@
     private int _streetNumber;
     private String _streetName;
     private String _city;
-    private int _zip;
+    private String _state;
+    private long _zip;
+
 
     public Address(int streetNumber,
                    String streetName,
                    String city,
-                   int zip)
+                   long zip,String state)
     {
         _streetNumber = streetNumber;
         _streetName = streetName;
         _city = city;
+        _state = state;
         _zip = zip;
     }
 
@@ -53,12 +58,22 @@
         _city = city;
     }
 
-    public int getZip()
+    public String  getState()
+    {
+        return _state;
+    }
+
+    public void setState(String  state)
+    {
+        _state = state;
+    }
+
+    public long getZip()
     {
         return _zip;
     }
 
-    public void setZip(int zip)
+    public void setZip(long zip)
     {
         _zip = zip;
     }

Modified: myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/inputSuggestAjax/InputSuggestAjaxBean.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/inputSuggestAjax/InputSuggestAjaxBean.java?rev=380943&r1=380942&r2=380943&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/inputSuggestAjax/InputSuggestAjaxBean.java (original)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/inputSuggestAjax/InputSuggestAjaxBean.java Sat Feb 25 08:33:02 2006
@@ -15,6 +15,7 @@
  */
 package org.apache.myfaces.examples.inputSuggestAjax;
 
+import javax.faces.model.SelectItem;
 import java.util.List;
 import java.util.ArrayList;
 
@@ -30,12 +31,12 @@
     {
         List addressList = new ArrayList();
 
-        addressList.add(new Address(11,"noname",cityFragment+"nocity",1111));
-        addressList.add(new Address(12,"max",cityFragment+"muster",1112));
-        addressList.add(new Address(13,"phil",cityFragment+"philadelphia",1113));
-        addressList.add(new Address(14,"new",cityFragment+"new york",1114));
-        addressList.add(new Address(15,"san",cityFragment+"san francisco",1115));
-        addressList.add(new Address(16,"san",cityFragment+"san diego",1116));
+        addressList.add(new Address(11,"noname",cityFragment+"nocity",15,"KL"));
+        addressList.add(new Address(12,"max",cityFragment+"muster",14,"SJ"));
+        addressList.add(new Address(13,"phil",cityFragment+"philadelphia",13,"NW"));
+        addressList.add(new Address(14,"new",cityFragment+"new york",12,"IL"));
+        addressList.add(new Address(15,"san",cityFragment+"san francisco",11,"NY"));
+        addressList.add(new Address(16,"san",cityFragment+"san diego",16,"MH"));
 
         return addressList;
     }

Modified: myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/inputSuggestAjax.jsp
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/inputSuggestAjax.jsp?rev=380943&r1=380942&r2=380943&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/inputSuggestAjax.jsp (original)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/inputSuggestAjax.jsp Sat Feb 25 08:33:02 2006
@@ -36,25 +36,21 @@
     
    <h:form>
 
-     <h:outputText value="Street"/>
-     <t:inputText id="streetNameField" />
-     <h:outputText value="Number"/>
-     <t:selectOneMenu id="streetNumberField">
-          <f:selectItem value="" itemLabel="11" itemValue="11"/>
-          <f:selectItem value="" itemLabel="12" itemValue="12"/>
-          <f:selectItem value="" itemLabel="13" itemValue="13"/>
-          <f:selectItem value="" itemLabel="14" itemValue="14"/>
-          <f:selectItem value="" itemLabel="15" itemValue="15"/>
-     </t:selectOneMenu>
-     <h:outputText value="Zip"/>
-     <t:inputText id="zipField"/>
-
      <f:verbatim><br/><br/></f:verbatim>
 
+     <h:panelGrid columns="4">
+         <h:outputText value="default suggest"/>
+         <s:inputSuggestAjax suggestedItemsMethod="#{inputSuggestAjax.getItems}"/>
+
+         <h:outputText value="suggest with limited suggested items"/>
+         <s:inputSuggestAjax suggestedItemsMethod="#{inputSuggestAjax.getItems}" maxSuggestedItems="2" />
+     </h:panelGrid>
+     <f:verbatim><br/><br/><br/></f:verbatim>
      <h:panelGrid columns="6">
          <h:outputText value="City Field TableSuggest"/>
-         <s:inputSuggestAjax var="address" id="cityField"  suggestedItemsMethod="#{inputSuggestAjax.getAddressList}">
-             <t:column>
+         <s:inputSuggestAjax var="address" id="cityField" startRequest="2" delay="200" 
+                             suggestedItemsMethod="#{inputSuggestAjax.getAddressList}">
+            <t:column>
                  <f:facet name="header">
                      <s:outputText value="city"/>
                  </f:facet>
@@ -68,30 +64,48 @@
              </t:column>
              <t:column>
                  <f:facet name="header">
-                     <s:outputText value="number"/>
+                     <s:outputText value="state"/>
+                 </f:facet>
+                 <s:outputText for="stateField" value="#{address.state}" label="#{address.zip}"/>
+             </t:column>
+         </s:inputSuggestAjax>
+         <s:inputSuggestAjax var="address" id="cityField1" startRequest="2"
+                             suggestedItemsMethod="#{inputSuggestAjax.getAddressList}">
+            <t:column>
+                 <f:facet name="header">
+                     <s:outputText value="city"/>
+                 </f:facet>
+                 <s:outputText for="cityField1" value="#{address.city}"/>
+             </t:column>
+             <t:column>
+                 <f:facet name="header">
+                     <s:outputText value="street"/>
                  </f:facet>
-                 <s:outputText for="streetNumberField" value="#{address.streetNumber}"/>
+                 <s:outputText for="streetNameField" value="#{address.streetName}"/>
              </t:column>
              <t:column>
                  <f:facet name="header">
-                     <s:outputText value="zip"/>
+                     <s:outputText value="state"/>
                  </f:facet>
-                 <s:outputText for="zipField" value="#{address.zip}"/>
+                 <s:outputText for="stateField" value="#{address.state}" label="#{address.zip}"/>
              </t:column>
          </s:inputSuggestAjax>
-
-         <h:outputText value="default suggest"/>
-         <s:inputSuggestAjax suggestedItemsMethod="#{inputSuggestAjax.getItems}"/>
-
-         <h:outputText value="suggest with limited suggested items"/>
-         <s:inputSuggestAjax suggestedItemsMethod="#{inputSuggestAjax.getItems}" maxSuggestedItems="2" />
+         <h:outputText value="Street"/>
+         <t:inputText id="streetNameField" />
+         <h:outputText value="State"/>
+         <t:selectOneMenu id="stateField">
+              <f:selectItem value="" itemLabel="NY" itemValue="11"/>
+              <f:selectItem value="" itemLabel="IL" itemValue="12"/>
+              <f:selectItem value="" itemLabel="NW" itemValue="13"/>
+              <f:selectItem value="" itemLabel="SJ" itemValue="14"/>
+              <f:selectItem value="" itemLabel="KL" itemValue="15"/>
+              <f:selectItem value="" itemLabel="MH" itemValue="16"/>
+         </t:selectOneMenu>
      </h:panelGrid>
-
-     <f:verbatim><br/><br/><br/><br/><br/><br/><br/><br/></f:verbatim>
+     <f:verbatim><br/><br/><br/><br/><br/></f:verbatim>
      <s:dojoInitializer debugConsole="true"/>
-
     </h:form>
-
+    
 </f:view>
 
 <%@include file="inc/page_footer.jsp" %>