You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2012/01/12 02:07:38 UTC

svn commit: r1230345 - in /myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/renderkit/html: CommonEventUtils.java CommonPropertyUtils.java HtmlOutcomeTargetButtonRendererBase.java HtmlRendererUtils.java

Author: lu4242
Date: Thu Jan 12 01:07:37 2012
New Revision: 1230345

URL: http://svn.apache.org/viewvc?rev=1230345&view=rev
Log:
MYFACES-3446 [perf] Improve html Renderers (add optimized methods for String attributes)

Added:
    myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/CommonEventUtils.java   (with props)
Modified:
    myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/CommonPropertyUtils.java
    myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlOutcomeTargetButtonRendererBase.java
    myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java

Added: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/CommonEventUtils.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/CommonEventUtils.java?rev=1230345&view=auto
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/CommonEventUtils.java (added)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/CommonEventUtils.java Thu Jan 12 01:07:37 2012
@@ -0,0 +1,541 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.shared.renderkit.html;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import javax.faces.component.UIComponent;
+import javax.faces.component.behavior.ClientBehavior;
+import javax.faces.component.behavior.ClientBehaviorContext;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import org.apache.myfaces.shared.renderkit.ClientBehaviorEvents;
+
+/**
+ *
+ * @author Leonardo Uribe
+ */
+public class CommonEventUtils
+{
+    public static long getCommonEventsMarked(UIComponent component)
+    {
+        Long commonEvents = (Long) component.getAttributes().get(CommonEventConstants.COMMON_EVENTS_MARKED);
+        
+        if (commonEvents == null)
+        {
+            commonEvents = 0L;
+        }
+        return commonEvents;
+    }
+        
+    /**
+     * Render an attribute taking into account the passed event and
+     * the component property. It will be rendered as "componentProperty"
+     * attribute.
+     *
+     * @param facesContext
+     * @param writer
+     * @param componentProperty
+     * @param component
+     * @param eventName
+     * @param clientBehaviors
+     * @return
+     * @throws IOException
+     * @since 4.0.1
+     */
+    /*
+    public static boolean renderBehaviorizedAttribute(
+            FacesContext facesContext, ResponseWriter writer,
+            String componentProperty, UIComponent component, String eventName,
+            Map<String, List<ClientBehavior>> clientBehaviors)
+            throws IOException
+    {
+        return renderBehaviorizedAttribute(facesContext, writer,
+                componentProperty, component, eventName, clientBehaviors,
+                componentProperty);
+    }
+
+    public static boolean renderBehaviorizedAttribute(
+            FacesContext facesContext, ResponseWriter writer,
+            String componentProperty, UIComponent component,
+            String targetClientId, String eventName,
+            Map<String, List<ClientBehavior>> clientBehaviors)
+            throws IOException
+    {
+        return renderBehaviorizedAttribute(facesContext, writer,
+                componentProperty, component, targetClientId, eventName,
+                clientBehaviors, componentProperty);
+    }*/
+
+    /**
+     * Render an attribute taking into account the passed event and
+     * the component property. The event will be rendered on the selected
+     * htmlAttrName
+     *
+     * @param facesContext
+     * @param writer
+     * @param component
+     * @param clientBehaviors
+     * @param eventName
+     * @param componentProperty
+     * @param htmlAttrName
+     * @return
+     * @throws IOException
+     * @since 4.0.1
+     */
+    /*
+    public static boolean renderBehaviorizedAttribute(
+            FacesContext facesContext, ResponseWriter writer,
+            String componentProperty, UIComponent component, String eventName,
+            Map<String, List<ClientBehavior>> clientBehaviors,
+            String htmlAttrName) throws IOException
+    {
+        return renderBehaviorizedAttribute(facesContext, writer,
+                componentProperty, component, eventName, null, clientBehaviors,
+                htmlAttrName,
+                (String) component.getAttributes().get(componentProperty));
+    }*/
+
+    public static boolean renderBehaviorizedAttribute(
+            FacesContext facesContext, ResponseWriter writer,
+            String componentProperty, UIComponent component,
+            String targetClientId, String eventName,
+            Map<String, List<ClientBehavior>> clientBehaviors,
+            String htmlAttrName) throws IOException
+    {
+        return renderBehaviorizedAttribute(facesContext, writer,
+                componentProperty, component, targetClientId, eventName, null,
+                clientBehaviors, htmlAttrName, (String) component
+                        .getAttributes().get(componentProperty));
+    }
+
+    /**
+     * Render an attribute taking into account the passed event,
+     * the component property and the passed attribute value for the component
+     * property. The event will be rendered on the selected htmlAttrName.
+     *
+     * @param facesContext
+     * @param writer
+     * @param componentProperty
+     * @param component
+     * @param eventName
+     * @param clientBehaviors
+     * @param htmlAttrName
+     * @param attributeValue
+     * @return
+     * @throws IOException
+     */
+    public static boolean renderBehaviorizedAttribute(
+            FacesContext facesContext, ResponseWriter writer,
+            String componentProperty, UIComponent component, String eventName,
+            Collection<ClientBehaviorContext.Parameter> eventParameters,
+            Map<String, List<ClientBehavior>> clientBehaviors,
+            String htmlAttrName, String attributeValue) throws IOException
+    {
+        return renderBehaviorizedAttribute(facesContext, writer,
+                componentProperty, component,
+                component.getClientId(facesContext), eventName,
+                eventParameters, clientBehaviors, htmlAttrName, attributeValue);
+    }
+
+    public static boolean renderBehaviorizedAttribute(
+            FacesContext facesContext, ResponseWriter writer,
+            String componentProperty, UIComponent component,
+            String targetClientId, String eventName,
+            Collection<ClientBehaviorContext.Parameter> eventParameters,
+            Map<String, List<ClientBehavior>> clientBehaviors,
+            String htmlAttrName, String attributeValue) throws IOException
+    {
+
+        List<ClientBehavior> cbl = (clientBehaviors != null) ? clientBehaviors
+                .get(eventName) : null;
+
+        if (cbl == null || cbl.size() == 0)
+        {
+            return HtmlRendererUtils.renderHTMLStringAttribute(writer, componentProperty, htmlAttrName,
+                    attributeValue);
+        }
+
+        if (cbl.size() > 1 || (cbl.size() == 1 && attributeValue != null))
+        {
+            return HtmlRendererUtils.renderHTMLStringAttribute(writer, componentProperty, htmlAttrName,
+                    HtmlRendererUtils.buildBehaviorChain(facesContext,
+                            component, targetClientId, eventName,
+                            eventParameters, clientBehaviors, attributeValue,
+                            HtmlRendererUtils.STR_EMPTY));
+        }
+        else
+        {
+            //Only 1 behavior and attrValue == null, so just render it directly
+            return HtmlRendererUtils.renderHTMLStringAttribute(
+                    writer,
+                    componentProperty,
+                    htmlAttrName,
+                    cbl.get(0).getScript(
+                            ClientBehaviorContext.createClientBehaviorContext(
+                                    facesContext, component, eventName,
+                                    targetClientId, eventParameters)));
+        }
+    }
+
+    public static void renderBehaviorizedEventHandlers(
+            FacesContext facesContext, ResponseWriter writer,
+            long commonPropertiesMarked, long commonEventsMarked,
+            UIComponent uiComponent,
+            Map<String, List<ClientBehavior>> clientBehaviors)
+            throws IOException
+    {
+        renderBehaviorizedEventHandlers(facesContext, writer, 
+                commonPropertiesMarked, commonEventsMarked, uiComponent,
+                uiComponent.getClientId(facesContext), clientBehaviors);
+    }
+    
+    public static void renderBehaviorizedEventHandlers(
+            FacesContext facesContext, ResponseWriter writer,
+            long commonPropertiesMarked, long commonEventsMarked,
+            UIComponent uiComponent, String targetClientId,
+            Map<String, List<ClientBehavior>> clientBehaviors)
+            throws IOException
+    {
+        if ((commonPropertiesMarked & CommonPropertyConstants.ONCLICK_PROP) != 0 ||
+            (commonEventsMarked & CommonEventConstants.CLICK_EVENT) != 0)
+        {
+            renderBehaviorizedAttribute(facesContext, writer, HTML.ONCLICK_ATTR,
+                    uiComponent, targetClientId, ClientBehaviorEvents.CLICK,
+                    clientBehaviors, HTML.ONCLICK_ATTR);
+        }
+        if ((commonPropertiesMarked & CommonPropertyConstants.ONDBLCLICK_PROP) != 0 ||
+            (commonEventsMarked & CommonEventConstants.DBLCLICK_EVENT) != 0)
+        {
+            renderBehaviorizedAttribute(facesContext, writer, HTML.ONDBLCLICK_ATTR,
+                    uiComponent, targetClientId, ClientBehaviorEvents.DBLCLICK,
+                    clientBehaviors, HTML.ONDBLCLICK_ATTR);
+        }
+        if ((commonPropertiesMarked & CommonPropertyConstants.ONMOUSEDOWN_PROP) != 0 ||
+            (commonEventsMarked & CommonEventConstants.MOUSEDOWN_EVENT) != 0)
+        {
+            renderBehaviorizedAttribute(facesContext, writer,
+                    HTML.ONMOUSEDOWN_ATTR, uiComponent, targetClientId,
+                    ClientBehaviorEvents.MOUSEDOWN, clientBehaviors,
+                    HTML.ONMOUSEDOWN_ATTR);
+        }
+        if ((commonPropertiesMarked & CommonPropertyConstants.ONMOUSEUP_PROP) != 0 ||
+            (commonEventsMarked & CommonEventConstants.MOUSEUP_EVENT) != 0)
+        {
+            renderBehaviorizedAttribute(facesContext, writer, HTML.ONMOUSEUP_ATTR,
+                    uiComponent, targetClientId, ClientBehaviorEvents.MOUSEUP,
+                    clientBehaviors, HTML.ONMOUSEUP_ATTR);
+        }
+        if ((commonPropertiesMarked & CommonPropertyConstants.ONMOUSEOVER_PROP) != 0 ||
+            (commonEventsMarked & CommonEventConstants.MOUSEOVER_EVENT) != 0)
+        {
+            renderBehaviorizedAttribute(facesContext, writer,
+                    HTML.ONMOUSEOVER_ATTR, uiComponent, targetClientId,
+                    ClientBehaviorEvents.MOUSEOVER, clientBehaviors,
+                    HTML.ONMOUSEOVER_ATTR);
+        }
+        if ((commonPropertiesMarked & CommonPropertyConstants.ONMOUSEMOVE_PROP) != 0 ||
+            (commonEventsMarked & CommonEventConstants.MOUSEMOVE_EVENT) != 0)
+        {
+            renderBehaviorizedAttribute(facesContext, writer,
+                    HTML.ONMOUSEMOVE_ATTR, uiComponent, targetClientId,
+                    ClientBehaviorEvents.MOUSEMOVE, clientBehaviors,
+                    HTML.ONMOUSEMOVE_ATTR);
+        }
+        if ((commonPropertiesMarked & CommonPropertyConstants.ONMOUSEOUT_PROP) != 0 ||
+            (commonEventsMarked & CommonEventConstants.MOUSEOUT_EVENT) != 0)
+        {
+            renderBehaviorizedAttribute(facesContext, writer, HTML.ONMOUSEOUT_ATTR,
+                    uiComponent, targetClientId, ClientBehaviorEvents.MOUSEOUT,
+                    clientBehaviors, HTML.ONMOUSEOUT_ATTR);
+        }
+        if ((commonPropertiesMarked & CommonPropertyConstants.ONKEYPRESS_PROP) != 0 ||
+            (commonEventsMarked & CommonEventConstants.KEYPRESS_EVENT) != 0)
+        {
+            renderBehaviorizedAttribute(facesContext, writer, HTML.ONKEYPRESS_ATTR,
+                    uiComponent, targetClientId, ClientBehaviorEvents.KEYPRESS,
+                    clientBehaviors, HTML.ONKEYPRESS_ATTR);
+        }
+        if ((commonPropertiesMarked & CommonPropertyConstants.ONKEYDOWN_PROP) != 0 ||
+            (commonEventsMarked & CommonEventConstants.KEYDOWN_EVENT) != 0)
+        {
+            renderBehaviorizedAttribute(facesContext, writer, HTML.ONKEYDOWN_ATTR,
+                    uiComponent, targetClientId, ClientBehaviorEvents.KEYDOWN,
+                    clientBehaviors, HTML.ONKEYDOWN_ATTR);
+        }
+        if ((commonPropertiesMarked & CommonPropertyConstants.ONKEYUP_PROP) != 0 ||
+            (commonEventsMarked & CommonEventConstants.KEYUP_EVENT) != 0)
+        {
+            renderBehaviorizedAttribute(facesContext, writer, HTML.ONKEYUP_ATTR,
+                    uiComponent, targetClientId, ClientBehaviorEvents.KEYUP,
+                    clientBehaviors, HTML.ONKEYUP_ATTR);
+        }
+    }
+
+    public static void renderBehaviorizedEventHandlersWithoutOnclick(
+            FacesContext facesContext, ResponseWriter writer,
+            long commonPropertiesMarked, long commonEventsMarked,
+            UIComponent uiComponent, 
+            Map<String, List<ClientBehavior>> clientBehaviors)
+            throws IOException
+    {
+        renderBehaviorizedEventHandlersWithoutOnclick(facesContext, writer, 
+                commonPropertiesMarked, commonEventsMarked, uiComponent,
+                uiComponent.getClientId(facesContext), clientBehaviors);
+    }
+
+    /**
+     * @param facesContext
+     * @param writer
+     * @param uiComponent
+     * @param clientBehaviors
+     * @throws IOException
+     * @since 4.0.0
+     */
+    public static void renderBehaviorizedEventHandlersWithoutOnclick(
+            FacesContext facesContext, ResponseWriter writer,
+            long commonPropertiesMarked, long commonEventsMarked,
+            UIComponent uiComponent, String targetClientId,
+            Map<String, List<ClientBehavior>> clientBehaviors)
+            throws IOException
+    {
+        if ((commonPropertiesMarked & CommonPropertyConstants.ONDBLCLICK_PROP) != 0 ||
+            (commonEventsMarked & CommonEventConstants.DBLCLICK_EVENT) != 0)
+        {
+            renderBehaviorizedAttribute(facesContext, writer, HTML.ONDBLCLICK_ATTR,
+                    uiComponent, targetClientId, ClientBehaviorEvents.DBLCLICK,
+                    clientBehaviors, HTML.ONDBLCLICK_ATTR);
+        }
+        if ((commonPropertiesMarked & CommonPropertyConstants.ONMOUSEDOWN_PROP) != 0 ||
+            (commonEventsMarked & CommonEventConstants.MOUSEDOWN_EVENT) != 0)
+        {
+            renderBehaviorizedAttribute(facesContext, writer,
+                    HTML.ONMOUSEDOWN_ATTR, uiComponent, targetClientId,
+                    ClientBehaviorEvents.MOUSEDOWN, clientBehaviors,
+                    HTML.ONMOUSEDOWN_ATTR);
+        }
+        if ((commonPropertiesMarked & CommonPropertyConstants.ONMOUSEUP_PROP) != 0 ||
+            (commonEventsMarked & CommonEventConstants.MOUSEUP_EVENT) != 0)
+        {
+            renderBehaviorizedAttribute(facesContext, writer, HTML.ONMOUSEUP_ATTR,
+                    uiComponent, targetClientId, ClientBehaviorEvents.MOUSEUP,
+                    clientBehaviors, HTML.ONMOUSEUP_ATTR);
+        }
+        if ((commonPropertiesMarked & CommonPropertyConstants.ONMOUSEOVER_PROP) != 0 ||
+            (commonEventsMarked & CommonEventConstants.MOUSEOVER_EVENT) != 0)
+        {
+            renderBehaviorizedAttribute(facesContext, writer,
+                    HTML.ONMOUSEOVER_ATTR, uiComponent, targetClientId,
+                    ClientBehaviorEvents.MOUSEOVER, clientBehaviors,
+                    HTML.ONMOUSEOVER_ATTR);
+        }
+        if ((commonPropertiesMarked & CommonPropertyConstants.ONMOUSEMOVE_PROP) != 0 ||
+            (commonEventsMarked & CommonEventConstants.MOUSEMOVE_EVENT) != 0)
+        {
+            renderBehaviorizedAttribute(facesContext, writer,
+                    HTML.ONMOUSEMOVE_ATTR, uiComponent, targetClientId,
+                    ClientBehaviorEvents.MOUSEMOVE, clientBehaviors,
+                    HTML.ONMOUSEMOVE_ATTR);
+        }
+        if ((commonPropertiesMarked & CommonPropertyConstants.ONMOUSEOUT_PROP) != 0 ||
+            (commonEventsMarked & CommonEventConstants.MOUSEOUT_EVENT) != 0)
+        {
+            renderBehaviorizedAttribute(facesContext, writer, HTML.ONMOUSEOUT_ATTR,
+                    uiComponent, targetClientId, ClientBehaviorEvents.MOUSEOUT,
+                    clientBehaviors, HTML.ONMOUSEOUT_ATTR);
+        }
+        if ((commonPropertiesMarked & CommonPropertyConstants.ONKEYPRESS_PROP) != 0 ||
+            (commonEventsMarked & CommonEventConstants.KEYPRESS_EVENT) != 0)
+        {
+            renderBehaviorizedAttribute(facesContext, writer, HTML.ONKEYPRESS_ATTR,
+                    uiComponent, targetClientId, ClientBehaviorEvents.KEYPRESS,
+                    clientBehaviors, HTML.ONKEYPRESS_ATTR);
+        }
+        if ((commonPropertiesMarked & CommonPropertyConstants.ONKEYDOWN_PROP) != 0 ||
+            (commonEventsMarked & CommonEventConstants.KEYDOWN_EVENT) != 0)
+        {
+            renderBehaviorizedAttribute(facesContext, writer, HTML.ONKEYDOWN_ATTR,
+                    uiComponent, targetClientId, ClientBehaviorEvents.KEYDOWN,
+                    clientBehaviors, HTML.ONKEYDOWN_ATTR);
+        }
+        if ((commonPropertiesMarked & CommonPropertyConstants.ONKEYUP_PROP) != 0 ||
+            (commonEventsMarked & CommonEventConstants.KEYUP_EVENT) != 0)
+        {
+            renderBehaviorizedAttribute(facesContext, writer, HTML.ONKEYUP_ATTR,
+                    uiComponent, targetClientId, ClientBehaviorEvents.KEYUP,
+                    clientBehaviors, HTML.ONKEYUP_ATTR);
+        }
+    }
+
+    /**
+     * @param facesContext
+     * @param writer
+     * @param uiComponent
+     * @param clientBehaviors
+     * @throws IOException
+     * @since 4.0.0
+     */
+    public static void renderBehaviorizedFieldEventHandlers(
+            FacesContext facesContext, ResponseWriter writer,
+            long commonPropertiesMarked, long commonEventsMarked,
+            UIComponent uiComponent, String targetClientId,
+            Map<String, List<ClientBehavior>> clientBehaviors)
+            throws IOException
+    {
+        if ((commonPropertiesMarked & CommonPropertyConstants.ONFOCUS_PROP) != 0 ||
+            (commonEventsMarked & CommonEventConstants.FOCUS_EVENT) != 0)
+        {
+            renderBehaviorizedAttribute(facesContext, writer, HTML.ONFOCUS_ATTR,
+                    uiComponent, targetClientId, ClientBehaviorEvents.FOCUS, clientBehaviors,
+                    HTML.ONFOCUS_ATTR);
+        }
+        if ((commonPropertiesMarked & CommonPropertyConstants.ONBLUR_PROP) != 0 ||
+            (commonEventsMarked & CommonEventConstants.BLUR_EVENT) != 0)
+        {
+            renderBehaviorizedAttribute(facesContext, writer, HTML.ONBLUR_ATTR,
+                    uiComponent, targetClientId, ClientBehaviorEvents.BLUR, clientBehaviors,
+                    HTML.ONBLUR_ATTR);
+        }
+        if ((commonPropertiesMarked & CommonPropertyConstants.ONCHANGE_PROP) != 0 ||
+            (commonEventsMarked & CommonEventConstants.CHANGE_EVENT) != 0)
+        {
+            renderBehaviorizedAttribute(facesContext, writer, HTML.ONCHANGE_ATTR,
+                    uiComponent, targetClientId, ClientBehaviorEvents.CHANGE, clientBehaviors,
+                    HTML.ONCHANGE_ATTR);
+        }
+        if ((commonPropertiesMarked & CommonPropertyConstants.ONSELECT_PROP) != 0 ||
+            (commonEventsMarked & CommonEventConstants.SELECT_EVENT) != 0)
+        {
+            renderBehaviorizedAttribute(facesContext, writer, HTML.ONSELECT_ATTR,
+                    uiComponent, targetClientId, ClientBehaviorEvents.SELECT, clientBehaviors,
+                    HTML.ONSELECT_ATTR);
+        }
+    }
+
+    public static void renderBehaviorizedFieldEventHandlersWithoutOnfocus(
+            FacesContext facesContext, ResponseWriter writer,
+            long commonPropertiesMarked, long commonEventsMarked,
+            UIComponent uiComponent, String targetClientId,
+            Map<String, List<ClientBehavior>> clientBehaviors)
+            throws IOException
+    {
+        if ((commonPropertiesMarked & CommonPropertyConstants.ONBLUR_PROP) != 0 ||
+            (commonEventsMarked & CommonEventConstants.BLUR_EVENT) != 0)
+        {
+            renderBehaviorizedAttribute(facesContext, writer, HTML.ONBLUR_ATTR,
+                    uiComponent, targetClientId, ClientBehaviorEvents.BLUR, clientBehaviors,
+                    HTML.ONBLUR_ATTR);
+        }
+        if ((commonPropertiesMarked & CommonPropertyConstants.ONCHANGE_PROP) != 0 ||
+            (commonEventsMarked & CommonEventConstants.CHANGE_EVENT) != 0)
+        {
+            renderBehaviorizedAttribute(facesContext, writer, HTML.ONCHANGE_ATTR,
+                    uiComponent, targetClientId, ClientBehaviorEvents.CHANGE, clientBehaviors,
+                    HTML.ONCHANGE_ATTR);
+        }
+        if ((commonPropertiesMarked & CommonPropertyConstants.ONSELECT_PROP) != 0 ||
+            (commonEventsMarked & CommonEventConstants.SELECT_EVENT) != 0)
+        {
+            renderBehaviorizedAttribute(facesContext, writer, HTML.ONSELECT_ATTR,
+                    uiComponent, targetClientId, ClientBehaviorEvents.SELECT, clientBehaviors,
+                    HTML.ONSELECT_ATTR);
+        }
+    }
+
+    public static void renderBehaviorizedFieldEventHandlersWithoutOnchange(
+            FacesContext facesContext, ResponseWriter writer,
+            long commonPropertiesMarked, long commonEventsMarked,
+            UIComponent uiComponent, 
+            Map<String, List<ClientBehavior>> clientBehaviors)
+            throws IOException
+    {
+        renderBehaviorizedFieldEventHandlersWithoutOnchange(
+                facesContext, writer, commonPropertiesMarked, commonEventsMarked, 
+                uiComponent, uiComponent.getClientId(facesContext), clientBehaviors);
+    }
+    
+    public static void renderBehaviorizedFieldEventHandlersWithoutOnchange(
+            FacesContext facesContext, ResponseWriter writer,
+            long commonPropertiesMarked, long commonEventsMarked,
+            UIComponent uiComponent, String targetClientId,
+            Map<String, List<ClientBehavior>> clientBehaviors)
+            throws IOException
+    {
+        if ((commonPropertiesMarked & CommonPropertyConstants.ONFOCUS_PROP) != 0 ||
+            (commonEventsMarked & CommonEventConstants.FOCUS_EVENT) != 0)
+        {
+            renderBehaviorizedAttribute(facesContext, writer, HTML.ONFOCUS_ATTR,
+                    uiComponent, targetClientId, ClientBehaviorEvents.FOCUS, clientBehaviors,
+                    HTML.ONFOCUS_ATTR);
+        }
+        if ((commonPropertiesMarked & CommonPropertyConstants.ONBLUR_PROP) != 0 ||
+            (commonEventsMarked & CommonEventConstants.BLUR_EVENT) != 0)
+        {
+            renderBehaviorizedAttribute(facesContext, writer, HTML.ONBLUR_ATTR,
+                    uiComponent, targetClientId, ClientBehaviorEvents.BLUR, clientBehaviors,
+                    HTML.ONBLUR_ATTR);
+        }
+        if ((commonPropertiesMarked & CommonPropertyConstants.ONSELECT_PROP) != 0 ||
+            (commonEventsMarked & CommonEventConstants.SELECT_EVENT) != 0)
+        {
+            renderBehaviorizedAttribute(facesContext, writer, HTML.ONSELECT_ATTR,
+                    uiComponent, targetClientId, ClientBehaviorEvents.SELECT, clientBehaviors,
+                    HTML.ONSELECT_ATTR);
+        }
+    }
+
+    public static void renderBehaviorizedFieldEventHandlersWithoutOnchangeAndOnselect(
+            FacesContext facesContext, ResponseWriter writer,
+            long commonPropertiesMarked, long commonEventsMarked,
+            UIComponent uiComponent,
+            Map<String, List<ClientBehavior>> clientBehaviors)
+            throws IOException
+    {
+        renderBehaviorizedFieldEventHandlersWithoutOnchangeAndOnselect(
+                facesContext, writer, 
+                commonPropertiesMarked, commonEventsMarked, 
+                uiComponent, uiComponent.getClientId(facesContext), 
+                clientBehaviors);
+    }
+    
+    public static void renderBehaviorizedFieldEventHandlersWithoutOnchangeAndOnselect(
+            FacesContext facesContext, ResponseWriter writer,
+            long commonPropertiesMarked, long commonEventsMarked,
+            UIComponent uiComponent, String targetClientId,
+            Map<String, List<ClientBehavior>> clientBehaviors)
+            throws IOException
+    {
+        if ((commonPropertiesMarked & CommonPropertyConstants.ONFOCUS_PROP) != 0 ||
+            (commonEventsMarked & CommonEventConstants.FOCUS_EVENT) != 0)
+        {
+            renderBehaviorizedAttribute(facesContext, writer, HTML.ONFOCUS_ATTR,
+                    uiComponent, targetClientId, ClientBehaviorEvents.FOCUS, clientBehaviors,
+                    HTML.ONFOCUS_ATTR);
+        }
+        if ((commonPropertiesMarked & CommonPropertyConstants.ONBLUR_PROP) != 0 ||
+            (commonEventsMarked & CommonEventConstants.BLUR_EVENT) != 0)
+        {
+            renderBehaviorizedAttribute(facesContext, writer, HTML.ONBLUR_ATTR,
+                    uiComponent, targetClientId, ClientBehaviorEvents.BLUR, clientBehaviors,
+                    HTML.ONBLUR_ATTR);
+        }
+    }
+}

