myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r1239799 [4/9] - in /myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared: application/ config/ context/flash/ renderkit/ renderkit/html/ renderkit/html/util/ resource/ util/ util/io/ util/xml/
Date Thu, 02 Feb 2012 20:00:44 GMT
Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlGridRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlGridRendererBase.java?rev=1239799&r1=1239798&r2=1239799&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlGridRendererBase.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlGridRendererBase.java Thu Feb  2 20:00:42 2012
@@ -19,7 +19,6 @@
 package org.apache.myfaces.shared.renderkit.html;
 
 import java.io.IOException;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.logging.Level;
@@ -94,7 +93,8 @@ public class HtmlGridRendererBase
         }
         else
         {
-            Integer i = (Integer)component.getAttributes().get(org.apache.myfaces.shared.renderkit.JSFAttr.COLUMNS_ATTR);
+            Integer i = (Integer)component.getAttributes().get(
+                    org.apache.myfaces.shared.renderkit.JSFAttr.COLUMNS_ATTR);
             columns = i != null ? i.intValue() : 0;
         }
 
@@ -102,7 +102,8 @@ public class HtmlGridRendererBase
         {
             if (log.isLoggable(Level.SEVERE))
             {
-                log.severe("Wrong columns attribute for PanelGrid " + component.getClientId(facesContext) + ": " + columns);
+                log.severe("Wrong columns attribute for PanelGrid " + 
+                        component.getClientId(facesContext) + ": " + columns);
             }
             columns = 1;
         }
@@ -121,7 +122,8 @@ public class HtmlGridRendererBase
         
         writer.startElement(HTML.TABLE_ELEM, component);
         
-        if (component instanceof ClientBehaviorHolder && JavascriptUtils.isJavascriptAllowed(facesContext.getExternalContext()))
+        if (component instanceof ClientBehaviorHolder && JavascriptUtils.isJavascriptAllowed(
+                facesContext.getExternalContext()))
         {
             if (!behaviors.isEmpty())
             {
@@ -131,16 +133,39 @@ public class HtmlGridRendererBase
             {
                 HtmlRendererUtils.writeIdIfNecessary(writer, component, facesContext);
             }
-            HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, component, behaviors);
+            long commonPropertiesMarked = 0L;
+            if (isCommonPropertiesOptimizationEnabled(facesContext))
+            {
+                commonPropertiesMarked = CommonPropertyUtils.getCommonPropertiesMarked(component);
+            }
+            if (behaviors.isEmpty() && isCommonPropertiesOptimizationEnabled(facesContext))
+            {
+                CommonPropertyUtils.renderEventProperties(writer, 
+                        commonPropertiesMarked, component);
+            }
+            else
+            {
+                if (isCommonEventsOptimizationEnabled(facesContext))
+                {
+                    CommonEventUtils.renderBehaviorizedEventHandlers(facesContext, writer, 
+                           commonPropertiesMarked,
+                           CommonEventUtils.getCommonEventsMarked(component), component, behaviors);
+                }
+                else
+                {
+                    HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, component, behaviors);
+                }
+            }
             if (isCommonPropertiesOptimizationEnabled(facesContext))
             {
                 HtmlRendererUtils.renderHTMLAttributes(writer, component, HTML.TABLE_ATTRIBUTES);
                 CommonPropertyUtils.renderCommonPassthroughPropertiesWithoutEvents(writer, 
-                        CommonPropertyUtils.getCommonPropertiesMarked(component), component);
+                        commonPropertiesMarked, component);
             }
             else
             {
-                HtmlRendererUtils.renderHTMLAttributes(writer, component, HTML.TABLE_PASSTHROUGH_ATTRIBUTES_WITHOUT_EVENTS);
+                HtmlRendererUtils.renderHTMLAttributes(writer, component, 
+                        HTML.TABLE_PASSTHROUGH_ATTRIBUTES_WITHOUT_EVENTS);
             }
         }
         else
@@ -181,10 +206,14 @@ public class HtmlGridRendererBase
         throws IOException
     {
         UIComponent facet = component.getFacet(header ? "header" : "footer");
-        if (facet == null) return;
+        if (facet == null)
+        {
+            return;
+        }
 
         HtmlRendererUtils.writePrettyLineSeparator(context);
-        writer.startElement(header ? org.apache.myfaces.shared.renderkit.html.HTML.THEAD_ELEM : HTML.TFOOT_ELEM, component);
+        writer.startElement(
+                header ? org.apache.myfaces.shared.renderkit.html.HTML.THEAD_ELEM : HTML.TFOOT_ELEM, component);
         writer.startElement(HTML.TR_ELEM, component);
         writer.startElement(header ? HTML.TH_ELEM : HTML.TD_ELEM, component);
 
@@ -194,11 +223,13 @@ public class HtmlGridRendererBase
                          ((HtmlPanelGrid)component).getFooterClass())
             : (header ?
                          (String)component.getAttributes().get(JSFAttr.HEADER_CLASS_ATTR) :
-                         (String)component.getAttributes().get(org.apache.myfaces.shared.renderkit.JSFAttr.FOOTER_CLASS_ATTR));
+                         (String)component.getAttributes().get(
+                                 org.apache.myfaces.shared.renderkit.JSFAttr.FOOTER_CLASS_ATTR));
         if (styleClass != null)
         {
             writer.writeAttribute(HTML.CLASS_ATTR, styleClass,
-                                  header ? JSFAttr.HEADER_CLASS_ATTR : org.apache.myfaces.shared.renderkit.JSFAttr.FOOTER_CLASS_ATTR);
+                                  header ? JSFAttr.HEADER_CLASS_ATTR : 
+                                      org.apache.myfaces.shared.renderkit.JSFAttr.FOOTER_CLASS_ATTR);
         }
 
         if (header)
@@ -243,7 +274,8 @@ public class HtmlGridRendererBase
         }
         else
         {
-            columnClasses = (String)component.getAttributes().get(org.apache.myfaces.shared.renderkit.JSFAttr.COLUMN_CLASSES_ATTR);
+            columnClasses = (String)component.getAttributes().get(
+                    org.apache.myfaces.shared.renderkit.JSFAttr.COLUMN_CLASSES_ATTR);
             rowClasses = (String)component.getAttributes().get(JSFAttr.ROW_CLASSES_ATTR);
         }
 
@@ -284,9 +316,9 @@ public class HtmlGridRendererBase
             int columnIndex = 0;
             int rowClassIndex = 0;
             boolean rowStarted = false;
