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 2007/02/07 13:52:16 UTC

svn commit: r504531 - in /myfaces/tomahawk/trunk/sandbox: core/src/main/java/org/apache/myfaces/custom/ajax/api/ core/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/ core/src/main/java/org/apache/myfaces/custom/inputAjax/ core/src/main/java/...

Author: gmuellan
Date: Wed Feb  7 04:52:15 2007
New Revision: 504531

URL: http://svn.apache.org/viewvc?view=rev&rev=504531
Log:
Applied patch https://issues.apache.org/jira/browse/TOMAHAWK-884, Many thx to Stefan Schuster for providing this useful patch.

Removed:
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/api/AjaxPhaseListener.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/suggestajax/
Modified:
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/api/AjaxDecodePhaseListener.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/HtmlAjaxChildComboBoxRenderer.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlCommandButtonAjax.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlInputTextAjax.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlSelectBooleanCheckboxAjax.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlSelectManyCheckboxAjax.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlSelectOneRadioAjax.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/tablesuggestajax/TableSuggestAjax.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/tablesuggestajax/TableSuggestAjaxRenderer.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/tablesuggestajax/TableSuggestAjaxTag.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/table_suggest_ajax_attributes.xml
    myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/css/basic.css
    myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/tableSuggestAjax.jsp

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/api/AjaxDecodePhaseListener.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/api/AjaxDecodePhaseListener.java?view=diff&rev=504531&r1=504530&r2=504531
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/api/AjaxDecodePhaseListener.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/api/AjaxDecodePhaseListener.java Wed Feb  7 04:52:15 2007
@@ -24,7 +24,6 @@
 import org.apache.myfaces.component.html.ext.UIComponentPerspective;
 import org.apache.myfaces.custom.ajax.util.AjaxRendererUtils;
 import org.apache.myfaces.custom.inputAjax.HtmlCommandButtonAjax;
-import org.apache.myfaces.custom.suggestajax.inputsuggestajax.InputSuggestAjax;
 import org.apache.myfaces.shared_tomahawk.component.ExecuteOnCallback;
 import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils;
 import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlResponseWriterImpl;
@@ -81,7 +80,7 @@
             String affectedAjaxComponent = (String) context.getExternalContext()
                                                         .getRequestParameterMap().get("affectedAjaxComponent");
             UIComponent ajaxComponent = root.findComponent(affectedAjaxComponent);
-            //checking if ajaxComp is inside a dataTable;
+            //checking if ajaxComp is inside a dataTable - necessary for non JSF 1.2 MyFaces implementation
             if (ajaxComponent instanceof UIComponentPerspective)
             {
                 UIComponentPerspective componentPerspective = (UIComponentPerspective) ajaxComponent;
@@ -134,6 +133,8 @@
             throw new ComponentNotFoundException(msg);
         }
         log.debug("affectedAjaxComponent: " + ajaxComponent + " - " + ajaxComponent.getId());
+        //todo: refactor this completely - should be somewhere else, but definitely not
+        //in the general phase listener
         if (ajaxComponent instanceof HtmlCommandButtonAjax)
         {
             // special treatment for this one, it will try to update the entire form
@@ -195,27 +196,8 @@
         */
         response.setLocale(viewRoot.getLocale());
 
-        if (component instanceof InputSuggestAjax)
-        {
-            try
-            {
-                if (context.getResponseWriter() == null)
-                {
-                    String contentType = getContentType("text/html", charset);
-                    response.setContentType(contentType);
-                    PrintWriter writer = response.getWriter();
-                    context.setResponseWriter(new HtmlResponseWriterImpl(writer,
-                                              contentType, response.getCharacterEncoding()));
-                }
 
-                ((AjaxComponent) component).encodeAjax(context);
-            }
-            catch (IOException e)
-            {
-                log.error("Exception while rendering ajax-response", e);
-            }
-        }
-        else
+        if(component instanceof DeprecatedAjaxComponent)
         {
             try
             {
@@ -272,6 +254,27 @@
                 log.error("Exception while rendering ajax-response", e);
             }
         }
+        else if (component instanceof AjaxComponent)
+        {
+            try
+            {
+                if (context.getResponseWriter() == null)
+                {
+                    String contentType = getContentType("text/html", charset);
+                    response.setContentType(contentType);
+                    PrintWriter writer = response.getWriter();
+                    context.setResponseWriter(new HtmlResponseWriterImpl(writer,
+                                              contentType, response.getCharacterEncoding()));
+                }
+
+                ((AjaxComponent) component).encodeAjax(context);
+            }
+            catch (IOException e)
+            {
+                log.error("Exception while rendering ajax-response", e);
+            }
+        }
+
     }
 
     private String getContentType(String contentType, String charset)

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/HtmlAjaxChildComboBoxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/HtmlAjaxChildComboBoxRenderer.java?view=diff&rev=504531&r1=504530&r2=504531
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/HtmlAjaxChildComboBoxRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/HtmlAjaxChildComboBoxRenderer.java Wed Feb  7 04:52:15 2007
@@ -137,15 +137,18 @@
 		SelectItem[] options = (SelectItem[])
 			mb.invoke(context, new Object[]{parentValue});
 
-		for (int i = 0; i < options.length; i++)
+        xml.append("<?xml version=\"1.0\"?>\n");
+        xml.append("<response>\n");
+        for (int i = 0; i < options.length; i++)
 		{
 			xml.append(BEGIN_OPTION);
 			xml.append(BEGIN_OPTION_TEXT).append(options[i].getLabel()).append(END_OPTION_TEXT);
 			xml.append(BEGIN_OPTION_VALUE).append(options[i].getValue()).append(END_OPTION_VALUE);
 			xml.append(END_OPTION);
 		}
+        xml.append("</response>");
 
-		writer.write(xml.toString());
+        writer.write(xml.toString());
 
 	}
 

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlCommandButtonAjax.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlCommandButtonAjax.java?view=diff&rev=504531&r1=504530&r2=504531
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlCommandButtonAjax.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlCommandButtonAjax.java Wed Feb  7 04:52:15 2007
@@ -18,12 +18,12 @@
  */
 package org.apache.myfaces.custom.inputAjax;
 
-import org.apache.myfaces.component.html.ext.HtmlCommandButton;
-import org.apache.myfaces.custom.ajax.api.AjaxComponent;
-import org.apache.myfaces.custom.ajax.api.AjaxRenderer;
-import org.apache.myfaces.custom.ajax.AjaxCallbacks;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.component.html.ext.HtmlCommandButton;
+import org.apache.myfaces.custom.ajax.AjaxCallbacks;
+import org.apache.myfaces.custom.ajax.api.AjaxRenderer;
+import org.apache.myfaces.custom.ajax.api.DeprecatedAjaxComponent;
 
 import javax.faces.context.FacesContext;
 import javax.faces.render.Renderer;
@@ -34,7 +34,7 @@
  * Date: Mar 22, 2006
  * Time: 4:37:53 PM
  */