Propchange: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/CommonEventUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/CommonPropertyUtils.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/CommonPropertyUtils.java?rev=1230345&r1=1230344&r2=1230345&view=diff
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/CommonPropertyUtils.java (original)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/CommonPropertyUtils.java Thu Jan 12 01:07:37 2012
@@ -43,32 +43,23 @@ public final class CommonPropertyUtils
         return component.getId() != null && !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX);
     }
 
-    public static final void renderHTMLStringAttribute(ResponseWriter writer,
-            UIComponent component, String componentProperty, String htmlAttrName)
-            throws IOException
-    {
-        String value = (String) component.getAttributes()
-                .get(componentProperty);
-        writer.writeAttribute(htmlAttrName, value, componentProperty);
-    }
-
     public static final void renderUniversalProperties(ResponseWriter writer,
             long commonPropertiesMarked, UIComponent component)
             throws IOException
     {
         if ((commonPropertiesMarked & CommonPropertyConstants.DIR_PROP) != 0)
         {
-            renderHTMLStringAttribute(writer, component,
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
                     HTML.DIR_ATTR, HTML.DIR_ATTR);
         }
         if ((commonPropertiesMarked & CommonPropertyConstants.LANG_PROP) != 0)
         {
-            renderHTMLStringAttribute(writer, component,
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
                     HTML.LANG_ATTR, HTML.LANG_ATTR);
         }
         if ((commonPropertiesMarked & CommonPropertyConstants.TITLE_PROP) != 0)
         {
-            renderHTMLStringAttribute(writer, component,
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
                     HTML.TITLE_ATTR, HTML.TITLE_ATTR);
         }
     }