-            for (Iterator it = getChildren(component).iterator(); it.hasNext(); )
+            for (int i = 0, size =  component.getChildCount(); i < size; i++)
             {
-                UIComponent child = (UIComponent)it.next();
+                UIComponent child = component.getChildren().get(i);
                 if (child.isRendered())
                 {
                     if (columnIndex == 0)
@@ -316,12 +348,14 @@ public class HtmlGridRendererBase
                         
                         //start of new/next row
                         writer.startElement(HTML.TR_ELEM, component);
-                        if (rowClassIndex < rowClassesCount) {
+                        if (rowClassIndex < rowClassesCount)
+                        {
                             writer.writeAttribute(HTML.CLASS_ATTR, rowClassesArray[rowClassIndex], null);
                         }
                         rowStarted = true;
                         rowClassIndex++;
-                        if (rowClassIndex == rowClassesCount) {
+                        if (rowClassIndex == rowClassesCount)
+                        {
                             rowClassIndex = 0;
                         }
                     }
@@ -337,7 +371,8 @@ public class HtmlGridRendererBase
                     writer.endElement(HTML.TD_ELEM);
 
                     columnIndex++;
-                    if (columnIndex >= columns) {
+                    if (columnIndex >= columns)
+                    {
                         columnIndex = 0;
                     }
                 }
@@ -350,7 +385,9 @@ public class HtmlGridRendererBase
                     Level level = context.isProjectStage(ProjectStage.Production) ? Level.FINE : Level.WARNING;
                     if (log.isLoggable(level))
                     {
-                        log.log(level, "PanelGrid " + RendererUtils.getPathToComponent(component) + " has not enough children. Child count should be a multiple of the columns attribute.");
+                        log.log(level, "PanelGrid " + RendererUtils.getPathToComponent(component) 
+                                + " has not enough children. Child count should be a " 
+                                + "multiple of the columns attribute.");
                     }
                     //Render empty columns, so that table is correct
                     for ( ; columnIndex < columns; columnIndex++)

Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlImageRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlImageRendererBase.java?rev=1239799&r1=1239798&r2=1239799&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlImageRendererBase.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlImageRendererBase.java Thu Feb  2 20:00:42 2012
@@ -61,7 +61,8 @@ public class HtmlImageRendererBase
     public void encodeEnd(FacesContext facesContext, UIComponent uiComponent)
             throws IOException
     {
-        org.apache.myfaces.shared.renderkit.RendererUtils.checkParamValidity(facesContext, uiComponent, UIGraphic.class);
+        org.apache.myfaces.shared.renderkit.RendererUtils.checkParamValidity(
+                facesContext, uiComponent, UIGraphic.class);
 
         ResponseWriter writer = facesContext.getResponseWriter();
         
@@ -95,8 +96,12 @@ public class HtmlImageRendererBase
         }
         else
         {
-          if (facesContext.isProjectStage(ProjectStage.Development) && log.isLoggable(Level.WARNING)) 
-              log.warning("Component UIGraphic " + uiComponent.getClientId(facesContext) + " has no attribute url, value, name or attribute resolves to null. Path to component " + RendererUtils.getPathToComponent(uiComponent));
+          if (facesContext.isProjectStage(ProjectStage.Development) && log.isLoggable(Level.WARNING))
+          {
+              log.warning("Component UIGraphic " + uiComponent.getClientId(facesContext) 
+                      + " has no attribute url, value, name or attribute resolves to null. Path to component " 
+                      + RendererUtils.getPathToComponent(uiComponent));
+          }
         }
 
         /* 
@@ -105,12 +110,34 @@ public class HtmlImageRendererBase
         if (uiComponent.getAttributes().get(HTML.ALT_ATTR) == null) 
         {
             if(!facesContext.isProjectStage(ProjectStage.Development) && log.isLoggable(Level.WARNING))
-                log.warning("Component UIGraphic " + uiComponent.getClientId(facesContext) + " has no attribute alt or attribute resolves to null. Path to component " + RendererUtils.getPathToComponent(uiComponent));
+            {
+                log.warning("Component UIGraphic " + uiComponent.getClientId(facesContext) 
+                        + " has no attribute alt or attribute resolves to null. Path to component " 
+                        + RendererUtils.getPathToComponent(uiComponent));
+            }
         }
 
-        if (uiComponent instanceof ClientBehaviorHolder && JavascriptUtils.isJavascriptAllowed(facesContext.getExternalContext()))
+        if (uiComponent instanceof ClientBehaviorHolder && JavascriptUtils.isJavascriptAllowed(
+                facesContext.getExternalContext()))
         {
-            HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, uiComponent, behaviors);
+            if (behaviors.isEmpty() && isCommonPropertiesOptimizationEnabled(facesContext))
+            {
+                CommonPropertyUtils.renderEventProperties(writer, 
+                        CommonPropertyUtils.getCommonPropertiesMarked(uiComponent), uiComponent);
+            }
+            else
+            {
+                if (isCommonEventsOptimizationEnabled(facesContext))
+                {
+                    CommonEventUtils.renderBehaviorizedEventHandlers(facesContext, writer, 
+                           CommonPropertyUtils.getCommonPropertiesMarked(uiComponent),
+                           CommonEventUtils.getCommonEventsMarked(uiComponent), uiComponent, behaviors);
+                }
+                else
+                {
+                    HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, uiComponent, behaviors);
+                }
+            }
             if (isCommonPropertiesOptimizationEnabled(facesContext))
             {
                 HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, HTML.IMG_ATTRIBUTES);
@@ -119,7 +146,8 @@ public class HtmlImageRendererBase
             }
             else
             {
-                HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, HTML.IMG_PASSTHROUGH_ATTRIBUTES_WITHOUT_EVENTS);
+                HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, 
+                        HTML.IMG_PASSTHROUGH_ATTRIBUTES_WITHOUT_EVENTS);
             }
         }
         else
@@ -132,7 +160,8 @@ public class HtmlImageRendererBase
             }
             else
             {
-                HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, HTML.IMG_PASSTHROUGH_ATTRIBUTES);
+                HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, 
+                        HTML.IMG_PASSTHROUGH_ATTRIBUTES);
             }
         }
 

Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlJavaScriptUtils.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlJavaScriptUtils.java?rev=1239799&r1=1239798&r2=1239799&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlJavaScriptUtils.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlJavaScriptUtils.java Thu Feb  2 20:00:42 2012
@@ -359,7 +359,7 @@ public final class HtmlJavaScriptUtils
         context.prettyLineDecreaseIndent();
     }
     
-    public static void appendAutoScrollAssignment(StringBuffer onClickValue,
+    public static void appendAutoScrollAssignment(StringBuilder onClickValue,
             String formName)
     {
         appendAutoScrollAssignment(FacesContext.getCurrentInstance(),
@@ -371,7 +371,7 @@ public final class HtmlJavaScriptUtils
      * feature to an html link or button onclick attribute.
      */
     public static void appendAutoScrollAssignment(FacesContext context,
-            StringBuffer onClickValue, String formName)
+            StringBuilder onClickValue, String formName)
     {
         appendAutoScrollAssignment(context, new ScriptContext(onClickValue,
                 false), formName);
@@ -380,11 +380,11 @@ public final class HtmlJavaScriptUtils
     private static void appendAutoScrollAssignment(FacesContext context,
             ScriptContext scriptContext, String formName)
     {
-        String formNameStr = formName == null ? "formName" : (new StringBuffer(
+        String formNameStr = formName == null ? "formName" : (new StringBuilder(
                 "'").append(formName).append("'").toString());
-        String paramName = new StringBuffer().append("'")
+        String paramName = new StringBuilder().append("'")
                 .append(AUTO_SCROLL_PARAM).append("'").toString();
-        String value = new StringBuffer().append(AUTO_SCROLL_FUNCTION)
+        String value = new StringBuilder().append(AUTO_SCROLL_FUNCTION)
                 .append("()").toString();
 
         scriptContext.prettyLine();
@@ -523,7 +523,7 @@ public final class HtmlJavaScriptUtils
     }
     
     public static void appendClearHiddenCommandFormParamsFunctionCall(
-            StringBuffer buf, String formName)
+            StringBuilder buf, String formName)
     {
         appendClearHiddenCommandFormParamsFunctionCall(new ScriptContext(buf,
                 false), formName);
@@ -611,7 +611,7 @@ public final class HtmlJavaScriptUtils
         writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
 
         // Using writeComment instead of write with <!-- tag
-        StringBuffer script = new StringBuffer();
+        StringBuilder script = new StringBuilder();
         script.append("function ");
         script.append(functionName);
         script.append("() {");
@@ -685,7 +685,7 @@ public final class HtmlJavaScriptUtils
 
         //return escaped;
 
-        StringBuffer out = null;
+        StringBuilder out = null;
         for (int pos = 0; pos < javaScript.length(); pos++)
         {
             char c = javaScript.charAt(pos);
@@ -694,7 +694,7 @@ public final class HtmlJavaScriptUtils
             {
                 if (out == null)
                 {
-                    out = new StringBuffer(javaScript.length() + 8);
+                    out = new StringBuilder(javaScript.length() + 8);
                     if (pos > 0)
                     {
                         out.append(javaScript, 0, pos);

Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlLinkRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlLinkRendererBase.java?rev=1239799&r1=1239798&r2=1239799&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlLinkRendererBase.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlLinkRendererBase.java Thu Feb  2 20:00:42 2012
@@ -24,6 +24,7 @@ import java.net.URLEncoder;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
+import java.util.RandomAccess;
 
 import javax.faces.application.ViewHandler;
 import javax.faces.component.UICommand;
@@ -244,13 +245,39 @@ public abstract class HtmlLinkRendererBa
                 {
                     HtmlRendererUtils.writeIdIfNecessary(writer, component, facesContext);
                 }
-                HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, component, behaviors);
-                HtmlRendererUtils.renderBehaviorizedFieldEventHandlersWithoutOnchangeAndOnselect(
-                        facesContext, writer, component, behaviors);
+                long commonPropertiesMarked = 0L;
+                if (isCommonPropertiesOptimizationEnabled(facesContext))
+                {
+                    commonPropertiesMarked = CommonPropertyUtils.getCommonPropertiesMarked(component);
+                }
+                if (behaviors.isEmpty() && isCommonPropertiesOptimizationEnabled(facesContext))
+                {
+                    CommonPropertyUtils.renderEventProperties(writer, 
+                            commonPropertiesMarked, component);
+                    CommonPropertyUtils.renderFocusBlurEventProperties(writer,
+                            commonPropertiesMarked, component);
+                }
+                else
+                {
+                    if (isCommonEventsOptimizationEnabled(facesContext))
+                    {
+                        Long commonEventsMarked = CommonEventUtils.getCommonEventsMarked(component);
+                        CommonEventUtils.renderBehaviorizedEventHandlers(facesContext, writer, 
+                                commonPropertiesMarked, commonEventsMarked, component, behaviors);
+                        CommonEventUtils.renderBehaviorizedFieldEventHandlersWithoutOnchangeAndOnselect(
+                            facesContext, writer, commonPropertiesMarked, commonEventsMarked, component, behaviors);
+                    }
+                    else
+                    {
+                        HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, component, behaviors);
+                        HtmlRendererUtils.renderBehaviorizedFieldEventHandlersWithoutOnchangeAndOnselect(
+                                facesContext, writer, component, behaviors);
+                    }
+                }
                 if (isCommonPropertiesOptimizationEnabled(facesContext))
                 {
                     CommonPropertyUtils.renderAnchorPassthroughPropertiesWithoutEvents(writer, 
-                            CommonPropertyUtils.getCommonPropertiesMarked(component), component);
+                            commonPropertiesMarked, component);
                 }
                 else
                 {
@@ -290,14 +317,29 @@ public abstract class HtmlLinkRendererBa
                     {
                         HtmlRendererUtils.writeIdIfNecessary(writer, component, facesContext);
                     }
-                    HtmlRendererUtils.renderBehaviorizedEventHandlersWithoutOnclick(
-                            facesContext, writer, component, behaviors);
-                    HtmlRendererUtils.renderBehaviorizedFieldEventHandlersWithoutOnchangeAndOnselect(
-                            facesContext, writer, component, behaviors);
+                    long commonPropertiesMarked = 0L;
+                    if (isCommonPropertiesOptimizationEnabled(facesContext))
+                    {
+                        commonPropertiesMarked = CommonPropertyUtils.getCommonPropertiesMarked(component);
+                    }
+                    if (behaviors.isEmpty() && isCommonPropertiesOptimizationEnabled(facesContext))
+                    {
+                        CommonPropertyUtils.renderEventPropertiesWithoutOnclick(writer,
+                            commonPropertiesMarked, component);
+                        CommonPropertyUtils.renderFocusBlurEventProperties(writer,
+                                commonPropertiesMarked, component);
+                    }
+                    else
+                    {
+                        HtmlRendererUtils.renderBehaviorizedEventHandlersWithoutOnclick(
+                                facesContext, writer, component, behaviors);
+                        HtmlRendererUtils.renderBehaviorizedFieldEventHandlersWithoutOnchangeAndOnselect(
+                                facesContext, writer, component, behaviors);
+                    }
                     if (isCommonPropertiesOptimizationEnabled(facesContext))
                     {
                         CommonPropertyUtils.renderAnchorPassthroughPropertiesWithoutStyleAndEvents(writer, 
-                                CommonPropertyUtils.getCommonPropertiesMarked(component), component);
+                                commonPropertiesMarked, component);
                     }
                     else
                     {
@@ -368,7 +410,7 @@ public abstract class HtmlLinkRendererBa
         UIComponent nestingForm = formInfo.getForm();
         String formName = formInfo.getFormName();
 
-        StringBuffer onClick = new StringBuffer();
+        StringBuilder onClick = new StringBuilder();
 
         String commandOnclick;
         if (component instanceof HtmlCommandLink)
@@ -400,7 +442,7 @@ public abstract class HtmlLinkRendererBa
         {
             HtmlRendererUtils.renderFormSubmitScript(facesContext);
 
-            StringBuffer params = addChildParameters(facesContext, component, nestingForm);
+            StringBuilder params = addChildParameters(facesContext, component, nestingForm);
 
             String target = getTarget(component);
 
@@ -511,11 +553,28 @@ public abstract class HtmlLinkRendererBa
         List<ClientBehavior> eventBehaviors = clientBehaviors.get(eventName);
         if (eventBehaviors != null && !eventBehaviors.isEmpty())
         {
-            for (ClientBehavior behavior : eventBehaviors)
+            // perf: in 99% cases is  eventBehaviors javax.faces.component._DeltaList._DeltaList(int) = RandomAccess
+            // instance created in javax.faces.component.UIComponentBase.addClientBehavior(String, ClientBehavior), but
+            // component libraries can provide own implementation
+            if (eventBehaviors instanceof RandomAccess)
             {
-                if (behavior.getHints().contains(ClientBehaviorHint.SUBMITTING))
+                for (int i = 0, size = eventBehaviors.size(); i < size; i++)
                 {
-                    return true;
+                    ClientBehavior behavior = eventBehaviors.get(i);
+                    if (behavior.getHints().contains(ClientBehaviorHint.SUBMITTING))
+                    {
+                        return true;
+                    }
+                }
+            }
+            else
+            {
+                for (ClientBehavior behavior : eventBehaviors)
+                {
+                    if (behavior.getHints().contains(ClientBehaviorHint.SUBMITTING))
+                    {
+                        return true;
+                    }
                 }
             }
         }
@@ -528,7 +587,7 @@ public abstract class HtmlLinkRendererBa
         UIComponent nestingForm = formInfo.getForm();
         String formName = formInfo.getFormName();
 
-        StringBuffer onClick = new StringBuffer();
+        StringBuilder onClick = new StringBuilder();
 
         if (RendererUtils.isAdfOrTrinidadForm(formInfo.getForm()))
         {
@@ -542,7 +601,7 @@ public abstract class HtmlLinkRendererBa
         {
             HtmlRendererUtils.renderFormSubmitScript(facesContext);
 
-            StringBuffer params = addChildParameters(facesContext, component, nestingForm);
+            StringBuilder params = addChildParameters(facesContext, component, nestingForm);
 
             String target = getTarget(component);
 
@@ -594,16 +653,17 @@ public abstract class HtmlLinkRendererBa
         return target;
     }
 
-    private StringBuffer addChildParameters(FacesContext context, UIComponent component, UIComponent nestingForm)
+    private StringBuilder addChildParameters(FacesContext context, UIComponent component, UIComponent nestingForm)
     {
         //add child parameters
-        StringBuffer params = new StringBuffer();
+        StringBuilder params = new StringBuilder();
         params.append("[");
         
         List<UIParameter> validParams = HtmlRendererUtils.getValidUIParameterChildren(
                 FacesContext.getCurrentInstance(), getChildren(component), false, false);
-        for (UIParameter param : validParams) 
+        for (int j = 0, size = validParams.size(); j < size; j++) 
         {
+            UIParameter param = validParams.get(j);
             String name = param.getName();
 
             //Not necessary, since we are using oamSetHiddenInput to create hidden fields
@@ -628,7 +688,7 @@ public abstract class HtmlLinkRendererBa
             if (value != null)
             {
                 strParamValue = value.toString();
-                StringBuffer buff = null;
+                StringBuilder buff = null;
                 for (int i = 0; i < strParamValue.length(); i++)
                 {
                     char c = strParamValue.charAt(i); 
@@ -636,7 +696,7 @@ public abstract class HtmlLinkRendererBa
                     {
                         if (buff == null)
                         {
-                            buff = new StringBuffer();
+                            buff = new StringBuilder();
                             buff.append(strParamValue.substring(0,i));
                         }
                         buff.append('\\');
@@ -701,7 +761,7 @@ public abstract class HtmlLinkRendererBa
         boolean strictXhtmlLinks
                 = MyfacesConfig.getCurrentInstance(facesContext.getExternalContext()).isStrictXhtmlLinks();
 
-        StringBuffer hrefBuf = new StringBuffer(path);
+        StringBuilder hrefBuf = new StringBuilder(path);
 
         //add clientId parameter for decode
 
@@ -741,7 +801,7 @@ public abstract class HtmlLinkRendererBa
 
     private void addChildParametersToHref(FacesContext facesContext,
                                           UIComponent linkComponent,
-                                          StringBuffer hrefBuf,
+                                          StringBuilder hrefBuf,
                                           boolean firstParameter,
                                           String charEncoding)
             throws IOException
@@ -751,8 +811,10 @@ public abstract class HtmlLinkRendererBa
         
         List<UIParameter> validParams = HtmlRendererUtils.getValidUIParameterChildren(
                 facesContext, getChildren(linkComponent), false, false);
-        for (UIParameter param : validParams)
+        
+        for (int i = 0, size = validParams.size(); i < size; i++)
         {
+            UIParameter param = validParams.get(i);
             String name = param.getName();
             Object value = param.getValue();
             addParameterToHref(name, value, hrefBuf, firstParameter, charEncoding, strictXhtmlLinks);
@@ -781,13 +843,40 @@ public abstract class HtmlLinkRendererBa
                 {
                     HtmlRendererUtils.writeIdIfNecessary(writer, output, facesContext);
                 }
-                HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, output, behaviors);
-                HtmlRendererUtils.renderBehaviorizedFieldEventHandlersWithoutOnchangeAndOnselect(
-                        facesContext, writer, output, behaviors);
+                long commonPropertiesMarked = 0L;
+                if (isCommonPropertiesOptimizationEnabled(facesContext))
+                {
+                    commonPropertiesMarked = CommonPropertyUtils.getCommonPropertiesMarked(output);
+                }
+
+                if (behaviors.isEmpty() && isCommonPropertiesOptimizationEnabled(facesContext))
+                {
+                    CommonPropertyUtils.renderEventProperties(writer, 
+                            commonPropertiesMarked, output);
+                    CommonPropertyUtils.renderFocusBlurEventProperties(writer,
+                            commonPropertiesMarked, output);
+                }
+                else
+                {
+                    if (isCommonEventsOptimizationEnabled(facesContext))
+                    {
+                        Long commonEventsMarked = CommonEventUtils.getCommonEventsMarked(output);
+                        CommonEventUtils.renderBehaviorizedEventHandlers(facesContext, writer, 
+                                commonPropertiesMarked, commonEventsMarked, output, behaviors);
+                        CommonEventUtils.renderBehaviorizedFieldEventHandlersWithoutOnchangeAndOnselect(
+                            facesContext, writer, commonPropertiesMarked, commonEventsMarked, output, behaviors);
+                    }
+                    else
+                    {
+                        HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, output, behaviors);
+                        HtmlRendererUtils.renderBehaviorizedFieldEventHandlersWithoutOnchangeAndOnselect(
+                                facesContext, writer, output, behaviors);
+                    }
+                }
                 if (isCommonPropertiesOptimizationEnabled(facesContext))
                 {
                     CommonPropertyUtils.renderAnchorPassthroughPropertiesWithoutEvents(writer, 
-                            CommonPropertyUtils.getCommonPropertiesMarked(output), output);
+                            commonPropertiesMarked, output);
                 }
                 else
                 {
@@ -826,7 +915,7 @@ public abstract class HtmlLinkRendererBa
             }
             if (getChildCount(output) > 0)
             {
-                StringBuffer hrefBuf = new StringBuffer(href);
+                StringBuilder hrefBuf = new StringBuilder(href);
                 addChildParametersToHref(facesContext, output, hrefBuf,
                                      (href.indexOf('?') == -1), //first url parameter?
                                      writer.getCharacterEncoding());
@@ -867,13 +956,39 @@ public abstract class HtmlLinkRendererBa
                 {
                     HtmlRendererUtils.writeIdAndNameIfNecessary(writer, output, facesContext);
                 }
-                HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, output, behaviors);
-                HtmlRendererUtils.renderBehaviorizedFieldEventHandlersWithoutOnchangeAndOnselect(
-                        facesContext, writer, output, behaviors);
+                long commonPropertiesMarked = 0L;
+                if (isCommonPropertiesOptimizationEnabled(facesContext))
+                {
+                    commonPropertiesMarked = CommonPropertyUtils.getCommonPropertiesMarked(output);
+                }
+                if (behaviors.isEmpty() && isCommonPropertiesOptimizationEnabled(facesContext))
+                {
+                    CommonPropertyUtils.renderEventProperties(writer, 
+                            commonPropertiesMarked, output);
+                    CommonPropertyUtils.renderFocusBlurEventProperties(writer,
+                            commonPropertiesMarked, output);
+                }
+                else
+                {
+                    if (isCommonEventsOptimizationEnabled(facesContext))
+                    {
+                        Long commonEventsMarked = CommonEventUtils.getCommonEventsMarked(output);
+                        CommonEventUtils.renderBehaviorizedEventHandlers(facesContext, writer, 
+                                commonPropertiesMarked, commonEventsMarked, output, behaviors);
+                        CommonEventUtils.renderBehaviorizedFieldEventHandlersWithoutOnchangeAndOnselect(
+                            facesContext, writer, commonPropertiesMarked, commonEventsMarked, output, behaviors);
+                    }
+                    else
+                    {
+                        HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, output, behaviors);
+                        HtmlRendererUtils.renderBehaviorizedFieldEventHandlersWithoutOnchangeAndOnselect(
+                                facesContext, writer, output, behaviors);
+                    }
+                }
                 if (isCommonPropertiesOptimizationEnabled(facesContext))
                 {
                     CommonPropertyUtils.renderAnchorPassthroughPropertiesWithoutEvents(writer, 
-                            CommonPropertyUtils.getCommonPropertiesMarked(output), output);
+                            commonPropertiesMarked, output);
                 }
                 else
                 {
@@ -923,13 +1038,39 @@ public abstract class HtmlLinkRendererBa
                 {
                     HtmlRendererUtils.writeIdIfNecessary(writer, output, facesContext);
                 }
-                HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, output, behaviors);
-                HtmlRendererUtils.renderBehaviorizedFieldEventHandlersWithoutOnchangeAndOnselect(
-                        facesContext, writer, output, behaviors);
+                long commonPropertiesMarked = 0L;
+                if (isCommonPropertiesOptimizationEnabled(facesContext))
+                {
+                    commonPropertiesMarked = CommonPropertyUtils.getCommonPropertiesMarked(output);
+                }
+                if (behaviors.isEmpty() && isCommonPropertiesOptimizationEnabled(facesContext))
+                {
+                    CommonPropertyUtils.renderEventProperties(writer, 
+                            commonPropertiesMarked, output);
+                    CommonPropertyUtils.renderFocusBlurEventProperties(writer,
+                            commonPropertiesMarked, output);
+                }
+                else
+                {
+                    if (isCommonEventsOptimizationEnabled(facesContext))
+                    {
+                        Long commonEventsMarked = CommonEventUtils.getCommonEventsMarked(output);
+                        CommonEventUtils.renderBehaviorizedEventHandlers(facesContext, writer, 
+                                commonPropertiesMarked, commonEventsMarked, output, behaviors);
+                        CommonEventUtils.renderBehaviorizedFieldEventHandlersWithoutOnchangeAndOnselect(
+                            facesContext, writer, commonPropertiesMarked, commonEventsMarked, output, behaviors);
+                    }
+                    else
+                    {
+                        HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, output, behaviors);
+                        HtmlRendererUtils.renderBehaviorizedFieldEventHandlersWithoutOnchangeAndOnselect(
+                                facesContext, writer, output, behaviors);
+                    }
+                }
                 if (isCommonPropertiesOptimizationEnabled(facesContext))
                 {
                     CommonPropertyUtils.renderAnchorPassthroughPropertiesWithoutEvents(writer, 
-                            CommonPropertyUtils.getCommonPropertiesMarked(output), output);
+                            commonPropertiesMarked, output);
                 }
                 else
                 {
@@ -975,13 +1116,39 @@ public abstract class HtmlLinkRendererBa
                 {
                     HtmlRendererUtils.writeIdAndNameIfNecessary(writer, output, facesContext);
                 }
-                HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, output, behaviors);
-                HtmlRendererUtils.renderBehaviorizedFieldEventHandlersWithoutOnchangeAndOnselect(
-                        facesContext, writer, output, behaviors);
+                long commonPropertiesMarked = 0L;
+                if (isCommonPropertiesOptimizationEnabled(facesContext))
+                {
+                    commonPropertiesMarked = CommonPropertyUtils.getCommonPropertiesMarked(output);
+                }
+                if (behaviors.isEmpty() && isCommonPropertiesOptimizationEnabled(facesContext))
+                {
+                    CommonPropertyUtils.renderEventProperties(writer, 
+                            commonPropertiesMarked, output);
+                    CommonPropertyUtils.renderFocusBlurEventProperties(writer,
+                            commonPropertiesMarked, output);
+                }
+                else
+                {
+                    if (isCommonEventsOptimizationEnabled(facesContext))
+                    {
+                        Long commonEventsMarked = CommonEventUtils.getCommonEventsMarked(output);
+                        CommonEventUtils.renderBehaviorizedEventHandlers(facesContext, writer, 
+                                commonPropertiesMarked, commonEventsMarked, output, behaviors);
+                        CommonEventUtils.renderBehaviorizedFieldEventHandlersWithoutOnchangeAndOnselect(
+                            facesContext, writer, commonPropertiesMarked, commonEventsMarked, output, behaviors);
+                    }
+                    else
+                    {
+                        HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, output, behaviors);
+                        HtmlRendererUtils.renderBehaviorizedFieldEventHandlersWithoutOnchangeAndOnselect(
+                                facesContext, writer, output, behaviors);
+                    }
+                }
                 if (isCommonPropertiesOptimizationEnabled(facesContext))
                 {
                     CommonPropertyUtils.renderAnchorPassthroughPropertiesWithoutEvents(writer, 
-                            CommonPropertyUtils.getCommonPropertiesMarked(output), output);
+                            commonPropertiesMarked, output);
                 }
                 else
                 {
@@ -1011,7 +1178,7 @@ public abstract class HtmlLinkRendererBa
 
     private void renderLinkParameter(String name,
                                      Object value,
-                                     StringBuffer onClick,
+                                     StringBuilder onClick,
                                      String jsForm,
                                      UIComponent nestingForm)
     {
@@ -1031,7 +1198,7 @@ public abstract class HtmlLinkRendererBa
 
     private static void addParameterToHref(String name,
                                            Object value,
-                                           StringBuffer hrefBuf,
+                                           StringBuilder hrefBuf,
                                            boolean firstParameter,
                                            String charEncoding,
                                            boolean strictXhtmlLinks) throws UnsupportedEncodingException

Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlListboxRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlListboxRendererBase.java?rev=1239799&r1=1239798&r2=1239799&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlListboxRendererBase.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlListboxRendererBase.java Thu Feb  2 20:00:42 2012
@@ -43,7 +43,7 @@ import java.util.Map;
  * @version $Revision$ $Date$
  */
 public class HtmlListboxRendererBase
-        extends HtmlRenderer
+        extends HtmlSelectableRendererBase
 {
     public void encodeEnd(FacesContext facesContext, UIComponent uiComponent)
             throws IOException
@@ -69,14 +69,14 @@ public class HtmlListboxRendererBase
 
         if (uiComponent instanceof UISelectMany)
         {
-            HtmlRendererUtils.renderListbox(facesContext,
+            renderListbox(facesContext,
                                             (UISelectMany)uiComponent,
                                             isDisabled(facesContext, uiComponent),
                                             size, getConverter(facesContext, uiComponent));
         }
         else if (uiComponent instanceof HtmlSelectOneListbox)
         {
-            HtmlRendererUtils.renderListbox(facesContext,
+            renderListbox(facesContext,
                                             (UISelectOne)uiComponent,
                                             isDisabled(facesContext, uiComponent),
                                             size, getConverter(facesContext, uiComponent));
@@ -86,6 +86,22 @@ public class HtmlListboxRendererBase
             throw new IllegalArgumentException("Unsupported component class " + uiComponent.getClass().getName());
         }
     }
+    
+    protected void renderListbox(FacesContext facesContext,
+            UISelectOne selectOne, boolean disabled, int size,
+            Converter converter) throws IOException
+    {
+        internalRenderSelect(facesContext, selectOne, disabled, size, false,
+                converter);
+    }
+
+    protected void renderListbox(FacesContext facesContext,
+            UISelectMany selectMany, boolean disabled, int size,
+            Converter converter) throws IOException
+    {
+        internalRenderSelect(facesContext, selectMany, disabled, size, true,
+                converter);
+    }
 
     protected boolean isDisabled(FacesContext facesContext, UIComponent uiComponent)
     {

Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlMenuRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlMenuRendererBase.java?rev=1239799&r1=1239798&r2=1239799&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlMenuRendererBase.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlMenuRendererBase.java Thu Feb  2 20:00:42 2012
@@ -44,7 +44,7 @@ import org.apache.myfaces.shared.renderk
  * @version $Revision$ $Date$
  */
 public class HtmlMenuRendererBase
-        extends HtmlRenderer
+        extends HtmlSelectableRendererBase
 {
     //private static final Log log = LogFactory.getLog(HtmlMenuRenderer.class);
 
@@ -66,14 +66,14 @@ public class HtmlMenuRendererBase
 
         if (component instanceof UISelectMany)
         {
-            HtmlRendererUtils.renderMenu(facesContext,
+            renderMenu(facesContext,
                                          (UISelectMany)component,
                                          isDisabled(facesContext, component),
                                          getConverter(facesContext, component));
         }
         else if (component instanceof UISelectOne)
         {
-            HtmlRendererUtils.renderMenu(facesContext,
+            renderMenu(facesContext,
                                          (UISelectOne)component,
                                          isDisabled(facesContext, component),
                                          getConverter(facesContext, component));
@@ -83,6 +83,22 @@ public class HtmlMenuRendererBase
             throw new IllegalArgumentException("Unsupported component class " + component.getClass().getName());
         }
     }
+    
+    protected void renderMenu(FacesContext facesContext,
+            UISelectOne selectOne, boolean disabled, Converter converter)
+            throws IOException
+    {
+        internalRenderSelect(facesContext, selectOne, disabled, 1, false,
+                converter);
+    }
+
+    protected void renderMenu(FacesContext facesContext,
+            UISelectMany selectMany, boolean disabled, Converter converter)
+            throws IOException
+    {
+        internalRenderSelect(facesContext, selectMany, disabled, 1, true,
+                converter);
+    }
 
     protected boolean isDisabled(FacesContext facesContext, UIComponent uiComponent)
     {

Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlMessageRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlMessageRendererBase.java?rev=1239799&r1=1239798&r2=1239799&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlMessageRendererBase.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlMessageRendererBase.java Thu Feb  2 20:00:42 2012
@@ -109,8 +109,8 @@ public abstract class HtmlMessageRendere
                 ResponseWriter writer = facesContext.getResponseWriter();
                 writer.startElement(HTML.SPAN_ELEM, null);
                 writer.writeAttribute(HTML.ID_ATTR, clientId + "_msgFor", null);
-                HtmlRendererUtils.renderHTMLAttribute(writer, message, JSFAttr.STYLE_ATTR, HTML.STYLE_ATTR);
-                HtmlRendererUtils.renderHTMLAttribute(writer, message, JSFAttr.STYLE_CLASS_ATTR, HTML.CLASS_ATTR);
+                HtmlRendererUtils.renderHTMLStringAttribute(writer, message, JSFAttr.STYLE_ATTR, HTML.STYLE_ATTR);
+                HtmlRendererUtils.renderHTMLStringAttribute(writer, message, JSFAttr.STYLE_CLASS_ATTR, HTML.CLASS_ATTR);
                 writer.endElement(HTML.SPAN_ELEM);
             }
             else if (renderDivWhenNoMessagesAndIdSet && message.getId() != null && 
@@ -247,7 +247,24 @@ public abstract class HtmlMessageRendere
                     facesContext.getExternalContext()))
             {
                 behaviors = ((ClientBehaviorHolder) message).getClientBehaviors();
-                HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, message, behaviors);
+                if (behaviors.isEmpty() && isCommonPropertiesOptimizationEnabled(facesContext))
+                {
+                    CommonPropertyUtils.renderEventProperties(writer, 
+                            CommonPropertyUtils.getCommonPropertiesMarked(message), message);
+                }
+                else
+                {
+                    if (isCommonEventsOptimizationEnabled(facesContext))
+                    {
+                        CommonEventUtils.renderBehaviorizedEventHandlers(facesContext, writer, 
+                               CommonPropertyUtils.getCommonPropertiesMarked(message),
+                               CommonEventUtils.getCommonEventsMarked(message), message, behaviors);
+                    }
+                    else
+                    {
+                        HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, message, behaviors);
+                    }
+                }
                 HtmlRendererUtils.renderHTMLAttributes(writer, message, 
                         HTML.UNIVERSAL_ATTRIBUTES_WITHOUT_STYLE_AND_TITLE);
             }

Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlOutcomeTargetButtonRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlOutcomeTargetButtonRendererBase.java?rev=1239799&r1=1239798&r2=1239799&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlOutcomeTargetButtonRendererBase.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlOutcomeTargetButtonRendererBase.java Thu Feb  2 20:00:42 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/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRadioRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRadioRendererBase.java?rev=1239799&r1=1239798&r2=1239799&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRadioRendererBase.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRadioRendererBase.java Thu Feb  2 20:00:42 2012
@@ -24,7 +24,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.logging.Logger;
 
-import javax.faces.component.NamingContainer;
 import javax.faces.component.UIComponent;
 import javax.faces.component.UIInput;
 import javax.faces.component.UINamingContainer;
@@ -60,7 +59,8 @@ public class HtmlRadioRendererBase
 
     public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException
     {
-        org.apache.myfaces.shared.renderkit.RendererUtils.checkParamValidity(facesContext, uiComponent, UISelectOne.class);
+        org.apache.myfaces.shared.renderkit.RendererUtils.checkParamValidity(
+                facesContext, uiComponent, UISelectOne.class);
 
         UISelectOne selectOne = (UISelectOne)uiComponent;
 
@@ -79,7 +79,8 @@ public class HtmlRadioRendererBase
             }
             else
             {
-                log.severe("Wrong layout attribute for component " + selectOne.getClientId(facesContext) + ": " + layout);
+                log.severe("Wrong layout attribute for component " + 
+                        selectOne.getClientId(facesContext) + ": " + layout);
             }
         }
 
@@ -109,13 +110,19 @@ public class HtmlRadioRendererBase
             HtmlRendererUtils.writeIdIfNecessary(writer, selectOne, facesContext); 
         }        
 
-        if (!pageDirectionLayout) writer.startElement(HTML.TR_ELEM, selectOne);
+        if (!pageDirectionLayout)
+        {
+            writer.startElement(HTML.TR_ELEM, selectOne);
+        }
 
         Converter converter;
-        List selectItemList = org.apache.myfaces.shared.renderkit.RendererUtils.getSelectItemList(selectOne, facesContext);
+        List selectItemList = org.apache.myfaces.shared.renderkit.RendererUtils.getSelectItemList(
+                selectOne, facesContext);
         converter = HtmlRendererUtils.findUIOutputConverterFailSafe(facesContext, selectOne);
         
-        Object currentValue = org.apache.myfaces.shared.renderkit.RendererUtils.getStringFromSubmittedValueOrLocalValueReturnNull(facesContext, selectOne);
+        Object currentValue = 
+            org.apache.myfaces.shared.renderkit.RendererUtils.getStringFromSubmittedValueOrLocalValueReturnNull(
+                    facesContext, selectOne);
 
         int itemNum = 0;
 
@@ -128,7 +135,10 @@ public class HtmlRadioRendererBase
                                              converter, pageDirectionLayout, itemNum);
         }
 
-        if (!pageDirectionLayout) writer.endElement(HTML.TR_ELEM);
+        if (!pageDirectionLayout)
+        {
+            writer.endElement(HTML.TR_ELEM);
+        }
         writer.endElement(HTML.TABLE_ELEM);
     }
 
@@ -179,13 +189,16 @@ public class HtmlRadioRendererBase
         if (isSelectItemGroup) 
         {
             if (pageDirectionLayout)
+            {
                 writer.startElement(HTML.TR_ELEM, selectOne);
+            }
 
             writer.startElement(HTML.TD_ELEM, selectOne);
             writer.write(selectItem.getLabel());
             writer.endElement(HTML.TD_ELEM);
 
-            if (pageDirectionLayout) {
+            if (pageDirectionLayout)
+            {
                 writer.endElement(HTML.TR_ELEM);
                 writer.startElement(HTML.TR_ELEM, selectOne);
             }
@@ -195,7 +208,9 @@ public class HtmlRadioRendererBase
             writer.writeAttribute(HTML.BORDER_ATTR, "0", null);
             
             if(!pageDirectionLayout)
+            {
                 writer.startElement(HTML.TR_ELEM, selectOne);
+            }
 
             SelectItemGroup group = (SelectItemGroup) selectItem;
             SelectItem[] selectItems = group.getSelectItems();
@@ -207,17 +222,22 @@ public class HtmlRadioRendererBase
             }
 
             if(!pageDirectionLayout)
+            {
                 writer.endElement(HTML.TR_ELEM);
+            }
             writer.endElement(HTML.TABLE_ELEM);
             writer.endElement(HTML.TD_ELEM);
 
             if (pageDirectionLayout)
+            {
                 writer.endElement(HTML.TR_ELEM);
+            }
 
         } 
         else 
         {
-            String itemStrValue = org.apache.myfaces.shared.renderkit.RendererUtils.getConvertedStringValue(facesContext, selectOne, converter, selectItem.getValue());
+            String itemStrValue = org.apache.myfaces.shared.renderkit.RendererUtils.getConvertedStringValue(
+                    facesContext, selectOne, converter, selectItem.getValue());
             boolean itemChecked = (itemStrValue == null) ? 
                     itemStrValue == currentValue : 
                     "".equals(itemStrValue) ? 
@@ -237,12 +257,15 @@ public class HtmlRadioRendererBase
             
             writer.write("\t\t");
             if (pageDirectionLayout)
+            {
                 writer.startElement(HTML.TR_ELEM, selectOne);
+            }
             writer.startElement(HTML.TD_ELEM, selectOne);
     
             boolean itemDisabled = selectItem.isDisabled();
     
-            String itemId = renderRadio(facesContext, selectOne, itemStrValue, itemDisabled, itemChecked, false, itemNum);
+            String itemId = renderRadio(facesContext, selectOne, itemStrValue, itemDisabled, 
+                    itemChecked, false, itemNum);
     
             // label element after the input
             boolean componentDisabled = isDisabled(facesContext, selectOne);
@@ -252,7 +275,9 @@ public class HtmlRadioRendererBase
     
             writer.endElement(HTML.TD_ELEM);
             if (pageDirectionLayout)
+            {
                 writer.endElement(HTML.TR_ELEM);
+            }
             
             // we rendered one radio --> increment itemNum
             itemNum++;
@@ -287,7 +312,8 @@ public class HtmlRadioRendererBase
     {
         String clientId = uiComponent.getClientId(facesContext);
 
-        String itemId = (itemNum == null)? null : clientId + UINamingContainer.getSeparatorChar(facesContext) + itemNum;
+        String itemId = (itemNum == null)? null : clientId + 
+                UINamingContainer.getSeparatorChar(facesContext) + itemNum;
 
         ResponseWriter writer = facesContext.getResponseWriter();
 
@@ -297,13 +323,15 @@ public class HtmlRadioRendererBase
         {
             writer.writeAttribute(HTML.ID_ATTR, itemId, null);
         }
-        else if (renderId) {
+        else if (renderId)
+        {
             writer.writeAttribute(HTML.ID_ATTR, clientId, null);
         }
         writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_RADIO, null);
         writer.writeAttribute(HTML.NAME_ATTR, clientId, null);
 
-        if (disabled) {
+        if (disabled)
+        {
             writer.writeAttribute(HTML.DISABLED_ATTR, HTML.DISABLED_ATTR, null);
         }
 
@@ -322,18 +350,50 @@ public class HtmlRadioRendererBase
         }
         
         Map<String, List<ClientBehavior>> behaviors = null;
-        if (uiComponent instanceof ClientBehaviorHolder && JavascriptUtils.isJavascriptAllowed(facesContext.getExternalContext()))
+        if (uiComponent instanceof ClientBehaviorHolder && JavascriptUtils.isJavascriptAllowed(
+                facesContext.getExternalContext()))
         {
             behaviors = ((ClientBehaviorHolder) uiComponent).getClientBehaviors();
             
-            HtmlRendererUtils.renderBehaviorizedOnchangeEventHandler(facesContext, writer, uiComponent, behaviors);
-            HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, uiComponent, behaviors);
-            HtmlRendererUtils.renderBehaviorizedFieldEventHandlersWithoutOnchange(facesContext, writer, uiComponent, behaviors);
-            HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, HTML.INPUT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED_AND_STYLE_AND_EVENTS);
+            long commonPropertiesMarked = 0L;
+            if (isCommonPropertiesOptimizationEnabled(facesContext))
+            {
+                commonPropertiesMarked = CommonPropertyUtils.getCommonPropertiesMarked(uiComponent);
+            }
+            if (behaviors.isEmpty() && isCommonPropertiesOptimizationEnabled(facesContext))
+            {
+                CommonPropertyUtils.renderChangeEventProperty(writer, 
+                        commonPropertiesMarked, uiComponent);
+                CommonPropertyUtils.renderEventProperties(writer, 
+                        commonPropertiesMarked, uiComponent);
+                CommonPropertyUtils.renderFieldEventPropertiesWithoutOnchange(writer, 
+                        commonPropertiesMarked, uiComponent);
+            }
+            else
+            {
+                HtmlRendererUtils.renderBehaviorizedOnchangeEventHandler(facesContext, writer, uiComponent, behaviors);
+                if (isCommonEventsOptimizationEnabled(facesContext))
+                {
+                    Long commonEventsMarked = CommonEventUtils.getCommonEventsMarked(uiComponent);
+                    CommonEventUtils.renderBehaviorizedEventHandlers(facesContext, writer, 
+                            commonPropertiesMarked, commonEventsMarked, uiComponent, behaviors);
+                    CommonEventUtils.renderBehaviorizedFieldEventHandlersWithoutOnchange(
+                        facesContext, writer, commonPropertiesMarked, commonEventsMarked, uiComponent, behaviors);
+                }
+                else
+                {
+                    HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, uiComponent, behaviors);
+                    HtmlRendererUtils.renderBehaviorizedFieldEventHandlersWithoutOnchange(
+                            facesContext, writer, uiComponent, behaviors);
+                }
+            }
+            HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, 
+                    HTML.INPUT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED_AND_STYLE_AND_EVENTS);
         }
         else
         {
-            HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, HTML.INPUT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED_AND_STYLE);
+            HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, 
+                    HTML.INPUT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED_AND_STYLE);
         }
 
         if (isDisabled(facesContext, uiComponent))
@@ -355,7 +415,8 @@ public class HtmlRadioRendererBase
             return ((HtmlSelectOneRadio)uiComponent).isDisabled();
         }
 
