You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ja...@apache.org on 2010/08/16 11:52:12 UTC

svn commit: r985849 [2/3] - in /myfaces: core/trunk/impl/ core/trunk/impl/src/assembler/ core/trunk/impl/src/main/java/org/apache/myfaces/resource/ core/trunk/impl/src/main/javascript/ core/trunk/impl/src/main/javascript/META-INF/ core/trunk/impl/src/m...

Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java?rev=985849&r1=985848&r2=985849&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java Mon Aug 16 09:52:11 2010
@@ -72,6 +72,7 @@ import org.apache.myfaces.shared.renderk
 import org.apache.myfaces.shared.renderkit.html.util.FormInfo;
 import org.apache.myfaces.shared.renderkit.html.util.HTMLEncoder;
 import org.apache.myfaces.shared.renderkit.html.util.JavascriptUtils;
+import org.apache.myfaces.shared.renderkit.html.util.ResourceUtils;
 import org.apache.myfaces.shared.util.StringUtils;
 
 /**
@@ -92,7 +93,7 @@ public final class HtmlRendererUtils {
     public static final String HIDDEN_COMMANDLINK_FIELD_NAME_TRINIDAD = "source";
 
     public static final String CLEAR_HIDDEN_FIELD_FN_NAME =
-        "clearFormHiddenParams";
+            "clearFormHiddenParams";
     public static final String SUBMIT_FORM_FN_NAME = "oamSubmitForm";
     public static final String ALLOW_CDATA_SECTION_ON = "org.apache.myfaces.ResponseWriter.CdataSectionOn";
 
@@ -105,11 +106,11 @@ public final class HtmlRendererUtils {
     private static final String FIRST_SUBMIT_SCRIPT_ON_PAGE = "org.apache.MyFaces.FIRST_SUBMIT_SCRIPT_ON_PAGE";
 
     public static final String NON_SUBMITTED_VALUE_WARNING
-    = "There should always be a submitted value for an input if it is rendered,"
-    + " its form is submitted, and it was not originally rendered disabled or read-only."
-    + "  You cannot submit a form after disabling an input element via javascript."
-    + "  Consider setting read-only to true instead"
-    + " or resetting the disabled value back to false prior to form submission.";
+            = "There should always be a submitted value for an input if it is rendered,"
+            + " its form is submitted, and it was not originally rendered disabled or read-only."
+            + "  You cannot submit a form after disabling an input element via javascript."
+            + "  Consider setting read-only to true instead"
+            + " or resetting the disabled value back to false prior to form submission.";
     private static final String STR_EMPTY = "";
 
 
@@ -120,7 +121,7 @@ public final class HtmlRendererUtils {
     /**
      * Utility to set the submitted value of the provided component from the
      * data in the current request object.
-     * <p>
+     * <p/>
      * Param component is required to be an EditableValueHolder. On return
      * from this method, the component's submittedValue property will be
      * set if the submitted form contained that component.
@@ -129,24 +130,22 @@ public final class HtmlRendererUtils {
                                      UIComponent component) {
         if (!(component instanceof EditableValueHolder)) {
             throw new IllegalArgumentException("Component "
-                                               + component.getClientId(facesContext)
-                                               + " is not an EditableValueHolder");
+                    + component.getClientId(facesContext)
+                    + " is not an EditableValueHolder");
         }
         Map paramMap = facesContext.getExternalContext()
                 .getRequestParameterMap();
         String clientId = component.getClientId(facesContext);
 
-        if(isDisabledOrReadOnly(component))
+        if (isDisabledOrReadOnly(component))
             return;
 
-        if(paramMap.containsKey(clientId))
-        {
+        if (paramMap.containsKey(clientId)) {
             ((EditableValueHolder) component).setSubmittedValue(paramMap
                     .get(clientId));
-        }
-        else {
+        } else {
             log.warning(NON_SUBMITTED_VALUE_WARNING +
-                " Component : " +
+                    " Component : " +
                     RendererUtils.getPathToComponent(component));
         }
     }
@@ -161,11 +160,11 @@ public final class HtmlRendererUtils {
                                              UIComponent component) {
         if (!(component instanceof EditableValueHolder)) {
             throw new IllegalArgumentException("Component "
-                                               + component.getClientId(facesContext)
-                                               + " is not an EditableValueHolder");
+                    + component.getClientId(facesContext)
+                    + " is not an EditableValueHolder");
         }
 
-        if(isDisabledOrReadOnly(component))
+        if (isDisabledOrReadOnly(component))
             return;
 
         Map paramMap = facesContext.getExternalContext()
@@ -174,7 +173,7 @@ public final class HtmlRendererUtils {
         if (paramMap.containsKey(clientId)) {
             String reqValue = (String) paramMap.get(clientId);
             if ((reqValue.equalsIgnoreCase("on")
-                 || reqValue.equalsIgnoreCase("yes") || reqValue
+                    || reqValue.equalsIgnoreCase("yes") || reqValue
                     .equalsIgnoreCase("true"))) {
                 ((EditableValueHolder) component)
                         .setSubmittedValue(Boolean.TRUE);
@@ -188,31 +187,26 @@ public final class HtmlRendererUtils {
         }
     }
 
-    public static boolean isDisabledOrReadOnly(UIComponent component)
-    {
+    public static boolean isDisabledOrReadOnly(UIComponent component) {
         return isDisplayValueOnly(component) ||
-            isDisabled(component) ||
-            isReadOnly(component);
+                isDisabled(component) ||
+                isReadOnly(component);
     }
 
-    public static boolean isDisabled(UIComponent component)
-    {
+    public static boolean isDisabled(UIComponent component) {
         return isTrue(component.getAttributes().get("disabled"));
     }
 
-    public static boolean isReadOnly(UIComponent component)
-    {
+    public static boolean isReadOnly(UIComponent component) {
         return isTrue(component.getAttributes().get("readonly"));
     }
 
-    private static boolean isTrue(Object obj)
-    {
-        if (obj instanceof String)
-        {
+    private static boolean isTrue(Object obj) {
+        if (obj instanceof String) {
             return new Boolean((String) obj);
         }
-        
-        if(!(obj instanceof Boolean))
+
+        if (!(obj instanceof Boolean))
             return false;
 
         return ((Boolean) obj).booleanValue();
@@ -228,14 +222,14 @@ public final class HtmlRendererUtils {
                                           UIComponent component) {
         if (!(component instanceof EditableValueHolder)) {
             throw new IllegalArgumentException("Component "
-                                               + component.getClientId(facesContext)
-                                               + " is not an EditableValueHolder");
+                    + component.getClientId(facesContext)
+                    + " is not an EditableValueHolder");
         }
         Map paramValuesMap = facesContext.getExternalContext()
                 .getRequestParameterValuesMap();
         String clientId = component.getClientId(facesContext);
 
-        if(isDisabledOrReadOnly(component))
+        if (isDisabledOrReadOnly(component))
             return;
 
         if (paramValuesMap.containsKey(clientId)) {
@@ -248,7 +242,7 @@ public final class HtmlRendererUtils {
 
                So in fact, there must be component value at this location, but for listboxes, comboboxes etc.
                the submitted value is not posted if no item is selected. */
-            ((EditableValueHolder) component).setSubmittedValue( new String[]{});
+            ((EditableValueHolder) component).setSubmittedValue(new String[]{});
         }
     }
 
@@ -262,11 +256,11 @@ public final class HtmlRendererUtils {
                                          UIComponent component) {
         if (!(component instanceof EditableValueHolder)) {
             throw new IllegalArgumentException("Component "
-                                               + component.getClientId(facesContext)
-                                               + " is not an EditableValueHolder");
+                    + component.getClientId(facesContext)
+                    + " is not an EditableValueHolder");
         }
 
-        if(isDisabledOrReadOnly(component))
+        if (isDisabledOrReadOnly(component))
             return;
 
         Map paramMap = facesContext.getExternalContext()
@@ -278,44 +272,37 @@ public final class HtmlRendererUtils {
                     .get(clientId));
         } else {
             //see reason for this action at decodeUISelectMany
-            ((EditableValueHolder) component).setSubmittedValue( STR_EMPTY );
+            ((EditableValueHolder) component).setSubmittedValue(STR_EMPTY);
         }
     }