@@ -79,12 +70,12 @@ public final class CommonPropertyUtils
     {
         if ((commonPropertiesMarked & CommonPropertyConstants.DIR_PROP) != 0)
         {
-            renderHTMLStringAttribute(writer, component,
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
                     HTML.DIR_ATTR, HTML.DIR_ATTR);
         }
         if ((commonPropertiesMarked & CommonPropertyConstants.LANG_PROP) != 0)
         {
-            renderHTMLStringAttribute(writer, component,
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
                     HTML.LANG_ATTR, HTML.LANG_ATTR);
         }
     }
@@ -95,12 +86,12 @@ public final class CommonPropertyUtils
     {
         if ((commonPropertiesMarked & CommonPropertyConstants.STYLE_PROP) != 0)
         {
-            renderHTMLStringAttribute(writer, component,
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
                     HTML.STYLE_ATTR, HTML.STYLE_ATTR);
         }
         if ((commonPropertiesMarked & CommonPropertyConstants.STYLECLASS_PROP) != 0)
         {
-            renderHTMLStringAttribute(writer, component,
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
                     HTML.STYLE_CLASS_ATTR, HTML.CLASS_ATTR);
         }
     }
@@ -111,7 +102,7 @@ public final class CommonPropertyUtils
     {
         if ((commonPropertiesMarked & CommonPropertyConstants.ONCLICK_PROP) != 0)
         {
-            renderHTMLStringAttribute(writer, component,
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
                     HTML.ONCLICK_ATTR, HTML.ONCLICK_ATTR);
         }
         renderEventPropertiesWithoutOnclick(writer, commonPropertiesMarked, component);
@@ -123,47 +114,47 @@ public final class CommonPropertyUtils
     {
         if ((commonPropertiesMarked & CommonPropertyConstants.ONDBLCLICK_PROP) != 0)
         {
-            renderHTMLStringAttribute(writer, component,
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
                     HTML.ONDBLCLICK_ATTR, HTML.ONDBLCLICK_ATTR);
         }
         if ((commonPropertiesMarked & CommonPropertyConstants.ONMOUSEDOWN_PROP) != 0)
         {
-            renderHTMLStringAttribute(writer, component,
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
                     HTML.ONMOUSEDOWN_ATTR, HTML.ONMOUSEDOWN_ATTR);
         }
         if ((commonPropertiesMarked & CommonPropertyConstants.ONMOUSEUP_PROP) != 0)
         {
-            renderHTMLStringAttribute(writer, component,
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
                     HTML.ONMOUSEUP_ATTR, HTML.ONMOUSEUP_ATTR);
         }
         if ((commonPropertiesMarked & CommonPropertyConstants.ONMOUSEOVER_PROP) != 0)
         {
-            renderHTMLStringAttribute(writer, component,
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
                     HTML.ONMOUSEOVER_ATTR, HTML.ONMOUSEOVER_ATTR);
         }
         if ((commonPropertiesMarked & CommonPropertyConstants.ONMOUSEMOVE_PROP) != 0)
         {
-            renderHTMLStringAttribute(writer, component,
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
                     HTML.ONMOUSEMOVE_ATTR, HTML.ONMOUSEMOVE_ATTR);
         }
         if ((commonPropertiesMarked & CommonPropertyConstants.ONMOUSEOUT_PROP) != 0)
         {
-            renderHTMLStringAttribute(writer, component,
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
                     HTML.ONMOUSEOUT_ATTR, HTML.ONMOUSEOUT_ATTR);
         }
         if ((commonPropertiesMarked & CommonPropertyConstants.ONKEYPRESS_PROP) != 0)
         {
-            renderHTMLStringAttribute(writer, component,
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
                     HTML.ONKEYPRESS_ATTR, HTML.ONKEYPRESS_ATTR);
         }
         if ((commonPropertiesMarked & CommonPropertyConstants.ONKEYDOWN_PROP) != 0)
         {
-            renderHTMLStringAttribute(writer, component,
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
                     HTML.ONKEYDOWN_ATTR, HTML.ONKEYDOWN_ATTR);
         }
         if ((commonPropertiesMarked & CommonPropertyConstants.ONKEYUP_PROP) != 0)
         {
-            renderHTMLStringAttribute(writer, component,
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
                     HTML.ONKEYUP_ATTR, HTML.ONKEYUP_ATTR);
         }
     }
@@ -175,12 +166,12 @@ public final class CommonPropertyUtils
     {
         if ((commonPropertiesMarked & CommonPropertyConstants.ONCHANGE_PROP) != 0)
         {
-            renderHTMLStringAttribute(writer, component,
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
                     HTML.ONCHANGE_ATTR, HTML.ONCHANGE_ATTR);
         }
         if ((commonPropertiesMarked & CommonPropertyConstants.ONSELECT_PROP) != 0)
         {
-            renderHTMLStringAttribute(writer, component,
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
                     HTML.ONSELECT_ATTR, HTML.ONSELECT_ATTR);
         }
     }
@@ -191,28 +182,73 @@ public final class CommonPropertyUtils
     {
         if ((commonPropertiesMarked & CommonPropertyConstants.ONFOCUS_PROP) != 0)
         {
-            renderHTMLStringAttribute(writer, component,
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
                     HTML.ONFOCUS_ATTR, HTML.ONFOCUS_ATTR);
         }
         if ((commonPropertiesMarked & CommonPropertyConstants.ONBLUR_PROP) != 0)
         {
-            renderHTMLStringAttribute(writer, component,
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
                     HTML.ONBLUR_ATTR, HTML.ONBLUR_ATTR);
         }
     }
     
+    public static final void renderFieldEventPropertiesWithoutOnchangeAndOnselect(ResponseWriter writer,
+            long commonPropertiesMarked, UIComponent component) throws IOException
+    {
+        if ((commonPropertiesMarked & CommonPropertyConstants.ONFOCUS_PROP) != 0)
+        {
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
+                    HTML.ONFOCUS_ATTR, HTML.ONFOCUS_ATTR);
+        }
+        if ((commonPropertiesMarked & CommonPropertyConstants.ONBLUR_PROP) != 0)
+        {
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
+                    HTML.ONBLUR_ATTR, HTML.ONBLUR_ATTR);
+        }
+    }
+    
+    public static final void renderFieldEventPropertiesWithoutOnchange(ResponseWriter writer,
+            long commonPropertiesMarked, UIComponent component) throws IOException
+    {
+        if ((commonPropertiesMarked & CommonPropertyConstants.ONFOCUS_PROP) != 0)
+        {
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
+                    HTML.ONFOCUS_ATTR, HTML.ONFOCUS_ATTR);
+        }
+        if ((commonPropertiesMarked & CommonPropertyConstants.ONBLUR_PROP) != 0)
+        {
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
+                    HTML.ONBLUR_ATTR, HTML.ONBLUR_ATTR);
+        }
+        if ((commonPropertiesMarked & CommonPropertyConstants.ONSELECT_PROP) != 0)
+        {
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
+                    HTML.ONSELECT_ATTR, HTML.ONSELECT_ATTR);
+        }
+    }
+    
+    public static final void renderChangeEventProperty(ResponseWriter writer,
+            long commonPropertiesMarked, UIComponent component) throws IOException
+    {
+        if ((commonPropertiesMarked & CommonPropertyConstants.ONCHANGE_PROP) != 0)
+        {
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
+                    HTML.ONCHANGE_ATTR, HTML.ONCHANGE_ATTR);
+        }
+    }
+    
     public static void renderAccesskeyTabindexProperties(ResponseWriter writer,
             long commonPropertiesMarked, UIComponent component)
             throws IOException
     {
         if ((commonPropertiesMarked & CommonPropertyConstants.ACCESSKEY_PROP) != 0)
         {
-            renderHTMLStringAttribute(writer, component,
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
                     HTML.ACCESSKEY_ATTR, HTML.ACCESSKEY_ATTR);
         }
         if ((commonPropertiesMarked & CommonPropertyConstants.TABINDEX_PROP) != 0)
         {
-            renderHTMLStringAttribute(writer, component,
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
                     HTML.TABINDEX_ATTR, HTML.TABINDEX_ATTR);
         }
     }