-        return org.apache.myfaces.shared.renderkit.RendererUtils.getBooleanAttribute(uiComponent, HTML.DISABLED_ATTR, false);
+        return org.apache.myfaces.shared.renderkit.RendererUtils.getBooleanAttribute(
+                uiComponent, HTML.DISABLED_ATTR, false);
     }
 
 
@@ -374,7 +435,8 @@ public class HtmlRadioRendererBase
     }
 
 
-    public Object getConvertedValue(FacesContext facesContext, UIComponent uiComponent, Object submittedValue) throws ConverterException
+    public Object getConvertedValue(FacesContext facesContext, UIComponent uiComponent, Object submittedValue)
+        throws ConverterException
     {
         RendererUtils.checkParamValidity(facesContext, uiComponent, UISelectOne.class);
         return org.apache.myfaces.shared.renderkit.RendererUtils.getConvertedUISelectOneValue(facesContext,

Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRenderer.java?rev=1239799&r1=1239798&r2=1239799&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRenderer.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRenderer.java Thu Feb  2 20:00:42 2012
@@ -114,11 +114,15 @@ public abstract class HtmlRenderer
 
       // Otherwise, if ID isn't set, don't bother
       if (id == null)
-        return false;
+      {
+          return false;
+      }
 
       // ... or if the ID was generated, don't bother
       if (id.startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
-        return false;
+      {
+          return false;
+      }
 
       return true;
     }
@@ -130,7 +134,9 @@ public abstract class HtmlRenderer
     static public String toUri(Object o)
     {
       if (o == null)
-        return null;
+      {
+          return null;
+      }
 
       String uri = o.toString();
       if (uri.startsWith("/"))
@@ -154,4 +160,9 @@ public abstract class HtmlRenderer
     {
         return false;
     }
+    
+    protected boolean isCommonEventsOptimizationEnabled(FacesContext facesContext)
+    {
+        return false;
+    }
 }



Mime
View raw message