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 2011/08/02 01:25:01 UTC
svn commit: r1152968 [1/2] - in /myfaces/core/branches/2.0.x:
api/src/main/java/javax/faces/component/html/
api/src/main/resources/META-INF/
impl/src/main/java/org/apache/myfaces/renderkit/html/
impl/src/test/java/org/apache/myfaces/renderkit/html/ sha...
Author: lu4242
Date: Mon Aug 1 23:24:53 2011
New Revision: 1152968
URL: http://svn.apache.org/viewvc?rev=1152968&view=rev
Log:
MYFACES-3237 [PERF] Renderers for components like h:outputText and others do many unecessary getAttributes().get() calls
Added:
myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/html/_CommonPropertyConstants.java
myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/CommonPropertyConstants.java
myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/CommonPropertyUtils.java
Modified:
myfaces/core/branches/2.0.x/api/src/main/resources/META-INF/componentClass20.vm
myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlBodyRenderer.java
myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlButtonRenderer.java
myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlFormRenderer.java
myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlFormatRenderer.java
myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlGridRenderer.java
myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlGroupRenderer.java
myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlImageRenderer.java
myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlLabelRenderer.java
myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlLinkRenderer.java
myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlOutcomeTargetButtonRenderer.java
myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlSecretRenderer.java
myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlTableRenderer.java
myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlTextRenderer.java
myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlTextareaRenderer.java
myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlFormatRendererTest.java
myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlGroupRendererTest.java
myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlBodyRendererBase.java
myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlButtonRendererBase.java
myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlFormRendererBase.java
myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlGridRendererBase.java
myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlGroupRendererBase.java
myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlImageRendererBase.java
myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlLinkRendererBase.java
myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlOutcomeTargetButtonRendererBase.java
myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRenderer.java
myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlSecretRendererBase.java
myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTableRendererBase.java
myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTextRendererBase.java
myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTextareaRendererBase.java
Added: myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/html/_CommonPropertyConstants.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/html/_CommonPropertyConstants.java?rev=1152968&view=auto
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/html/_CommonPropertyConstants.java (added)
+++ myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/html/_CommonPropertyConstants.java Mon Aug 1 23:24:53 2011
@@ -0,0 +1,204 @@
+/*
+ * 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 javax.faces.component.html;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+
+/**
+ * This is a list of the most common properties used by a JSF html
+ * component, organized by interfaces.
+ *
+ * Note there is a copy of this class on
+ * org.apache.myfaces.shared.renderkit.html.CommonPropertyConstants.
+ * Any changes here should be committed there too.
+ *
+ * @author Leonardo Uribe
+ *
+ */
+class _CommonPropertyConstants
+{
+ public static final String COMMON_PROPERTIES_MARKED = "oam.COMMON_PROPERTIES_MARKED";
+
+ //_StyleProperties
+ public static final long STYLE_PROP = 0x1L;
+ public static final long STYLECLASS_PROP = 0x2L;
+
+ //_UniversalProperties
+ //_TitleProperty
+ public static final long DIR_PROP = 0x4L;
+ public static final long LANG_PROP = 0x8L;
+ public static final long TITLE_PROP = 0x10L;
+
+ //_EscapeProperty
+ public static final long ESCAPE_PROP = 0x20L;
+
+ //_DisabledClassEnabledClassProperties
+ //_DisabledReadonlyProperties
+ public static final long DISABLED_PROP = 0x40L;
+ public static final long ENABLED_PROP = 0x80L;
+ public static final long READONLY_PROP = 0x100L;
+
+ //_AccesskeyProperty
+ public static final long ACCESSKEY_PROP = 0x200L;
+
+ //_AltProperty
+ public static final long ALT_PROP = 0x400L;
+
+ //_ChangeSelectProperties
+ public static final long ONCHANGE_PROP = 0x800L;
+ public static final long ONSELECT_PROP = 0x1000L;
+
+ //_EventProperties
+ public static final long ONCLICK_PROP = 0x2000L;
+ public static final long ONDBLCLICK_PROP = 0x4000L;
+ public static final long ONMOUSEDOWN_PROP = 0x8000L;
+ public static final long ONMOUSEUP_PROP = 0x10000L;
+ public static final long ONMOUSEOVER_PROP = 0x20000L;
+ public static final long ONMOUSEMOVE_PROP = 0x40000L;
+ public static final long ONMOUSEOUT_PROP = 0x80000L;
+ public static final long ONKEYPRESS_PROP = 0x100000L;
+ public static final long ONKEYDOWN_PROP = 0x200000L;
+ public static final long ONKEYUP_PROP = 0x400000L;
+
+ //_FocusBlurProperties
+ public static final long ONFOCUS_PROP = 0x800000L;
+ public static final long ONBLUR_PROP = 0x1000000L;
+
+ //_LabelProperty
+ public static final long LABEL_PROP = 0x2000000L;
+
+ //_LinkProperties
+ public static final long CHARSET_PROP = 0x4000000L;
+ public static final long COORDS_PROP = 0x8000000L;
+ public static final long HREFLANG_PROP = 0x10000000L;
+ public static final long REL_PROP = 0x20000000L;
+ public static final long REV_PROP = 0x40000000L;
+ public static final long SHAPE_PROP = 0x80000000L;
+ public static final long TARGET_PROP = 0x100000000L;
+ public static final long TYPE_PROP = 0x200000000L;
+
+ //_TabindexProperty
+ public static final long TABINDEX_PROP = 0x400000000L;
+
+ //Common to input fields
+ public static final long ALIGN_PROP = 0x800000000L;
+ public static final long CHECKED_PROP = 0x1000000000L;
+ public static final long MAXLENGTH_PROP = 0x2000000000L;
+ public static final long SIZE_PROP = 0x4000000000L;
+
+ public static Map<String, Long> COMMON_PROPERTIES_KEY_BY_NAME = new HashMap<String, Long>(64,1);
+
+ static
+ {
+ COMMON_PROPERTIES_KEY_BY_NAME.put("style", STYLE_PROP);
+
+ COMMON_PROPERTIES_KEY_BY_NAME.put("styleClass", STYLECLASS_PROP);
+
+ //_UniversalProperties
+ //_TitleProperty
+ COMMON_PROPERTIES_KEY_BY_NAME.put("dir", DIR_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("lang", LANG_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("title", TITLE_PROP);
+
+ //_EscapeProperty
+ COMMON_PROPERTIES_KEY_BY_NAME.put("escape", ESCAPE_PROP);
+
+ //_DisabledClassEnabledClassProperties
+ //_DisabledReadonlyProperties
+ COMMON_PROPERTIES_KEY_BY_NAME.put("disabled", DISABLED_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("enabled", ENABLED_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("readonly", READONLY_PROP);
+
+ //_AccesskeyProperty
+ COMMON_PROPERTIES_KEY_BY_NAME.put("accesskey", ACCESSKEY_PROP);
+
+ //_AltProperty
+ COMMON_PROPERTIES_KEY_BY_NAME.put("alt", ALT_PROP);
+
+ //_ChangeSelectProperties
+ COMMON_PROPERTIES_KEY_BY_NAME.put("onchange", ONCHANGE_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("onselect", ONSELECT_PROP);
+
+ //_EventProperties
+ COMMON_PROPERTIES_KEY_BY_NAME.put("onclick", ONCLICK_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("ondblclick", ONDBLCLICK_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("onmousedown",ONMOUSEDOWN_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("onmouseup", ONMOUSEUP_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("onmouseover",ONMOUSEOVER_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("onmousemove",ONMOUSEMOVE_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("onmouseout", ONMOUSEOUT_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("onkeypress", ONKEYPRESS_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("onkeydown", ONKEYDOWN_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("onkeyup", ONKEYUP_PROP);
+
+ //_FocusBlurProperties
+ COMMON_PROPERTIES_KEY_BY_NAME.put("onfocus", ONFOCUS_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("onblur", ONBLUR_PROP);
+
+ //_LabelProperty
+ COMMON_PROPERTIES_KEY_BY_NAME.put("label", LABEL_PROP);
+
+ //_LinkProperties
+ COMMON_PROPERTIES_KEY_BY_NAME.put("charset", CHARSET_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("coords", COORDS_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("hreflang", HREFLANG_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("rel", REL_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("rev", REV_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("shape", SHAPE_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("target", TARGET_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("type", TYPE_PROP);
+
+ //_TabindexProperty
+ COMMON_PROPERTIES_KEY_BY_NAME.put("tabindex", TABINDEX_PROP);
+
+ //Common to input fields
+ COMMON_PROPERTIES_KEY_BY_NAME.put("align", ALIGN_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("checked", CHECKED_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("maxlength", MAXLENGTH_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("size", SIZE_PROP);
+ }
+
+ public static void markProperty(UIComponent component, String name)
+ {
+ Long propertyConstant = COMMON_PROPERTIES_KEY_BY_NAME.get(name);
+ if (propertyConstant == null)
+ {
+ return;
+ }
+ Long commonPropertiesSet = (Long) component.getAttributes().get(COMMON_PROPERTIES_MARKED);
+ if (commonPropertiesSet == null)
+ {
+ commonPropertiesSet = 0L;
+ }
+ component.getAttributes().put(COMMON_PROPERTIES_MARKED, commonPropertiesSet | propertyConstant);
+ }
+
+ public static void markProperty(UIComponent component, long propertyConstant)
+ {
+ Long commonPropertiesSet = (Long) component.getAttributes().get(COMMON_PROPERTIES_MARKED);
+ if (commonPropertiesSet == null)
+ {
+ commonPropertiesSet = 0L;
+ }
+ component.getAttributes().put(COMMON_PROPERTIES_MARKED, commonPropertiesSet | propertyConstant);
+ }
+}
Modified: myfaces/core/branches/2.0.x/api/src/main/resources/META-INF/componentClass20.vm
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/main/resources/META-INF/componentClass20.vm?rev=1152968&r1=1152967&r2=1152968&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/main/resources/META-INF/componentClass20.vm (original)
+++ myfaces/core/branches/2.0.x/api/src/main/resources/META-INF/componentClass20.vm Mon Aug 1 23:24:53 2011
@@ -33,6 +33,9 @@
*/
package ${component.packageName};
+#if ($component.className.startsWith("javax.faces.component.html"))
+import javax.faces.el.ValueBinding;
+#end
import javax.el.ValueExpression;
import javax.faces.context.FacesContext;
$utils.importTagClasses($component)
@@ -266,8 +269,65 @@ $innersource
public void $utils.getPrefixedPropertyName("set", $property.name)($type $utils.getVariableFromName($property.name))
{
getStateHelper().put(PropertyKeys.$field, $utils.getVariableFromName($property.name) );
- }
+#if ($property.name == "style" ||
+ $property.name == "styleClass" ||
+ $property.name == "dir" ||
+ $property.name == "lang" ||
+ $property.name == "title" ||
+ $property.name == "escape" ||
+ $property.name == "disabled" ||
+ $property.name == "enabled" ||
+ $property.name == "readOnly" ||
+ $property.name == "accesskey" ||
+ $property.name == "alt" ||
+ $property.name == "onchange" ||
+ $property.name == "onselect" ||
+ $property.name == "onclick" ||
+ $property.name == "ondblclick" ||
+ $property.name == "onmousedown" ||
+ $property.name == "onmouseup" ||
+ $property.name == "onmouseover" ||
+ $property.name == "onmousemove" ||
+ $property.name == "onmouseout" ||
+ $property.name == "onkeypress" ||
+ $property.name == "onkeydown" ||
+ $property.name == "onkeyup" ||
+ $property.name == "onfocus" ||
+ $property.name == "onblur" ||
+ $property.name == "label" ||
+ $property.name == "charset" ||
+ $property.name == "coords" ||
+ $property.name == "hreflang" ||
+ $property.name == "rel" ||
+ $property.name == "rev" ||
+ $property.name == "shape" ||
+ $property.name == "target" ||
+ $property.name == "type" ||
+ $property.name == "tabindex" ||
+ $property.name == "align" ||
+ $property.name == "checked" ||
+ $property.name == "maxlength" ||
+ $property.name == "size"
+ )
+#set($overrideSetValueExpression = true)
+ _CommonPropertyConstants.markProperty(this, _CommonPropertyConstants.${property.name.toUpperCase()}_PROP);
+#end
+ }
+#end
#end
+
+#if ($component.className.startsWith("javax.faces.component.html") && $overrideSetValueExpression)
+ public void setValueBinding(String name, ValueBinding binding)
+ {
+ super.setValueBinding(name, binding);
+ _CommonPropertyConstants.markProperty(this, name);
+ }
+
+ public void setValueExpression(String name, ValueExpression expression)
+ {
+ super.setValueExpression(name, expression);
+ _CommonPropertyConstants.markProperty(this, name);
+ }
#end
#if ($component.className.startsWith("javax.faces.component.html"))
Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlBodyRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlBodyRenderer.java?rev=1152968&r1=1152967&r2=1152968&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlBodyRenderer.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlBodyRenderer.java Mon Aug 1 23:24:53 2011
@@ -18,6 +18,8 @@
*/
package org.apache.myfaces.renderkit.html;
+import javax.faces.context.FacesContext;
+
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFRenderer;
import org.apache.myfaces.shared.renderkit.html.HtmlBodyRendererBase;
@@ -31,5 +33,9 @@ import org.apache.myfaces.shared.renderk
@JSFRenderer(renderKitId = "HTML_BASIC", family = "javax.faces.Output", type = "javax.faces.Body")
public class HtmlBodyRenderer extends HtmlBodyRendererBase
{
-
+ @Override
+ protected boolean isCommonPropertiesOptimizationEnabled(FacesContext facesContext)
+ {
+ return true;
+ }
}
Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlButtonRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlButtonRenderer.java?rev=1152968&r1=1152967&r2=1152968&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlButtonRenderer.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlButtonRenderer.java Mon Aug 1 23:24:53 2011
@@ -18,6 +18,8 @@
*/
package org.apache.myfaces.renderkit.html;
+import javax.faces.context.FacesContext;
+
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFRenderer;
import org.apache.myfaces.shared.renderkit.html.HtmlButtonRendererBase;
@@ -34,4 +36,9 @@ import org.apache.myfaces.shared.renderk
public class HtmlButtonRenderer
extends HtmlButtonRendererBase
{
+ @Override
+ protected boolean isCommonPropertiesOptimizationEnabled(FacesContext facesContext)
+ {
+ return true;
+ }
}
Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlFormRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlFormRenderer.java?rev=1152968&r1=1152967&r2=1152968&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlFormRenderer.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlFormRenderer.java Mon Aug 1 23:24:53 2011
@@ -66,4 +66,10 @@ public class HtmlFormRenderer
writer.endElement(HTML.INPUT_ELEM);
}
}
+
+ @Override
+ protected boolean isCommonPropertiesOptimizationEnabled(FacesContext facesContext)
+ {
+ return true;
+ }
}
Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlFormatRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlFormatRenderer.java?rev=1152968&r1=1152967&r2=1152968&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlFormatRenderer.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlFormatRenderer.java Mon Aug 1 23:24:53 2011
@@ -28,15 +28,18 @@ import java.util.logging.Logger;
import javax.faces.component.UIComponent;
import javax.faces.component.UIOutput;
import javax.faces.component.UIParameter;
+import javax.faces.component.UIViewRoot;
import javax.faces.component.html.HtmlOutputFormat;
import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFRenderer;
import org.apache.myfaces.shared.renderkit.JSFAttr;
import org.apache.myfaces.shared.renderkit.RendererUtils;
+import org.apache.myfaces.shared.renderkit.html.CommonPropertyUtils;
+import org.apache.myfaces.shared.renderkit.html.HTML;
import org.apache.myfaces.shared.renderkit.html.HtmlRenderer;
import org.apache.myfaces.shared.renderkit.html.HtmlRendererUtils;
-import org.apache.myfaces.shared.renderkit.html.HtmlTextRendererBase;
/**
*
@@ -51,6 +54,12 @@ public class HtmlFormatRenderer extends
private static final Logger log = Logger.getLogger(HtmlFormatRenderer.class.getName());
private static final Object[] EMPTY_ARGS = new Object[0];
+
+ @Override
+ protected boolean isCommonPropertiesOptimizationEnabled(FacesContext facesContext)
+ {
+ return true;
+ }
@Override
public void encodeBegin(FacesContext facesContext, UIComponent uiComponent) throws IOException
@@ -68,16 +77,75 @@ public class HtmlFormatRenderer extends
RendererUtils.checkParamValidity(facesContext, component, UIOutput.class);
String text = getOutputFormatText(facesContext, component);
- boolean isEscape;
+ boolean escape;
if (component instanceof HtmlOutputFormat)
{
- isEscape = ((HtmlOutputFormat) component).isEscape();
+ escape = ((HtmlOutputFormat) component).isEscape();
}
else
{
- isEscape = RendererUtils.getBooleanAttribute(component, JSFAttr.ESCAPE_ATTR, true);
+ escape = RendererUtils.getBooleanAttribute(component, JSFAttr.ESCAPE_ATTR, true);
+ }
+ if (text != null)
+ {
+ ResponseWriter writer = facesContext.getResponseWriter();
+ boolean span = false;
+
+ if (isCommonPropertiesOptimizationEnabled(facesContext))
+ {
+ long commonPropertiesMarked = CommonPropertyUtils.getCommonPropertiesMarked(component);
+
+ if (commonPropertiesMarked > 0)
+ {
+ span = true;
+ writer.startElement(HTML.SPAN_ELEM, component);
+ HtmlRendererUtils.writeIdIfNecessary(writer, component, facesContext);
+ }
+ else if (CommonPropertyUtils.isIdRenderingNecessary(component))
+ {
+ span = true;
+ writer.startElement(HTML.SPAN_ELEM, component);
+ writer.writeAttribute(HTML.ID_ATTR, component.getClientId(facesContext), null);
+ }
+
+ CommonPropertyUtils.renderUniversalProperties(writer, commonPropertiesMarked, component);
+ CommonPropertyUtils.renderStyleProperties(writer, commonPropertiesMarked, component);
+ }
+ else
+ {
+ if(component.getId()!=null && !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
+ {
+ span = true;
+
+ writer.startElement(HTML.SPAN_ELEM, component);
+
+ HtmlRendererUtils.writeIdIfNecessary(writer, component, facesContext);
+
+ HtmlRendererUtils.renderHTMLAttributes(writer, component, HTML.COMMON_PASSTROUGH_ATTRIBUTES);
+
+ }
+ else
+ {
+ span = HtmlRendererUtils.renderHTMLAttributesWithOptionalStartElement(writer,component,
+ HTML.SPAN_ELEM,HTML.COMMON_PASSTROUGH_ATTRIBUTES);
+ }
+ }
+
+ if (escape)
+ {
+ if (log.isLoggable(Level.FINE)) log.fine("renderOutputText writing '" + text + "'");
+ writer.writeText(text, org.apache.myfaces.shared.renderkit.JSFAttr.VALUE_ATTR);
+ }
+ else
+ {
+ writer.write(text);
+ }
+
+ if(span)
+ {
+ writer.endElement(org.apache.myfaces.shared.renderkit.html.HTML.SPAN_ELEM);
+ }
}
- HtmlTextRendererBase.renderOutputText(facesContext, component, text, isEscape);
}
private String getOutputFormatText(FacesContext facesContext, UIComponent htmlOutputFormat)
Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlGridRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlGridRenderer.java?rev=1152968&r1=1152967&r2=1152968&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlGridRenderer.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlGridRenderer.java Mon Aug 1 23:24:53 2011
@@ -18,6 +18,8 @@
*/
package org.apache.myfaces.renderkit.html;
+import javax.faces.context.FacesContext;
+
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFRenderer;
import org.apache.myfaces.shared.renderkit.html.HtmlGridRendererBase;
@@ -37,5 +39,9 @@ import org.apache.myfaces.shared.renderk
public class HtmlGridRenderer
extends HtmlGridRendererBase
{
-
+ @Override
+ protected boolean isCommonPropertiesOptimizationEnabled(FacesContext facesContext)
+ {
+ return true;
+ }
}
Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlGroupRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlGroupRenderer.java?rev=1152968&r1=1152967&r2=1152968&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlGroupRenderer.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlGroupRenderer.java Mon Aug 1 23:24:53 2011
@@ -18,6 +18,8 @@
*/
package org.apache.myfaces.renderkit.html;
+import javax.faces.context.FacesContext;
+
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFRenderer;
import org.apache.myfaces.shared.renderkit.html.HtmlGroupRendererBase;
@@ -35,4 +37,9 @@ import org.apache.myfaces.shared.renderk
public class HtmlGroupRenderer
extends HtmlGroupRendererBase
{
+ @Override
+ protected boolean isCommonPropertiesOptimizationEnabled(FacesContext facesContext)
+ {
+ return true;
+ }
}
Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlImageRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlImageRenderer.java?rev=1152968&r1=1152967&r2=1152968&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlImageRenderer.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlImageRenderer.java Mon Aug 1 23:24:53 2011
@@ -18,6 +18,8 @@
*/
package org.apache.myfaces.renderkit.html;
+import javax.faces.context.FacesContext;
+
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFRenderer;
import org.apache.myfaces.shared.renderkit.html.HtmlImageRendererBase;
@@ -35,5 +37,10 @@ import org.apache.myfaces.shared.renderk
public class HtmlImageRenderer
extends HtmlImageRendererBase
{
+ @Override
+ protected boolean isCommonPropertiesOptimizationEnabled(FacesContext facesContext)
+ {
+ return true;
+ }
}
Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlLabelRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlLabelRenderer.java?rev=1152968&r1=1152967&r2=1152968&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlLabelRenderer.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlLabelRenderer.java Mon Aug 1 23:24:53 2011
@@ -36,6 +36,7 @@ import org.apache.myfaces.buildtools.mav
import org.apache.myfaces.shared.component.EscapeCapable;
import org.apache.myfaces.shared.renderkit.JSFAttr;
import org.apache.myfaces.shared.renderkit.RendererUtils;
+import org.apache.myfaces.shared.renderkit.html.CommonPropertyUtils;
import org.apache.myfaces.shared.renderkit.html.HTML;
import org.apache.myfaces.shared.renderkit.html.HtmlRenderer;
import org.apache.myfaces.shared.renderkit.html.HtmlRendererUtils;
@@ -56,6 +57,12 @@ public class HtmlLabelRenderer extends H
private static final Logger log = Logger.getLogger(HtmlLabelRenderer.class.getName());
@Override
+ protected boolean isCommonPropertiesOptimizationEnabled(FacesContext facesContext)
+ {
+ return true;
+ }
+
+ @Override
public void decode(FacesContext context, UIComponent component)
{
// Check for npe
@@ -96,12 +103,28 @@ public class HtmlLabelRenderer extends H
}
HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, uiComponent, behaviors);
HtmlRendererUtils.renderBehaviorizedFieldEventHandlersWithoutOnchangeAndOnselect(facesContext, writer, uiComponent, behaviors);
- HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, HTML.LABEL_PASSTHROUGH_ATTRIBUTES_WITHOUT_EVENTS);
+ if (isCommonPropertiesOptimizationEnabled(facesContext))
+ {
+ CommonPropertyUtils.renderLabelPassthroughPropertiesWithoutEvents(writer,
+ CommonPropertyUtils.getCommonPropertiesMarked(uiComponent), uiComponent);
+ }
+ else
+ {
+ HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, HTML.LABEL_PASSTHROUGH_ATTRIBUTES_WITHOUT_EVENTS);
+ }
}
else
{
HtmlRendererUtils.writeIdIfNecessary(writer, uiComponent, facesContext);
- HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, HTML.LABEL_PASSTHROUGH_ATTRIBUTES);
+ if (isCommonPropertiesOptimizationEnabled(facesContext))
+ {
+ CommonPropertyUtils.renderLabelPassthroughProperties(writer,
+ CommonPropertyUtils.getCommonPropertiesMarked(uiComponent), uiComponent);
+ }
+ else
+ {
+ HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, HTML.LABEL_PASSTHROUGH_ATTRIBUTES);
+ }
}
String forAttr = getFor(uiComponent);
Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlLinkRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlLinkRenderer.java?rev=1152968&r1=1152967&r2=1152968&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlLinkRenderer.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlLinkRenderer.java Mon Aug 1 23:24:53 2011
@@ -18,6 +18,8 @@
*/
package org.apache.myfaces.renderkit.html;
+import javax.faces.context.FacesContext;
+
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFRenderer;
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFRenderers;
import org.apache.myfaces.shared.renderkit.html.HtmlLinkRendererBase;
@@ -46,4 +48,10 @@ public class HtmlLinkRenderer
extends HtmlLinkRendererBase
{
//private static final Log log = LogFactory.getLog(HtmlLinkRenderer.class);
+
+ @Override
+ protected boolean isCommonPropertiesOptimizationEnabled(FacesContext facesContext)
+ {
+ return true;
+ }
}
Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlOutcomeTargetButtonRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlOutcomeTargetButtonRenderer.java?rev=1152968&r1=1152967&r2=1152968&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlOutcomeTargetButtonRenderer.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlOutcomeTargetButtonRenderer.java Mon Aug 1 23:24:53 2011
@@ -18,9 +18,6 @@
*/
package org.apache.myfaces.renderkit.html;
-import java.io.IOException;
-
-import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFRenderer;
@@ -36,5 +33,9 @@ import org.apache.myfaces.shared.renderk
type="javax.faces.Button")
public class HtmlOutcomeTargetButtonRenderer extends HtmlOutcomeTargetButtonRendererBase
{
-
+ @Override
+ protected boolean isCommonPropertiesOptimizationEnabled(FacesContext facesContext)
+ {
+ return true;
+ }
}
Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlSecretRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlSecretRenderer.java?rev=1152968&r1=1152967&r2=1152968&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlSecretRenderer.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlSecretRenderer.java Mon Aug 1 23:24:53 2011
@@ -18,6 +18,8 @@
*/
package org.apache.myfaces.renderkit.html;
+import javax.faces.context.FacesContext;
+
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFRenderer;
import org.apache.myfaces.shared.renderkit.html.HtmlSecretRendererBase;
@@ -34,4 +36,10 @@ import org.apache.myfaces.shared.renderk
public class HtmlSecretRenderer
extends HtmlSecretRendererBase
{
+ @Override
+ protected boolean isCommonPropertiesOptimizationEnabled(FacesContext facesContext)
+ {
+ return true;
+ }
+
}
Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlTableRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlTableRenderer.java?rev=1152968&r1=1152967&r2=1152968&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlTableRenderer.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlTableRenderer.java Mon Aug 1 23:24:53 2011
@@ -18,6 +18,8 @@
*/
package org.apache.myfaces.renderkit.html;
+import javax.faces.context.FacesContext;
+
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFRenderer;
import org.apache.myfaces.shared.renderkit.html.HtmlTableRendererBase;
@@ -36,4 +38,9 @@ public class HtmlTableRenderer
{
//private static final Log log = LogFactory.getLog(HtmlTableRenderer.class);
+ @Override
+ protected boolean isCommonPropertiesOptimizationEnabled(FacesContext facesContext)
+ {
+ return true;
+ }
}
Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlTextRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlTextRenderer.java?rev=1152968&r1=1152967&r2=1152968&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlTextRenderer.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlTextRenderer.java Mon Aug 1 23:24:53 2011
@@ -18,6 +18,8 @@
*/
package org.apache.myfaces.renderkit.html;
+import javax.faces.context.FacesContext;
+
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFRenderer;
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFRenderers;
import org.apache.myfaces.shared.renderkit.html.HtmlTextRendererBase;
@@ -42,4 +44,16 @@ public class HtmlTextRenderer
extends HtmlTextRendererBase
{
//private static final Log log = LogFactory.getLog(HtmlTextRenderer.class);
+
+ @Override
+ protected boolean isCommonPropertiesOptimizationEnabled(FacesContext facesContext)
+ {
+ return true;
+ }
+
+ @Override
+ protected boolean isRenderOutputEventAttributes()
+ {
+ return false;
+ }
}
Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlTextareaRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlTextareaRenderer.java?rev=1152968&r1=1152967&r2=1152968&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlTextareaRenderer.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlTextareaRenderer.java Mon Aug 1 23:24:53 2011
@@ -18,6 +18,8 @@
*/
package org.apache.myfaces.renderkit.html;
+import javax.faces.context.FacesContext;
+
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFRenderer;
import org.apache.myfaces.shared.renderkit.html.HtmlTextareaRendererBase;
@@ -34,4 +36,10 @@ import org.apache.myfaces.shared.renderk
public class HtmlTextareaRenderer
extends HtmlTextareaRendererBase
{
+ @Override
+ protected boolean isCommonPropertiesOptimizationEnabled(FacesContext facesContext)
+ {
+ return true;
+ }
+
}
Modified: myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlFormatRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlFormatRendererTest.java?rev=1152968&r1=1152967&r2=1152968&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlFormatRendererTest.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlFormatRendererTest.java Mon Aug 1 23:24:53 2011
@@ -67,7 +67,15 @@ public class HtmlFormatRendererTest exte
public void testHtmlPropertyPassTru() throws Exception
{
- HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateBasicReadOnlyAttrs();
+ HtmlRenderedAttr[] attrs = {
+ //_UniversalProperties
+ new HtmlRenderedAttr("dir"),
+ new HtmlRenderedAttr("lang"),
+ new HtmlRenderedAttr("title"),
+ //_StyleProperties
+ new HtmlRenderedAttr("style"),
+ new HtmlRenderedAttr("styleClass", "styleClass", "class=\"styleClass\""),
+ };
outputFormat.setValue("outputdata");
HtmlCheckAttributesUtil.checkRenderedAttributes(
Modified: myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlGroupRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlGroupRendererTest.java?rev=1152968&r1=1152967&r2=1152968&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlGroupRendererTest.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlGroupRendererTest.java Mon Aug 1 23:24:53 2011
@@ -86,7 +86,11 @@ public class HtmlGroupRendererTest exten
public void testHtmlPropertyPassTru() throws Exception
{
- HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateBasicReadOnlyAttrs();
+ HtmlRenderedAttr[] attrs = {
+ new HtmlRenderedAttr("style"),
+ new HtmlRenderedAttr("styleClass", "styleClass", "class=\"styleClass\"")
+ };
+ //HtmlCheckAttributesUtil.generateBasicReadOnlyAttrs();
HtmlCheckAttributesUtil.checkRenderedAttributes(
panelGroup, facesContext, writer, attrs);
Added: myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/CommonPropertyConstants.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/CommonPropertyConstants.java?rev=1152968&view=auto
==============================================================================
--- myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/CommonPropertyConstants.java (added)
+++ myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/CommonPropertyConstants.java Mon Aug 1 23:24:53 2011
@@ -0,0 +1,203 @@
+/*
+ * 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.util.HashMap;
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+
+/**
+ * This is a list of the most common properties used by a JSF html
+ * component, organized by interfaces.
+ *
+ * This is a copy from javax.faces.component._CommonPropertyConstants
+ * and should be synchronized with this copy on shared
+ *
+ * @author Leonardo Uribe
+ *
+ */
+public class CommonPropertyConstants
+{
+ public static final String COMMON_PROPERTIES_MARKED = "oam.COMMON_PROPERTIES_MARKED";
+
+ //_StyleProperties
+ public static final long STYLE_PROP = 0x1L;
+ public static final long STYLECLASS_PROP = 0x2L;
+
+ //_UniversalProperties
+ //_TitleProperty
+ public static final long DIR_PROP = 0x4L;
+ public static final long LANG_PROP = 0x8L;
+ public static final long TITLE_PROP = 0x10L;
+
+ //_EscapeProperty
+ public static final long ESCAPE_PROP = 0x20L;
+
+ //_DisabledClassEnabledClassProperties
+ //_DisabledReadonlyProperties
+ public static final long DISABLED_PROP = 0x40L;
+ public static final long ENABLED_PROP = 0x80L;
+ public static final long READONLY_PROP = 0x100L;
+
+ //_AccesskeyProperty
+ public static final long ACCESSKEY_PROP = 0x200L;
+
+ //_AltProperty
+ public static final long ALT_PROP = 0x400L;
+
+ //_ChangeSelectProperties
+ public static final long ONCHANGE_PROP = 0x800L;
+ public static final long ONSELECT_PROP = 0x1000L;
+
+ //_EventProperties
+ public static final long ONCLICK_PROP = 0x2000L;
+ public static final long ONDBLCLICK_PROP = 0x4000L;
+ public static final long ONMOUSEDOWN_PROP = 0x8000L;
+ public static final long ONMOUSEUP_PROP = 0x10000L;
+ public static final long ONMOUSEOVER_PROP = 0x20000L;
+ public static final long ONMOUSEMOVE_PROP = 0x40000L;
+ public static final long ONMOUSEOUT_PROP = 0x80000L;
+ public static final long ONKEYPRESS_PROP = 0x100000L;
+ public static final long ONKEYDOWN_PROP = 0x200000L;
+ public static final long ONKEYUP_PROP = 0x400000L;
+
+ //_FocusBlurProperties
+ public static final long ONFOCUS_PROP = 0x800000L;
+ public static final long ONBLUR_PROP = 0x1000000L;
+
+ //_LabelProperty
+ public static final long LABEL_PROP = 0x2000000L;
+
+ //_LinkProperties
+ public static final long CHARSET_PROP = 0x4000000L;
+ public static final long COORDS_PROP = 0x8000000L;
+ public static final long HREFLANG_PROP = 0x10000000L;
+ public static final long REL_PROP = 0x20000000L;
+ public static final long REV_PROP = 0x40000000L;
+ public static final long SHAPE_PROP = 0x80000000L;
+ public static final long TARGET_PROP = 0x100000000L;
+ public static final long TYPE_PROP = 0x200000000L;
+
+ //_TabindexProperty
+ public static final long TABINDEX_PROP = 0x400000000L;
+
+ //Common to input fields
+ public static final long ALIGN_PROP = 0x800000000L;
+ public static final long CHECKED_PROP = 0x1000000000L;
+ public static final long MAXLENGTH_PROP = 0x2000000000L;
+ public static final long SIZE_PROP = 0x4000000000L;
+
+ public static Map<String, Long> COMMON_PROPERTIES_KEY_BY_NAME = new HashMap<String, Long>(64,1);
+
+ static
+ {
+ COMMON_PROPERTIES_KEY_BY_NAME.put("style", STYLE_PROP);
+
+ COMMON_PROPERTIES_KEY_BY_NAME.put("styleClass", STYLECLASS_PROP);
+
+ //_UniversalProperties
+ //_TitleProperty
+ COMMON_PROPERTIES_KEY_BY_NAME.put("dir", DIR_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("lang", LANG_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("title", TITLE_PROP);
+
+ //_EscapeProperty
+ COMMON_PROPERTIES_KEY_BY_NAME.put("escape", ESCAPE_PROP);
+
+ //_DisabledClassEnabledClassProperties
+ //_DisabledReadonlyProperties
+ COMMON_PROPERTIES_KEY_BY_NAME.put("disabled", DISABLED_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("enabled", ENABLED_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("readonly", READONLY_PROP);
+
+ //_AccesskeyProperty
+ COMMON_PROPERTIES_KEY_BY_NAME.put("accesskey", ACCESSKEY_PROP);
+
+ //_AltProperty
+ COMMON_PROPERTIES_KEY_BY_NAME.put("alt", ALT_PROP);
+
+ //_ChangeSelectProperties
+ COMMON_PROPERTIES_KEY_BY_NAME.put("onchange", ONCHANGE_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("onselect", ONSELECT_PROP);
+
+ //_EventProperties
+ COMMON_PROPERTIES_KEY_BY_NAME.put("onclick", ONCLICK_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("ondblclick", ONDBLCLICK_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("onmousedown",ONMOUSEDOWN_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("onmouseup", ONMOUSEUP_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("onmouseover",ONMOUSEOVER_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("onmousemove",ONMOUSEMOVE_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("onmouseout", ONMOUSEOUT_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("onkeypress", ONKEYPRESS_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("onkeydown", ONKEYDOWN_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("onkeyup", ONKEYUP_PROP);
+
+ //_FocusBlurProperties
+ COMMON_PROPERTIES_KEY_BY_NAME.put("onfocus", ONFOCUS_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("onblur", ONBLUR_PROP);
+
+ //_LabelProperty
+ COMMON_PROPERTIES_KEY_BY_NAME.put("label", LABEL_PROP);
+
+ //_LinkProperties
+ COMMON_PROPERTIES_KEY_BY_NAME.put("charset", CHARSET_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("coords", COORDS_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("hreflang", HREFLANG_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("rel", REL_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("rev", REV_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("shape", SHAPE_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("target", TARGET_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("type", TYPE_PROP);
+
+ //_TabindexProperty
+ COMMON_PROPERTIES_KEY_BY_NAME.put("tabindex", TABINDEX_PROP);
+
+ //Common to input fields
+ COMMON_PROPERTIES_KEY_BY_NAME.put("align", ALIGN_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("checked", CHECKED_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("maxlength", MAXLENGTH_PROP);
+ COMMON_PROPERTIES_KEY_BY_NAME.put("size", SIZE_PROP);
+ }
+
+ public static void markProperty(UIComponent component, String name)
+ {
+ Long propertyConstant = COMMON_PROPERTIES_KEY_BY_NAME.get(name);
+ if (propertyConstant == null)
+ {
+ return;
+ }
+ Long commonPropertiesSet = (Long) component.getAttributes().get(COMMON_PROPERTIES_MARKED);
+ if (commonPropertiesSet == null)
+ {
+ commonPropertiesSet = 0L;
+ }
+ component.getAttributes().put(COMMON_PROPERTIES_MARKED, commonPropertiesSet | propertyConstant);
+ }
+
+ public static void markProperty(UIComponent component, long propertyConstant)
+ {
+ Long commonPropertiesSet = (Long) component.getAttributes().get(COMMON_PROPERTIES_MARKED);
+ if (commonPropertiesSet == null)
+ {
+ commonPropertiesSet = 0L;
+ }
+ component.getAttributes().put(COMMON_PROPERTIES_MARKED, commonPropertiesSet | propertyConstant);
+ }
+}
Added: myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/CommonPropertyUtils.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/CommonPropertyUtils.java?rev=1152968&view=auto
==============================================================================
--- myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/CommonPropertyUtils.java (added)
+++ myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/CommonPropertyUtils.java Mon Aug 1 23:24:53 2011
@@ -0,0 +1,466 @@
+/*
+ * 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 javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.ResponseWriter;
+
+public final class CommonPropertyUtils
+{
+ public static long getCommonPropertiesMarked(UIComponent component)
+ {
+ Long commonProperties = (Long) component.getAttributes().get(CommonPropertyConstants.COMMON_PROPERTIES_MARKED);
+
+ if (commonProperties == null)
+ {
+ commonProperties = 0L;
+ }
+
+ return commonProperties;
+ }
+
+ public static boolean isIdRenderingNecessary(UIComponent component)
+ {
+ 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,
+ HTML.DIR_ATTR, HTML.DIR_ATTR);
+ }
+ if ((commonPropertiesMarked & CommonPropertyConstants.LANG_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.LANG_ATTR, HTML.LANG_ATTR);
+ }
+ if ((commonPropertiesMarked & CommonPropertyConstants.TITLE_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.TITLE_ATTR, HTML.TITLE_ATTR);
+ }
+ }
+
+ public static final void renderUniversalPropertiesWithoutTitle(ResponseWriter writer,
+ long commonPropertiesMarked, UIComponent component)
+ throws IOException
+ {
+ if ((commonPropertiesMarked & CommonPropertyConstants.DIR_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.DIR_ATTR, HTML.DIR_ATTR);
+ }
+ if ((commonPropertiesMarked & CommonPropertyConstants.LANG_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.LANG_ATTR, HTML.LANG_ATTR);
+ }
+ }
+
+ public static final void renderStyleProperties(ResponseWriter writer,
+ long commonPropertiesMarked, UIComponent component)
+ throws IOException
+ {
+ if ((commonPropertiesMarked & CommonPropertyConstants.STYLE_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.STYLE_ATTR, HTML.STYLE_ATTR);
+ }
+ if ((commonPropertiesMarked & CommonPropertyConstants.STYLECLASS_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.STYLE_CLASS_ATTR, HTML.CLASS_ATTR);
+ }
+ }
+
+ public static final void renderEventProperties(ResponseWriter writer,
+ long commonPropertiesMarked, UIComponent component)
+ throws IOException
+ {
+ if ((commonPropertiesMarked & CommonPropertyConstants.ONCLICK_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.ONCLICK_ATTR, HTML.ONCLICK_ATTR);
+ }
+ renderEventPropertiesWithoutOnclick(writer, commonPropertiesMarked, component);
+ }
+
+ public static final void renderEventPropertiesWithoutOnclick(ResponseWriter writer,
+ long commonPropertiesMarked, UIComponent component)
+ throws IOException
+ {
+ if ((commonPropertiesMarked & CommonPropertyConstants.ONDBLCLICK_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.ONDBLCLICK_ATTR, HTML.ONDBLCLICK_ATTR);
+ }
+ if ((commonPropertiesMarked & CommonPropertyConstants.ONMOUSEDOWN_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.ONMOUSEDOWN_ATTR, HTML.ONMOUSEDOWN_ATTR);
+ }
+ if ((commonPropertiesMarked & CommonPropertyConstants.ONMOUSEUP_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.ONMOUSEUP_ATTR, HTML.ONMOUSEUP_ATTR);
+ }
+ if ((commonPropertiesMarked & CommonPropertyConstants.ONMOUSEOVER_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.ONMOUSEOVER_ATTR, HTML.ONMOUSEOVER_ATTR);
+ }
+ if ((commonPropertiesMarked & CommonPropertyConstants.ONMOUSEMOVE_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.ONMOUSEMOVE_ATTR, HTML.ONMOUSEMOVE_ATTR);
+ }
+ if ((commonPropertiesMarked & CommonPropertyConstants.ONMOUSEOUT_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.ONMOUSEOUT_ATTR, HTML.ONMOUSEOUT_ATTR);
+ }
+ if ((commonPropertiesMarked & CommonPropertyConstants.ONKEYPRESS_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.ONKEYPRESS_ATTR, HTML.ONKEYPRESS_ATTR);
+ }
+ if ((commonPropertiesMarked & CommonPropertyConstants.ONKEYDOWN_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.ONKEYDOWN_ATTR, HTML.ONKEYDOWN_ATTR);
+ }
+ if ((commonPropertiesMarked & CommonPropertyConstants.ONKEYUP_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.ONKEYUP_ATTR, HTML.ONKEYUP_ATTR);
+ }
+ }
+
+
+ public static final void renderChangeSelectEventProperties(ResponseWriter writer,
+ long commonPropertiesMarked, UIComponent component)
+ throws IOException
+ {
+ if ((commonPropertiesMarked & CommonPropertyConstants.ONCHANGE_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.ONCHANGE_ATTR, HTML.ONCHANGE_ATTR);
+ }
+ if ((commonPropertiesMarked & CommonPropertyConstants.ONSELECT_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.ONSELECT_ATTR, HTML.ONSELECT_ATTR);
+ }
+ }
+
+ public static final void renderFocusBlurEventProperties(ResponseWriter writer,
+ long commonPropertiesMarked, UIComponent component)
+ throws IOException
+ {
+ if ((commonPropertiesMarked & CommonPropertyConstants.ONFOCUS_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.ONFOCUS_ATTR, HTML.ONFOCUS_ATTR);
+ }
+ if ((commonPropertiesMarked & CommonPropertyConstants.ONBLUR_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.ONBLUR_ATTR, HTML.ONBLUR_ATTR);
+ }
+ }
+
+ public static void renderAccesskeyTabindexProperties(ResponseWriter writer,
+ long commonPropertiesMarked, UIComponent component)
+ throws IOException
+ {
+ if ((commonPropertiesMarked & CommonPropertyConstants.ACCESSKEY_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.ACCESSKEY_ATTR, HTML.ACCESSKEY_ATTR);
+ }
+ if ((commonPropertiesMarked & CommonPropertyConstants.TABINDEX_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.TABINDEX_ATTR, HTML.TABINDEX_ATTR);
+ }
+ }
+
+ public static void renderAltAlignProperties(ResponseWriter writer,
+ long commonPropertiesMarked, UIComponent component)
+ throws IOException
+ {
+ if ((commonPropertiesMarked & CommonPropertyConstants.ALIGN_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.ALIGN_ATTR, HTML.ALIGN_ATTR);
+ }
+ if ((commonPropertiesMarked & CommonPropertyConstants.ALT_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.ALT_ATTR, HTML.ALT_ATTR);
+ }
+ }
+
+ public static final void renderInputProperties(ResponseWriter writer,
+ long commonPropertiesMarked, UIComponent component)
+ throws IOException
+ {
+ if ((commonPropertiesMarked & CommonPropertyConstants.ALIGN_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.ALIGN_ATTR, HTML.ALIGN_ATTR);
+ }
+ if ((commonPropertiesMarked & CommonPropertyConstants.ALT_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.ALT_ATTR, HTML.ALT_ATTR);
+ }
+ if ((commonPropertiesMarked & CommonPropertyConstants.CHECKED_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.CHECKED_ATTR, HTML.CHECKED_ATTR);
+ }
+ if ((commonPropertiesMarked & CommonPropertyConstants.MAXLENGTH_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.MAXLENGTH_ATTR, HTML.MAXLENGTH_ATTR);
+ }
+ if ((commonPropertiesMarked & CommonPropertyConstants.READONLY_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.READONLY_ATTR, HTML.READONLY_ATTR);
+ }
+ if ((commonPropertiesMarked & CommonPropertyConstants.SIZE_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.SIZE_ATTR, HTML.SIZE_ATTR);
+ }
+ }
+
+ public static final void renderAnchorProperties(ResponseWriter writer,
+ long commonPropertiesMarked, UIComponent component)
+ throws IOException
+ {
+ renderAccesskeyTabindexProperties(writer, commonPropertiesMarked, component);
+ if ((commonPropertiesMarked & CommonPropertyConstants.CHARSET_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.CHARSET_ATTR, HTML.CHARSET_ATTR);
+ }
+ if ((commonPropertiesMarked & CommonPropertyConstants.COORDS_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.COORDS_ATTR, HTML.COORDS_ATTR);
+ }
+ if ((commonPropertiesMarked & CommonPropertyConstants.HREFLANG_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.HREFLANG_ATTR, HTML.HREFLANG_ATTR);
+ }
+ if ((commonPropertiesMarked & CommonPropertyConstants.REL_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.REL_ATTR, HTML.REL_ATTR);
+ }
+ if ((commonPropertiesMarked & CommonPropertyConstants.REV_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.REV_ATTR, HTML.REV_ATTR);
+ }
+ if ((commonPropertiesMarked & CommonPropertyConstants.SHAPE_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.SHAPE_ATTR, HTML.SHAPE_ATTR);
+ }
+ if ((commonPropertiesMarked & CommonPropertyConstants.TARGET_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.TARGET_ATTR, HTML.TARGET_ATTR);
+ }
+ if ((commonPropertiesMarked & CommonPropertyConstants.TYPE_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.TYPE_ATTR, HTML.TYPE_ATTR);
+ }
+ }
+
+ public static final void renderCommonPassthroughPropertiesWithoutEvents(ResponseWriter writer,
+ long commonPropertiesMarked, UIComponent component)
+ throws IOException
+ {
+ renderStyleProperties(writer, commonPropertiesMarked, component);
+ renderUniversalProperties(writer, commonPropertiesMarked, component);
+ }
+
+ public static final void renderCommonPassthroughProperties(ResponseWriter writer,
+ long commonPropertiesMarked, UIComponent component)
+ throws IOException
+ {
+ renderStyleProperties(writer, commonPropertiesMarked, component);
+ renderUniversalProperties(writer, commonPropertiesMarked, component);
+ renderEventProperties(writer, commonPropertiesMarked, component);
+ }
+
+ //Methods
+ public static final void renderCommonFieldEventProperties(ResponseWriter writer,
+ long commonPropertiesMarked, UIComponent component)
+ throws IOException
+ {
+ renderChangeSelectEventProperties(writer, commonPropertiesMarked, component);
+ renderFocusBlurEventProperties(writer, commonPropertiesMarked, component);
+ }
+
+ public static final void renderCommonFieldPassthroughPropertiesWithoutDisabled(ResponseWriter writer,
+ long commonPropertiesMarked, UIComponent component)
+ throws IOException
+ {
+ renderCommonPassthroughProperties(writer, commonPropertiesMarked, component);
+ renderAccesskeyTabindexProperties(writer, commonPropertiesMarked, component);
+ renderCommonFieldEventProperties(writer, commonPropertiesMarked, component);
+ }
+
+ public static final void renderCommonFieldPassthroughPropertiesWithoutDisabledAndEvents(ResponseWriter writer,
+ long commonPropertiesMarked, UIComponent component)
+ throws IOException
+ {
+ renderCommonPassthroughPropertiesWithoutEvents(writer, commonPropertiesMarked, component);
+ renderAccesskeyTabindexProperties(writer, commonPropertiesMarked, component);
+ }
+
+ public static final void renderInputPassthroughPropertiesWithoutDisabled(ResponseWriter writer,
+ long commonPropertiesMarked, UIComponent component)
+ throws IOException
+ {
+ renderInputProperties(writer, commonPropertiesMarked, component);
+ renderCommonFieldPassthroughPropertiesWithoutDisabled(writer, commonPropertiesMarked, component);
+ }
+
+ public static final void renderInputPassthroughPropertiesWithoutDisabledAndEvents(ResponseWriter writer,
+ long commonPropertiesMarked, UIComponent component)
+ throws IOException
+ {
+ renderInputProperties(writer, commonPropertiesMarked, component);
+ renderCommonFieldPassthroughPropertiesWithoutDisabledAndEvents(writer, commonPropertiesMarked, component);
+ }
+
+ public static final void renderAnchorPassthroughProperties(ResponseWriter writer,
+ long commonPropertiesMarked, UIComponent component)
+ throws IOException
+ {
+ renderAnchorProperties(writer, commonPropertiesMarked, component);
+ renderCommonPassthroughProperties(writer, commonPropertiesMarked, component);
+ renderFocusBlurEventProperties(writer, commonPropertiesMarked, component);
+ }
+
+ public static final void renderAnchorPassthroughPropertiesWithoutEvents(ResponseWriter writer,
+ long commonPropertiesMarked, UIComponent component)
+ throws IOException
+ {
+ renderAnchorProperties(writer, commonPropertiesMarked, component);
+ renderStyleProperties(writer, commonPropertiesMarked, component);
+ renderUniversalProperties(writer, commonPropertiesMarked, component);
+ }
+
+ public static final void renderAnchorPassthroughPropertiesWithoutStyleAndEvents(ResponseWriter writer,
+ long commonPropertiesMarked, UIComponent component)
+ throws IOException
+ {
+ renderAnchorProperties(writer, commonPropertiesMarked, component);
+ renderUniversalProperties(writer, commonPropertiesMarked, component);
+ }
+
+ public static final void renderAnchorPassthroughPropertiesWithoutStyle(ResponseWriter writer,
+ long commonPropertiesMarked, UIComponent component)
+ throws IOException
+ {
+ renderAnchorProperties(writer, commonPropertiesMarked, component);
+ renderUniversalProperties(writer, commonPropertiesMarked, component);
+ renderEventProperties(writer, commonPropertiesMarked, component);
+ renderFocusBlurEventProperties(writer, commonPropertiesMarked, component);
+ }
+
+ public static final void renderAnchorPassthroughPropertiesWithoutOnclickAndStyle(ResponseWriter writer,
+ long commonPropertiesMarked, UIComponent component)
+ throws IOException
+ {
+ renderAnchorProperties(writer, commonPropertiesMarked, component);
+ renderUniversalProperties(writer, commonPropertiesMarked, component);
+ renderEventPropertiesWithoutOnclick(writer, commonPropertiesMarked, component);
+ renderFocusBlurEventProperties(writer, commonPropertiesMarked, component);
+ }
+
+ public static final void renderButtonPassthroughPropertiesWithoutDisabledAndEvents(ResponseWriter writer,
+ long commonPropertiesMarked, UIComponent component)
+ throws IOException
+ {
+ renderUniversalProperties(writer, commonPropertiesMarked, component);
+ renderStyleProperties(writer, commonPropertiesMarked, component);
+ renderAccesskeyTabindexProperties(writer, commonPropertiesMarked, component);
+ renderAltAlignProperties(writer, commonPropertiesMarked, component);
+ }
+
+ public static final void renderLabelProperties(ResponseWriter writer,
+ long commonPropertiesMarked, UIComponent component)
+ throws IOException
+ {
+ renderFocusBlurEventProperties(writer, commonPropertiesMarked, component);
+ if ((commonPropertiesMarked & CommonPropertyConstants.ACCESSKEY_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.ACCESSKEY_ATTR, HTML.ACCESSKEY_ATTR);
+ }
+ }
+
+
+ public static final void renderLabelPassthroughProperties(ResponseWriter writer,
+ long commonPropertiesMarked, UIComponent component)
+ throws IOException
+ {
+ renderLabelProperties(writer, commonPropertiesMarked, component);
+ renderCommonPassthroughProperties(writer, commonPropertiesMarked, component);
+ }
+
+ public static final void renderLabelPassthroughPropertiesWithoutEvents(ResponseWriter writer,
+ long commonPropertiesMarked, UIComponent component)
+ throws IOException
+ {
+ if ((commonPropertiesMarked & CommonPropertyConstants.ACCESSKEY_PROP) != 0)
+ {
+ renderHTMLStringAttribute(writer, component,
+ HTML.ACCESSKEY_ATTR, HTML.ACCESSKEY_ATTR);
+ }
+ renderCommonPassthroughPropertiesWithoutEvents(writer, commonPropertiesMarked, component);
+ }
+}
Modified: myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlBodyRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlBodyRendererBase.java?rev=1152968&r1=1152967&r2=1152968&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlBodyRendererBase.java (original)
+++ myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlBodyRendererBase.java Mon Aug 1 23:24:53 2011
@@ -84,16 +84,35 @@ public class HtmlBodyRendererBase extend
ClientBehaviorEvents.LOAD, behaviors, HTML.ONLOAD_ATTR);
HtmlRendererUtils.renderBehaviorizedAttribute(facesContext, writer, HTML.ONUNLOAD_ATTR, component,
ClientBehaviorEvents.UNLOAD, behaviors, HTML.ONUNLOAD_ATTR);
- HtmlRendererUtils.renderHTMLAttributes(writer, component,
- HTML.BODY_PASSTHROUGH_ATTRIBUTES_WITHOUT_EVENTS);
-
+ if (isCommonPropertiesOptimizationEnabled(facesContext))
+ {
+ HtmlRendererUtils.renderHTMLAttributes(writer, component,
+ HTML.BODY_ATTRIBUTES);
+ CommonPropertyUtils.renderCommonPassthroughPropertiesWithoutEvents(writer,
+ CommonPropertyUtils.getCommonPropertiesMarked(component), component);
+ }
+ else
+ {
+ HtmlRendererUtils.renderHTMLAttributes(writer, component,
+ HTML.BODY_PASSTHROUGH_ATTRIBUTES_WITHOUT_EVENTS);
+ }
}
else
{
writer.startElement(HTML.BODY_ELEM, component);
HtmlRendererUtils.writeIdIfNecessary(writer, component, facesContext);
- HtmlRendererUtils.renderHTMLAttributes(writer, component,
- HTML.BODY_PASSTHROUGH_ATTRIBUTES);
+ if (isCommonPropertiesOptimizationEnabled(facesContext))
+ {
+ HtmlRendererUtils.renderHTMLAttributes(writer, component,
+ HTML.BODY_ATTRIBUTES);
+ CommonPropertyUtils.renderCommonPassthroughProperties(writer,
+ CommonPropertyUtils.getCommonPropertiesMarked(component), component);
+ }
+ else
+ {
+ HtmlRendererUtils.renderHTMLAttributes(writer, component,
+ HTML.BODY_PASSTHROUGH_ATTRIBUTES);
+ }
}
}
Modified: myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlButtonRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlButtonRendererBase.java?rev=1152968&r1=1152967&r2=1152968&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlButtonRendererBase.java (original)
+++ myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlButtonRendererBase.java Mon Aug 1 23:24:53 2011
@@ -141,7 +141,9 @@ public class HtmlButtonRendererBase
List<UIParameter> validParams = HtmlRendererUtils.getValidUIParameterChildren(
facesContext, getChildren(uiComponent), false, false);
- if (formInfo != null && JavascriptUtils.isJavascriptAllowed(facesContext.getExternalContext())
+ boolean javascriptAllowed = JavascriptUtils.isJavascriptAllowed(facesContext.getExternalContext());
+
+ if (formInfo != null && javascriptAllowed
&& (MyfacesConfig.getCurrentInstance(facesContext.getExternalContext()).isAutoScroll() ||
(validParams != null && !validParams.isEmpty() )))
{
@@ -184,7 +186,7 @@ public class HtmlButtonRendererBase
}
}
- if (JavascriptUtils.isJavascriptAllowed(externalContext) &&
+ if (javascriptAllowed &&
(HtmlRendererUtils.hasClientBehavior(ClientBehaviorEvents.CLICK, behaviors, facesContext) ||
HtmlRendererUtils.hasClientBehavior(ClientBehaviorEvents.ACTION, behaviors, facesContext)))
{
@@ -215,11 +217,8 @@ public class HtmlButtonRendererBase
HtmlRendererUtils.buildBehaviorChain(
facesContext, uiComponent, ClientBehaviorEvents.DBLCLICK, null, behaviors,
(String) attributes.get(HTML.ONDBLCLICK_ATTR), "");
-
- HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent,
- HTML.BUTTON_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED_AND_EVENTS);
}
- else if (JavascriptUtils.isJavascriptAllowed(externalContext))
+ else if (javascriptAllowed)
{
//fallback into the pre 2.0 code to keep backwards compatibility with libraries which rely on internals
if (!reset && !button)
@@ -234,14 +233,22 @@ public class HtmlButtonRendererBase
{
HtmlRendererUtils.renderHTMLAttribute(writer, uiComponent, HTML.ONCLICK_ATTR, HTML.ONCLICK_ATTR);
}
- HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent,
- HTML.BUTTON_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED_AND_EVENTS);
}
- else
+
+ if (javascriptAllowed)
{
- HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent,
- HTML.BUTTON_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED_AND_EVENTS);
+ if (isCommonPropertiesOptimizationEnabled(facesContext))
+ {
+ CommonPropertyUtils.renderButtonPassthroughPropertiesWithoutDisabledAndEvents(writer,
+ CommonPropertyUtils.getCommonPropertiesMarked(uiComponent), uiComponent);
+ }
+ else
+ {
+ HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent,
+ HTML.BUTTON_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED_AND_EVENTS);
+ }
}
+
if (behaviors != null && !behaviors.isEmpty())
{
@@ -250,10 +257,19 @@ public class HtmlButtonRendererBase
}
else
{
- HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent,
- HTML.EVENT_HANDLER_ATTRIBUTES_WITHOUT_ONCLICK);
- HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent,
- HTML.COMMON_FIELD_EVENT_ATTRIBUTES);
+ if (isCommonPropertiesOptimizationEnabled(facesContext))
+ {
+ long commonPropertiesMarked = CommonPropertyUtils.getCommonPropertiesMarked(uiComponent);
+ CommonPropertyUtils.renderEventPropertiesWithoutOnclick(writer, commonPropertiesMarked, uiComponent);
+ CommonPropertyUtils.renderCommonFieldEventProperties(writer, commonPropertiesMarked, uiComponent);
+ }
+ else
+ {
+ HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent,
+ HTML.EVENT_HANDLER_ATTRIBUTES_WITHOUT_ONCLICK);
+ HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent,
+ HTML.COMMON_FIELD_EVENT_ATTRIBUTES);
+ }
}
if (isDisabled(facesContext, uiComponent))
Modified: myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlFormRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlFormRendererBase.java?rev=1152968&r1=1152967&r2=1152968&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlFormRendererBase.java (original)
+++ myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlFormRendererBase.java Mon Aug 1 23:24:53 2011
@@ -97,11 +97,29 @@ public class HtmlFormRendererBase
{
behaviors = ((ClientBehaviorHolder) htmlForm).getClientBehaviors();
HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, htmlForm, behaviors);
- HtmlRendererUtils.renderHTMLAttributes(writer, htmlForm, HTML.FORM_PASSTHROUGH_ATTRIBUTES_WITHOUT_EVENTS);
+ if (isCommonPropertiesOptimizationEnabled(facesContext))
+ {
+ CommonPropertyUtils.renderCommonPassthroughPropertiesWithoutEvents(writer,
+ CommonPropertyUtils.getCommonPropertiesMarked(component), component);
+ HtmlRendererUtils.renderHTMLAttributes(writer, htmlForm, HTML.FORM_ATTRIBUTES);
+ }
+ else
+ {
+ HtmlRendererUtils.renderHTMLAttributes(writer, htmlForm, HTML.FORM_PASSTHROUGH_ATTRIBUTES_WITHOUT_EVENTS);
+ }
}
else
{
- HtmlRendererUtils.renderHTMLAttributes(writer, htmlForm, HTML.FORM_PASSTHROUGH_ATTRIBUTES);
+ if (isCommonPropertiesOptimizationEnabled(facesContext))
+ {
+ CommonPropertyUtils.renderCommonPassthroughProperties(writer,
+ CommonPropertyUtils.getCommonPropertiesMarked(component), component);
+ HtmlRendererUtils.renderHTMLAttributes(writer, htmlForm, HTML.FORM_ATTRIBUTES);
+ }
+ else
+ {
+ HtmlRendererUtils.renderHTMLAttributes(writer, htmlForm, HTML.FORM_PASSTHROUGH_ATTRIBUTES);
+ }
}
writer.write(""); // force start element tag to be closed
Modified: myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlGridRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlGridRendererBase.java?rev=1152968&r1=1152967&r2=1152968&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlGridRendererBase.java (original)
+++ myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlGridRendererBase.java Mon Aug 1 23:24:53 2011
@@ -132,12 +132,30 @@ public class HtmlGridRendererBase
HtmlRendererUtils.writeIdIfNecessary(writer, component, facesContext);
}
HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, component, behaviors);
- HtmlRendererUtils.renderHTMLAttributes(writer, component, HTML.TABLE_PASSTHROUGH_ATTRIBUTES_WITHOUT_EVENTS);
+ if (isCommonPropertiesOptimizationEnabled(facesContext))
+ {
+ HtmlRendererUtils.renderHTMLAttributes(writer, component, HTML.TABLE_ATTRIBUTES);
+ CommonPropertyUtils.renderCommonPassthroughPropertiesWithoutEvents(writer,
+ CommonPropertyUtils.getCommonPropertiesMarked(component), component);
+ }
+ else
+ {
+ HtmlRendererUtils.renderHTMLAttributes(writer, component, HTML.TABLE_PASSTHROUGH_ATTRIBUTES_WITHOUT_EVENTS);
+ }
}
else
{
HtmlRendererUtils.writeIdIfNecessary(writer, component, facesContext);
- HtmlRendererUtils.renderHTMLAttributes(writer, component, HTML.TABLE_PASSTHROUGH_ATTRIBUTES);
+ if (isCommonPropertiesOptimizationEnabled(facesContext))
+ {
+ HtmlRendererUtils.renderHTMLAttributes(writer, component, HTML.TABLE_ATTRIBUTES);
+ CommonPropertyUtils.renderCommonPassthroughProperties(writer,
+ CommonPropertyUtils.getCommonPropertiesMarked(component), component);
+ }
+ else
+ {
+ HtmlRendererUtils.renderHTMLAttributes(writer, component, HTML.TABLE_PASSTHROUGH_ATTRIBUTES);
+ }
}
writer.flush();
Modified: myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlGroupRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlGroupRendererBase.java?rev=1152968&r1=1152967&r2=1152968&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlGroupRendererBase.java (original)
+++ myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlGroupRendererBase.java Mon Aug 1 23:24:53 2011
@@ -79,14 +79,37 @@ public class HtmlGroupRendererBase
HtmlRendererUtils.writeIdIfNecessary(writer, component, context);
- HtmlRendererUtils.renderHTMLAttributes(writer, component, HTML.COMMON_PASSTROUGH_ATTRIBUTES);
+ if (isCommonPropertiesOptimizationEnabled(context))
+ {
+ CommonPropertyUtils.renderCommonPassthroughProperties(writer,
+ CommonPropertyUtils.getCommonPropertiesMarked(component), component);
+ }
+ else
+ {
+ HtmlRendererUtils.renderHTMLAttributes(writer, component, HTML.COMMON_PASSTROUGH_ATTRIBUTES);
+ }
}
else
{
- span=HtmlRendererUtils.renderHTMLAttributesWithOptionalStartElement(writer,
- component,
- layoutElement,
- HTML.COMMON_PASSTROUGH_ATTRIBUTES);
+ if (isCommonPropertiesOptimizationEnabled(context))
+ {
+ long commonPropertiesMarked = CommonPropertyUtils.getCommonPropertiesMarked(component);
+ if (commonPropertiesMarked > 0)
+ {
+ span = true;
+ writer.startElement(layoutElement, component);
+ HtmlRendererUtils.writeIdIfNecessary(writer, component, context);
+
+ CommonPropertyUtils.renderCommonPassthroughProperties(writer, commonPropertiesMarked, component);
+ }
+ }
+ else
+ {
+ span=HtmlRendererUtils.renderHTMLAttributesWithOptionalStartElement(writer,
+ component,
+ layoutElement,
+ HTML.COMMON_PASSTROUGH_ATTRIBUTES);
+ }
}
RendererUtils.renderChildren(context, component);