@@ -223,12 +259,12 @@ public final class CommonPropertyUtils
     {
         if ((commonPropertiesMarked & CommonPropertyConstants.ALIGN_PROP) != 0)
         {
-            renderHTMLStringAttribute(writer, component,
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
                     HTML.ALIGN_ATTR, HTML.ALIGN_ATTR);
         }
         if ((commonPropertiesMarked & CommonPropertyConstants.ALT_PROP) != 0)
         {
-            renderHTMLStringAttribute(writer, component,
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
                     HTML.ALT_ATTR, HTML.ALT_ATTR);
         }
     }
@@ -244,7 +280,7 @@ public final class CommonPropertyUtils
         }
         if ((commonPropertiesMarked & CommonPropertyConstants.ALT_PROP) != 0)
         {
-            renderHTMLStringAttribute(writer, component,
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
                     HTML.ALT_ATTR, HTML.ALT_ATTR);
         }
         if ((commonPropertiesMarked & CommonPropertyConstants.CHECKED_PROP) != 0)
@@ -276,42 +312,42 @@ public final class CommonPropertyUtils
         renderAccesskeyTabindexProperties(writer, commonPropertiesMarked, component);
         if ((commonPropertiesMarked & CommonPropertyConstants.CHARSET_PROP) != 0)
         {
-            renderHTMLStringAttribute(writer, component,
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
                     HTML.CHARSET_ATTR, HTML.CHARSET_ATTR);
         }        
         if ((commonPropertiesMarked & CommonPropertyConstants.COORDS_PROP) != 0)
         {
-            renderHTMLStringAttribute(writer, component,
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
                     HTML.COORDS_ATTR, HTML.COORDS_ATTR);
         }        
         if ((commonPropertiesMarked & CommonPropertyConstants.HREFLANG_PROP) != 0)
         {
-            renderHTMLStringAttribute(writer, component,
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
                     HTML.HREFLANG_ATTR, HTML.HREFLANG_ATTR);
         }        
         if ((commonPropertiesMarked & CommonPropertyConstants.REL_PROP) != 0)
         {
-            renderHTMLStringAttribute(writer, component,
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
                     HTML.REL_ATTR, HTML.REL_ATTR);
         }        
         if ((commonPropertiesMarked & CommonPropertyConstants.REV_PROP) != 0)
         {
-            renderHTMLStringAttribute(writer, component,
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
                     HTML.REV_ATTR, HTML.REV_ATTR);
         }        
         if ((commonPropertiesMarked & CommonPropertyConstants.SHAPE_PROP) != 0)
         {
-            renderHTMLStringAttribute(writer, component,
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
                     HTML.SHAPE_ATTR, HTML.SHAPE_ATTR);
         }        
         if ((commonPropertiesMarked & CommonPropertyConstants.TARGET_PROP) != 0)
         {
-            renderHTMLStringAttribute(writer, component,
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
                     HTML.TARGET_ATTR, HTML.TARGET_ATTR);
         }        
         if ((commonPropertiesMarked & CommonPropertyConstants.TYPE_PROP) != 0)
         {
-            renderHTMLStringAttribute(writer, component,
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
                     HTML.TYPE_ATTR, HTML.TYPE_ATTR);
         }        
     }