-public class HtmlCommandButtonAjax extends HtmlCommandButton implements AjaxComponent, AjaxCallbacks
+public class HtmlCommandButtonAjax extends HtmlCommandButton implements DeprecatedAjaxComponent, AjaxCallbacks
 {
     private static final Log log = LogFactory.getLog(HtmlInputTextAjax.class);
     public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlCommandButtonAjax";

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlInputTextAjax.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlInputTextAjax.java?view=diff&rev=504531&r1=504530&r2=504531
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlInputTextAjax.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlInputTextAjax.java Wed Feb  7 04:52:15 2007
@@ -29,13 +29,14 @@
 import org.apache.myfaces.custom.ajax.AjaxCallbacks;
 import org.apache.myfaces.custom.ajax.api.AjaxComponent;
 import org.apache.myfaces.custom.ajax.api.AjaxRenderer;
+import org.apache.myfaces.custom.ajax.api.DeprecatedAjaxComponent;
 
 /**
  * User: treeder
  * Date: Oct 28, 2005
  * Time: 7:48:57 PM
  */
-public class HtmlInputTextAjax extends HtmlInputText implements AjaxComponent, AjaxCallbacks
+public class HtmlInputTextAjax extends HtmlInputText implements DeprecatedAjaxComponent, AjaxCallbacks
 {
     private static final Log log = LogFactory.getLog(HtmlInputTextAjax.class);
     public static final String COMPONENT_TYPE = "org.apache.myfaces.InputTextAjax";

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlSelectBooleanCheckboxAjax.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlSelectBooleanCheckboxAjax.java?view=diff&rev=504531&r1=504530&r2=504531
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlSelectBooleanCheckboxAjax.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlSelectBooleanCheckboxAjax.java Wed Feb  7 04:52:15 2007
@@ -32,13 +32,15 @@
 import org.apache.myfaces.custom.ajax.AjaxCallbacks;
 import org.apache.myfaces.custom.ajax.api.AjaxComponent;
 import org.apache.myfaces.custom.ajax.api.AjaxRenderer;
+import org.apache.myfaces.custom.ajax.api.DeprecatedAjaxComponent;
 
 /**
  * User: treeder
  * Date: Nov 21, 2005
  * Time: 8:47:27 AM
  */
-public class HtmlSelectBooleanCheckboxAjax extends HtmlSelectBooleanCheckbox implements AjaxComponent, AjaxCallbacks
+public class HtmlSelectBooleanCheckboxAjax extends HtmlSelectBooleanCheckbox
+        implements DeprecatedAjaxComponent, AjaxCallbacks
 {
 
     private static final Log log = LogFactory.getLog(HtmlSelectBooleanCheckboxAjax.class);

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlSelectManyCheckboxAjax.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlSelectManyCheckboxAjax.java?view=diff&rev=504531&r1=504530&r2=504531
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlSelectManyCheckboxAjax.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlSelectManyCheckboxAjax.java Wed Feb  7 04:52:15 2007
@@ -32,6 +32,7 @@
 import org.apache.myfaces.custom.ajax.AjaxCallbacks;
 import org.apache.myfaces.custom.ajax.api.AjaxComponent;
 import org.apache.myfaces.custom.ajax.api.AjaxRenderer;
+import org.apache.myfaces.custom.ajax.api.DeprecatedAjaxComponent;
 
 /**
  * Current limitations
@@ -40,7 +41,7 @@
  * @author Travis Reeder (latest modification by $Author: mmarinschek $)
  * @version $Revision: 290397 $ $Date: 2005-09-20 10:35:09 +0200 (Di, 20 Sep 2005) $
  */
-public class HtmlSelectManyCheckboxAjax extends HtmlSelectManyCheckbox implements AjaxComponent, AjaxCallbacks
+public class HtmlSelectManyCheckboxAjax extends HtmlSelectManyCheckbox implements DeprecatedAjaxComponent, AjaxCallbacks
 {
     private static final Log log = LogFactory.getLog(HtmlSelectManyCheckboxAjax.class);
     public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlSelectManyCheckboxAjax";

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlSelectOneRadioAjax.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlSelectOneRadioAjax.java?view=diff&rev=504531&r1=504530&r2=504531
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlSelectOneRadioAjax.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlSelectOneRadioAjax.java Wed Feb  7 04:52:15 2007
@@ -30,13 +30,14 @@
 import org.apache.myfaces.custom.ajax.AjaxCallbacks;
 import org.apache.myfaces.custom.ajax.api.AjaxComponent;
 import org.apache.myfaces.custom.ajax.api.AjaxRenderer;
+import org.apache.myfaces.custom.ajax.api.DeprecatedAjaxComponent;
 
 /**
  * User: treeder
  * Date: Nov 10, 2005
  * Time: 4:45:09 PM
  */
-public class HtmlSelectOneRadioAjax extends HtmlSelectOneRadio implements AjaxComponent, AjaxCallbacks
+public class HtmlSelectOneRadioAjax extends HtmlSelectOneRadio implements DeprecatedAjaxComponent, AjaxCallbacks
 {
     private static final Log log = LogFactory.getLog(HtmlSelectOneRadioAjax.class);
     public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlSelectOneRadioAjax";

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=504531&r1=504530&r2=504531
==============================================================================
--- 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 Wed Feb  7 04:52:15 2007
@@ -83,7 +83,7 @@
 
         ResponseWriter out = context.getResponseWriter();
 
-        Object valueObject = inputSuggestAjax.getValue();
+        Object valueObject = inputSuggestAjax.getValue();  //Todo -> Use submitted value rather than value if submitted value != null (RendererUtils.getStringValue)
         String label = null;
         String value = null;
 

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/tablesuggestajax/TableSuggestAjax.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/tablesuggestajax/TableSuggestAjax.java?view=diff&rev=504531&r1=504530&r2=504531
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/tablesuggestajax/TableSuggestAjax.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/tablesuggestajax/TableSuggestAjax.java Wed Feb  7 04:52:15 2007
@@ -29,76 +29,66 @@
  *         Date: 25.03.2006
  *         Time: 17:04:58
  */
-public class TableSuggestAjax extends SuggestAjax
-{
+public class TableSuggestAjax extends SuggestAjax {
     public static final String COMPONENT_TYPE = "org.apache.myfaces.TableSuggestAjax";
     public static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.TableSuggestAjax";
 
-    private String _layout;
     private String _popupId;
-    private String _popupStyleClass;
-    private String _popupStyle;
-
-    private String _tableStyleClass;
-    private String _nextPageFieldClass;
-
-    private String _columnHoverClass;
-    private String _columnOutClass;
-
     private Integer _betweenKeyUp;
     private Integer _startRequest;
 
-    private Boolean _acceptValueToField = new Boolean(false);
+    private String _popupStyleClass;
+    private String _tableStyleClass;
+    private String _comboBoxStyleClass;
+    private String _rowStyleClass;
+    private String _evenRowStyleClass;
+    private String _oddRowStyleClass;
+    private String _hoverRowStyleClass;
 
     private String _var;
 
-    public TableSuggestAjax()
-    {
+
+    public TableSuggestAjax() {
         super();
 
         setRendererType(DEFAULT_RENDERER_TYPE);
     }
 
-    public Object saveState(FacesContext context)
-    {
+    public Object saveState(FacesContext context) {
         Object[] values = new Object[13];
         values[0] = super.saveState(context);
         values[1] = _var;
-        values[2] = _columnHoverClass;
-        values[3] = _columnOutClass;
-        values[4] = _betweenKeyUp;
-        values[5] = _startRequest;
-        values[6] = _tableStyleClass;
-        values[7] = _nextPageFieldClass;
-        values[8] = _acceptValueToField;
-        values[9] = _popupId;
-        values[10] = _popupStyleClass;
-        values[11] = _popupStyle;
-        values[12] = _layout;
+        values[2] = _betweenKeyUp;
+        values[3] = _startRequest;
+        values[4] = _tableStyleClass;
+        values[5] = _popupId;
+        values[6] = _popupStyleClass;
+        values[7] = _comboBoxStyleClass;
+        values[8] = _rowStyleClass;
+        values[9] = _evenRowStyleClass;
+        values[10] = _oddRowStyleClass;
+        values[11] = _hoverRowStyleClass;
 
         return values;
     }
 
-    public void restoreState(FacesContext context, Object state)
-    {
+    public void restoreState(FacesContext context, Object state) {
         Object values[] = (Object[])state;
         super.restoreState(context, values[0]);
         _var = (String) values[1];
-        _columnHoverClass = (String) values[2];
-        _columnOutClass = (String) values[3];
-        _betweenKeyUp = (Integer) values[4];
-        _startRequest = (Integer) values[5];
-        _tableStyleClass = (String) values[6];
-        _nextPageFieldClass = (String) values[7];
-        _acceptValueToField = (Boolean) values[8];
-        _popupId = (String) values[9];
-        _popupStyleClass = (String) values[10];
-        _popupStyle = (String) values[11];
-        _layout = (String) values[12];
+        _betweenKeyUp = (Integer) values[2];
+        _startRequest = (Integer) values[3];
+        _tableStyleClass = (String) values[4];
+        _popupId = (String) values[5];
+        _popupStyleClass = (String) values[6];
+        _comboBoxStyleClass = (String) values[7];
+        _rowStyleClass = (String) values[8];
+        _evenRowStyleClass = (String) values[9];
+        _oddRowStyleClass = (String) values[10];
+        _hoverRowStyleClass = (String) values[11];
     }
 
-    public boolean getRendersChildren()
-    {
+    public boolean getRendersChildren() {
         if (getVar() != null)
         {
             return true;
@@ -109,152 +99,139 @@
         }
     }
 
-    public void encodeChildren(FacesContext context) throws IOException
-    {
+    public void encodeChildren(FacesContext context) throws IOException {
         super.encodeChildren(context);
     }
 
-    public Integer getBetweenKeyUp()
-    {
-        if (_betweenKeyUp != null)
-        {
+    public Integer getBetweenKeyUp() {
+        if (_betweenKeyUp != null) {
             return _betweenKeyUp;
         }
         ValueBinding vb = getValueBinding("delay");
         return vb != null ? (Integer) vb.getValue(getFacesContext()) : null;
     }
 
-    public void setBetweenKeyUp(Integer betweenKeyUp)
-    {
+    public void setBetweenKeyUp(Integer betweenKeyUp) {
         _betweenKeyUp = betweenKeyUp;
     }
 
-    public Integer getStartRequest()
-    {
-        if (_startRequest != null)
-        {
+    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)
-    {
+    public void setStartRequest(Integer startRequest) {
         _startRequest = startRequest;
     }
 
-    public void setVar(String var)
-    {
+    public void setVar(String var) {
         _var = var;
     }
 
-    public String getVar()
-    {
-        if (_var != null) return _var;
+    public String getVar() {
+        if (_var != null) {
+            return _var;
+        }
         ValueBinding vb = getValueBinding("var");
         return vb != null ? vb.getValue(getFacesContext()).toString() : null;
     }
 
-    public String getColumnHoverClass()
-    {
-        return _columnHoverClass;
-    }
-
-    public void setColumnHoverClass(String columnHoverClass)
-    {
-        _columnHoverClass = columnHoverClass;
-    }
-
-    public String getColumnOutClass()
-    {
-        return _columnOutClass;
+    public String getTableStyleClass() {
+        if (_tableStyleClass != null) {
+            return _tableStyleClass;
+        }
+        ValueBinding vb = getValueBinding("tableStyleClass");
+        return vb != null ? vb.getValue(getFacesContext()).toString() : null;
     }
 
-    public void setColumnOutClass(String columnOutClass)
-    {
-        _columnOutClass = columnOutClass;
+    public void setTableStyleClass(String tableStyleClass) {
+        _tableStyleClass = tableStyleClass;
     }
 
-    public String getTableStyleClass()
+    public String getPopupId()
     {
-        return _tableStyleClass;
+        if (_popupId != null) {
+            return _popupId;
+        }
+        ValueBinding vb = getValueBinding("popupId");
+        return vb != null ? vb.getValue(getFacesContext()).toString() : null;
     }
 
-    public void setTableStyleClass(String tableStyleClass)
-    {
-        _tableStyleClass = tableStyleClass;
+    public void setPopupId(String popupId) {
+        _popupId = popupId;
     }
 
-    public String getNextPageFieldClass()
-    {
-        return _nextPageFieldClass;
+    public String getPopupStyleClass() {
+        if (_popupStyleClass != null)
+            return _popupStyleClass;
+        ValueBinding vb = getValueBinding("popupStyleClass");
+        return vb != null ? vb.getValue(getFacesContext()).toString() : null;
     }
 
-    public void setNextPageFieldClass(String nextPageFieldClass)
-    {
-        _nextPageFieldClass = nextPageFieldClass;
+    public void setPopupStyleClass(String popupStyleClass) {
+        _popupStyleClass = popupStyleClass;
     }
 
-    public Boolean getAcceptValueToField()
-    {
-        return _acceptValueToField;
+    public String getComboBoxStyleClass() {
+        if (_comboBoxStyleClass != null) {
+            return _comboBoxStyleClass;
+        }
+        ValueBinding vb = getValueBinding("comboBoxStyleClass");
+        return vb != null ? vb.getValue(getFacesContext()).toString() : null;
     }
 
-    public void setAcceptValueToField(Boolean acceptValueToField)
-    {
-        _acceptValueToField = acceptValueToField;
+    public void setComboBoxStyleClass(String comboBoxStyleClass) {
+        _comboBoxStyleClass = comboBoxStyleClass;
     }
 
-     public String getPopupId()
-    {
-        if (_popupId != null)
-            return _popupId;
-        ValueBinding vb = getValueBinding("popupId");
+    public String getRowStyleClass() {
+        if (_rowStyleClass != null) {
+            return _rowStyleClass;
+        }
+        ValueBinding vb = getValueBinding("rowStyleClass");
         return vb != null ? vb.getValue(getFacesContext()).toString() : null;
     }
 
-    public void setPopupId(String popupId)
-    {
-        _popupId = popupId;
+    public void setRowStyleClass(String rowStyleClass) {
+        _rowStyleClass = rowStyleClass;
     }
 
-    public String getPopupStyleClass()
-    {
-        if (_popupStyleClass != null)
-            return _popupStyleClass;
-        ValueBinding vb = getValueBinding("popupStyleClass");
+    public String getEvenRowStyleClass() {
+        if (_evenRowStyleClass != null) {
+            return _evenRowStyleClass;
+        }
+        ValueBinding vb = getValueBinding("evenRowStyleClass");
         return vb != null ? vb.getValue(getFacesContext()).toString() : null;
     }
 
-    public void setPopupStyleClass(String popupStyleClass)
-    {
-        _popupStyleClass = popupStyleClass;
+    public void setEvenRowStyleClass(String evenRowStyleClass) {
+        _evenRowStyleClass = evenRowStyleClass;
     }
 
-    public String getPopupStyle()
-    {
-        if (_popupStyle != null)
-            return _popupStyle;
-        ValueBinding vb = getValueBinding("popupStyle");
+    public String getOddRowStyleClass() {
+        if (_oddRowStyleClass != null) {
+            return _oddRowStyleClass;
+        }
+        ValueBinding vb = getValueBinding("oddRowStyleClass");
         return vb != null ? vb.getValue(getFacesContext()).toString() : null;
     }
 
-    public void setPopupStyle(String popupStyle)
-    {
-        _popupStyle = popupStyle;
+    public void setOddRowStyleClass(String oddRowStyleClass) {
+        _oddRowStyleClass = oddRowStyleClass;
     }
 
-    public String getLayout()
-    {
-        if (_layout != null)
-            return _layout;
-        ValueBinding vb = getValueBinding("layout");
-        return vb != null ? vb.getValue(getFacesContext()).toString() : "default";
+    public String getHoverRowStyleClass() {
+        if (_hoverRowStyleClass != null) {
+            return _hoverRowStyleClass;
+        }
+        ValueBinding vb = getValueBinding("hoverRowStyleClass");
+        return vb != null ? vb.getValue(getFacesContext()).toString() : null;
     }
 
-    public void setLayout(String layout)
-    {
-        _layout = layout;
+    public void setHoverRowStyleClass(String hoverRowStyleClass) {
+        _hoverRowStyleClass = hoverRowStyleClass;
     }
-}
\ No newline at end of file
+}

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/tablesuggestajax/TableSuggestAjaxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/tablesuggestajax/TableSuggestAjaxRenderer.java?view=diff&rev=504531&r1=504530&r2=504531
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/tablesuggestajax/TableSuggestAjaxRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/tablesuggestajax/TableSuggestAjaxRenderer.java Wed Feb  7 04:52:15 2007
@@ -18,13 +18,12 @@
  */
 package org.apache.myfaces.custom.suggestajax.tablesuggestajax;
 
+import org.apache.commons.collections.map.HashedMap;
 import org.apache.myfaces.component.html.ext.UIComponentPerspective;
 import org.apache.myfaces.custom.ajax.api.AjaxRenderer;
 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.renderkit.html.util.AddResource;
-import org.apache.myfaces.renderkit.html.util.AddResourceFactory;
 import org.apache.myfaces.shared_tomahawk.component.ExecuteOnCallback;
 import org.apache.myfaces.shared_tomahawk.renderkit.JSFAttr;
 import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils;
@@ -36,10 +35,9 @@
 import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;
 import java.io.IOException;
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
-import java.util.List;
+import java.util.Map;
 
 /**
  * @author Gerald Muellan
@@ -50,6 +48,7 @@
 {
     public static final int DEFAULT_START_REQUEST = 0;
     public static final int DEFAULT_BETWEEN_KEY_UP = 1000;
+    public static final String DEFAULT_AUTO_COMPLETE = "true";
     
    /**
      * Encodes any stand-alone javascript functions that are needed.
@@ -60,49 +59,16 @@
      * @param component UIComponent
      * @throws java.io.IOException
      */
-    private void encodeJavascript(FacesContext context, UIComponent component)
-                                                                        throws IOException
+    private void encodeJavascript(FacesContext context, UIComponent component) throws IOException
     {
+
         String javascriptLocation = (String)component.getAttributes().get(JSFAttr.JAVASCRIPT_LOCATION);
-        String styleLocation = (String)component.getAttributes().get(JSFAttr.STYLE_LOCATION);
 
-        DojoUtils.addMainInclude(context, component, javascriptLocation, new DojoConfig());
+        DojoConfig dojoConfig = new DojoConfig();
+        DojoUtils.addMainInclude(context, component, javascriptLocation, dojoConfig);
         DojoUtils.addRequire(context, component, "extensions.FacesIO");
+        DojoUtils.addRequire(context, component, "extensions.widget.TableSuggest");
         DojoUtils.addRequire(context, component, "dojo.event.*");
-        DojoUtils.addRequire(context, component, "dojo.string");
-        DojoUtils.addRequire(context, component, "dojo.lfx.html");
-        DojoUtils.addRequire(context, component, "dojo.lang");
-        DojoUtils.addRequire(context, component, "dojo.html");
-        DojoUtils.addRequire(context, component, "dojo.style");
-        DojoUtils.addRequire(context, component, "dojo.collections.ArrayList");
-
-        AddResource addResource = AddResourceFactory.getInstance(context);
-
-        if(javascriptLocation != null)
-        {
-            addResource.addJavaScriptHere(context,  javascriptLocation + "/tableSuggest.js");
-        }
-        else
-        {
-            addResource.addJavaScriptHere(context,  TableSuggestAjaxRenderer.class, "tableSuggest.js");
-        }
-
-        TableSuggestAjax tableSuggestAjax = (TableSuggestAjax) component;
-
-        if (tableSuggestAjax.getPopupStyleClass() == null)
-        {
-            if( styleLocation != null )
-            {
-                addResource.addStyleSheet(context, AddResource.HEADER_BEGIN, styleLocation + "/table_suggest.css");
-            }
-            else
-            {
-                String theme = ((TableSuggestAjax)component).getLayout();
-                if(theme == null)
-                    theme = "default";
-                addResource.addStyleSheet(context, AddResource.HEADER_BEGIN, TableSuggestAjaxRenderer.class, theme + "/table_suggest.css");
-            }
-        }
     }
 
     public void encodeEnd(FacesContext context, UIComponent component) throws IOException
@@ -113,123 +79,124 @@
 
         encodeJavascript(context,component);
 
-       tableSuggestAjax.getAttributes().put("autocomplete","off");
+        //Disables browser auto completion
+        tableSuggestAjax.getAttributes().put("autocomplete","off");
 
         String clientId = component.getClientId(context);
         String actionURL = getActionUrl(context);
 
-        String ajaxUrl = context.getExternalContext().encodeActionURL(addQueryString(actionURL, "affectedAjaxComponent=" + clientId));
+        String charset = (tableSuggestAjax.getCharset() != null ? tableSuggestAjax.getCharset() : "");
+        String ajaxUrl = context.getExternalContext().encodeActionURL(addQueryString(actionURL, "affectedAjaxComponent=" + clientId +
+                "&charset=" + charset + "&" + clientId + "=%{searchString}"));
 
         ResponseWriter out = context.getResponseWriter();
 
+        String valueToRender = RendererUtils.getStringValue(context,tableSuggestAjax);
+        valueToRender = escapeQuotes(valueToRender);
+
         if (getChildren(tableSuggestAjax) != null
                 && !getChildren(tableSuggestAjax).isEmpty())
         {
-            //suggestTable stuff
-            out.startElement(HTML.TABLE_ELEM, null);
-            out.writeAttribute(HTML.STYLE_ATTR,"border-collapse:collapse;",null);
-            out.writeAttribute(HTML.CELLPADDING_ATTR,"0",null);
-            out.startElement(HTML.TR_ELEM, null);
-            out.startElement(HTML.TD_ELEM, null);
-
-            super.encodeEnd(context, tableSuggestAjax);
+            out.startElement(HTML.DIV_ELEM, component);
+            out.writeAttribute(HTML.ID_ATTR, clientId , null);
+            out.endElement(HTML.DIV_ELEM);
 
-            out.endElement(HTML.TR_ELEM);
-            out.endElement(HTML.TD_ELEM);
+            String tableSuggestComponentVar = DojoUtils.calculateWidgetVarName(clientId);
 
-            out.startElement(HTML.TR_ELEM, null);
-            out.startElement(HTML.TD_ELEM, null);
+            Map attributes = new HashedMap();
+            String betweenKeyUp = "";
+            String startRequest = "";
+            String autoComplete = "";
 
-            out.startElement(HTML.DIV_ELEM, null);
-            if(tableSuggestAjax.getPopupStyleClass()!= null)
-            {
-                out.writeAttribute(HTML.CLASS_ATTR, tableSuggestAjax.getPopupStyleClass(), null);
+            //General attributes
+            attributes.put("dataUrl", ajaxUrl);
+            attributes.put("mode", "remote");
+
+            //BetweenKeyUp
+            if (tableSuggestAjax.getBetweenKeyUp() != null) {
+                betweenKeyUp = tableSuggestAjax.getBetweenKeyUp().toString();
             }
-            else if(tableSuggestAjax.getLayout().equals("default"))
-            {
-                out.writeAttribute(HTML.CLASS_ATTR, "ajaxTablePopup", null);
+            else {
+                betweenKeyUp = Integer.toString(DEFAULT_BETWEEN_KEY_UP);
             }
-            if (tableSuggestAjax.getPopupId() != null)
-            {
-                out.writeAttribute(HTML.ID_ATTR,tableSuggestAjax.getPopupId(), null);
+            attributes.put("searchDelay", betweenKeyUp);
+
+            //StartRequest
+            if (tableSuggestAjax.getStartRequest() != null) {
+                startRequest = tableSuggestAjax.getStartRequest().toString();
             }
-            else
-            {
-                out.writeAttribute(HTML.ID_ATTR,
-                        component.getClientId(context)+"_auto_complete", null);
+            else {
+                startRequest = Integer.toString(DEFAULT_START_REQUEST);
             }
-            if (tableSuggestAjax.getPopupStyle() != null)
-            {
-                out.writeAttribute(HTML.STYLE_ATTR, tableSuggestAjax.getPopupStyle(), null);
+            attributes.put("startRequest", startRequest);
+
+            //Autocomplete
+            if (tableSuggestAjax.getAutocomplete()!=null) {
+                autoComplete = tableSuggestAjax.getAutocomplete();
             }
-            else
-            {
-                out.writeAttribute(HTML.STYLE_ATTR,"display:inline;", null);
+            else {
+                autoComplete = DEFAULT_AUTO_COMPLETE;
             }
+            attributes.put("autoComplete", autoComplete);
 
-            out.endElement(HTML.DIV_ELEM);
+            //PopupId
+            if (tableSuggestAjax.getPopupId() != null) {
+                attributes.put("popupId", tableSuggestAjax.getPopupId());
+            }
 
-            out.endElement(HTML.TR_ELEM);
-            out.endElement(HTML.TD_ELEM);
-            out.endElement(HTML.TABLE_ELEM);
+            //PopupStyleClass
+            if (tableSuggestAjax.getPopupStyleClass() != null) {
+                attributes.put("popupStyleClass", tableSuggestAjax.getPopupStyleClass());
+            }
 
-            out.startElement(HTML.SCRIPT_ELEM, null);
-            out.writeAttribute(HTML.TYPE_ATTR, HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT, null);
+            //TableStyleClass
+            if (tableSuggestAjax.getTableStyleClass() != null) {
+                attributes.put("tableStyleClass", tableSuggestAjax.getTableStyleClass());
+            }
 
-            out.write(getEventHandlingCode(ajaxUrl, clientId, tableSuggestAjax).toString());
+            //ComboBoxStyleClass
+            if (tableSuggestAjax.getComboBoxStyleClass() != null) {
+                attributes.put("comboBoxStyleClass", tableSuggestAjax.getComboBoxStyleClass());
+            }
 
-            out.endElement(HTML.SCRIPT_ELEM);
-        }
-    }
+            //RowStyleClass
+            if (tableSuggestAjax.getRowStyleClass() != null) {
+                attributes.put("rowStyleClass", tableSuggestAjax.getRowStyleClass());
+            }
 
-    private StringBuffer getEventHandlingCode(String ajaxUrl, String clientId, TableSuggestAjax tableSuggestAjax)
-    {
-        FacesContext context = FacesContext.getCurrentInstance(); 
-        
-        int betweenKeyUp = 0;
-        int startRequest = 0;
-        String charset = null;
+            //EvenRowStyleClass
+            if (tableSuggestAjax.getEvenRowStyleClass() != null) {
+                attributes.put("evenRowStyleClass", tableSuggestAjax.getEvenRowStyleClass());
+            }
 
-        if (tableSuggestAjax.getBetweenKeyUp()!=null)
-            betweenKeyUp = tableSuggestAjax.getBetweenKeyUp().intValue();
-        else
-            betweenKeyUp = DEFAULT_BETWEEN_KEY_UP;
+            //OddRowStyleClass
+            if (tableSuggestAjax.getOddRowStyleClass() != null) {
+                attributes.put("oddRowStyleClass", tableSuggestAjax.getOddRowStyleClass());
+            }
 
-        if(tableSuggestAjax.getStartRequest()!=null)
-            startRequest = tableSuggestAjax.getStartRequest().intValue();
-        else
-            startRequest = DEFAULT_START_REQUEST;
+            //HoverRowStyleClass
+            if (tableSuggestAjax.getHoverRowStyleClass() != null) {
+                attributes.put("hoverRowStyleClass", tableSuggestAjax.getHoverRowStyleClass());
+            }
 
-        if (tableSuggestAjax.getCharset() != null)
-            charset = tableSuggestAjax.getCharset();
-        else
-            charset = "";
-        
-        StringBuffer buf = new StringBuffer();
-        String tableSuggestVar = "tableSuggest"+clientId.replace(':','_');
-        String fieldNames = this.getFieldNames(tableSuggestAjax, context);
-        String fieldNamesVar = tableSuggestVar + "_fieldNames";
-        String styleClassOptions = this.getStyleClassOptions(tableSuggestAjax);
-        String styleClassOptionsVar = tableSuggestVar + "_options";
-        
-        //doing ajax request and handling the response
-        buf.append( "var " + fieldNamesVar + " = " + fieldNames + ";\n"
-                   + "var " + styleClassOptionsVar + " = " + styleClassOptions + ";\n"
-                   + "var " + tableSuggestVar + " = new org_apache_myfaces_TableSuggest(\""+ ajaxUrl + "\", " 
-                   + betweenKeyUp + ", " + startRequest + ", \"" + charset + "\", " + tableSuggestAjax.getAcceptValueToField().toString() 
-                   + ", " + fieldNamesVar + ", " + styleClassOptionsVar + ");\n" 
-                   + "dojo.event.connect(dojo.byId(\"" + clientId + "\"), \"onkeyup\", function(evt) { " 
-                   + tableSuggestVar + ".decideRequest(evt); });\n"  
-                   + "dojo.event.connect(dojo.byId(\"" + clientId + "\"), \"onblur\", function(evt) { " 
-                   + tableSuggestVar + ".onBlur(evt); });\n" 
-                   + "dojo.event.connect(dojo.byId(\"" + clientId + "\"), \"onfocus\", function(evt) { " 
-                   + tableSuggestVar + ".onFocus(evt); });\n"
-                   + "dojo.event.connect(dojo.byId(\"" + clientId + "\"), \"onkeydown\", function(evt) { " 
-                   + "return " + tableSuggestVar + ".handleKeyDown(evt); });\n");
-
-        //if setting the focus outside the input field, popup should not be displayed
-        buf.append("dojo.event.connect(document, \"onclick\", function(evt) { " + tableSuggestVar + ".resetSettings(); });\n");
-        return buf;
+            DojoUtils.renderWidgetInitializationCode(context, component, "extensions:TableSuggest", attributes);
+
+            out.startElement(HTML.SCRIPT_ELEM, null);
+            out.writeAttribute(HTML.TYPE_ATTR, HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT, null);
+
+            StringBuffer buffer = new StringBuffer();
+
+            buffer.append("dojo.addOnLoad(function() {\n")
+                  .append(tableSuggestComponentVar).append(".textInputNode.id=\"").append(clientId).append("\";\n")
+                  .append(tableSuggestComponentVar).append(".textInputNode.value = \"").append(valueToRender).append("\";\n")
+                  .append(tableSuggestComponentVar).append(".comboBoxValue.value = \"").append(valueToRender).append("\";\n")
+                  .append(tableSuggestComponentVar).append(".onResize();\n")
+                  .append("});\n");
+
+            out.write(buffer.toString());
+
+            out.endElement(HTML.SCRIPT_ELEM);
+        }
     }
 
     public void decode(FacesContext facesContext, UIComponent component)
@@ -275,41 +242,19 @@
             renderResponse ( (TableSuggestAjax) uiComponent, context);
         }
     }
-
-    private void writeOneSuggestList(StringBuffer buf,Collection suggesteds,
-                                     FacesContext context, TableSuggestAjax tableSuggestAjax)
-    {
-        writeSuggestList(buf, suggesteds, context, tableSuggestAjax);
-    }
-
-    private void writeSuggestList(StringBuffer buf,Collection suggesteds,
-                                  FacesContext context, TableSuggestAjax tableSuggestAjax)
-    {
-        buf.append("<table");
-        if(tableSuggestAjax.getTableStyleClass()!=null)
-            buf.append(" class=\""+tableSuggestAjax.getTableStyleClass()+"\">");
-        else
-            buf.append(">");
-
-        buf.append(renderTableHeader(tableSuggestAjax.getChildren()));
-        buf.append(renderTableBody(tableSuggestAjax, suggesteds, context));
-
-        buf.append("</table>");
-
-        buf.append(renderNextPageField(tableSuggestAjax, context));
-    }
-
     
     //renders the response data in an XML format
     private void renderResponse(TableSuggestAjax tableSuggestAjax,
             FacesContext context) throws IOException
     {
-        
+
+        context.getResponseWriter().write("[");
         renderColumnHeaders(tableSuggestAjax, context);
         
         StringBuffer response = new StringBuffer();
+        response.append("[");
 
-        Collection suggestedItems = 
+        Collection suggestedItems =
             getSuggestedItems(context, tableSuggestAjax);
 
         if (getChildren(tableSuggestAjax) == null
@@ -325,8 +270,8 @@
             
             context.getExternalContext().getRequestMap().put(
                     tableSuggestAjax.getVar(), addressEntryObject);
-            
-            response.append("<item>");
+
+            response.append("[");
 
             Iterator columns = tableSuggestAjax.getChildren().iterator();
             while (columns.hasNext()) 
@@ -346,268 +291,60 @@
                     HtmlOutputText htmlOutputText = 
                         (HtmlOutputText) component;
 
-                    response.append("<column>");
+                    response.append("{");
                     
                     //foreign-key field is a simple text field
                     if (htmlOutputText.getFor() != null)
                     {
-                        response.append("<forText>");
-                        
+                        response.append("\"forText\": ");
                         String forText = RendererUtils.getClientId(context,
                                 tableSuggestAjax,
                                 htmlOutputText.getFor());
-                        
-                        response.append(forText);
-                                                
-                        response.append("</forText>");
-                        
-                        response.append("<label>");
-                        response.append(
-                                htmlOutputText.getLabel());
-                        response.append("</label>");
-                        
+                        response.append("\"").append(forText).append("\",");
+                        response.append("\"label\": ");
+                        response.append("\"").append(htmlOutputText.getLabel()).append("\"");
                     }
                     //foreign-key field is a combo-box field 
                     else if (htmlOutputText.getForValue() != null)
                     {
-                        response.append("<forValue>");
-                        
+                        response.append("\"forValue\": ");
                         String forValue = RendererUtils.getClientId(context,
                                 tableSuggestAjax,
                                 htmlOutputText.getForValue());
-                        
-                        response.append(forValue);
-                                                
-                        response.append("</forValue>");
-                        
-                        response.append("<label>");
-                        
-                        response.append(
-                                htmlOutputText.getLabel());
-                        response.append("</label>");
-                        
-                        response.append("<value>");
-                        
-                        response.append(
-                                htmlOutputText.getValue());
-                        response.append("</value>");
+                        response.append("\"").append(forValue).append("\",");
+                        response.append("\"label\": ");
+                        response.append("\"").append(htmlOutputText.getLabel()).append("\",");
+                        response.append("\"value\": ");
+                        response.append("\"").append(htmlOutputText.getValue()).append("\"");
                     } else {
-						response.append("<value>");
-                        response.append(htmlOutputText.getValue());
-                        response.append("</value>");
+                        response.append("\"label\": ");
+                        response.append("\"").append(htmlOutputText.getValue()).append("\"");
+                    }
+                    response.append("}");
+                    if (columnChildren.hasNext() || columns.hasNext()) {
+                        response.append(",");
                     }
-                    response.append("</column>");
                 }
             }
-            response.append("</item>");
+            response.append("]");
+            if (it.hasNext()) {
+                response.append(",");
+            }
         }
         
         context.getExternalContext().getRequestMap().remove(tableSuggestAjax.getVar());
+        response.append("]");
         context.getResponseWriter().write(response.toString());
+        context.getResponseWriter().write("]");
         
     }
-    
-    //Gather the names of the the primary field as well as all
-    //the foreign-key fields in the javascript array literal format:
-    // eg. [ field1, field2, field3 ]
-    private String getFieldNames(TableSuggestAjax tableSuggestAjax,
-            FacesContext context) 
-    {
-        StringBuffer fieldNames = new StringBuffer(); 
-        fieldNames.append("[");
-        
-        if (getChildren(tableSuggestAjax) == null
-                || getChildren(tableSuggestAjax).isEmpty())
-        {
-            return null;
-        }
-            
-        Iterator columns = tableSuggestAjax.getChildren().iterator();
-        boolean first = true;
-        while (columns.hasNext()) 
-        {
-            
-            if (first) 
-            {
-                first = false;
-            }
-            else 
-            {
-                fieldNames.append(",");
-            }
-            
-            UIComponent column = (UIComponent) columns.next();
-
-            Iterator columnChildren = column.getChildren().iterator(); 
-            while (columnChildren.hasNext())
-            {
-                Object component = columnChildren.next();
-                    
-                if (!(component instanceof HtmlOutputText)) 
-                {
-                    continue;
-                }
-                    
-                HtmlOutputText htmlOutputText = (HtmlOutputText) component;
-                    
-                //foreign-key field is a simple text field
-                if (htmlOutputText.getFor() != null)
-                {
-
-                    String fieldName = RendererUtils.getClientId(context,
-                            tableSuggestAjax,
-                            htmlOutputText.getFor());
-                        
-                    fieldNames.append("\"" + fieldName + "\"");                                                        
-                        
-                }
-                //foreign-key field is a combo-box field 
-                else if (htmlOutputText.getForValue() != null)
-                {
-                    String fieldName = RendererUtils.getClientId(context,
-                            tableSuggestAjax,
-                            htmlOutputText.getForValue());
-                    fieldNames.append("\"" + fieldName + "\"");
-                }        
-            }
-        }
-                
-        fieldNames.append("]");
-        return fieldNames.toString();
-    }   
-    
-    
-    //returns a javascript hashmap containing the style class settings
-    private String getStyleClassOptions(TableSuggestAjax tableSuggestAjax)
-    {
-        StringBuffer settings = new StringBuffer();
-        settings.append("{ ");
-        settings.append("tableStyleClass: "); 
-        settings.append("\"" + tableSuggestAjax.getTableStyleClass() + "\"");
-        settings.append(", ");
-        settings.append("columnOutClass: "); 
-        settings.append("\"" + tableSuggestAjax.getColumnOutClass() + "\"");
-        settings.append(", ");
-        settings.append("columnHoverClass: "); 
-        settings.append("\"" + tableSuggestAjax.getColumnHoverClass() + "\"");
-        settings.append(" }");
-        
-        return settings.toString();
-        
-    }
-    
-    
-    
-    
-    
-    private StringBuffer renderTableBody(TableSuggestAjax tableSuggestAjax,
-                                         Collection suggesteds,
-                                         FacesContext context)
-    {
-        StringBuffer bodyContent = new StringBuffer();
-
-        String clientId = tableSuggestAjax.getClientId(context);
-        String tableSuggestVar = clientId.replace(':','_');
-
-        bodyContent.append("<tbody>");
-
-        int i = 0;
-
-        for (Iterator suggestedEntry = suggesteds.iterator(); suggestedEntry.hasNext();)
-        {
-           Object addressEntryObject = suggestedEntry.next();
-
-           bodyContent.append("<tr id=\"row"+ (i+1) + clientId +"\" onmouseover=");
-            if(tableSuggestAjax.getColumnHoverClass()!=null)
-                bodyContent.append("\"this.className='")
-                        .append(tableSuggestAjax.getColumnHoverClass()).append("'\" ");
-
-            if(tableSuggestAjax.getColumnOutClass()!=null)
-                bodyContent.append("onmouseout=\"this.className='")
-                        .append(tableSuggestAjax.getColumnOutClass()).append("'\" ");
-
-            bodyContent.append("onclick=\"tableSuggest"+ tableSuggestVar +".putValueToField(this,'"+ clientId +"')\">");
-            i++;
-
-            context.getExternalContext().getRequestMap()
-                            .put(tableSuggestAjax.getVar(),addressEntryObject);
-
-            for (Iterator iterColumns = tableSuggestAjax.getChildren().iterator(); iterColumns.hasNext();)
-            {
-                UIComponent column = (UIComponent)iterColumns.next();
-
-                for (Iterator iterComps = column.getChildren().iterator(); iterComps.hasNext();)
-                {
-                    Object comp =  iterComps.next();
-
-                    if (comp instanceof HtmlOutputText)
-                    {
-                        HtmlOutputText htmlOutputText = (HtmlOutputText) comp;
-
-                        if (htmlOutputText.getLabel()!=null)
-                        {
-                            bodyContent.append("<td> <span ");
-                            if(htmlOutputText.getFor()!=null)
-                                bodyContent.append("id=\"putValueTo"+RendererUtils.getClientId(context, tableSuggestAjax, htmlOutputText.getFor()) + "\"");
-                                
-                            bodyContent.append(">" + htmlOutputText.getLabel() + "</span>");
-                            if (htmlOutputText.getValue()!=null)
-                            {
-                                bodyContent.append("<span id=\"putValueTo")
-                                        .append(RendererUtils.getClientId(context, tableSuggestAjax, htmlOutputText.getForValue()) + "\"")
-                                        .append(" style=\"display:none;\">" + htmlOutputText.getValue() + "</span>").append("</td>");
-                            }
-                            else
-                            {
-                                bodyContent.append("</td>");
-                                break;
-                            }
-                        }
-                    }
-                }
-            }
-            context.getExternalContext().getRequestMap().remove(tableSuggestAjax.getVar());
-            bodyContent.append("</tr>");
-        }
-
-        bodyContent.append("</tbody>");
-
-        return bodyContent;
-    }
-
-
-    private StringBuffer renderTableHeader(List columns)
-    {
-        StringBuffer headerContent = new StringBuffer();
-
-        headerContent.append("<thead><tr>");
-
-        for (Iterator iterColumns = columns.iterator(); iterColumns.hasNext();)
-        {
-            UIComponent column = (UIComponent)iterColumns.next();
-
-            if (column instanceof UIColumn)
-            {
-                UIComponent tableHeader = (UIComponent) column.getFacet("header");
-
-                if (tableHeader!=null &&
-                        tableHeader instanceof HtmlOutputText)
-                {
-                    HtmlOutputText htmlOutputText = (HtmlOutputText) tableHeader;
-                    headerContent.append("<th>").append(htmlOutputText.getValue()).append("</th>");
-                }
-            }
-        }
-
-        headerContent.append("</tr></thead>");
-        return headerContent;
-    }
 
     //renders column names in the XML response
     private void renderColumnHeaders(TableSuggestAjax tableSuggestAjax,
             FacesContext context) throws IOException
     {
         StringBuffer columnHeaders = new StringBuffer();
+        columnHeaders.append("[");
 
         Iterator it = tableSuggestAjax.getChildren().iterator();
         
@@ -619,45 +356,24 @@
             {
                 UIComponent tableHeader = (UIComponent) column.getFacet("header");
 
-                if (tableHeader != null &&
-                        tableHeader instanceof HtmlOutputText)
+                if (tableHeader != null && tableHeader instanceof HtmlOutputText)
                 {
-                    columnHeaders.append("<columnHeader>");
                     HtmlOutputText htmlOutputText = (HtmlOutputText) tableHeader;
-                    columnHeaders.append(htmlOutputText.getValue());
-                    columnHeaders.append("</columnHeader>");
+                    columnHeaders.append("\"").append(htmlOutputText.getValue()).append("\"");
+                    if (it.hasNext()) {
+                        columnHeaders.append(",");
+                    }
                 }
             }
         }
+        columnHeaders.append("],");
         context.getResponseWriter().write(columnHeaders.toString());
     }
-    
-    
-    
-    
-    
-    
-    
-    private StringBuffer renderNextPageField(TableSuggestAjax tableSuggestAjax,FacesContext context)
-    {
-        StringBuffer content = new StringBuffer();
-
-        String tableSuggestVar = tableSuggestAjax.getClientId(context).replace(':','_');
-
-        content.append("<div onclick=\"tableSuggest"+ tableSuggestVar +".nextPage(this)\"");
-        if(tableSuggestAjax.getNextPageFieldClass()!=null)
-            content.append(" class=\""+ tableSuggestAjax.getNextPageFieldClass() +"\" ");
 
-            String popUpStyle = tableSuggestAjax.getPopupStyle();
-            if(popUpStyle!=null && popUpStyle.indexOf("overflow:auto") > -1)
-                content.append("style=\"display:none;\"");
-
-        content.append(">. . . </div>");
-
-        return content;
+    private String escapeQuotes(String input)
+    {
+   	    return input != null ? input.replaceAll("\"", "\\\\\"") : "";
     }
 
 }
-
-
 

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/tablesuggestajax/TableSuggestAjaxTag.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/tablesuggestajax/TableSuggestAjaxTag.java?view=diff&rev=504531&r1=504530&r2=504531
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/tablesuggestajax/TableSuggestAjaxTag.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/tablesuggestajax/TableSuggestAjaxTag.java Wed Feb  7 04:52:15 2007
@@ -30,23 +30,18 @@
  */
 public class TableSuggestAjaxTag extends SuggestAjaxTag
 {
+    private String _var;
     private String _popupId;
-    private String _popupStyleClass;
-    private String _popupStyle;
-    private String _layout;
-
-    private String _tableStyleClass;
-    private String _nextPageFieldClass;
-
-    private String _columnHoverClass;
-    private String _columnOutClass;
-
     private String _betweenKeyUp;
     private String _startRequest;
 
-    private String _acceptValueToField;
-
-    private String _var;
+    private String _popupStyleClass;
+    private String _tableStyleClass;
+    private String _comboBoxStyleClass;
+    private String _rowStyleClass;
+    private String _evenRowStyleClass;
+    private String _oddRowStyleClass;
+    private String _hoverRowStyleClass;
 
     public String getComponentType() {
         return TableSuggestAjax.COMPONENT_TYPE;
@@ -61,37 +56,34 @@
         super.release();
 
        _var = null;
-       _columnHoverClass = null;
-       _columnOutClass = null;
+       _popupId = null;
        _betweenKeyUp = null;
        _startRequest = null;
        _tableStyleClass = null;
-       _nextPageFieldClass = null;
-       _acceptValueToField = null;
-       _popupId = null;
        _popupStyleClass = null;
-       _popupStyle = null;
-       _layout = null;
+       _comboBoxStyleClass = null;
+       _rowStyleClass = null;
+       _evenRowStyleClass = null;
+       _oddRowStyleClass = null;
+       _hoverRowStyleClass = null;
     }
 
     protected void setProperties(UIComponent component) {
 
         super.setProperties(component);
 
+        setStringProperty(component, JSFAttr.VAR_ATTR, _var);
+        setStringProperty(component,"popupId",_popupId);
         setIntegerProperty(component,"betweenKeyUp",_betweenKeyUp);
         setIntegerProperty(component,"startRequest", _startRequest);
 
-        setStringProperty(component,"columnHoverClass",_columnHoverClass);
-        setStringProperty(component,"columnOutClass",_columnOutClass);
         setStringProperty(component,"tableStyleClass",_tableStyleClass);
-        setStringProperty(component,"nextPageFieldClass",_nextPageFieldClass);
-        setBooleanProperty(component,"acceptValueToField",_acceptValueToField);
-        setStringProperty(component,"popupId",_popupId);
         setStringProperty(component,"popupStyleClass",_popupStyleClass);
-        setStringProperty(component,"popupStyle",_popupStyle);
-        setStringProperty(component,"layout",_layout);
-
-        setStringProperty(component, JSFAttr.VAR_ATTR, _var);
+        setStringProperty(component,"comboBoxStyleClass",_comboBoxStyleClass);
+        setStringProperty(component,"rowStyleClass",_rowStyleClass);
+        setStringProperty(component,"evenRowStyleClass",_evenRowStyleClass);
+        setStringProperty(component,"oddRowStyleClass",_oddRowStyleClass);
+        setStringProperty(component,"hoverRowStyleClass",_hoverRowStyleClass);
     }
 
     // setter methodes to populate the components properites
@@ -115,43 +107,34 @@
         _var = var;
     }
 
-    public void setColumnHoverClass(String columnHoverClass)
+    public void setPopupId(String popupId)
     {
-        _columnHoverClass = columnHoverClass;
+        _popupId = popupId;
     }
 
-    public void setColumnOutClass(String columnOutClass)
+    public void setPopupStyleClass(String popupStyleClass)
     {
-        _columnOutClass = columnOutClass;
+        _popupStyleClass = popupStyleClass;
     }
 
-    public void setNextPageFieldClass(String nextPageFieldClass)
-    {
-        _nextPageFieldClass = nextPageFieldClass;
+    public void setComboBoxStyleClass(String comboBoxStyleClass) {
+        _comboBoxStyleClass = comboBoxStyleClass;
     }
 
-    public void setAcceptValueToField(String acceptValueToField)
-    {
-        _acceptValueToField = acceptValueToField;
+    public void setRowStyleClass(String rowStyleClass) {
+        _rowStyleClass = rowStyleClass;
     }
 
-    public void setLayout(String layout)
-    {
-        _layout = layout;
+    public void setEvenRowStyleClass(String evenRowStyleClass) {
+        _evenRowStyleClass = evenRowStyleClass;
     }
 
-        public void setPopupId(String popupId)
-    {
-        _popupId = popupId;
+    public void setOddRowStyleClass(String oddRowStyleClass) {
+        _oddRowStyleClass = oddRowStyleClass;
     }
 
-    public void setPopupStyleClass(String popupStyleClass)
-    {
-        _popupStyleClass = popupStyleClass;
+    public void setHoverRowStyleClass(String hoverRowStyleClass) {
+        _hoverRowStyleClass = hoverRowStyleClass;
     }
 
-    public void setPopupStyle(String popupStyle)
-    {
-        _popupStyle = popupStyle;
-    }
 }

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/table_suggest_ajax_attributes.xml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/table_suggest_ajax_attributes.xml?view=diff&rev=504531&r1=504530&r2=504531
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/table_suggest_ajax_attributes.xml (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/table_suggest_ajax_attributes.xml Wed Feb  7 04:52:15 2007
@@ -11,16 +11,6 @@
 </attribute>
 
 <attribute>
-    <name>acceptValueToField</name>
-    <required>false</required>
-    <rtexprvalue>false</rtexprvalue>
-    <type>java.lang.String</type>
-    <description>If set to true and if there is only one suggested column, values are put mandatory to
-                 the corresponding dom nodes.
-    </description>
-</attribute>
-
-<attribute>
     <name>startRequest</name>
     <required>false</required>
     <rtexprvalue>false</rtexprvalue>
@@ -31,76 +21,76 @@
 </attribute>
 
 <attribute>
-    <name>tableStyleClass</name>
+    <name>var</name>
     <required>false</required>
     <rtexprvalue>false</rtexprvalue>
     <type>java.lang.String</type>
-    <description>StyleClass for the suggested table.</description>
+    <description>Same principle as it can be found in dataTable. SuggestedItemsMethod returns
+                 a list of objects, where the class variables can be accessed with the alias after the
+                 dot of the var.
+    </description>
 </attribute>
 
 <attribute>
-    <name>nextPageFieldClass</name>
+    <name>popupId</name>
     <required>false</required>
     <rtexprvalue>false</rtexprvalue>
     <type>java.lang.String</type>
-    <description>StyleClass for the div field which steps to next page</description>
+    <description>Id for the pop up window</description>
 </attribute>
 
 <attribute>
-    <name>columnHoverClass</name>
+    <name>popupStyleClass</name>
     <required>false</required>
     <rtexprvalue>false</rtexprvalue>
     <type>java.lang.String</type>
-    <description>StyleClass for a onmouseover event of the suggested columns</description>
+    <description>StyleClass for the window with a suggested list of items;pop up for each incoming Ajax response</description>
 </attribute>
 
 <attribute>
-    <name>columnOutClass</name>
+    <name>tableStyleClass</name>
     <required>false</required>
     <rtexprvalue>false</rtexprvalue>
     <type>java.lang.String</type>
-    <description>StyleClass for a onmouseout event of the suggested columns</description>
+    <description>StyleClass for the suggested table.</description>
 </attribute>
 
 <attribute>
-    <name>var</name>
+    <name>comboBoxStyleClass</name>
     <required>false</required>
     <rtexprvalue>false</rtexprvalue>
     <type>java.lang.String</type>
-    <description>Same principle as it can be found in dataTable. SuggestedItemsMethod returns
-                 a list of objects, where the class variables can be accessed with the alias after the
-                 dot of the var.
-    </description>
+    <description>StyleClass for dropdown box and arrow.</description>
 </attribute>
 
 <attribute>
-    <name>layout</name>
+    <name>rowStyleClass</name>
     <required>false</required>
     <rtexprvalue>false</rtexprvalue>
     <type>java.lang.String</type>
-    <description></description>
+    <description>StyleClass which applies to every row in the suggested table.</description>
 </attribute>
 
 <attribute>
-    <name>popupStyle</name>
+    <name>evenRowStyleClass</name>
     <required>false</required>
     <rtexprvalue>false</rtexprvalue>
     <type>java.lang.String</type>
-    <description>Style for the window with a suggested list of items;pop up for each incoming Ajax response</description>
+    <description>StyleClass which only applies to even rows in the suggested table.</description>
 </attribute>
 
 <attribute>
-    <name>popupStyleClass</name>
+    <name>oddRowStyleClass</name>
     <required>false</required>
     <rtexprvalue>false</rtexprvalue>
     <type>java.lang.String</type>
-    <description>StyleClass for the window with a suggested list of items;pop up for each incoming Ajax response</description>
+    <description>StyleClass which only applies to odd rows in the suggested table.</description>
 </attribute>
 
 <attribute>
-    <name>popupId</name>
+    <name>hoverRowStyleClass</name>
     <required>false</required>
     <rtexprvalue>false</rtexprvalue>
     <type>java.lang.String</type>
-    <description>Id for the pop up window</description>
-</attribute>
\ No newline at end of file
+    <description>StyleClass for the rows for onmouseover events.</description>
+</attribute>

Modified: myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/css/basic.css
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/css/basic.css?view=diff&rev=504531&r1=504530&r2=504531
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/css/basic.css (original)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/css/basic.css Wed Feb  7 04:52:15 2007
@@ -1,4 +1,4 @@
-body, td {
+body, td, th {
 	font-family : arial, verdana, Geneva, Arial, Helvetica, sans-serif;
     font-size : 12px;
 }

Modified: myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/tableSuggestAjax.jsp
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/tableSuggestAjax.jsp?view=diff&rev=504531&r1=504530&r2=504531
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/tableSuggestAjax.jsp (original)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/tableSuggestAjax.jsp Wed Feb  7 04:52:15 2007
@@ -41,11 +41,8 @@
         <h:panelGrid columns="4">
          <f:verbatim> City Names starting with 'Sa' <br/> Suggest starts with 2. char </f:verbatim>
          <s:tableSuggestAjax var="address" id="suggest" startRequest="2"
-                             nextPageFieldClass="ajaxNextTablePageField"
                              value="#{inputSuggestAjax.suggestValue}" betweenKeyUp="300"
-                             columnOutClass="tableSuggestOut" columnHoverClass="tableSuggestHover"
-                             suggestedItemsMethod="#{inputSuggestAjax.getCityList}"
-                             tableStyleClass="ajaxTable" charset="utf-8">
+                             suggestedItemsMethod="#{inputSuggestAjax.getCityList}" charset="utf-8">
             <t:column>
                  <f:facet name="header">
                      <s:outputText value="City"/>
@@ -89,4 +86,5 @@
 </body>
 
 </html>
+