-    
+
     /**
-     * @since 4.0.0
      * @param facesContext
      * @param component
+     * @since 4.0.0
      */
     public static void decodeClientBehaviors(FacesContext facesContext,
-            UIComponent component)
-    {
-        if (component instanceof ClientBehaviorHolder)
-        {
+                                             UIComponent component) {
+        if (component instanceof ClientBehaviorHolder) {
             ClientBehaviorHolder clientBehaviorHolder = (ClientBehaviorHolder) component;
-            
-            Map<String,List<ClientBehavior>> clientBehaviors = 
-                clientBehaviorHolder.getClientBehaviors();
-                        
-            if (clientBehaviors != null && !clientBehaviors.isEmpty())
-            {
-                Map<String,String> paramMap = facesContext.getExternalContext().
-                    getRequestParameterMap();
-                
+
+            Map<String, List<ClientBehavior>> clientBehaviors =
+                    clientBehaviorHolder.getClientBehaviors();
+
+            if (clientBehaviors != null && !clientBehaviors.isEmpty()) {
+                Map<String, String> paramMap = facesContext.getExternalContext().
+                        getRequestParameterMap();
+
                 String behaviorEventName = paramMap.get("javax.faces.behavior.event");
-                
-                if (behaviorEventName != null)
-                {
+
+                if (behaviorEventName != null) {
                     List<ClientBehavior> clientBehaviorList = clientBehaviors.get(behaviorEventName);
-                    
-                    if (clientBehaviorList != null && !clientBehaviorList.isEmpty())
-                    {
+
+                    if (clientBehaviorList != null && !clientBehaviorList.isEmpty()) {
                         String clientId = paramMap.get("javax.faces.source");
-                        
-                        if (component.getClientId().equals(clientId))
-                        {
-                            for (ClientBehavior clientBehavior : clientBehaviorList)
-                            {
+
+                        if (component.getClientId().equals(clientId)) {
+                            for (ClientBehavior clientBehavior : clientBehaviorList) {
                                 clientBehavior.decode(facesContext, component);
                             }
                         }
@@ -354,51 +341,43 @@ public final class HtmlRendererUtils {
      */
 
     public static void renderListbox(FacesContext facesContext, UISelectOne selectOne,
-            boolean disabled, int size, Converter converter)
-            throws IOException 
-    {
+                                     boolean disabled, int size, Converter converter)
+            throws IOException {
         internalRenderSelect(facesContext, selectOne, disabled, size, false, converter);
     }
 
     public static void renderListbox(FacesContext facesContext, UISelectMany selectMany,
-            boolean disabled, int size, Converter converter)
-            throws IOException 
-    {
+                                     boolean disabled, int size, Converter converter)
+            throws IOException {
         internalRenderSelect(facesContext, selectMany, disabled, size, true, converter);
     }
 
     public static void renderMenu(FacesContext facesContext, UISelectOne selectOne,
-            boolean disabled, Converter converter) throws IOException 
-    {
+                                  boolean disabled, Converter converter) throws IOException {
         internalRenderSelect(facesContext, selectOne, disabled, 1, false, converter);
     }
 
     public static void renderMenu(FacesContext facesContext, UISelectMany selectMany,
-            boolean disabled, Converter converter) throws IOException 
-    {
+                                  boolean disabled, Converter converter) throws IOException {
         internalRenderSelect(facesContext, selectMany, disabled, 1, true, converter);
     }
 
     private static void internalRenderSelect(FacesContext facesContext,
                                              UIComponent uiComponent, boolean disabled, int size,
-                                             boolean selectMany, Converter converter) throws IOException 
-    {
+                                             boolean selectMany, Converter converter) throws IOException {
         ResponseWriter writer = facesContext.getResponseWriter();
 
         writer.startElement(HTML.SELECT_ELEM, uiComponent);
-        if (uiComponent instanceof ClientBehaviorHolder 
+        if (uiComponent instanceof ClientBehaviorHolder
                 && JavascriptUtils.isJavascriptAllowed(facesContext.getExternalContext())
-                && !((ClientBehaviorHolder) uiComponent).getClientBehaviors().isEmpty())
-        {
-            writer.writeAttribute(HTML.ID_ATTR, 
-                                  uiComponent.getClientId(facesContext), null);
-        }
-        else
-        {
+                && !((ClientBehaviorHolder) uiComponent).getClientBehaviors().isEmpty()) {
+            writer.writeAttribute(HTML.ID_ATTR,
+                    uiComponent.getClientId(facesContext), null);
+        } else {
             HtmlRendererUtils.writeIdIfNecessary(writer, uiComponent, facesContext);
         }
         writer.writeAttribute(HTML.NAME_ATTR,
-                              uiComponent.getClientId(facesContext), null);
+                uiComponent.getClientId(facesContext), null);
 
         List selectItemList;
         if (selectMany) {
@@ -418,16 +397,13 @@ public final class HtmlRendererUtils {
             writer.writeAttribute(HTML.SIZE_ATTR, Integer.toString(size), null);
         }
         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();
             renderBehaviorizedOnchangeEventHandler(facesContext, writer, uiComponent, behaviors);
             renderBehaviorizedEventHandlers(facesContext, writer, uiComponent, behaviors);
             renderBehaviorizedFieldEventHandlersWithoutOnchange(facesContext, writer, uiComponent, behaviors);
             renderHTMLAttributes(writer, uiComponent, HTML.SELECT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED_AND_EVENTS);
-        }
-        else
-        {
+        } else {
             renderHTMLAttributes(writer, uiComponent,
                     HTML.SELECT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED);
         }
@@ -436,15 +412,14 @@ public final class HtmlRendererUtils {
             writer.writeAttribute(HTML.DISABLED_ATTR, Boolean.TRUE, null);
         }
 
-        if (isReadOnly(uiComponent))
-        {
+        if (isReadOnly(uiComponent)) {
             writer.writeAttribute(HTML.READONLY_ATTR, HTML.READONLY_ATTR, null);
         }
 
         Set lookupSet = getSubmittedOrSelectedValuesAsSet(selectMany, uiComponent, facesContext, converter);
 
         renderSelectOptions(facesContext, uiComponent, converter, lookupSet,
-                            selectItemList);
+                selectItemList);
         // bug #970747: force separate end tag
         writer.writeText(STR_EMPTY, null);
         writer.endElement(HTML.SELECT_ELEM);
@@ -456,47 +431,39 @@ public final class HtmlRendererUtils {
         if (selectMany) {
             UISelectMany uiSelectMany = (UISelectMany) uiComponent;
             lookupSet = RendererUtils.getSubmittedValuesAsSet(facesContext, uiComponent, converter, uiSelectMany);
-            if (lookupSet == null)
-            {
+            if (lookupSet == null) {
                 lookupSet = RendererUtils.getSelectedValuesAsSet(facesContext, uiComponent, converter, uiSelectMany);
             }
         } else {
             UISelectOne uiSelectOne = (UISelectOne) uiComponent;
             Object lookup = uiSelectOne.getSubmittedValue();
-            if (lookup == null)
-            {
+            if (lookup == null) {
                 lookup = uiSelectOne.getValue();
                 String lookupString = RendererUtils.getConvertedStringValue(facesContext, uiComponent, converter, lookup);
                 lookupSet = Collections.singleton(lookupString);
-            }
-            else if(STR_EMPTY.equals(lookup))
-            {
+            } else if (STR_EMPTY.equals(lookup)) {
                 lookupSet = Collections.EMPTY_SET;
-            }
-            else
-            {
+            } else {
                 lookupSet = Collections.singleton(lookup);
             }
         }
         return lookupSet;
     }
-    
-    public static Converter findUISelectManyConverterFailsafe(FacesContext facesContext, UIComponent uiComponent)
-    {
+
+    public static Converter findUISelectManyConverterFailsafe(FacesContext facesContext, UIComponent uiComponent) {
         // invoke with considerValueType = false
         return findUISelectManyConverterFailsafe(facesContext, uiComponent, false);
     }
 
     public static Converter findUISelectManyConverterFailsafe(FacesContext facesContext,
-            UIComponent uiComponent, boolean considerValueType) 
-    {
+                                                              UIComponent uiComponent, boolean considerValueType) {
         Converter converter;
         try {
             converter = RendererUtils.findUISelectManyConverter(
                     facesContext, (UISelectMany) uiComponent, considerValueType);
         } catch (FacesException e) {
             log.log(Level.SEVERE, "Error finding Converter for component with id "
-                      + uiComponent.getClientId(facesContext), e);
+                    + uiComponent.getClientId(facesContext), e);
             converter = null;
         }
         return converter;
@@ -506,10 +473,10 @@ public final class HtmlRendererUtils {
         Converter converter;
         try {
             converter = RendererUtils.findUIOutputConverter(facesContext,
-                                                            (UIOutput) uiComponent);
+                    (UIOutput) uiComponent);
         } catch (FacesException e) {
             log.log(Level.SEVERE, "Error finding Converter for component with id "
-                      + uiComponent.getClientId(facesContext), e);
+                    + uiComponent.getClientId(facesContext), e);
             converter = null;
         }
         return converter;
@@ -519,25 +486,20 @@ public final class HtmlRendererUtils {
      * Renders the select options for a <code>UIComponent</code> that is
      * rendered as an HTML select element.
      *
-     * @param context
-     *            the current <code>FacesContext</code>.
-     * @param component
-     *            the <code>UIComponent</code> whose options need to be
-     *            rendered.
-     * @param converter
-     *            <code>component</code>'s converter
-     * @param lookupSet
-     *            the <code>Set</code> to use to look up selected options
-     * @param selectItemList
-     *            the <code>List</code> of <code>SelectItem</code> s to be
-     *            rendered as HTML option elements.
+     * @param context        the current <code>FacesContext</code>.
+     * @param component      the <code>UIComponent</code> whose options need to be
+     *                       rendered.
+     * @param converter      <code>component</code>'s converter
+     * @param lookupSet      the <code>Set</code> to use to look up selected options
+     * @param selectItemList the <code>List</code> of <code>SelectItem</code> s to be
+     *                       rendered as HTML option elements.
      * @throws IOException
      */
     public static void renderSelectOptions(FacesContext context,
                                            UIComponent component, Converter converter, Set lookupSet,
                                            List selectItemList) throws IOException {
         ResponseWriter writer = context.getResponseWriter();
-        
+
         // check for the hideNoSelectionOption attribute
         boolean hideNoSelectionOption = isHideNoSelectionOption(component);
 
@@ -547,45 +509,44 @@ public final class HtmlRendererUtils {
             if (selectItem instanceof SelectItemGroup) {
                 writer.startElement(HTML.OPTGROUP_ELEM, component);
                 writer.writeAttribute(HTML.LABEL_ATTR, selectItem.getLabel(),
-                                      null);
+                        null);
                 SelectItem[] selectItems = ((SelectItemGroup) selectItem)
                         .getSelectItems();
                 renderSelectOptions(context, component, converter, lookupSet,
-                                    Arrays.asList(selectItems));
+                        Arrays.asList(selectItems));
                 writer.endElement(HTML.OPTGROUP_ELEM);
             } else {
                 String itemStrValue = org.apache.myfaces.shared.renderkit.RendererUtils.getConvertedStringValue(context, component,
                         converter, selectItem);
                 boolean selected = lookupSet.contains(itemStrValue); //TODO/FIX: we always compare the String vales, better fill lookupSet with Strings only when useSubmittedValue==true, else use the real item value Objects
-                
+
                 // IF the hideNoSelectionOption attribute of the component is true
                 // AND this selectItem is the "no selection option"
                 // AND there are currently selected items 
                 // AND this item (the "no selection option") is not selected
                 // (if there is currently no value on UISelectOne, lookupSet contains "")
-                if (hideNoSelectionOption && selectItem.isNoSelectionOption() 
+                if (hideNoSelectionOption && selectItem.isNoSelectionOption()
                         && lookupSet.size() != 0 && !(lookupSet.size() == 1 && lookupSet.contains(""))
-                        && !selected)
-                {
+                        && !selected) {
                     // do not render this selectItem
                     continue;
                 }
-                
+
                 writer.write(TABULATOR);
                 writer.startElement(HTML.OPTION_ELEM, component);
                 if (itemStrValue != null) {
                     writer.writeAttribute(HTML.VALUE_ATTR, itemStrValue, null);
                 }
 
-                if (selected) {  
+                if (selected) {
                     writer.writeAttribute(HTML.SELECTED_ATTR,
-                                          HTML.SELECTED_ATTR, null);
+                            HTML.SELECTED_ATTR, null);
                 }
 
                 boolean disabled = selectItem.isDisabled();
                 if (disabled) {
                     writer.writeAttribute(HTML.DISABLED_ATTR,
-                                          HTML.DISABLED_ATTR, null);
+                            HTML.DISABLED_ATTR, null);
                 }
 
                 String labelClass = null;
@@ -601,27 +562,22 @@ public final class HtmlRendererUtils {
                 }
 
                 boolean escape;
-                if (component instanceof EscapeCapable)
-                {
-                    escape = ((EscapeCapable)component).isEscape();
-                    
+                if (component instanceof EscapeCapable) {
+                    escape = ((EscapeCapable) component).isEscape();
+
                     // Preserve tomahawk semantic. If escape=false
                     // all items should be non escaped. If escape
                     // is true check if selectItem.isEscape() is
                     // true and do it.
                     // This is done for remain compatibility.
-                    if (escape && selectItem.isEscape())
-                    {
+                    if (escape && selectItem.isEscape()) {
                         writer.writeText(selectItem.getLabel(), null);
-                    } else
-                    {
+                    } else {
                         writer.write(selectItem.getLabel());
                     }
-                }
-                else
-                {
+                } else {
                     escape = RendererUtils.getBooleanAttribute(component, JSFAttr.ESCAPE_ATTR,
-                                                               false);
+                            false);
                     //default is to escape
                     //In JSF 1.2, when a SelectItem is created by default 
                     //selectItem.isEscape() returns true (this property
@@ -629,11 +585,9 @@ public final class HtmlRendererUtils {
                     //so, if we found a escape property on the component
                     //set to true, escape every item, but if not
                     //check if isEscape() = true first.
-                    if (escape || selectItem.isEscape())
-                    {
+                    if (escape || selectItem.isEscape()) {
                         writer.writeText(selectItem.getLabel(), null);
-                    } else
-                    {
+                    } else {
                         writer.write(selectItem.getLabel());
                     }
                 }
@@ -698,7 +652,7 @@ public final class HtmlRendererUtils {
             // render JSF "styleClass" and "itemStyleClass" attributes as "class"
             String htmlAttrName =
                     attrName.equals(HTML.STYLE_CLASS_ATTR) ?
-                    HTML.CLASS_ATTR : attrName;
+                            HTML.CLASS_ATTR : attrName;
             writer.writeAttribute(htmlAttrName, value, componentProperty);
             return true;
         }
@@ -715,7 +669,7 @@ public final class HtmlRendererUtils {
             throws IOException {
         Object value = component.getAttributes().get(componentProperty);
         return renderHTMLAttribute(writer, componentProperty, htmlAttrName,
-                                   value);
+                value);
     }
 
     /**
@@ -788,72 +742,62 @@ public final class HtmlRendererUtils {
 
     public static void writeIdIfNecessary(ResponseWriter writer, UIComponent component,
                                           FacesContext facesContext)
-            throws IOException
-    {
-        if(component.getId()!=null && !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
-        {
-            writer.writeAttribute(HTML.ID_ATTR, component.getClientId(facesContext),null);
+            throws IOException {
+        if (component.getId() != null && !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX)) {
+            writer.writeAttribute(HTML.ID_ATTR, component.getClientId(facesContext), null);
         }
     }
 
     public static void writeIdAndNameIfNecessary(ResponseWriter writer, UIComponent component,
                                                  FacesContext facesContext)
-            throws IOException
-    {
-        if(component.getId()!=null && !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
-        {
+            throws IOException {
+        if (component.getId() != null && !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX)) {
             String clientId = component.getClientId(facesContext);
             writer.writeAttribute(HTML.ID_ATTR, clientId, null);
             writer.writeAttribute(HTML.NAME_ATTR, clientId, null);
         }
     }
-    
+
     public static void writeIdAndName(ResponseWriter writer, UIComponent component,
                                       FacesContext facesContext)
-            throws IOException 
-    {
+            throws IOException {
         String clientId = component.getClientId(facesContext);
         writer.writeAttribute(HTML.ID_ATTR, clientId, null);
         writer.writeAttribute(HTML.NAME_ATTR, clientId, null);
     }
-    
+
     public static void renderDisplayValueOnlyForSelects(FacesContext facesContext,
-            UIComponent uiComponent) throws IOException
-    {
+                                                        UIComponent uiComponent) throws IOException {
         // invoke renderDisplayValueOnlyForSelects with considerValueType = false
         renderDisplayValueOnlyForSelects(facesContext, uiComponent, false);
     }
 
     public static void renderDisplayValueOnlyForSelects(FacesContext facesContext,
-            UIComponent uiComponent, boolean considerValueType)
-            throws IOException
-    {
+                                                        UIComponent uiComponent, boolean considerValueType)
+            throws IOException {
         ResponseWriter writer = facesContext.getResponseWriter();
 
-        List selectItemList=null;
-        Converter converter=null;
-        boolean isSelectOne=false;
+        List selectItemList = null;
+        Converter converter = null;
+        boolean isSelectOne = false;
 
-        if(uiComponent instanceof UISelectBoolean)
-        {
+        if (uiComponent instanceof UISelectBoolean) {
             converter = findUIOutputConverterFailSafe(facesContext, uiComponent);
 
             writer.startElement(HTML.SPAN_ELEM, uiComponent);
             writeIdIfNecessary(writer, uiComponent, facesContext);
             renderDisplayValueOnlyAttributes(uiComponent, writer);
-            writer.writeText(RendererUtils.getConvertedStringValue(facesContext,uiComponent,
-                                                                   converter,((UISelectBoolean) uiComponent).getValue()),JSFAttr.VALUE_ATTR);
+            writer.writeText(RendererUtils.getConvertedStringValue(facesContext, uiComponent,
+                    converter, ((UISelectBoolean) uiComponent).getValue()), JSFAttr.VALUE_ATTR);
             writer.endElement(HTML.SPAN_ELEM);
 
-        }
-        else
-        {
+        } else {
             if (uiComponent instanceof UISelectMany) {
                 isSelectOne = false;
                 selectItemList = RendererUtils
                         .getSelectItemList((UISelectMany) uiComponent, facesContext);
                 converter = findUISelectManyConverterFailsafe(facesContext, uiComponent, considerValueType);
-            } else if(uiComponent instanceof UISelectOne){
+            } else if (uiComponent instanceof UISelectOne) {
                 isSelectOne = true;
                 selectItemList = RendererUtils
                         .getSelectItemList((UISelectOne) uiComponent, facesContext);
@@ -870,7 +814,7 @@ public final class HtmlRendererUtils {
                     uiComponent, facesContext, converter);
 
             renderSelectOptionsAsText(facesContext, uiComponent, converter, lookupSet,
-                                      selectItemList, isSelectOne);
+                    selectItemList, isSelectOne);
 
             // bug #970747: force separate end tag
             writer.writeText(STR_EMPTY, null);
@@ -880,42 +824,32 @@ public final class HtmlRendererUtils {
     }
 
     public static void renderDisplayValueOnlyAttributes(UIComponent uiComponent, ResponseWriter writer) throws IOException {
-        if(!(uiComponent instanceof org.apache.myfaces.shared.component.DisplayValueOnlyCapable))
-        {
+        if (!(uiComponent instanceof org.apache.myfaces.shared.component.DisplayValueOnlyCapable)) {
             log.severe("Wrong type of uiComponent. needs DisplayValueOnlyCapable.");
             renderHTMLAttributes(writer, uiComponent,
-                                 HTML.COMMON_PASSTROUGH_ATTRIBUTES);
+                    HTML.COMMON_PASSTROUGH_ATTRIBUTES);
 
             return;
         }
 
-        if(getDisplayValueOnlyStyle(uiComponent) != null || getDisplayValueOnlyStyleClass(uiComponent)!=null)
-        {
-            if(getDisplayValueOnlyStyle(uiComponent) != null )
-            {
+        if (getDisplayValueOnlyStyle(uiComponent) != null || getDisplayValueOnlyStyleClass(uiComponent) != null) {
+            if (getDisplayValueOnlyStyle(uiComponent) != null) {
                 writer.writeAttribute(HTML.STYLE_ATTR, getDisplayValueOnlyStyle(uiComponent), null);
-            }
-            else if(uiComponent.getAttributes().get("style")!=null)
-            {
+            } else if (uiComponent.getAttributes().get("style") != null) {
                 writer.writeAttribute(HTML.STYLE_ATTR, uiComponent.getAttributes().get("style"), null);
             }
 
-            if(getDisplayValueOnlyStyleClass(uiComponent) != null )
-            {
+            if (getDisplayValueOnlyStyleClass(uiComponent) != null) {
                 writer.writeAttribute(HTML.CLASS_ATTR, getDisplayValueOnlyStyleClass(uiComponent), null);
-            }
-            else if(uiComponent.getAttributes().get("styleClass")!=null)
-            {
+            } else if (uiComponent.getAttributes().get("styleClass") != null) {
                 writer.writeAttribute(HTML.CLASS_ATTR, uiComponent.getAttributes().get("styleClass"), null);
             }
 
             renderHTMLAttributes(writer, uiComponent,
-                                 HTML.COMMON_PASSTROUGH_ATTRIBUTES_WITHOUT_STYLE);
-        }
-        else
-        {
+                    HTML.COMMON_PASSTROUGH_ATTRIBUTES_WITHOUT_STYLE);
+        } else {
             renderHTMLAttributes(writer, uiComponent,
-                                 HTML.COMMON_PASSTROUGH_ATTRIBUTES);
+                    HTML.COMMON_PASSTROUGH_ATTRIBUTES);
         }
     }
 
@@ -931,21 +865,20 @@ public final class HtmlRendererUtils {
                 SelectItem[] selectItems = ((SelectItemGroup) selectItem)
                         .getSelectItems();
                 renderSelectOptionsAsText(context, component, converter, lookupSet,
-                                          Arrays.asList(selectItems), isSelectOne);
+                        Arrays.asList(selectItems), isSelectOne);
             } else {
                 String itemStrValue = RendererUtils.getConvertedStringValue(context, component,
-                                                                            converter, selectItem);
+                        converter, selectItem);
 
                 if (lookupSet.contains(itemStrValue)) {  //TODO/FIX: we always compare the String vales, better fill lookupSet with Strings only when useSubmittedValue==true, else use the real item value Objects
 
-                    if( ! isSelectOne )
+                    if (!isSelectOne)
                         writer.startElement(HTML.LI_ELEM, component);
                     writer.writeText(selectItem.getLabel(), null);
-                    if( ! isSelectOne )
+                    if (!isSelectOne)
                         writer.endElement(HTML.LI_ELEM);
 
-                    if( isSelectOne )
-                    {
+                    if (isSelectOne) {
                         //take care of several choices with the same value; use only the first one
                         return;
                     }
@@ -955,44 +888,36 @@ public final class HtmlRendererUtils {
     }
 
     public static void renderTableCaption(FacesContext context,
-                                 ResponseWriter writer,
-                                 UIComponent component)
-            throws IOException
-    {
+                                          ResponseWriter writer,
+                                          UIComponent component)
+            throws IOException {
         UIComponent captionFacet = component.getFacet("caption");
         if (captionFacet == null) return;
 
         String captionClass;
         String captionStyle;
 
-        if (component instanceof HtmlPanelGrid)
-        {
+        if (component instanceof HtmlPanelGrid) {
             HtmlPanelGrid panelGrid = (HtmlPanelGrid) component;
             captionClass = panelGrid.getCaptionClass();
             captionStyle = panelGrid.getCaptionStyle();
-        }
-        else if (component instanceof HtmlDataTable)
-        {
+        } else if (component instanceof HtmlDataTable) {
             HtmlDataTable dataTable = (HtmlDataTable) component;
             captionClass = dataTable.getCaptionClass();
             captionStyle = dataTable.getCaptionStyle();
-        }
-        else
-        {
-            captionClass = (String)component.getAttributes().get(org.apache.myfaces.shared.renderkit.JSFAttr.CAPTION_CLASS_ATTR);
-            captionStyle = (String)component.getAttributes().get(org.apache.myfaces.shared.renderkit.JSFAttr.CAPTION_STYLE_ATTR);
+        } else {
+            captionClass = (String) component.getAttributes().get(org.apache.myfaces.shared.renderkit.JSFAttr.CAPTION_CLASS_ATTR);
+            captionStyle = (String) component.getAttributes().get(org.apache.myfaces.shared.renderkit.JSFAttr.CAPTION_STYLE_ATTR);
         }
 
         HtmlRendererUtils.writePrettyLineSeparator(context);
         writer.startElement(HTML.CAPTION_ELEM, component);
 
-        if (captionClass != null)
-        {
+        if (captionClass != null) {
             writer.writeAttribute(HTML.CLASS_ATTR, captionClass, null);
         }
 
-        if (captionStyle != null)
-        {
+        if (captionStyle != null) {
             writer.writeAttribute(HTML.STYLE_ATTR, captionStyle, null);
         }
 
@@ -1003,18 +928,15 @@ public final class HtmlRendererUtils {
 
     public static String getDisplayValueOnlyStyleClass(UIComponent component) {
 
-        if(component instanceof org.apache.myfaces.shared.component.DisplayValueOnlyCapable)
-        {
-            if(((org.apache.myfaces.shared.component.DisplayValueOnlyCapable) component).getDisplayValueOnlyStyleClass()!=null)
+        if (component instanceof org.apache.myfaces.shared.component.DisplayValueOnlyCapable) {
+            if (((org.apache.myfaces.shared.component.DisplayValueOnlyCapable) component).getDisplayValueOnlyStyleClass() != null)
                 return ((org.apache.myfaces.shared.component.DisplayValueOnlyCapable) component).getDisplayValueOnlyStyleClass();
 
-            UIComponent parent=component;
+            UIComponent parent = component;
 
-            while((parent = parent.getParent())!=null)
-            {
-                if(parent instanceof org.apache.myfaces.shared.component.DisplayValueOnlyCapable &&
-                   ((org.apache.myfaces.shared.component.DisplayValueOnlyCapable) parent).getDisplayValueOnlyStyleClass()!=null)
-                {
+            while ((parent = parent.getParent()) != null) {
+                if (parent instanceof org.apache.myfaces.shared.component.DisplayValueOnlyCapable &&
+                        ((org.apache.myfaces.shared.component.DisplayValueOnlyCapable) parent).getDisplayValueOnlyStyleClass() != null) {
                     return ((org.apache.myfaces.shared.component.DisplayValueOnlyCapable) parent).getDisplayValueOnlyStyleClass();
                 }
             }
@@ -1025,18 +947,15 @@ public final class HtmlRendererUtils {
 
     public static String getDisplayValueOnlyStyle(UIComponent component) {
 
-        if(component instanceof DisplayValueOnlyCapable)
-        {
-            if(((org.apache.myfaces.shared.component.DisplayValueOnlyCapable) component).getDisplayValueOnlyStyle()!=null)
+        if (component instanceof DisplayValueOnlyCapable) {
+            if (((org.apache.myfaces.shared.component.DisplayValueOnlyCapable) component).getDisplayValueOnlyStyle() != null)
                 return ((org.apache.myfaces.shared.component.DisplayValueOnlyCapable) component).getDisplayValueOnlyStyle();
 
-            UIComponent parent=component;
+            UIComponent parent = component;
 
-            while((parent = parent.getParent())!=null)
-            {
-                if(parent instanceof org.apache.myfaces.shared.component.DisplayValueOnlyCapable &&
-                   ((DisplayValueOnlyCapable) parent).getDisplayValueOnlyStyle()!=null)
-                {
+            while ((parent = parent.getParent()) != null) {
+                if (parent instanceof org.apache.myfaces.shared.component.DisplayValueOnlyCapable &&
+                        ((DisplayValueOnlyCapable) parent).getDisplayValueOnlyStyle() != null) {
                     return ((DisplayValueOnlyCapable) parent).getDisplayValueOnlyStyle();
                 }
             }
@@ -1047,18 +966,15 @@ public final class HtmlRendererUtils {
 
     public static boolean isDisplayValueOnly(UIComponent component) {
 
-        if(component instanceof DisplayValueOnlyCapable)
-        {
-            if(((DisplayValueOnlyCapable) component).isSetDisplayValueOnly())
+        if (component instanceof DisplayValueOnlyCapable) {
+            if (((DisplayValueOnlyCapable) component).isSetDisplayValueOnly())
                 return ((org.apache.myfaces.shared.component.DisplayValueOnlyCapable) component).isDisplayValueOnly();
 
-            UIComponent parent=component;
+            UIComponent parent = component;
 
-            while((parent = parent.getParent())!=null)
-            {
-                if(parent instanceof DisplayValueOnlyCapable &&
-                   ((DisplayValueOnlyCapable) parent).isSetDisplayValueOnly())
-                {
+            while ((parent = parent.getParent()) != null) {
+                if (parent instanceof DisplayValueOnlyCapable &&
+                        ((DisplayValueOnlyCapable) parent).isSetDisplayValueOnly()) {
                     return ((org.apache.myfaces.shared.component.DisplayValueOnlyCapable) parent).isDisplayValueOnly();
                 }
             }
@@ -1076,21 +992,20 @@ public final class HtmlRendererUtils {
         renderDisplayValueOnlyAttributes(input, writer);
 
         String strValue = RendererUtils.getStringValue(facesContext, input);
-        writer.write( HTMLEncoder.encode(strValue, true, true) );
+        writer.write(HTMLEncoder.encode(strValue, true, true));
 
         writer.endElement(HTML.SPAN_ELEM);
     }
 
     public static void appendClearHiddenCommandFormParamsFunctionCall(StringBuffer buf, String formName) {
-        appendClearHiddenCommandFormParamsFunctionCall(new ScriptContext(buf,false), formName);
+        appendClearHiddenCommandFormParamsFunctionCall(new ScriptContext(buf, false), formName);
     }
 
     private static void appendClearHiddenCommandFormParamsFunctionCall(ScriptContext context, String formName) {
 
         String functionName = HtmlRendererUtils.getClearHiddenCommandFormParamsFunctionName(formName);
 
-        if(formName == null)
-        {
+        if (formName == null) {
             context.prettyLine();
             context.append("var clearFn = ");
             context.append(functionName);
@@ -1100,9 +1015,7 @@ public final class HtmlRendererUtils {
             context.append("{");
             context.append("window[clearFn](formName);");
             context.append("}");
-        }
-        else
-        {
+        } else {
             context.prettyLine();
             context.append("if(typeof window.");
             context.append(functionName);
@@ -1113,21 +1026,58 @@ public final class HtmlRendererUtils {
         }
     }
 
-
+    @SuppressWarnings("unchecked")
     public static void renderFormSubmitScript(FacesContext facesContext)
-            throws IOException
-    {
+            throws IOException {
 
         Map map = facesContext.getExternalContext().getRequestMap();
         Boolean firstScript = (Boolean) map.get(FIRST_SUBMIT_SCRIPT_ON_PAGE);
 
         if (firstScript == null || firstScript.equals(Boolean.TRUE)) {
             map.put(FIRST_SUBMIT_SCRIPT_ON_PAGE, Boolean.FALSE);
-            HtmlRendererUtils.renderFormSubmitScriptIfNecessary(facesContext);
+            // HtmlRendererUtils.renderFormSubmitScriptIfNecessary(facesContext);
 
+            ResourceUtils.renderMyfacesJSInlineIfNecessary(facesContext, facesContext.getResponseWriter());
+            //we have to render the config just in case
+            renderConfigOptionsIfNecessary(facesContext);
+        }
+    }
+
+    private static void renderConfigOptionsIfNecessary(FacesContext facesContext) throws IOException {
+        ResponseWriter writer = facesContext.getResponseWriter();
+        MyfacesConfig config = MyfacesConfig.getCurrentInstance(facesContext.getExternalContext());
+        ScriptContext script = new ScriptContext(config.isPrettyHtml());
+        boolean autoScroll = config.isAutoScroll();
+        boolean autoSave = JavascriptUtils.isSaveFormSubmitLinkIE(facesContext.getExternalContext());
+
+        if (autoScroll || autoSave) {
+            script.prettyLine();
+            script.increaseIndent();
+            script.append("(!window.myfaces) ? window.myfaces = {} : null;");
+            script.append("(!myfaces.core) ? myfaces.core = {} : null;");
+            script.append("(!myfaces.core.config) ? myfaces.core.config = {} : null;");
+        }
+
+        if (autoScroll) {
+            script.append("myfaces.core.config.autoScroll = true;");
+        }
+        if (autoSave) {
+            script.append("myfaces.core.config.ieAutoSave = true;");
+        }
+        if (autoScroll || autoSave) {
+            writer.startElement(HTML.SCRIPT_ELEM, null);
+            writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
+            writer.writeText(script.toString(), null);
+            writer.endElement(HTML.SCRIPT_ELEM);
         }
     }
 
+    /**
+     * @deprecated use renderFormSubmitScript() instead (renders oamSubmit.js)
+     * @param facesContext
+     * @throws IOException
+     */
+    @Deprecated
     private static void renderFormSubmitScriptIfNecessary(FacesContext facesContext) throws IOException {
         ResponseWriter writer = facesContext.getResponseWriter();
 
@@ -1139,19 +1089,25 @@ public final class HtmlRendererUtils {
         boolean autoScroll = currentInstance.isAutoScroll();
 
         ScriptContext context = new ScriptContext(currentInstance
-            .isPrettyHtml());
+                .isPrettyHtml());
         context.prettyLine();
         context.increaseIndent();
 
         prepareScript(facesContext, context, autoScroll);
 
-        writer.writeText(context.toString(),null);
+        writer.writeText(context.toString(), null);
 
         writer.endElement(HTML.SCRIPT_ELEM);
     }
 
-    private static void prepareScript(FacesContext facesContext, ScriptContext context, boolean autoScroll)
-    {
+    /**
+     * @deprecated use oamSubmit.js instead
+     * @param facesContext
+     * @param context
+     * @param autoScroll
+     */
+    @Deprecated
+    private static void prepareScript(FacesContext facesContext, ScriptContext context, boolean autoScroll) {
 
         final char separatorChar = UINamingContainer.getSeparatorChar(facesContext);
         context.prettyLine();
@@ -1224,8 +1180,7 @@ public final class HtmlRendererUtils {
         //clear the parameters
         HtmlRendererUtils.appendClearHiddenCommandFormParamsFunctionCall(context, null);
 
-        if (autoScroll)
-        {
+        if (autoScroll) {
             appendAutoScrollAssignment(context, null);
         }
 
@@ -1238,14 +1193,14 @@ public final class HtmlRendererUtils {
         context.append("form = document.getElementById(formName);");
         context.append("}");
         context.prettyLine();
-        
-        if (JavascriptUtils.isSaveFormSubmitLinkIE(FacesContext.getCurrentInstance().getExternalContext())){
+
+        if (JavascriptUtils.isSaveFormSubmitLinkIE(FacesContext.getCurrentInstance().getExternalContext())) {
             context.append("var agentString = navigator.userAgent.toLowerCase();");
             context.prettyLine();
             //context.append("var isIE = false;");
             context.prettyLine();
             context.append("if (agentString.indexOf('msie') != -1)");
-        
+
             context.append("{");
             context.append("if (!(agentString.indexOf('ppc') != -1 && agentString.indexOf('windows ce') != -1 && version >= 4.0))");
             context.append("{");
@@ -1257,7 +1212,7 @@ public final class HtmlRendererUtils {
 //        context.append("isIE = true;");
 //        context.prettyLine();
 //        context.append("}");
-        
+
             context.append("}");
 
             context.prettyLine();
@@ -1286,8 +1241,8 @@ public final class HtmlRendererUtils {
         context.prettyLine();
 
         context.append(SET_HIDDEN_INPUT_FN_NAME);
-        context.append("(formName,formName +'"+separatorChar+
-                "'+'"+HtmlRendererUtils.HIDDEN_COMMANDLINK_FIELD_NAME+"',linkId);");
+        context.append("(formName,formName +'" + separatorChar +
+                "'+'" + HtmlRendererUtils.HIDDEN_COMMANDLINK_FIELD_NAME + "',linkId);");
 
         context.prettyLine();
         context.prettyLine();
@@ -1337,8 +1292,8 @@ public final class HtmlRendererUtils {
         context.prettyLine();
 
         context.append(CLEAR_HIDDEN_INPUT_FN_NAME);
-        context.append("(formName,formName +'"+separatorChar+
-                "'+'"+HtmlRendererUtils.HIDDEN_COMMANDLINK_FIELD_NAME+"',linkId);");
+        context.append("(formName,formName +'" + separatorChar +
+                "'+'" + HtmlRendererUtils.HIDDEN_COMMANDLINK_FIELD_NAME + "',linkId);");
 
 
         //return false, so that browser does not handle the click
@@ -1352,20 +1307,18 @@ public final class HtmlRendererUtils {
      * Adds the hidden form input value assignment that is necessary for the autoscroll
      * feature to an html link or button onclick attribute.
      */
-    public static void appendAutoScrollAssignment(StringBuffer onClickValue, String formName)
-    {
-        appendAutoScrollAssignment(new ScriptContext(onClickValue,false),formName);
+    public static void appendAutoScrollAssignment(StringBuffer onClickValue, String formName) {
+        appendAutoScrollAssignment(new ScriptContext(onClickValue, false), formName);
     }
 
-    private static void appendAutoScrollAssignment(ScriptContext scriptContext, String formName)
-    {
-        String formNameStr = formName == null? "formName" : (new StringBuffer("'").append(formName).append("'").toString());
+    private static void appendAutoScrollAssignment(ScriptContext scriptContext, String formName) {
+        String formNameStr = formName == null ? "formName" : (new StringBuffer("'").append(formName).append("'").toString());
         String paramName = new StringBuffer().append("'").
                 append(AUTO_SCROLL_PARAM).append("'").toString();
         String value = new StringBuffer().append(AUTO_SCROLL_FUNCTION).append("()").toString();
 
         scriptContext.prettyLine();
-        scriptContext.append("if(typeof window."+AUTO_SCROLL_FUNCTION+"!='undefined')");
+        scriptContext.append("if(typeof window." + AUTO_SCROLL_FUNCTION + "!='undefined')");
         scriptContext.append("{");
         scriptContext.append(SET_HIDDEN_INPUT_FN_NAME);
         scriptContext.append("(").append(formNameStr).append(",").append(paramName).append(",").append(value).append(");");
@@ -1376,8 +1329,7 @@ public final class HtmlRendererUtils {
     /**
      * Renders the hidden form input that is necessary for the autoscroll feature.
      */
-    public static void renderAutoScrollHiddenInput(FacesContext facesContext, ResponseWriter writer) throws IOException
-    {
+    public static void renderAutoScrollHiddenInput(FacesContext facesContext, ResponseWriter writer) throws IOException {
         writePrettyLineSeparator(facesContext);
         writer.startElement(HTML.INPUT_ELEM, null);
         writer.writeAttribute(HTML.TYPE_ATTR, "hidden", null);
@@ -1390,18 +1342,16 @@ public final class HtmlRendererUtils {
      * Renders the autoscroll javascript function.
      */
     public static void renderAutoScrollFunction(FacesContext facesContext,
-                                                ResponseWriter writer) throws IOException
-    {
+                                                ResponseWriter writer) throws IOException {
         writePrettyLineSeparator(facesContext);
-        writer.startElement(HTML.SCRIPT_ELEM,null);
-        writer.writeAttribute(HTML.SCRIPT_TYPE_ATTR, HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT,null);
-        writer.writeText(getAutoScrollFunction(facesContext),null);
+        writer.startElement(HTML.SCRIPT_ELEM, null);
+        writer.writeAttribute(HTML.SCRIPT_TYPE_ATTR, HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT, null);
+        writer.writeText(getAutoScrollFunction(facesContext), null);
         writer.endElement(HTML.SCRIPT_ELEM);
         writePrettyLineSeparator(facesContext);
     }
-    
-    public static String getAutoScrollFunction(FacesContext facesContext)
-    {
+
+    public static String getAutoScrollFunction(FacesContext facesContext) {
         ScriptContext script = new ScriptContext(
                 MyfacesConfig.getCurrentInstance(facesContext.getExternalContext()).isPrettyHtml());
 
@@ -1412,7 +1362,7 @@ public final class HtmlRendererUtils {
         script.append("()");
         script.append("{");
         script.append("var x = 0; var y = 0;");
-        script.append( "if (self.pageXOffset || self.pageYOffset)");
+        script.append("if (self.pageXOffset || self.pageYOffset)");
         script.append("{");
         script.append("x = self.pageXOffset;");
         script.prettyLine();
@@ -1435,21 +1385,16 @@ public final class HtmlRendererUtils {
 
         ExternalContext externalContext = facesContext.getExternalContext();
         String oldViewId = JavascriptUtils.getOldViewId(externalContext);
-        if (oldViewId != null && oldViewId.equals(facesContext.getViewRoot().getViewId()))
-        {
+        if (oldViewId != null && oldViewId.equals(facesContext.getViewRoot().getViewId())) {
             //ok, we stayed on the same page, so let's scroll it to the former place
-            String scrolling = (String)externalContext.getRequestParameterMap().get(AUTO_SCROLL_PARAM);
-            if (scrolling != null && scrolling.length() > 0)
-            {
+            String scrolling = (String) externalContext.getRequestParameterMap().get(AUTO_SCROLL_PARAM);
+            if (scrolling != null && scrolling.length() > 0) {
                 int x = 0;
                 int y = 0;
                 int comma = scrolling.indexOf(',');
-                if (comma == -1)
-                {
+                if (comma == -1) {
                     log.warning("Illegal autoscroll request parameter: " + scrolling);
-                }
-                else
-                {
+                } else {
                     try {
                         //we convert to int against XSS vulnerability
                         x = Integer.parseInt(scrolling.substring(0, comma));
@@ -1469,7 +1414,7 @@ public final class HtmlRendererUtils {
                 script.append("window.scrollTo(").append(x).append(",").append(y).append(");\n");
             }
         }
-        
+
         return script.toString();
     }
 
@@ -1483,9 +1428,8 @@ public final class HtmlRendererUtils {
         return value != null && ((Boolean) value).booleanValue();
     }
 
-    public static void allowCdataSection(FacesContext fc, boolean cdataSectionAllowed)
-    {
-          fc.getExternalContext().getRequestMap().put(ALLOW_CDATA_SECTION_ON,Boolean.valueOf(cdataSectionAllowed));
+    public static void allowCdataSection(FacesContext fc, boolean cdataSectionAllowed) {
+        fc.getExternalContext().getRequestMap().put(ALLOW_CDATA_SECTION_ON, Boolean.valueOf(cdataSectionAllowed));
     }
 
     public static class LinkParameter {
@@ -1520,61 +1464,53 @@ public final class HtmlRendererUtils {
     }
 
     public static void renderHiddenInputField(ResponseWriter writer, Object name, Object value)
-            throws IOException
-    {
+            throws IOException {
         writer.startElement(HTML.INPUT_ELEM, null);
         writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
         writer.writeAttribute(HTML.NAME_ATTR, name, null);
-        if(value!=null)
-        {
-            writer.writeAttribute(HTML.VALUE_ATTR,value,null);
+        if (value != null) {
+            writer.writeAttribute(HTML.VALUE_ATTR, value, null);
         }
         writer.endElement(HTML.INPUT_ELEM);
     }
 
     /**
      * @deprecated Replaced by
-     * renderLabel(ResponseWriter writer,
-                                   UIComponent component,
-                                   String forClientId,
-                                   SelectItem item,
-                                   boolean disabled).
-     * Renders a label HTML element
+     *             renderLabel(ResponseWriter writer,
+     *             UIComponent component,
+     *             String forClientId,
+     *             SelectItem item,
+     *             boolean disabled).
+     *             Renders a label HTML element
      */
     @Deprecated
     public static void renderLabel(ResponseWriter writer,
                                    UIComponent component,
                                    String forClientId,
                                    String labelValue,
-                                   boolean disabled) throws IOException
-    {
-            writer.startElement(HTML.LABEL_ELEM, component);
-            writer.writeAttribute(HTML.FOR_ATTR, forClientId, null);
+                                   boolean disabled) throws IOException {
+        writer.startElement(HTML.LABEL_ELEM, component);
+        writer.writeAttribute(HTML.FOR_ATTR, forClientId, null);
 
-            String labelClass = null;
+        String labelClass = null;
 
-            if (disabled)
-            {
-                labelClass = (String) component.getAttributes().get(JSFAttr.DISABLED_CLASS_ATTR);
-            }
-            else
-            {
-                labelClass = (String) component.getAttributes().get(org.apache.myfaces.shared.renderkit.JSFAttr.ENABLED_CLASS_ATTR);
-            }
-            if (labelClass != null)
-            {
-                writer.writeAttribute("class", labelClass, "labelClass");
-            }
+        if (disabled) {
+            labelClass = (String) component.getAttributes().get(JSFAttr.DISABLED_CLASS_ATTR);
+        } else {
+            labelClass = (String) component.getAttributes().get(org.apache.myfaces.shared.renderkit.JSFAttr.ENABLED_CLASS_ATTR);
+        }
+        if (labelClass != null) {
+            writer.writeAttribute("class", labelClass, "labelClass");
+        }
 
-            if ((labelValue != null) && (labelValue.length() > 0))
-            {
-                writer.write(HTML.NBSP_ENTITY);
-                writer.writeText(labelValue, null);
-            }
+        if ((labelValue != null) && (labelValue.length() > 0)) {
+            writer.write(HTML.NBSP_ENTITY);
+            writer.writeText(labelValue, null);
+        }
 
-            writer.endElement(HTML.LABEL_ELEM);
+        writer.endElement(HTML.LABEL_ELEM);
     }
-    
+
     /**
      * Renders a label HTML element
      */
@@ -1582,43 +1518,34 @@ public final class HtmlRendererUtils {
                                    UIComponent component,
                                    String forClientId,
                                    SelectItem item,
-                                   boolean disabled) throws IOException
-    {
-            writer.startElement(HTML.LABEL_ELEM, component);
-            writer.writeAttribute(HTML.FOR_ATTR, forClientId, null);
+                                   boolean disabled) throws IOException {
+        writer.startElement(HTML.LABEL_ELEM, component);
+        writer.writeAttribute(HTML.FOR_ATTR, forClientId, null);
 
-            String labelClass = null;
+        String labelClass = null;
 
-            if (disabled)
-            {
-                labelClass = (String) component.getAttributes().get(JSFAttr.DISABLED_CLASS_ATTR);
-            }
-            else
-            {
-                labelClass = (String) component.getAttributes().get(org.apache.myfaces.shared.renderkit.JSFAttr.ENABLED_CLASS_ATTR);
-            }
-            if (labelClass != null)
-            {
-                writer.writeAttribute("class", labelClass, "labelClass");
-            }
+        if (disabled) {
+            labelClass = (String) component.getAttributes().get(JSFAttr.DISABLED_CLASS_ATTR);
+        } else {
+            labelClass = (String) component.getAttributes().get(org.apache.myfaces.shared.renderkit.JSFAttr.ENABLED_CLASS_ATTR);
+        }
+        if (labelClass != null) {
+            writer.writeAttribute("class", labelClass, "labelClass");
+        }
 
-            if ((item.getLabel() != null) && (item.getLabel().length() > 0))
-            {
-                // writer.write(HTML.NBSP_ENTITY);
-                writer.write(" ");
-                if(item.isEscape())
-                {
-                    //writer.write(item.getLabel());
-                    writer.writeText(item.getLabel(), null);
-                }
-                else
-                {
-                    //writer.write(HTMLEncoder.encode (item.getLabel()));
-                    writer.write(item.getLabel());
-                }
+        if ((item.getLabel() != null) && (item.getLabel().length() > 0)) {
+            // writer.write(HTML.NBSP_ENTITY);
+            writer.write(" ");
+            if (item.isEscape()) {
+                //writer.write(item.getLabel());
+                writer.writeText(item.getLabel(), null);
+            } else {
+                //writer.write(HTMLEncoder.encode (item.getLabel()));
+                writer.write(item.getLabel());
             }
+        }
 
-            writer.endElement(HTML.LABEL_ELEM);
+        writer.endElement(HTML.LABEL_ELEM);
     }
 
     /**
@@ -1629,66 +1556,50 @@ public final class HtmlRendererUtils {
                                    String forClientId,
                                    SelectItem item,
                                    boolean disabled,
-                                   boolean selected) throws IOException
-    {
-            writer.startElement(HTML.LABEL_ELEM, component);
-            writer.writeAttribute(HTML.FOR_ATTR, forClientId, null);
-
-            String labelClass = null;
-
-            if (disabled)
-            {
-                labelClass = (String) component.getAttributes().get(JSFAttr.DISABLED_CLASS_ATTR);
-            }
-            else
-            {
-                labelClass = (String) component.getAttributes().get(org.apache.myfaces.shared.renderkit.JSFAttr.ENABLED_CLASS_ATTR);
-            }
-            
-            String labelSelectedClass = null;
-            
-            if(selected)
-            {
-                labelSelectedClass = (String) component.getAttributes().get(JSFAttr.SELECTED_CLASS_ATTR);
-            }
-            else
-            {
-                labelSelectedClass = (String) component.getAttributes().get(JSFAttr.UNSELECTED_CLASS_ATTR);
-            }
-            
-            if(labelSelectedClass != null) 
-            {
-                if(labelClass == null)
-                {
-                    labelClass = labelSelectedClass;
-                }
-                else
-                {
-                    labelClass = labelClass + " " + labelSelectedClass;
-                }
-            }
-            
-            if (labelClass != null)
-            {
-                writer.writeAttribute("class", labelClass, "labelClass");
-            }
-
-            if ((item.getLabel() != null) && (item.getLabel().length() > 0))
-            {
-                writer.write(HTML.NBSP_ENTITY);
-                if(item.isEscape())
-                {
-                    //writer.write(item.getLabel());
-                    writer.writeText(item.getLabel(), null);
-                }
-                else
-                {
-                    //writer.write(HTMLEncoder.encode (item.getLabel()));
-                    writer.write(item.getLabel());
-                }
+                                   boolean selected) throws IOException {
+        writer.startElement(HTML.LABEL_ELEM, component);
+        writer.writeAttribute(HTML.FOR_ATTR, forClientId, null);
+
+        String labelClass = null;
+
+        if (disabled) {
+            labelClass = (String) component.getAttributes().get(JSFAttr.DISABLED_CLASS_ATTR);
+        } else {
+            labelClass = (String) component.getAttributes().get(org.apache.myfaces.shared.renderkit.JSFAttr.ENABLED_CLASS_ATTR);
+        }
+
+        String labelSelectedClass = null;
+
+        if (selected) {
+            labelSelectedClass = (String) component.getAttributes().get(JSFAttr.SELECTED_CLASS_ATTR);
+        } else {
+            labelSelectedClass = (String) component.getAttributes().get(JSFAttr.UNSELECTED_CLASS_ATTR);
+        }
+
+        if (labelSelectedClass != null) {
+            if (labelClass == null) {
+                labelClass = labelSelectedClass;
+            } else {
+                labelClass = labelClass + " " + labelSelectedClass;
             }
+        }
+
+        if (labelClass != null) {
+            writer.writeAttribute("class", labelClass, "labelClass");
+        }
 
-            writer.endElement(HTML.LABEL_ELEM);
+        if ((item.getLabel() != null) && (item.getLabel().length() > 0)) {
+            writer.write(HTML.NBSP_ENTITY);
+            if (item.isEscape()) {
+                //writer.write(item.getLabel());
+                writer.writeText(item.getLabel(), null);
+            } else {
+                //writer.write(HTMLEncoder.encode (item.getLabel()));
+                writer.write(item.getLabel());
+            }
+        }
+
+        writer.endElement(HTML.LABEL_ELEM);
     }
 
     /**
@@ -1720,15 +1631,15 @@ public final class HtmlRendererUtils {
             script.append("\n  var f = document.forms['");
             script.append(formName);
             script.append("'];");
-            int i=0;
+            int i = 0;
             for (Iterator it = dummyFormParams.iterator(); it.hasNext();) {
-                String elemVarName = "elem"+i;
+                String elemVarName = "elem" + i;
                 script.append("\n  var ").append(elemVarName).append(" = ");
                 script.append("f.elements['").append((String) it.next()).append("'];");
                 script.append("\n  if(typeof ").append(elemVarName).append(" !='undefined' && ");
                 script.append(elemVarName).append(".nodeName=='INPUT'){");
                 script.append("\n   if (").append(elemVarName).append(".value != '') {");
-                script.append("\n    "+elemVarName+".value='';");
+                script.append("\n    " + elemVarName + ".value='';");
                 script.append("\n   }");
                 script.append("\n  }");
                 i++;
@@ -1755,7 +1666,7 @@ public final class HtmlRendererUtils {
         script.append(functionName);
         script.append("();");
 
-        writer.writeText(script.toString(),null);
+        writer.writeText(script.toString(), null);
         writer.endElement(HTML.SCRIPT_ELEM);
     }
 
@@ -1766,11 +1677,9 @@ public final class HtmlRendererUtils {
      * @return String
      */
     public static String getClearHiddenCommandFormParamsFunctionName(
-            String formName)
-    {
+            String formName) {
         final char separatorChar = UINamingContainer.getSeparatorChar(FacesContext.getCurrentInstance());
-        if (formName == null)
-        {
+        if (formName == null) {
             return "'" + CLEAR_HIDDEN_FIELD_FN_NAME
                     + "_'+formName.replace(/-/g, '\\$" + separatorChar + "').replace(/" + separatorChar + "/g,'_')";
         }
@@ -1782,8 +1691,7 @@ public final class HtmlRendererUtils {
     }
 
     public static String getClearHiddenCommandFormParamsFunctionNameMyfacesLegacy(
-            String formName)
-    {
+            String formName) {
         return "clear_"
                 + JavascriptUtils.getValidJavascriptName(formName, false);
     }
@@ -1810,11 +1718,10 @@ public final class HtmlRendererUtils {
             return HIDDEN_COMMANDLINK_FIELD_NAME_TRINIDAD;
         }
         return formInfo.getFormName() + UINamingContainer.getSeparatorChar(FacesContext.getCurrentInstance())
-            + HIDDEN_COMMANDLINK_FIELD_NAME;
+                + HIDDEN_COMMANDLINK_FIELD_NAME;
     }
 
-    public static boolean isPartialOrBehaviorSubmit(FacesContext facesContext, String clientId)
-    {
+    public static boolean isPartialOrBehaviorSubmit(FacesContext facesContext, String clientId) {
         Map<String, String> params = facesContext.getExternalContext().getRequestParameterMap();
 
         String sourceId = params.get("javax.faces.source");
@@ -1833,86 +1740,75 @@ public final class HtmlRendererUtils {
     }
 
     /**
-     *
      * @param formInfo
-     * @deprecated Use getHiddenCommandLinkFieldNameMyfaces(FormInfo) instead
      * @return
+     * @deprecated Use getHiddenCommandLinkFieldNameMyfaces(FormInfo) instead
      */
     public static String getHiddenCommandLinkFieldNameMyfacesOld(FormInfo formInfo) {
         return formInfo.getFormName() + UINamingContainer.getSeparatorChar(FacesContext.getCurrentInstance())
-            + HIDDEN_COMMANDLINK_FIELD_NAME_MYFACES_OLD;
+                + HIDDEN_COMMANDLINK_FIELD_NAME_MYFACES_OLD;
     }
-    
-    public static String getOutcomeTargetLinkHref (
-            FacesContext facesContext, UIOutcomeTarget component) throws IOException
-    {
+
+    public static String getOutcomeTargetLinkHref(
+            FacesContext facesContext, UIOutcomeTarget component) throws IOException {
         String outcome = component.getOutcome();
         outcome = ((outcome == null) ? STR_EMPTY : outcome.trim());
-        
+
         // Get the correct URL for the outcome.
         NavigationHandler nh = facesContext.getApplication().getNavigationHandler();
-        if (!(nh instanceof ConfigurableNavigationHandler))
-        {
+        if (!(nh instanceof ConfigurableNavigationHandler)) {
             throw new FacesException("Navigation handler must be an instance of " +
                     "ConfigurableNavigationHandler for using h:link or h:button");
         }
         ConfigurableNavigationHandler navigationHandler = (ConfigurableNavigationHandler) nh;
         // fromAction is null because there is no action method that was called to get the outcome
         NavigationCase navigationCase = navigationHandler.getNavigationCase(facesContext, null, outcome);
-        
+
         // when navigation case is null, force the "link" to be rendered as text
-        if (navigationCase == null)
-        {
+        if (navigationCase == null) {
             return null;
         }
-        
+
         // handle URL parameters
-        Map<String, List<String>> parameters = new HashMap<String,List<String>>();
+        Map<String, List<String>> parameters = new HashMap<String, List<String>>();
         List<UIParameter> validParams = getValidUIParameterChildren(
                 facesContext, component.getChildren(), true, false);
-        for (UIParameter param : validParams)
-        {
+        for (UIParameter param : validParams) {
             String name = param.getName();
             Object value = param.getValue();
-            if (parameters.containsKey(name))
-            {
+            if (parameters.containsKey(name)) {
                 parameters.get(name).add(value.toString());
-            }
-            else
-            {
+            } else {
                 List<String> list = new ArrayList<String>(1);
                 list.add(value.toString());
                 parameters.put(name, list);
             }
         }
-        
+
         // handle NavigationCase parameters
         Map<String, List<String>> navigationCaseParams = navigationCase.getParameters();
-        if (navigationCaseParams != null)
-        {
+        if (navigationCaseParams != null) {
             parameters.putAll(navigationCaseParams);
         }
-        
+
         // In theory the precedence order to deal with params is this:
         // component parameters, navigation-case parameters, view parameters
         // getBookmarkableURL deal with this details.
         ViewHandler viewHandler = facesContext.getApplication().getViewHandler();
-        String href = viewHandler.getBookmarkableURL(facesContext, 
-                navigationCase.getToViewId(facesContext), parameters, 
+        String href = viewHandler.getBookmarkableURL(facesContext,
+                navigationCase.getToViewId(facesContext), parameters,
                 navigationCase.isIncludeViewParams() || component.isIncludeViewParams());
-        
+
         // handle fragment (viewId#fragment)
         String fragment = (String) component.getAttributes().get("fragment");
-        if (fragment != null)
-        {
+        if (fragment != null) {
             fragment = fragment.trim();
-            
-            if (fragment.length() > 0)
-            {
+
+            if (fragment.length() > 0) {
                 href += "#" + fragment;
             }
         }
-                
+
         return href;
     }
 
@@ -1926,39 +1822,34 @@ public final class HtmlRendererUtils {
     private static String TEXT_XML_CONTENT_TYPE = "text/xml";
 
     // The order is important in this case.
-    private static final String [] SUPPORTED_CONTENT_TYPES = {
+    private static final String[] SUPPORTED_CONTENT_TYPES = {
             HTML_CONTENT_TYPE, //Prefer this over any other, because IE does not support XHTML content type
             XHTML_CONTENT_TYPE,
             APPLICATION_XML_CONTENT_TYPE,
             TEXT_XML_CONTENT_TYPE,
             TEXT_ANY_CONTENT_TYPE,
             ANY_CONTENT_TYPE
-        };
+    };
 
-    public static String selectContentType(String contentTypeListString)
-    {
-        if (contentTypeListString == null)
-        {
+    public static String selectContentType(String contentTypeListString) {
+        if (contentTypeListString == null) {
             FacesContext context = FacesContext.getCurrentInstance();
-            if(context != null)
-            {
+            if (context != null) {
                 contentTypeListString = (String)
-                    context.getExternalContext().getRequestHeaderMap().get("Accept");
-                
+                        context.getExternalContext().getRequestHeaderMap().get("Accept");
+
                 // There is a windows mobile IE client (6.12) sending
                 // "application/vnd.wap.mms-message;*/*"
                 // Note that the Accept header should be written as 
                 // "application/vnd.wap.mms-message,*/*" ,
                 // so this is bug of the client. Anyway, this is a workaround ...
-                if (contentTypeListString != null && 
-                    contentTypeListString.startsWith("application/vnd.wap.mms-message;*/*"))
-                {
-                        contentTypeListString = "*/*";
-            }
+                if (contentTypeListString != null &&
+                        contentTypeListString.startsWith("application/vnd.wap.mms-message;*/*")) {
+                    contentTypeListString = "*/*";
+                }
             }
 
-            if(contentTypeListString == null)
-            {
+            if (contentTypeListString == null) {
                 if (log.isLoggable(Level.FINE))
                     log.fine("No content type list given, creating HtmlResponseWriterImpl with default content type.");
 
@@ -1971,75 +1862,62 @@ public final class HtmlRendererUtils {
 
         String selectedContentType = null;
 
-        for (int i = 0; i < supportedContentTypeArray.length; i++)
-        {
+        for (int i = 0; i < supportedContentTypeArray.length; i++) {
             String supportedContentType = supportedContentTypeArray[i].trim();
 
-            for (int j = 0; j < contentTypeList.size(); j++)
-            {
+            for (int j = 0; j < contentTypeList.size(); j++) {
                 String contentType = (String) contentTypeList.get(j);
 
-                if (contentType.indexOf(supportedContentType) != -1)
-                {
+                if (contentType.indexOf(supportedContentType) != -1) {
                     if (isHTMLContentType(contentType)) {
                         selectedContentType = HTML_CONTENT_TYPE;
-                    }
-
-                    else if (isXHTMLContentType(contentType)) {
+                    } else if (isXHTMLContentType(contentType)) {
                         selectedContentType = XHTML_CONTENT_TYPE;
                     }
                     break;
                 }
             }
-            if (selectedContentType!=null)
-            {
+            if (selectedContentType != null) {
                 break;
             }
         }
 
-        if(selectedContentType==null)
-        {
+        if (selectedContentType == null) {
             throw new IllegalArgumentException("ContentTypeList does not contain a supported content type: " +
-                                               contentTypeListString);
+                    contentTypeListString);
         }
         return selectedContentType;
     }
 
-    public static String[] getSupportedContentTypes()
-    {
+    public static String[] getSupportedContentTypes() {
         //String[] supportedContentTypeArray = new String[]{HTML_CONTENT_TYPE,TEXT_ANY_CONTENT_TYPE,ANY_CONTENT_TYPE,
         //                                                  XHTML_CONTENT_TYPE,APPLICATION_XML_CONTENT_TYPE,TEXT_XML_CONTENT_TYPE};
         return SUPPORTED_CONTENT_TYPES;
     }
 
-    private static boolean isHTMLContentType(String contentType)
-    {
+    private static boolean isHTMLContentType(String contentType) {
         return contentType.indexOf(HTML_CONTENT_TYPE) != -1 ||
-            contentType.indexOf(ANY_CONTENT_TYPE) != -1 ||
-            contentType.indexOf(TEXT_ANY_CONTENT_TYPE) != -1 ;
+                contentType.indexOf(ANY_CONTENT_TYPE) != -1 ||
+                contentType.indexOf(TEXT_ANY_CONTENT_TYPE) != -1;
     }
 
-    public static boolean isXHTMLContentType(String contentType)
-    {
+    public static boolean isXHTMLContentType(String contentType) {
         return contentType.indexOf(XHTML_CONTENT_TYPE) != -1 ||
-               contentType.indexOf(APPLICATION_XML_CONTENT_TYPE) != -1 ||
-               contentType.indexOf(TEXT_XML_CONTENT_TYPE) != -1;
+                contentType.indexOf(APPLICATION_XML_CONTENT_TYPE) != -1 ||
+                contentType.indexOf(TEXT_XML_CONTENT_TYPE) != -1;
     }
 
-    private static List splitContentTypeListString(String contentTypeListString)
-    {
+    private static List splitContentTypeListString(String contentTypeListString) {
         List contentTypeList = new ArrayList();
 
         StringTokenizer st = new StringTokenizer(contentTypeListString, ",");
-        while (st.hasMoreTokens())
-        {
+        while (st.hasMoreTokens()) {
             String contentType = st.nextToken().trim();
 
             int semicolonIndex = contentType.indexOf(";");
 
-            if (semicolonIndex!=-1)
-            {
-                contentType = contentType.substring(0,semicolonIndex);
+            if (semicolonIndex != -1) {
+                contentType = contentType.substring(0, semicolonIndex);
             }
 
             contentTypeList.add(contentType);
@@ -2048,88 +1926,78 @@ public final class HtmlRendererUtils {
         return contentTypeList;
     }
 
-    public static String getJavascriptLocation(UIComponent component)
-    {
-        if(component==null)
+    public static String getJavascriptLocation(UIComponent component) {
+        if (component == null)
             return null;
 
-        return (String)component.getAttributes().get(JSFAttr.JAVASCRIPT_LOCATION);
+        return (String) component.getAttributes().get(JSFAttr.JAVASCRIPT_LOCATION);
     }
 
-    public static String getImageLocation(UIComponent component)
-    {
-        if(component==null)
+    public static String getImageLocation(UIComponent component) {
+        if (component == null)
             return null;
 
-        return (String)component.getAttributes().get(JSFAttr.IMAGE_LOCATION);
+        return (String) component.getAttributes().get(JSFAttr.IMAGE_LOCATION);
     }
 
-    public static String getStyleLocation(UIComponent component)
-    {
-        if(component==null)
+    public static String getStyleLocation(UIComponent component) {
+        if (component == null)
             return null;
 
-        return (String)component.getAttributes().get(JSFAttr.STYLE_LOCATION);
+        return (String) component.getAttributes().get(JSFAttr.STYLE_LOCATION);
     }
 
     /**
      * Checks if the given component has a behavior attachment with a given name.
-     * 
-     * @since 4.0.0
+     *
      * @param eventName the event name to be checked for
      * @param behaviors map of behaviors attached to the component
      * @return true if client behavior with given name is attached, false otherwise
+     * @since 4.0.0
      */
     public static boolean hasClientBehavior(String eventName,
-            Map<String, List<ClientBehavior>> behaviors,
-            FacesContext facesContext)
-    {
-        if (behaviors == null)
-        {
+                                            Map<String, List<ClientBehavior>> behaviors,
+                                            FacesContext facesContext) {
+        if (behaviors == null) {
             return false;
         }
         return (behaviors.get(eventName) != null);
     }
 
     public static Collection<ClientBehaviorContext.Parameter> getClientBehaviorContextParameters(
-            Map<String, String> params)
-    {
+            Map<String, String> params) {
         List<ClientBehaviorContext.Parameter> paramList = null;
-        if (params != null)
-        {
+        if (params != null) {
             paramList = new ArrayList<ClientBehaviorContext.Parameter>(
                     params.size());
-            for (Map.Entry<String, String> paramEntry : params.entrySet())
-            {
+            for (Map.Entry<String, String> paramEntry : params.entrySet()) {
                 paramList.add(new ClientBehaviorContext.Parameter(paramEntry
                         .getKey(), paramEntry.getValue()));
             }
         }
         return paramList;
     }
-    
+
     /**
-    * builds the chained behavior script which then can be reused
-    * in following order by the other script building parts
-    *
-    * user defined event handling script
-    * behavior script
-    * renderer default script
-    *
-    * @since 4.0.0
-    * @param eventName event name ("onclick" etc...)
-    * @param uiComponent   the component which has the attachement (or should have)
-    * @param facesContext  the facesContext
-    * @param params    params map of params which have to be dragged into the request
-    * @return a string representation of the javascripts for the attached event behavior, an empty string if none is present
-    */
+     * builds the chained behavior script which then can be reused
+     * in following order by the other script building parts
+     * <p/>
+     * user defined event handling script
+     * behavior script
+     * renderer default script
+     *
+     * @param eventName    event name ("onclick" etc...)
+     * @param uiComponent  the component which has the attachement (or should have)
+     * @param facesContext the facesContext
+     * @param params       params map of params which have to be dragged into the request
+     * @return a string representation of the javascripts for the attached event behavior, an empty string if none is present
+     * @since 4.0.0
+     */
     private static boolean getClientBehaviorScript(FacesContext facesContext,
-            UIComponent uiComponent,  String eventName,
-            Map<String, List<ClientBehavior>> clientBehaviors,
-            ScriptContext target, Collection<ClientBehaviorContext.Parameter> params)
-    {
-        if (!(uiComponent instanceof ClientBehaviorHolder))
-        {
+                                                   UIComponent uiComponent, String eventName,
+                                                   Map<String, List<ClientBehavior>> clientBehaviors,
+                                                   ScriptContext target, Collection<ClientBehaviorContext.Parameter> params) {
+        if (!(uiComponent instanceof ClientBehaviorHolder)) {
             target.append(STR_EMPTY);
             return false;
         }
@@ -2139,8 +2007,7 @@ public final class HtmlRendererUtils {
         boolean renderClientBehavior = JavascriptUtils
                 .isJavascriptAllowed(externalContext)
                 && clientBehaviors != null && clientBehaviors.size() > 0;
-        if (!renderClientBehavior)
-        {
+        if (!renderClientBehavior) {
             target.append(STR_EMPTY);
             return false;
         }
@@ -2148,8 +2015,7 @@ public final class HtmlRendererUtils {
         List<ClientBehavior> attachedEventBehaviors = clientBehaviors
                 .get(eventName);
         if (attachedEventBehaviors == null
-                || attachedEventBehaviors.size() == 0)
-        {
+                || attachedEventBehaviors.size() == 0) {
             target.append(STR_EMPTY);
             return false;
         }
@@ -2163,20 +2029,17 @@ public final class HtmlRendererUtils {
         boolean submitting = false;
         Iterator<ClientBehavior> clientIterator = attachedEventBehaviors
                 .iterator();
-        while (clientIterator.hasNext())
-        {
+        while (clientIterator.hasNext()) {
             ClientBehavior clientBehavior = clientIterator.next();
-            String script = clientBehavior.getScript (context);
-            
+            String script = clientBehavior.getScript(context);
+
             // The script _can_ be null, and in fact is for <f:ajax disabled="true" />
-            
-            if (script != null)
-            {
+
+            if (script != null) {
                 //either strings or functions, but I assume string is more appropriate since it allows access to the
                 //origin as this!
                 target.append("'" + escapeJavaScriptForChain(script) + "'");
-                if (clientIterator.hasNext())
-                {
+                if (clientIterator.hasNext()) {
                     target.append(", ");
                 }
             }
@@ -2188,7 +2051,6 @@ public final class HtmlRendererUtils {
     }
 
     /**
-     * @since 4.0.0
      * @param facesContext
      * @param uiComponent
      * @param clientBehaviors
@@ -2197,23 +2059,21 @@ public final class HtmlRendererUtils {
      * @param serverEventCode
      * @param params
      * @return
+     * @since 4.0.0
      */
     public static String buildBehaviorChain(FacesContext facesContext,
-            UIComponent uiComponent,
-            String eventName, Collection<ClientBehaviorContext.Parameter> params, 
-            Map<String, List<ClientBehavior>> clientBehaviors,
-            String userEventCode, String serverEventCode)
-    {
+                                            UIComponent uiComponent,
+                                            String eventName, Collection<ClientBehaviorContext.Parameter> params,
+                                            Map<String, List<ClientBehavior>> clientBehaviors,
+                                            String userEventCode, String serverEventCode) {
         ExternalContext externalContext = facesContext.getExternalContext();
         boolean renderCode = JavascriptUtils
                 .isJavascriptAllowed(externalContext);
-        if (!renderCode)
-        {
+        if (!renderCode) {
             return STR_EMPTY;
         }
         List<String> finalParams = new ArrayList<String>(3);
-        if (userEventCode != null && !userEventCode.trim().equals(STR_EMPTY))
-        {
+        if (userEventCode != null && !userEventCode.trim().equals(STR_EMPTY)) {
             // escape every ' in the user event code since it will
             // be a string attribute of jsf.util.chain
             finalParams.add('\'' + escapeJavaScriptForChain(userEventCode) + '\'');

[... 996 lines stripped ...]