@@ -438,7 +474,7 @@ public final class CommonPropertyUtils
         renderFocusBlurEventProperties(writer, commonPropertiesMarked, component);
         if ((commonPropertiesMarked & CommonPropertyConstants.ACCESSKEY_PROP) != 0)
         {
-            renderHTMLStringAttribute(writer, component,
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
                     HTML.ACCESSKEY_ATTR, HTML.ACCESSKEY_ATTR);
         }
     }
@@ -458,9 +494,23 @@ public final class CommonPropertyUtils
     {
         if ((commonPropertiesMarked & CommonPropertyConstants.ACCESSKEY_PROP) != 0)
         {
-            renderHTMLStringAttribute(writer, component,
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
                     HTML.ACCESSKEY_ATTR, HTML.ACCESSKEY_ATTR);
         }
         renderCommonPassthroughPropertiesWithoutEvents(writer, commonPropertiesMarked, component);
     }
+    
+    public static final void renderSelectPassthroughPropertiesWithoutDisabled(ResponseWriter writer,
+            long commonPropertiesMarked, UIComponent component)
+            throws IOException
+    {
+        renderCommonFieldPassthroughPropertiesWithoutDisabled(writer, commonPropertiesMarked, component);
+    }
+    
+    public static final void renderSelectPassthroughPropertiesWithoutDisabledAndEvents(ResponseWriter writer,
+            long commonPropertiesMarked, UIComponent component)
+            throws IOException
+    {
+        renderCommonFieldPassthroughPropertiesWithoutDisabledAndEvents(writer, commonPropertiesMarked, component);
+    }
 }

