You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ma...@apache.org on 2006/08/01 19:44:01 UTC

svn commit: r427657 [29/42] - in /myfaces: core/trunk/api/src/main/java/javax/faces/component/ core/trunk/api/src/test/java/javax/faces/ core/trunk/api/src/test/java/javax/faces/application/ core/trunk/api/src/test/java/javax/faces/component/ core/trun...

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/accordion/HtmlAccordionPanelRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/accordion/HtmlAccordionPanelRenderer.java?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/accordion/HtmlAccordionPanelRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/accordion/HtmlAccordionPanelRenderer.java Tue Aug  1 10:43:28 2006
@@ -1,389 +1,389 @@
-/**
- * Copyright 2004 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.
- */
-package org.apache.myfaces.custom.accordion;
-
-import org.apache.myfaces.renderkit.html.util.AddResource;
-import org.apache.myfaces.renderkit.html.util.AddResourceFactory;
-import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
-import org.apache.myfaces.custom.tabbedpane.HtmlPanelTab;
-import org.apache.myfaces.shared_tomahawk.renderkit.JSFAttr;
-import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils;
-import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils;
-import org.apache.myfaces.renderkit.html.ext.HtmlGroupRenderer;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-
-/**
- * @author Martin Marinschek
- *
- *
- *
- * @version $Revision: $ $Date: $
- *          <p/>
- */
-public class HtmlAccordionPanelRenderer extends HtmlGroupRenderer
-{
-    public void encodeBegin(FacesContext context, UIComponent component) throws IOException
-    {
-        encodeJavascript(context, component);
-
-        super.encodeBegin(context, component);
-    }
-
-    public void encodeChildren(FacesContext context, UIComponent component) throws IOException
-    {
-    }
-
-    public void encodeEnd(FacesContext context, UIComponent component) throws IOException
-    {
-        RendererUtils.checkParamValidity(context, component, HtmlAccordionPanel.class);
-
-        HtmlAccordionPanel panel = (HtmlAccordionPanel) component;
-
-        ResponseWriter writer = context.getResponseWriter();
-
-        writer.startElement(HTML.DIV_ELEM, component);
-        writer.writeAttribute(HTML.ID_ATTR,component.getClientId(context), JSFAttr.ID_ATTR);
-        HtmlRendererUtils.renderHTMLAttributes(writer, component, HTML.COMMON_PASSTROUGH_ATTRIBUTES);
-
-        List childExpanded = panel.getChildExpanded();
-
-        if (component.getChildCount() > 0)
-        {
-            int i = 0;
-            for (Iterator it = component.getChildren().iterator(); it.hasNext(); i++)
-            {
-                UIComponent child = (UIComponent)it.next();
-
-                if(child instanceof HtmlPanelTab)
-                {
-                    HtmlPanelTab pane = (HtmlPanelTab) child;
-                    writer.startElement(HTML.DIV_ELEM, child);
-                    writer.writeAttribute(HTML.ID_ATTR,
-                                          child.getClientId(context) + "_MAIN_DIV",
-                                          JSFAttr.ID_ATTR);
-
-                    writer.startElement(HTML.DIV_ELEM, child);
-                    writer.writeAttribute(HTML.ID_ATTR,
-                                          child.getClientId(context) + "_HEADER_DIV",
-                                          JSFAttr.ID_ATTR);
-                    if(pane.getLabel() != null)
-                    {
-                        writer.writeText(pane.getLabel(), JSFAttr.LABEL_ATTR);
-                    }
-                    else
-                    {
-                        UIComponent header = pane.getFacet("header");
-
-                        if(header == null)
-                        {
-                            throw new IllegalStateException("You need to set a label on the tab or include a facet with name 'header' into it.");
-                        }
-
-                        RendererUtils.renderChild(context, header);
-                    }
-                    writer.endElement(HTML.DIV_ELEM);
-
-                    UIComponent closedContent = pane.getFacet("closedContent");
-
-                    if(closedContent != null)
-                    {
-                        writer.startElement(HTML.DIV_ELEM, child);
-                        writer.writeAttribute(HTML.ID_ATTR,
-                                              child.getClientId(context) + "_CLOSED_CONTENT_DIV",
-                                              JSFAttr.ID_ATTR);
-                        RendererUtils.renderChild(context, closedContent);
-                        writer.endElement(HTML.DIV_ELEM);
-                    }
-
-                    writer.startElement(HTML.DIV_ELEM, child);
-                    writer.writeAttribute(HTML.ID_ATTR,
-                                          child.getClientId(context) + "_CONTENT_DIV",
-                                          JSFAttr.ID_ATTR);
-                    RendererUtils.renderChildren(context, child);
-                    writer.endElement(HTML.DIV_ELEM);
-
-                    //stateholder hidden input
-                    String stateID = child.getClientId(context) + HtmlAccordionPanel.EXPAND_STATEHOLDER_ID;
-                    writer.startElement(HTML.INPUT_ELEM, child);
-                    writer.writeAttribute(HTML.ID_ATTR,
-                                          stateID,
-                                          JSFAttr.ID_ATTR);
-                    //must be setted, else not included in requestmap
-                    writer.writeAttribute(HTML.NAME_ATTR,
-                                          stateID,
-                                          null);
-                    writer.writeAttribute(HTML.TYPE_ATTR,
-                                          HTML.INPUT_TYPE_HIDDEN,
-                                          JSFAttr.TYPE_ATTR);
-                    Object o = childExpanded.get(i);
-                    if(o instanceof Integer)
-                    {
-                        writer.writeAttribute(HTML.VALUE_ATTR,
-                                              o,
-                                              JSFAttr.VALUE_ATTR);
-                    }
-                    writer.endElement(HTML.INPUT_ELEM);
-
-                    writer.endElement(HTML.DIV_ELEM);
-
-                }
-                else
-                {
-                    throw new IllegalStateException("no other children accepted");
-                }
-            }
-        }
-
-        writer.endElement(HTML.DIV_ELEM);
-
-        writer.startElement(HTML.SCRIPT_ELEM, component);
-        writer.writeAttribute(HTML.SCRIPT_TYPE_ATTR,
-                              HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT,
-                              null);
-
-        String jsObjectName = "options";
-        encodeOptions(writer, panel, jsObjectName);
-
-        String id = component.getClientId(context);
-
-        if(panel.getLayout().equals(HtmlAccordionPanel.ACCORDION_LAYOUT))
-        {
-            writer.writeText("new Rico.Accordion.Custom('"+ id +"', " + jsObjectName + ");",
-                             null);
-        }
-        else if(panel.getLayout().equals(HtmlAccordionPanel.TOGGLING_LAYOUT))
-        {
-            writer.writeText("new Rico.Toggler.Custom('" + id + "', " + jsObjectName + ");",
-                             null);
-        }
-        else
-        {
-            throw new IllegalStateException("nothing known about layout : " +
-                                            panel.getLayout());
-        }
-
-        writer.endElement(HTML.SCRIPT_ELEM);
-    }
-
-
-    public void decode(FacesContext context, UIComponent component)
-    {
-        super.decode(context, component);
-
-        RendererUtils.checkParamValidity(context, component, HtmlAccordionPanel.class);
-
-        HtmlAccordionPanel panel = (HtmlAccordionPanel) component;
-
-        Map requestParams = context.getExternalContext().getRequestParameterMap();
-
-        if(panel.getChildCount() > 0)
-        {
-            int i = 0;
-            List list = panel.getChildExpanded();
-
-            for (Iterator it = component.getChildren().iterator(); it.hasNext(); i++)
-            {
-                UIComponent child = (UIComponent)it.next();
-
-                if(child instanceof HtmlPanelTab)
-                {
-                    String stateID = child.getClientId(context) + HtmlAccordionPanel.EXPAND_STATEHOLDER_ID;
-                    String stateValue = (String)requestParams.get(stateID);
-
-                    try
-                    {
-                        Integer cur = Integer.valueOf(stateValue);
-                        list.set(i, cur);
-                    }
-                    catch(NumberFormatException e)
-                    {
-                        e.printStackTrace();
-                    }
-                }
-            }
-            panel.setChildExpanded(list);
-        }
-    }
-
-
-    /**
-     * Encodes any stand-alone javascript functions that are needed.
-     * Uses either the extension filter, or a
-     * user-supplied location for the javascript files.
-     *
-     * @param context FacesContext
-     * @param component UIComponent
-     */
-    private void encodeJavascript(FacesContext context, UIComponent component)
-    {
-        // AddResource takes care to add only one reference to the same script
-        String javascriptLocation = (String)component.getAttributes().get(JSFAttr.JAVASCRIPT_LOCATION);
-        AddResource addResource = AddResourceFactory.getInstance(context);
-        if(javascriptLocation != null)
-        {
-            // add user defined javascripts
-            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, javascriptLocation + "/dpdump.js");
-            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, javascriptLocation + "/prototype.js");
-            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, javascriptLocation + "/rico.js");
-            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, javascriptLocation + "/toggler.js");
-            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, javascriptLocation + "/customRico.js");
-        }
-        else
-        {
-            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, HtmlAccordionPanelRenderer.class, "dpdump.js");
-            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, HtmlAccordionPanelRenderer.class, "prototype.js");
-            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, HtmlAccordionPanelRenderer.class, "rico.js");
-            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, HtmlAccordionPanelRenderer.class, "toggler.js");
-            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, HtmlAccordionPanelRenderer.class, "customRico.js");
-        }
-    }
-
-
-    /**
-     * Writes the style options for the given {@link HtmlAccordionPanel}.
-     *
-     * @param writer the {@link ResponseWriter} of the current {@link FacesContext}.
-     * @param panel the {@link HtmlAccordionPanel} to encode.
-     *
-     * @throws IOException
-     */
-
-    private void encodeOptions(ResponseWriter writer,
-                               HtmlAccordionPanel panel,
-                               String jsObjectName)
-                                throws IOException
-    {
-        writer.writeText("var " + jsObjectName + " = new Object();", null);
-
-        if(panel.getExpandedBackColor() != null)
-        {
-            String statement;
-            statement = getJSPropertySetString(jsObjectName,
-                                               HtmlAccordionPanel.EXPANDED_BACK_COLOR,
-                                               panel.getExpandedBackColor());
-
-            writer.writeText(statement, null);
-        }
-        if(panel.getExpandedTextColor() != null)
-        {
-            String statement;
-            statement = getJSPropertySetString(jsObjectName,
-                                               HtmlAccordionPanel.EXPANDED_TEXT_COLOR,
-                                               panel.getExpandedTextColor());
-
-            writer.writeText(statement, null);
-        }
-        if(panel.getExpandedFontWeight() != null)
-        {
-            String statement;
-            statement = getJSPropertySetString(jsObjectName,
-                                               HtmlAccordionPanel.EXPANDED_FONT_WEIGHT,
-                                               panel.getExpandedFontWeight());
-
-            writer.writeText(statement, null);
-        }
-
-        if(panel.getCollapsedBackColor() != null)
-        {
-            String statement;
-            statement = getJSPropertySetString(jsObjectName,
-                                               HtmlAccordionPanel.COLLAPSED_BACK_COLOR,
-                                               panel.getCollapsedBackColor());
-
-            writer.writeText(statement, null);
-        }
-        if(panel.getCollapsedTextColor() != null)
-        {
-            String statement;
-            statement = getJSPropertySetString(jsObjectName,
-                                               HtmlAccordionPanel.COLLAPSED_TEXT_COLOR,
-                                               panel.getCollapsedTextColor());
-
-            writer.writeText(statement, null);
-        }
-        if(panel.getCollapsedFontWeight() != null)
-        {
-            String statement;
-            statement = getJSPropertySetString(jsObjectName,
-                                               HtmlAccordionPanel.COLLAPSED_FONT_WEIGHT,
-                                               panel.getCollapsedFontWeight());
-
-            writer.writeText(statement, null);
-        }
-
-        if(panel.getHoverBackColor() != null)
-        {
-            String statement;
-            statement = getJSPropertySetString(jsObjectName,
-                                               HtmlAccordionPanel.HOVER_BACK_COLOR,
-                                               panel.getHoverBackColor());
-
-            writer.writeText(statement, null);
-        }
-        if(panel.getHoverTextColor() != null)
-        {
-            String statement;
-            statement = getJSPropertySetString(jsObjectName,
-                                               HtmlAccordionPanel.HOVER_TEXT_COLOR,
-                                               panel.getHoverTextColor());
-
-            writer.writeText(statement, null);
-        }
-
-        if(panel.getBorderColor() != null)
-        {
-            String statement;
-            statement = getJSPropertySetString(jsObjectName,
-                                               HtmlAccordionPanel.BORDER_COLOR,
-                                               panel.getBorderColor());
-
-            writer.writeText(statement, null);
-        }
-    }
-
-
-    /**
-     * Builds a set statement for a property of an Javascript Object.
-     *
-     * @param object the name of the Javascript object.
-     * @param property the name of the object's property.
-     * @param value the new value of the property.
-     *
-     * @return a set statement for a Javascript object.
-     */
-
-    private String getJSPropertySetString(String object,
-                                          String property,
-                                          String value)
-    {
-        StringBuffer sb = new StringBuffer();
-        sb.append(object);
-        sb.append(".");
-        sb.append(property);
-        sb.append("='");
-        sb.append(value);
-        sb.append("';");
-        return sb.toString();
-    }
-}
+/**
+ * Copyright 2004 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.
+ */
+package org.apache.myfaces.custom.accordion;
+
+import org.apache.myfaces.renderkit.html.util.AddResource;
+import org.apache.myfaces.renderkit.html.util.AddResourceFactory;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
+import org.apache.myfaces.custom.tabbedpane.HtmlPanelTab;
+import org.apache.myfaces.shared_tomahawk.renderkit.JSFAttr;
+import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils;
+import org.apache.myfaces.renderkit.html.ext.HtmlGroupRenderer;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * @author Martin Marinschek
+ *
+ *
+ *
+ * @version $Revision: $ $Date: $
+ *          <p/>
+ */
+public class HtmlAccordionPanelRenderer extends HtmlGroupRenderer
+{
+    public void encodeBegin(FacesContext context, UIComponent component) throws IOException
+    {
+        encodeJavascript(context, component);
+
+        super.encodeBegin(context, component);
+    }
+
+    public void encodeChildren(FacesContext context, UIComponent component) throws IOException
+    {
+    }
+
+    public void encodeEnd(FacesContext context, UIComponent component) throws IOException
+    {
+        RendererUtils.checkParamValidity(context, component, HtmlAccordionPanel.class);
+
+        HtmlAccordionPanel panel = (HtmlAccordionPanel) component;
+
+        ResponseWriter writer = context.getResponseWriter();
+
+        writer.startElement(HTML.DIV_ELEM, component);
+        writer.writeAttribute(HTML.ID_ATTR,component.getClientId(context), JSFAttr.ID_ATTR);
+        HtmlRendererUtils.renderHTMLAttributes(writer, component, HTML.COMMON_PASSTROUGH_ATTRIBUTES);
+
+        List childExpanded = panel.getChildExpanded();
+
+        if (component.getChildCount() > 0)
+        {
+            int i = 0;
+            for (Iterator it = component.getChildren().iterator(); it.hasNext(); i++)
+            {
+                UIComponent child = (UIComponent)it.next();
+
+                if(child instanceof HtmlPanelTab)
+                {
+                    HtmlPanelTab pane = (HtmlPanelTab) child;
+                    writer.startElement(HTML.DIV_ELEM, child);
+                    writer.writeAttribute(HTML.ID_ATTR,
+                                          child.getClientId(context) + "_MAIN_DIV",
+                                          JSFAttr.ID_ATTR);
+
+                    writer.startElement(HTML.DIV_ELEM, child);
+                    writer.writeAttribute(HTML.ID_ATTR,
+                                          child.getClientId(context) + "_HEADER_DIV",
+                                          JSFAttr.ID_ATTR);
+                    if(pane.getLabel() != null)
+                    {
+                        writer.writeText(pane.getLabel(), JSFAttr.LABEL_ATTR);
+                    }
+                    else
+                    {
+                        UIComponent header = pane.getFacet("header");
+
+                        if(header == null)
+                        {
+                            throw new IllegalStateException("You need to set a label on the tab or include a facet with name 'header' into it.");
+                        }
+
+                        RendererUtils.renderChild(context, header);
+                    }
+                    writer.endElement(HTML.DIV_ELEM);
+
+                    UIComponent closedContent = pane.getFacet("closedContent");
+
+                    if(closedContent != null)
+                    {
+                        writer.startElement(HTML.DIV_ELEM, child);
+                        writer.writeAttribute(HTML.ID_ATTR,
+                                              child.getClientId(context) + "_CLOSED_CONTENT_DIV",
+                                              JSFAttr.ID_ATTR);
+                        RendererUtils.renderChild(context, closedContent);
+                        writer.endElement(HTML.DIV_ELEM);
+                    }
+
+                    writer.startElement(HTML.DIV_ELEM, child);
+                    writer.writeAttribute(HTML.ID_ATTR,
+                                          child.getClientId(context) + "_CONTENT_DIV",
+                                          JSFAttr.ID_ATTR);
+                    RendererUtils.renderChildren(context, child);
+                    writer.endElement(HTML.DIV_ELEM);
+
+                    //stateholder hidden input
+                    String stateID = child.getClientId(context) + HtmlAccordionPanel.EXPAND_STATEHOLDER_ID;
+                    writer.startElement(HTML.INPUT_ELEM, child);
+                    writer.writeAttribute(HTML.ID_ATTR,
+                                          stateID,
+                                          JSFAttr.ID_ATTR);
+                    //must be setted, else not included in requestmap
+                    writer.writeAttribute(HTML.NAME_ATTR,
+                                          stateID,
+                                          null);
+                    writer.writeAttribute(HTML.TYPE_ATTR,
+                                          HTML.INPUT_TYPE_HIDDEN,
+                                          JSFAttr.TYPE_ATTR);
+                    Object o = childExpanded.get(i);
+                    if(o instanceof Integer)
+                    {
+                        writer.writeAttribute(HTML.VALUE_ATTR,
+                                              o,
+                                              JSFAttr.VALUE_ATTR);
+                    }
+                    writer.endElement(HTML.INPUT_ELEM);
+
+                    writer.endElement(HTML.DIV_ELEM);
+
+                }
+                else
+                {
+                    throw new IllegalStateException("no other children accepted");
+                }
+            }
+        }
+
+        writer.endElement(HTML.DIV_ELEM);
+
+        writer.startElement(HTML.SCRIPT_ELEM, component);
+        writer.writeAttribute(HTML.SCRIPT_TYPE_ATTR,
+                              HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT,
+                              null);
+
+        String jsObjectName = "options";
+        encodeOptions(writer, panel, jsObjectName);
+
+        String id = component.getClientId(context);
+
+        if(panel.getLayout().equals(HtmlAccordionPanel.ACCORDION_LAYOUT))
+        {
+            writer.writeText("new Rico.Accordion.Custom('"+ id +"', " + jsObjectName + ");",
+                             null);
+        }
+        else if(panel.getLayout().equals(HtmlAccordionPanel.TOGGLING_LAYOUT))
+        {
+            writer.writeText("new Rico.Toggler.Custom('" + id + "', " + jsObjectName + ");",
+                             null);
+        }
+        else
+        {
+            throw new IllegalStateException("nothing known about layout : " +
+                                            panel.getLayout());
+        }
+
+        writer.endElement(HTML.SCRIPT_ELEM);
+    }
+
+
+    public void decode(FacesContext context, UIComponent component)
+    {
+        super.decode(context, component);
+
+        RendererUtils.checkParamValidity(context, component, HtmlAccordionPanel.class);
+
+        HtmlAccordionPanel panel = (HtmlAccordionPanel) component;
+
+        Map requestParams = context.getExternalContext().getRequestParameterMap();
+
+        if(panel.getChildCount() > 0)
+        {
+            int i = 0;
+            List list = panel.getChildExpanded();
+
+            for (Iterator it = component.getChildren().iterator(); it.hasNext(); i++)
+            {
+                UIComponent child = (UIComponent)it.next();
+
+                if(child instanceof HtmlPanelTab)
+                {
+                    String stateID = child.getClientId(context) + HtmlAccordionPanel.EXPAND_STATEHOLDER_ID;
+                    String stateValue = (String)requestParams.get(stateID);
+
+                    try
+                    {
+                        Integer cur = Integer.valueOf(stateValue);
+                        list.set(i, cur);
+                    }
+                    catch(NumberFormatException e)
+                    {
+                        e.printStackTrace();
+                    }
+                }
+            }
+            panel.setChildExpanded(list);
+        }
+    }
+
+
+    /**
+     * Encodes any stand-alone javascript functions that are needed.
+     * Uses either the extension filter, or a
+     * user-supplied location for the javascript files.
+     *
+     * @param context FacesContext
+     * @param component UIComponent
+     */
+    private void encodeJavascript(FacesContext context, UIComponent component)
+    {
+        // AddResource takes care to add only one reference to the same script
+        String javascriptLocation = (String)component.getAttributes().get(JSFAttr.JAVASCRIPT_LOCATION);
+        AddResource addResource = AddResourceFactory.getInstance(context);
+        if(javascriptLocation != null)
+        {
+            // add user defined javascripts
+            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, javascriptLocation + "/dpdump.js");
+            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, javascriptLocation + "/prototype.js");
+            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, javascriptLocation + "/rico.js");
+            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, javascriptLocation + "/toggler.js");
+            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, javascriptLocation + "/customRico.js");
+        }
+        else
+        {
+            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, HtmlAccordionPanelRenderer.class, "dpdump.js");
+            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, HtmlAccordionPanelRenderer.class, "prototype.js");
+            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, HtmlAccordionPanelRenderer.class, "rico.js");
+            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, HtmlAccordionPanelRenderer.class, "toggler.js");
+            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, HtmlAccordionPanelRenderer.class, "customRico.js");
+        }
+    }
+
+
+    /**
+     * Writes the style options for the given {@link HtmlAccordionPanel}.
+     *
+     * @param writer the {@link ResponseWriter} of the current {@link FacesContext}.
+     * @param panel the {@link HtmlAccordionPanel} to encode.
+     *
+     * @throws IOException
+     */
+
+    private void encodeOptions(ResponseWriter writer,
+                               HtmlAccordionPanel panel,
+                               String jsObjectName)
+                                throws IOException
+    {
+        writer.writeText("var " + jsObjectName + " = new Object();", null);
+
+        if(panel.getExpandedBackColor() != null)
+        {
+            String statement;
+            statement = getJSPropertySetString(jsObjectName,
+                                               HtmlAccordionPanel.EXPANDED_BACK_COLOR,
+                                               panel.getExpandedBackColor());
+
+            writer.writeText(statement, null);
+        }
+        if(panel.getExpandedTextColor() != null)
+        {
+            String statement;
+            statement = getJSPropertySetString(jsObjectName,
+                                               HtmlAccordionPanel.EXPANDED_TEXT_COLOR,
+                                               panel.getExpandedTextColor());
+
+            writer.writeText(statement, null);
+        }
+        if(panel.getExpandedFontWeight() != null)
+        {
+            String statement;
+            statement = getJSPropertySetString(jsObjectName,
+                                               HtmlAccordionPanel.EXPANDED_FONT_WEIGHT,
+                                               panel.getExpandedFontWeight());
+
+            writer.writeText(statement, null);
+        }
+
+        if(panel.getCollapsedBackColor() != null)
+        {
+            String statement;
+            statement = getJSPropertySetString(jsObjectName,
+                                               HtmlAccordionPanel.COLLAPSED_BACK_COLOR,
+                                               panel.getCollapsedBackColor());
+
+            writer.writeText(statement, null);
+        }
+        if(panel.getCollapsedTextColor() != null)
+        {
+            String statement;
+            statement = getJSPropertySetString(jsObjectName,
+                                               HtmlAccordionPanel.COLLAPSED_TEXT_COLOR,
+                                               panel.getCollapsedTextColor());
+
+            writer.writeText(statement, null);
+        }
+        if(panel.getCollapsedFontWeight() != null)
+        {
+            String statement;
+            statement = getJSPropertySetString(jsObjectName,
+                                               HtmlAccordionPanel.COLLAPSED_FONT_WEIGHT,
+                                               panel.getCollapsedFontWeight());
+
+            writer.writeText(statement, null);
+        }
+
+        if(panel.getHoverBackColor() != null)
+        {
+            String statement;
+            statement = getJSPropertySetString(jsObjectName,
+                                               HtmlAccordionPanel.HOVER_BACK_COLOR,
+                                               panel.getHoverBackColor());
+
+            writer.writeText(statement, null);
+        }
+        if(panel.getHoverTextColor() != null)
+        {
+            String statement;
+            statement = getJSPropertySetString(jsObjectName,
+                                               HtmlAccordionPanel.HOVER_TEXT_COLOR,
+                                               panel.getHoverTextColor());
+
+            writer.writeText(statement, null);
+        }
+
+        if(panel.getBorderColor() != null)
+        {
+            String statement;
+            statement = getJSPropertySetString(jsObjectName,
+                                               HtmlAccordionPanel.BORDER_COLOR,
+                                               panel.getBorderColor());
+
+            writer.writeText(statement, null);
+        }
+    }
+
+
+    /**
+     * Builds a set statement for a property of an Javascript Object.
+     *
+     * @param object the name of the Javascript object.
+     * @param property the name of the object's property.
+     * @param value the new value of the property.
+     *
+     * @return a set statement for a Javascript object.
+     */
+
+    private String getJSPropertySetString(String object,
+                                          String property,
+                                          String value)
+    {
+        StringBuffer sb = new StringBuffer();
+        sb.append(object);
+        sb.append(".");
+        sb.append(property);
+        sb.append("='");
+        sb.append(value);
+        sb.append("';");
+        return sb.toString();
+    }
+}

Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/accordion/HtmlAccordionPanelRenderer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/accordion/HtmlAccordionPanelTag.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/accordion/HtmlAccordionPanelTag.java?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/accordion/HtmlAccordionPanelTag.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/accordion/HtmlAccordionPanelTag.java Tue Aug  1 10:43:28 2006
@@ -1,157 +1,157 @@
-/**
- * Copyright 2004 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.
- */
-package org.apache.myfaces.custom.accordion;
-
-import javax.faces.component.UIComponent;
-
-import org.apache.myfaces.taglib.html.ext.HtmlPanelGroupTag;
-
-
-/**
- * @author Martin Marinschek
- *
- *
- *
- * @version $Revision: $ $Date: $
- *          <p/>
- */
-public class HtmlAccordionPanelTag  extends HtmlPanelGroupTag
-{
-    private String _layout;
-
-    //style properties
-    private String _expandedBackColor;
-    private String _expandedTextColor;
-    private String _expandedFontWeight;
-    private String _collapsedBackColor;
-    private String _collapsedTextColor;
-    private String _collapsedFontWeight;
-    private String _hoverBackColor;
-    private String _hoverTextColor;
-    private String _borderColor;
-
-
-//    private String _expandedStyleClass; //Background, Textcolor, Fontweight
-//    private String _hoverStyleClass; //Background, Textcolor
-//    private String _collapsedStyleClass; //Background, Textcolor, Fontweight
-
-
-    public String getComponentType()
-    {
-        return HtmlAccordionPanel.COMPONENT_TYPE;
-    }
-
-    public String getRendererType()
-    {
-        return HtmlAccordionPanel.DEFAULT_RENDERER_TYPE;
-    }
-
-    public void release()
-    {
-
-        super.release();
-
-        _layout = null;
-        //style properties
-        _expandedBackColor = null;
-        _expandedTextColor = null;
-        _expandedFontWeight = null;
-        _collapsedBackColor = null;
-        _collapsedTextColor = null;
-        _collapsedFontWeight = null;
-        _hoverBackColor = null;
-        _hoverTextColor = null;
-        _borderColor = null;
-    }
-
-    protected void setProperties(UIComponent component)
-    {
-
-        super.setProperties(component);
-
-        setStringProperty(component,"layout",_layout);
-        //style properties
-        setStringProperty(component, "expandedBackColor", _expandedBackColor);
-        setStringProperty(component, "expandedTextColor", _expandedTextColor);
-        setStringProperty(component, "expandedFontWeight", _expandedFontWeight);
-        setStringProperty(component, "collapsedBackColor", _collapsedBackColor);
-        setStringProperty(component, "collapsedTextColor", _collapsedTextColor);
-        setStringProperty(component, "collapsedFontWeight", _collapsedFontWeight);
-        setStringProperty(component, "hoverBackColor", _hoverBackColor);
-        setStringProperty(component, "hoverTextColor", _hoverTextColor);
-        setStringProperty(component, "borderColor", _borderColor);
-
-    }
-
-    public void setLayout(String layout)
-    {
-        _layout = layout;
-    }
-
-
-    public void setExpandedBackColor(String expandedBackColor)
-    {
-        _expandedBackColor = expandedBackColor;
-    }
-
-
-    public void setExpandedTextColor(String expandedTextColor)
-    {
-        _expandedTextColor = expandedTextColor;
-    }
-
-
-    public void setExpandedFontWeight(String expandedFontWeight)
-    {
-        _expandedFontWeight = expandedFontWeight;
-    }
-
-
-    public void setCollapsedBackColor(String collapsedBackColor)
-    {
-        _collapsedBackColor = collapsedBackColor;
-    }
-
-
-    public void setCollapsedTextColor(String collapsedTextColor)
-    {
-        _collapsedTextColor = collapsedTextColor;
-    }
-
-
-    public void setCollapsedFontWeight(String collapsedFontWeight)
-    {
-        _collapsedFontWeight = collapsedFontWeight;
-    }
-
-
-    public void setHoverBackColor(String hoverBackColor)
-    {
-        _hoverBackColor = hoverBackColor;
-    }
-
-
-    public void setHoverTextColor(String hoverTextColor)
-    {
-        _hoverTextColor = hoverTextColor;
-    }
-
-
-    public void setBorderColor(String borderColor)
-    {
-        _borderColor = borderColor;
-    }
-}
+/**
+ * Copyright 2004 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.
+ */
+package org.apache.myfaces.custom.accordion;
+
+import javax.faces.component.UIComponent;
+
+import org.apache.myfaces.taglib.html.ext.HtmlPanelGroupTag;
+
+
+/**
+ * @author Martin Marinschek
+ *
+ *
+ *
+ * @version $Revision: $ $Date: $
+ *          <p/>
+ */
+public class HtmlAccordionPanelTag  extends HtmlPanelGroupTag
+{
+    private String _layout;
+
+    //style properties
+    private String _expandedBackColor;
+    private String _expandedTextColor;
+    private String _expandedFontWeight;
+    private String _collapsedBackColor;
+    private String _collapsedTextColor;
+    private String _collapsedFontWeight;
+    private String _hoverBackColor;
+    private String _hoverTextColor;
+    private String _borderColor;
+
+
+//    private String _expandedStyleClass; //Background, Textcolor, Fontweight
+//    private String _hoverStyleClass; //Background, Textcolor
+//    private String _collapsedStyleClass; //Background, Textcolor, Fontweight
+
+
+    public String getComponentType()
+    {
+        return HtmlAccordionPanel.COMPONENT_TYPE;
+    }
+
+    public String getRendererType()
+    {
+        return HtmlAccordionPanel.DEFAULT_RENDERER_TYPE;
+    }
+
+    public void release()
+    {
+
+        super.release();
+
+        _layout = null;
+        //style properties
+        _expandedBackColor = null;
+        _expandedTextColor = null;
+        _expandedFontWeight = null;
+        _collapsedBackColor = null;
+        _collapsedTextColor = null;
+        _collapsedFontWeight = null;
+        _hoverBackColor = null;
+        _hoverTextColor = null;
+        _borderColor = null;
+    }
+
+    protected void setProperties(UIComponent component)
+    {
+
+        super.setProperties(component);
+
+        setStringProperty(component,"layout",_layout);
+        //style properties
+        setStringProperty(component, "expandedBackColor", _expandedBackColor);
+        setStringProperty(component, "expandedTextColor", _expandedTextColor);
+        setStringProperty(component, "expandedFontWeight", _expandedFontWeight);
+        setStringProperty(component, "collapsedBackColor", _collapsedBackColor);
+        setStringProperty(component, "collapsedTextColor", _collapsedTextColor);
+        setStringProperty(component, "collapsedFontWeight", _collapsedFontWeight);
+        setStringProperty(component, "hoverBackColor", _hoverBackColor);
+        setStringProperty(component, "hoverTextColor", _hoverTextColor);
+        setStringProperty(component, "borderColor", _borderColor);
+
+    }
+
+    public void setLayout(String layout)
+    {
+        _layout = layout;
+    }
+
+
+    public void setExpandedBackColor(String expandedBackColor)
+    {
+        _expandedBackColor = expandedBackColor;
+    }
+
+
+    public void setExpandedTextColor(String expandedTextColor)
+    {
+        _expandedTextColor = expandedTextColor;
+    }
+
+
+    public void setExpandedFontWeight(String expandedFontWeight)
+    {
+        _expandedFontWeight = expandedFontWeight;
+    }
+
+
+    public void setCollapsedBackColor(String collapsedBackColor)
+    {
+        _collapsedBackColor = collapsedBackColor;
+    }
+
+
+    public void setCollapsedTextColor(String collapsedTextColor)
+    {
+        _collapsedTextColor = collapsedTextColor;
+    }
+
+
+    public void setCollapsedFontWeight(String collapsedFontWeight)
+    {
+        _collapsedFontWeight = collapsedFontWeight;
+    }
+
+
+    public void setHoverBackColor(String hoverBackColor)
+    {
+        _hoverBackColor = hoverBackColor;
+    }
+
+
+    public void setHoverTextColor(String hoverTextColor)
+    {
+        _hoverTextColor = hoverTextColor;
+    }
+
+
+    public void setBorderColor(String borderColor)
+    {
+        _borderColor = borderColor;
+    }
+}

Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/accordion/HtmlAccordionPanelTag.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/AjaxCallbacks.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/api/AjaxComponent.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/api/AjaxComponent.java?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/api/AjaxComponent.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/api/AjaxComponent.java Tue Aug  1 10:43:28 2006
@@ -1,31 +1,31 @@
-/**
- * Copyright 2004 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.
- */
-package org.apache.myfaces.custom.ajax.api;
-
-import javax.faces.context.FacesContext;
-import java.io.IOException;
-
-/**
- * @author Martin Marinschek
- * @version $Revision: $ $Date: $
- *          <p/>
- */
-public interface AjaxComponent
-{
-    void encodeAjax(FacesContext context) throws IOException;
-
-    void decodeAjax(FacesContext context);   
-}
+/**
+ * Copyright 2004 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.
+ */
+package org.apache.myfaces.custom.ajax.api;
+
+import javax.faces.context.FacesContext;
+import java.io.IOException;
+
+/**
+ * @author Martin Marinschek
+ * @version $Revision: $ $Date: $
+ *          <p/>
+ */
+public interface AjaxComponent
+{
+    void encodeAjax(FacesContext context) throws IOException;
+
+    void decodeAjax(FacesContext context);   
+}

Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/api/AjaxComponent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/api/AjaxDecodePhaseListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/api/AjaxPhaseListener.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/api/AjaxPhaseListener.java?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/api/AjaxPhaseListener.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/api/AjaxPhaseListener.java Tue Aug  1 10:43:28 2006
@@ -1,136 +1,136 @@
-/**
- * Copyright 2004 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.
- */
-package org.apache.myfaces.custom.ajax.api;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.FacesContext;
-import javax.faces.event.PhaseEvent;
-import javax.faces.event.PhaseId;
-import javax.faces.event.PhaseListener;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * @author Martin Marinschek
- * @version $Revision: $ $Date: $
- *          <p/>
- *          $Log: $
- */
-public class AjaxPhaseListener implements PhaseListener
-{
-    private static Log log = LogFactory.getLog(AjaxPhaseListener.class);
-
-    public void beforePhase(PhaseEvent event)
-    {
-
-    }
-
-    public static Object getValueForComponent(FacesContext facesContext, UIComponent component)
-    {
-        String possibleClientId = component.getClientId(facesContext);
-
-        if (facesContext.getExternalContext().getRequestParameterMap().containsKey(possibleClientId))
-        {
-            return facesContext.getExternalContext().getRequestParameterMap().get(possibleClientId);
-        }
-        else
-        {
-            possibleClientId = (String) facesContext.getExternalContext().getRequestParameterMap().get(
-                    "affectedAjaxComponent");
-
-            UIViewRoot root = facesContext.getViewRoot();
-
-            UIComponent ajaxComponent =
-                    facesContext.getViewRoot().findComponent(possibleClientId);
-
-            if (ajaxComponent == component)
-            {
-                return facesContext.getExternalContext().getRequestParameterMap().get(possibleClientId);
-            }
-            else
-            {
-                log.error("No value found for this component : " + possibleClientId);
-                return null;
-            }
-        }
-    }
-
-
-
-    public void afterPhase(PhaseEvent event)
-    {
-        log.debug("In AjaxPhaseListener afterPhase");
-        /*FacesContext context = event.getFacesContext();
-
-        if (context.getExternalContext().getRequestParameterMap().containsKey("affectedAjaxComponent"))
-        {
-            UIViewRoot root = context.getViewRoot();
-            String clientId = (String)context.getExternalContext().getRequestParameterMap().get("affectedAjaxComponent");
-            UIComponent ajaxComponent = ComponentUtils.findComponentFullTree(context, root, clientId); //root.findComponent(clientId);
-            log.debug("affectedAjaxComponent: " + ajaxComponent + " - " + ajaxComponent.getId());
-            
-            if (ajaxComponent instanceof AjaxComponent)
-            {
-                try
-                {
-                    // TR - What is this HtmlBufferResponseWriterWrapper stuff for????  This caused me hours and hours of pain
-                    if (context.getResponseWriter() == null)
-                    {
-                        ServletResponse response = (ServletResponse) context.getExternalContext().getResponse();
-                        Writer htmlResponseWriter = response.getWriter();
-                        context.setResponseWriter(new HtmlResponseWriterImpl(htmlResponseWriter, "text/html", "UTF-8"));
-                    }
-                    ((AjaxComponent) ajaxComponent).encodeAjax(context);
-                }
-                catch (IOException e)
-                {
-                    log.error("Exception while rendering ajax-response", e);
-                }
-            }
-            else
-            {
-
-
-                log.error("Found component is no ajaxComponent : " + RendererUtils.getPathToComponent(ajaxComponent));
-            }
-
-
-            StateManager stateManager = context.getApplication().getStateManager();
-            if (!stateManager.isSavingStateInClient(context))
-            {
-                stateManager.saveSerializedView(context);
-            }
-            context.responseComplete();
-        }*/
-    }
-
-
-    /**
-     * We need to hang our AJAX phase listener in the invoke application phase as it is
-     * impossible to stop rendering in the render response phase.
-     *
-     * @return PhaseId The AJAX phase listener will be invoked after the invoke application phase.
-     */
-    public PhaseId getPhaseId()
-    {
-        //return PhaseId.ANY_PHASE;
-        //return PhaseId.RESTORE_VIEW;
-        return PhaseId.INVOKE_APPLICATION;
-    }
-
-}
+/**
+ * Copyright 2004 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.
+ */
+package org.apache.myfaces.custom.ajax.api;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseEvent;
+import javax.faces.event.PhaseId;
+import javax.faces.event.PhaseListener;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author Martin Marinschek
+ * @version $Revision: $ $Date: $
+ *          <p/>
+ *          $Log: $
+ */
+public class AjaxPhaseListener implements PhaseListener
+{
+    private static Log log = LogFactory.getLog(AjaxPhaseListener.class);
+
+    public void beforePhase(PhaseEvent event)
+    {
+
+    }
+
+    public static Object getValueForComponent(FacesContext facesContext, UIComponent component)
+    {
+        String possibleClientId = component.getClientId(facesContext);
+
+        if (facesContext.getExternalContext().getRequestParameterMap().containsKey(possibleClientId))
+        {
+            return facesContext.getExternalContext().getRequestParameterMap().get(possibleClientId);
+        }
+        else
+        {
+            possibleClientId = (String) facesContext.getExternalContext().getRequestParameterMap().get(
+                    "affectedAjaxComponent");
+
+            UIViewRoot root = facesContext.getViewRoot();
+
+            UIComponent ajaxComponent =
+                    facesContext.getViewRoot().findComponent(possibleClientId);
+
+            if (ajaxComponent == component)
+            {
+                return facesContext.getExternalContext().getRequestParameterMap().get(possibleClientId);
+            }
+            else
+            {
+                log.error("No value found for this component : " + possibleClientId);
+                return null;
+            }
+        }
+    }
+
+
+
+    public void afterPhase(PhaseEvent event)
+    {
+        log.debug("In AjaxPhaseListener afterPhase");
+        /*FacesContext context = event.getFacesContext();
+
+        if (context.getExternalContext().getRequestParameterMap().containsKey("affectedAjaxComponent"))
+        {
+            UIViewRoot root = context.getViewRoot();
+            String clientId = (String)context.getExternalContext().getRequestParameterMap().get("affectedAjaxComponent");
+            UIComponent ajaxComponent = ComponentUtils.findComponentFullTree(context, root, clientId); //root.findComponent(clientId);
+            log.debug("affectedAjaxComponent: " + ajaxComponent + " - " + ajaxComponent.getId());
+            
+            if (ajaxComponent instanceof AjaxComponent)
+            {
+                try
+                {
+                    // TR - What is this HtmlBufferResponseWriterWrapper stuff for????  This caused me hours and hours of pain
+                    if (context.getResponseWriter() == null)
+                    {
+                        ServletResponse response = (ServletResponse) context.getExternalContext().getResponse();
+                        Writer htmlResponseWriter = response.getWriter();
+                        context.setResponseWriter(new HtmlResponseWriterImpl(htmlResponseWriter, "text/html", "UTF-8"));
+                    }
+                    ((AjaxComponent) ajaxComponent).encodeAjax(context);
+                }
+                catch (IOException e)
+                {
+                    log.error("Exception while rendering ajax-response", e);
+                }
+            }
+            else
+            {
+
+
+                log.error("Found component is no ajaxComponent : " + RendererUtils.getPathToComponent(ajaxComponent));
+            }
+
+
+            StateManager stateManager = context.getApplication().getStateManager();
+            if (!stateManager.isSavingStateInClient(context))
+            {
+                stateManager.saveSerializedView(context);
+            }
+            context.responseComplete();
+        }*/
+    }
+
+
+    /**
+     * We need to hang our AJAX phase listener in the invoke application phase as it is
+     * impossible to stop rendering in the render response phase.
+     *
+     * @return PhaseId The AJAX phase listener will be invoked after the invoke application phase.
+     */
+    public PhaseId getPhaseId()
+    {
+        //return PhaseId.ANY_PHASE;
+        //return PhaseId.RESTORE_VIEW;
+        return PhaseId.INVOKE_APPLICATION;
+    }
+
+}

Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/api/AjaxPhaseListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/api/AjaxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/api/AjaxRenderer.java?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/api/AjaxRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/api/AjaxRenderer.java Tue Aug  1 10:43:28 2006
@@ -1,31 +1,31 @@
-/**
- * Copyright 2004 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.
- */
-package org.apache.myfaces.custom.ajax.api;
-
-import javax.faces.context.FacesContext;
-import javax.faces.component.UIComponent;
-import java.io.IOException;
-
-/**
- * @author Martin Marinschek
- * @version $Revision: $ $Date: $
- *          <p/>
- *          $Log: $
- */
-public interface AjaxRenderer
-{
-    void encodeAjax(FacesContext context, UIComponent component) throws IOException;
-}
+/**
+ * Copyright 2004 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.
+ */
+package org.apache.myfaces.custom.ajax.api;
+
+import javax.faces.context.FacesContext;
+import javax.faces.component.UIComponent;
+import java.io.IOException;
+
+/**
+ * @author Martin Marinschek
+ * @version $Revision: $ $Date: $
+ *          <p/>
+ *          $Log: $
+ */
+public interface AjaxRenderer
+{
+    void encodeAjax(FacesContext context, UIComponent component) throws IOException;
+}

Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/api/AjaxRenderer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/api/AjaxSuggestRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/api/AjaxSuggestRenderer.java?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/api/AjaxSuggestRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/api/AjaxSuggestRenderer.java Tue Aug  1 10:43:28 2006
@@ -1,30 +1,30 @@
-/*
- * Copyright 2004-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.
- */
-package org.apache.myfaces.custom.ajax.api;
-
-import javax.faces.context.FacesContext;
-import javax.faces.component.UIComponent;
-import java.util.Collection;
-
-/**
- * @author Gerald M�llan
- *         Date: 01.04.2006
- *         Time: 16:05:52
- */
-public interface AjaxSuggestRenderer
-{
-    public Collection getSuggestedItems(FacesContext context, UIComponent uiComponent);
-}
+/*
+ * Copyright 2004-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.
+ */
+package org.apache.myfaces.custom.ajax.api;
+
+import javax.faces.context.FacesContext;
+import javax.faces.component.UIComponent;
+import java.util.Collection;
+
+/**
+ * @author Gerald M�llan
+ *         Date: 01.04.2006
+ *         Time: 16:05:52
+ */
+public interface AjaxSuggestRenderer
+{
+    public Collection getSuggestedItems(FacesContext context, UIComponent uiComponent);
+}

Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/api/AjaxSuggestRenderer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/api/ComponentNotFoundException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/util/AjaxRendererUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/autoupdatedatatable/AutoUpdateDataTable.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/autoupdatedatatable/AutoUpdateDataTable.java?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/autoupdatedatatable/AutoUpdateDataTable.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/autoupdatedatatable/AutoUpdateDataTable.java Tue Aug  1 10:43:28 2006
@@ -1,152 +1,152 @@
-/**
- * Copyright 2004 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.
- */
-package org.apache.myfaces.custom.autoupdatedatatable;
-
-import org.apache.myfaces.component.html.ext.HtmlDataTable;
-import org.apache.myfaces.custom.ajax.api.AjaxComponent;
-import org.apache.myfaces.custom.ajax.api.AjaxRenderer;
-
-import javax.faces.context.FacesContext;
-import javax.faces.render.Renderer;
-import javax.faces.el.ValueBinding;
-import java.io.IOException;
-
-/**
- * @author J&ouml;rg Artaker
- * @author Thomas Huber
- * @version $Revision: $ $Date: $
- *          <p/>
- *          $Log: $
- */
-public class AutoUpdateDataTable extends HtmlDataTable implements AjaxComponent{
-
-    public static final String COMPONENT_TYPE = "org.apache.myfaces.AutoUpdateDataTable";
-    public static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.AutoUpdateDataTable";
-
-    private String _frequency;
-    private String _onSuccess;
-
-    public AutoUpdateDataTable()
-    {
-        super();
-        setRendererType(DEFAULT_RENDERER_TYPE);
-    }
-
-    /**
-     * @param context FacesContext
-     * @param state Object
-     */
-    public void processRestoreState(FacesContext context, Object state)
-	{
-		super.processRestoreState(context, state);
-	}
-
-    /**
-     * @param context FacesContext
-     * @return Object
-     */
-    public Object processSaveState(FacesContext context)
-	{
-		return super.processSaveState(context);
-	}   
-
-    /**
-     * @param context FacesContext
-     * @return the values Object[]
-     */
-    public Object saveState(FacesContext context)
-    {
-        Object[] values = new Object[3];
-        values[0] = super.saveState(context);
-        values[1] = _frequency;
-        values[2] = _onSuccess;
-
-        return values;
-    }
-
-    /**
-     * @param context FacesContext
-     * @param state Object
-     */
-    public void restoreState(FacesContext context, Object state)
-    {
-        Object values[] = (Object[])state;
-        super.restoreState(context, values[0]);
-        _frequency = (String) values[1];
-        _onSuccess = (String) values[2];
-    }
-
-    /**
-     * @return the frequency String
-     */
-    public String getFrequency() {
-        if (_frequency!= null)
-            return _frequency;
-        ValueBinding vb = getValueBinding("frequency");
-        if( vb == null )
-        	return null;
-        Object eval = vb.getValue(getFacesContext());
-        return eval == null ? null : eval.toString();
-    }
-
-    /**
-     * @param frequency String
-     */
-    public void setFrequency(String frequency) {
-        _frequency = frequency;
-    }
-
-    public String getOnSuccess() {
-         if (_onSuccess!= null)
-            return _onSuccess;
-        ValueBinding vb = getValueBinding("onSuccess");
-        if( vb == null )
-        	return null;
-        Object eval = vb.getValue(getFacesContext());
-        return eval == null ? null : eval.toString();
-    }
-
-    public void setOnSuccess(String _onSuccess) {
-        this._onSuccess = _onSuccess;
-    }
-
-    /**
-     * @param context FacesContext
-     * @throws java.io.IOException
-     */
-    public void encodeAjax(FacesContext context) throws IOException {
-        if (context == null) throw new NullPointerException("context");
-        if (!isRendered()) return;
-        Renderer renderer = getRenderer(context);
-
-         if (isValidChildren())
-        {
-            setPreservedDataModel(null);
-        }
-        
-        if (renderer != null && renderer instanceof AjaxRenderer)
-        {
-
-            ((AjaxRenderer) renderer).encodeAjax(context, this);
-            
-        }
-    }
-
-    public void decodeAjax(FacesContext context)
-    {
-
-    }
-}
+/**
+ * Copyright 2004 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.
+ */
+package org.apache.myfaces.custom.autoupdatedatatable;
+
+import org.apache.myfaces.component.html.ext.HtmlDataTable;
+import org.apache.myfaces.custom.ajax.api.AjaxComponent;
+import org.apache.myfaces.custom.ajax.api.AjaxRenderer;
+
+import javax.faces.context.FacesContext;
+import javax.faces.render.Renderer;
+import javax.faces.el.ValueBinding;
+import java.io.IOException;
+
+/**
+ * @author J&ouml;rg Artaker
+ * @author Thomas Huber
+ * @version $Revision: $ $Date: $
+ *          <p/>
+ *          $Log: $
+ */
+public class AutoUpdateDataTable extends HtmlDataTable implements AjaxComponent{
+
+    public static final String COMPONENT_TYPE = "org.apache.myfaces.AutoUpdateDataTable";
+    public static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.AutoUpdateDataTable";
+
+    private String _frequency;
+    private String _onSuccess;
+
+    public AutoUpdateDataTable()
+    {
+        super();
+        setRendererType(DEFAULT_RENDERER_TYPE);
+    }
+
+    /**
+     * @param context FacesContext
+     * @param state Object
+     */
+    public void processRestoreState(FacesContext context, Object state)
+	{
+		super.processRestoreState(context, state);
+	}
+
+    /**
+     * @param context FacesContext
+     * @return Object
+     */
+    public Object processSaveState(FacesContext context)
+	{
+		return super.processSaveState(context);
+	}   
+
+    /**
+     * @param context FacesContext
+     * @return the values Object[]
+     */
+    public Object saveState(FacesContext context)
+    {
+        Object[] values = new Object[3];
+        values[0] = super.saveState(context);
+        values[1] = _frequency;
+        values[2] = _onSuccess;
+
+        return values;
+    }
+
+    /**
+     * @param context FacesContext
+     * @param state Object
+     */
+    public void restoreState(FacesContext context, Object state)
+    {
+        Object values[] = (Object[])state;
+        super.restoreState(context, values[0]);
+        _frequency = (String) values[1];
+        _onSuccess = (String) values[2];
+    }
+
+    /**
+     * @return the frequency String
+     */
+    public String getFrequency() {
+        if (_frequency!= null)
+            return _frequency;
+        ValueBinding vb = getValueBinding("frequency");
+        if( vb == null )
+        	return null;
+        Object eval = vb.getValue(getFacesContext());
+        return eval == null ? null : eval.toString();
+    }
+
+    /**
+     * @param frequency String
+     */
+    public void setFrequency(String frequency) {
+        _frequency = frequency;
+    }
+
+    public String getOnSuccess() {
+         if (_onSuccess!= null)
+            return _onSuccess;
+        ValueBinding vb = getValueBinding("onSuccess");
+        if( vb == null )
+        	return null;
+        Object eval = vb.getValue(getFacesContext());
+        return eval == null ? null : eval.toString();
+    }
+
+    public void setOnSuccess(String _onSuccess) {
+        this._onSuccess = _onSuccess;
+    }
+
+    /**
+     * @param context FacesContext
+     * @throws java.io.IOException
+     */
+    public void encodeAjax(FacesContext context) throws IOException {
+        if (context == null) throw new NullPointerException("context");
+        if (!isRendered()) return;
+        Renderer renderer = getRenderer(context);
+
+         if (isValidChildren())
+        {
+            setPreservedDataModel(null);
+        }
+        
+        if (renderer != null && renderer instanceof AjaxRenderer)
+        {
+
+            ((AjaxRenderer) renderer).encodeAjax(context, this);
+            
+        }
+    }
+
+    public void decodeAjax(FacesContext context)
+    {
+
+    }
+}

Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/autoupdatedatatable/AutoUpdateDataTable.java
------------------------------------------------------------------------------
    svn:eol-style = native