Modified: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlOutcomeTargetButtonRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlOutcomeTargetButtonRendererBase.java?rev=1230345&r1=1230344&r2=1230345&view=diff
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlOutcomeTargetButtonRendererBase.java (original)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlOutcomeTargetButtonRendererBase.java Thu Jan 12 01:07:37 2012
@@ -119,7 +119,7 @@ public class HtmlOutcomeTargetButtonRend
             }
             else
             {
-                StringBuffer onClick = new StringBuffer();
+                StringBuilder onClick = new StringBuilder();
     
                 if (commandOnClick != null)
                 {
@@ -162,7 +162,7 @@ public class HtmlOutcomeTargetButtonRend
                     writer, commonPropertiesMarked, uiComponent);
             if ((commonPropertiesMarked & CommonPropertyConstants.ALT_PROP) != 0)
             {
-                CommonPropertyUtils.renderHTMLStringAttribute(writer, uiComponent,
+                HtmlRendererUtils.renderHTMLStringAttribute(writer, uiComponent,
                         HTML.ALT_ATTR, HTML.ALT_ATTR);
             }
         }
@@ -186,7 +186,7 @@ public class HtmlOutcomeTargetButtonRend
             }
             HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent,
                     HTML.COMMON_FIELD_PASSTROUGH_ATTRIBUTES_WITHOUT_DISABLED_AND_EVENTS);
-            HtmlRendererUtils.renderHTMLAttribute(writer, uiComponent,
+            HtmlRendererUtils.renderHTMLStringAttribute(writer, uiComponent,
                     HTML.ALT_ATTR, HTML.ALT_ATTR);
         }
 

Modified: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java?rev=1230345&r1=1230344&r2=1230345&view=diff
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java (original)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java Thu Jan 12 01:07:37 2012
@@ -105,7 +105,7 @@ public final class HtmlRendererUtils
             + "  You cannot submit a form after disabling an input element via javascript."
             + "  Consider setting read-only to true instead"
             + " or resetting the disabled value back to false prior to form submission.";
-    private static final String STR_EMPTY = "";
+    public static final String STR_EMPTY = "";
 
     private HtmlRendererUtils()
     {
@@ -861,6 +861,158 @@ public final class HtmlRendererUtils
             writer.writeAttribute(HTML.NAME_ATTR, clientId, null);
         }
     }
+    
+    /**
+     * Renders a html string type attribute. If the value retrieved from the component 
+     * property is "", the attribute is rendered.
+     * 
+     * @param writer
+     * @param component
+     * @param componentProperty
+     * @param htmlAttrName
+     * @return
+     * @throws IOException
+     */
+    public static final boolean renderHTMLStringPreserveEmptyAttribute(ResponseWriter writer,
+            UIComponent component, String componentProperty, String htmlAttrName)
+            throws IOException
+    {
+        String value = (String) component.getAttributes()
+                .get(componentProperty);
+        if (!isDefaultStringPreserveEmptyAttributeValue(value))
+        {
+            writer.writeAttribute(htmlAttrName, value, componentProperty);
+            return true;
+        }
+        return false;
+    }
+    
+    /**
+     * Renders a html string type attribute. If the value retrieved from the component 
+     * property is "", the attribute is rendered.
+     * 
+     * @param writer
+     * @param component
+     * @param componentProperty
+     * @param htmlAttrName
+     * @return
+     * @throws IOException
+     */
+    public static final boolean renderHTMLStringPreserveEmptyAttribute(ResponseWriter writer,
+            String componentProperty, String htmlAttrName, String value)
+            throws IOException
+    {
+        if (!isDefaultStringPreserveEmptyAttributeValue(value))
+        {
+            writer.writeAttribute(htmlAttrName, value, componentProperty);
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * Check if the value is the default for String type attributes that requires preserve "" as
+     * a valid value.
+     * 
+     * @param value
+     * @return
+     */
+    private static final boolean isDefaultStringPreserveEmptyAttributeValue(String value)
+    {
+        if (value == null)
+        {
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+    /**
+     * Renders a html string type attribute. If the value retrieved from the component 
+     * property is "" or null, the attribute is not rendered.
+     * 
+     * @param writer
+     * @param component
+     * @param componentProperty
+     * @param htmlAttrName
+     * @return
+     * @throws IOException
+     */
+    public static final boolean renderHTMLStringAttribute(ResponseWriter writer,
+            UIComponent component, String componentProperty, String htmlAttrName)
+            throws IOException
+    {
+        String value = (String) component.getAttributes()
+                .get(componentProperty);
+        if (!isDefaultStringAttributeValue(value))
+        {
+            writer.writeAttribute(htmlAttrName, value, componentProperty);
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * Renders a html string type attribute. If the value retrieved from the component 
+     * property is "" or null, the attribute is not rendered.
+     * 
+     * @param writer
+     * @param componentProperty
+     * @param htmlAttrName
+     * @param value
+     * @return
+     * @throws IOException
+     */
+    public static final boolean renderHTMLStringAttribute(ResponseWriter writer,
+            String componentProperty, String htmlAttrName, String value)
+            throws IOException
+    {
+        if (!isDefaultStringAttributeValue(value))
+        {
+            writer.writeAttribute(htmlAttrName, value, componentProperty);
+            return true;
+        }
+        return false;
+    }
+    
+    /**
+     * Check if the value is the default for String type attributes (null or "").
+     * 
+     * @param value
+     * @return
+     */
+    private static final boolean isDefaultStringAttributeValue(String value)
+    {
+        if (value == null)
+        {
+            return true;
+        }
+        else if (value.length() == 0)
+        {
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    }
+    
+    public static boolean renderHTMLStringNoStyleAttributes(ResponseWriter writer,
+            UIComponent component, String[] attributes) throws IOException
+    {
+        boolean somethingDone = false;
+        for (int i = 0, len = attributes.length; i < len; i++)
+        {
+            String attrName = attributes[i];
+            if (renderHTMLStringAttribute(writer, component, attrName, attrName))
+            {
+                somethingDone = true;
+            }
+        }
+        return somethingDone;
+    }
 
     public static void writeIdAndName(ResponseWriter writer,
             UIComponent component, FacesContext facesContext)
@@ -2494,18 +2646,18 @@ public final class HtmlRendererUtils
             {
                 if (attributeValue != null)
                 {
-                    return renderHTMLAttribute(writer, componentProperty,
+                    return renderHTMLStringAttribute(writer, componentProperty,
                             htmlAttrName, attributeValue);
                 }
                 else
                 {
-                    return renderHTMLAttribute(writer, componentProperty,
+                    return renderHTMLStringAttribute(writer, componentProperty,
                             htmlAttrName, serverSideScript);
                 }
             }
             else
             {
-                return renderHTMLAttribute(
+                return renderHTMLStringAttribute(
                         writer,
                         componentProperty,
                         htmlAttrName,
@@ -2519,7 +2671,7 @@ public final class HtmlRendererUtils
         }
         else
         {
-            return renderHTMLAttribute(writer, componentProperty, htmlAttrName,
+            return renderHTMLStringAttribute(writer, componentProperty, htmlAttrName,
                     HtmlRendererUtils.buildBehaviorChain(facesContext,
                             component, targetClientId, eventName,
                             eventParameters, clientBehaviors, attributeValue,
@@ -2581,17 +2733,17 @@ public final class HtmlRendererUtils
         {
             if (attributeValue != null)
             {
-                return renderHTMLAttribute(writer, componentProperty,
+                return renderHTMLStringAttribute(writer, componentProperty,
                         htmlAttrName, attributeValue);
             }
             else if (serverSideScript != null)
             {
-                return renderHTMLAttribute(writer, componentProperty,
+                return renderHTMLStringAttribute(writer, componentProperty,
                         htmlAttrName, serverSideScript);
             }
             else if (((cb1 != null) ? cb1.size() : 0) > 0)
             {
-                return renderHTMLAttribute(
+                return renderHTMLStringAttribute(
                         writer,
                         componentProperty,
                         htmlAttrName,
@@ -2604,7 +2756,7 @@ public final class HtmlRendererUtils
             }
             else
             {
-                return renderHTMLAttribute(
+                return renderHTMLStringAttribute(
                         writer,
                         componentProperty,
                         htmlAttrName,
@@ -2618,7 +2770,7 @@ public final class HtmlRendererUtils
         }
         else
         {
-            return renderHTMLAttribute(writer, componentProperty, htmlAttrName,
+            return renderHTMLStringAttribute(writer, componentProperty, htmlAttrName,
                     HtmlRendererUtils.buildBehaviorChain(facesContext,
                             component, targetClientId, eventName,
                             eventParameters, eventName2, eventParameters2,
@@ -2895,7 +3047,7 @@ public final class HtmlRendererUtils
                     (String) uiComponent.getAttributes()
                             .get(HTML.ONCHANGE_ATTR), null);
 
-            return HtmlRendererUtils.renderHTMLAttribute(writer,
+            return HtmlRendererUtils.renderHTMLStringAttribute(writer,
                     HTML.ONCHANGE_ATTR, HTML.ONCHANGE_ATTR, chain);
         }
         else if (hasChange)
@@ -2914,7 +3066,7 @@ public final class HtmlRendererUtils
         }
         else
         {
-            return HtmlRendererUtils.renderHTMLAttribute(writer, uiComponent,
+            return HtmlRendererUtils.renderHTMLStringAttribute(writer, uiComponent,
                     HTML.ONCHANGE_ATTR, HTML.ONCHANGE_ATTR);
         }
     }
@@ -2940,7 +3092,7 @@ public final class HtmlRendererUtils
                     (String) uiComponent.getAttributes()
                             .get(HTML.ONCHANGE_ATTR), null);
 
-            return HtmlRendererUtils.renderHTMLAttribute(writer,
+            return HtmlRendererUtils.renderHTMLStringAttribute(writer,
                     HTML.ONCHANGE_ATTR, HTML.ONCHANGE_ATTR, chain);
         }
         else if (hasChange)
@@ -2959,7 +3111,7 @@ public final class HtmlRendererUtils
         }
         else
         {
-            return HtmlRendererUtils.renderHTMLAttribute(writer, uiComponent,
+            return HtmlRendererUtils.renderHTMLStringAttribute(writer, uiComponent,
                     HTML.ONCHANGE_ATTR, HTML.ONCHANGE_ATTR);
         }
     }