myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r1239799 [6/9] - in /myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared: application/ config/ context/flash/ renderkit/ renderkit/html/ renderkit/html/util/ resource/ util/ util/io/ util/xml/
Date Thu, 02 Feb 2012 20:00:44 GMT
Added: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlSelectableRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlSelectableRendererBase.java?rev=1239799&view=auto
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlSelectableRendererBase.java (added)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlSelectableRendererBase.java Thu Feb  2 20:00:42 2012
@@ -0,0 +1,176 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.shared.renderkit.html;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UISelectMany;
+import javax.faces.component.UISelectOne;
+import javax.faces.component.behavior.ClientBehavior;
+import javax.faces.component.behavior.ClientBehaviorHolder;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.convert.Converter;
+import org.apache.myfaces.shared.renderkit.RendererUtils;
+import org.apache.myfaces.shared.renderkit.html.util.JavascriptUtils;
+
+/**
+ *
+ * @author Leonardo Uribe
+ */
+public class HtmlSelectableRendererBase extends HtmlRenderer
+{
+    
+    protected void internalRenderSelect(FacesContext facesContext,
+            UIComponent uiComponent, boolean disabled, int size,
+            boolean selectMany, Converter converter) throws IOException
+    {
+        ResponseWriter writer = facesContext.getResponseWriter();
+        writer.startElement(HTML.SELECT_ELEM, uiComponent);
+        if (uiComponent instanceof ClientBehaviorHolder
+                && JavascriptUtils.isJavascriptAllowed(facesContext
+                        .getExternalContext())
+                && !((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);
+        List selectItemList;
+        if (selectMany)
+        {
+            writer.writeAttribute(HTML.MULTIPLE_ATTR, HTML.MULTIPLE_ATTR, null);
+            selectItemList = org.apache.myfaces.shared.renderkit.RendererUtils
+                    .getSelectItemList((UISelectMany) uiComponent, facesContext);
+        }
+        else
+        {
+            selectItemList = RendererUtils.getSelectItemList(
+                    (UISelectOne) uiComponent, facesContext);
+        }
+
+        if (size == Integer.MIN_VALUE)
+        {
+            //No size given (Listbox) --> size is number of select items
+            writer.writeAttribute(HTML.SIZE_ATTR,
+                    Integer.toString(selectItemList.size()), null);
+        }
+        else
+        {
+            writer.writeAttribute(HTML.SIZE_ATTR, Integer.toString(size), null);
+        }
+        Map<String, List<ClientBehavior>> behaviors = null;
+        if (uiComponent instanceof ClientBehaviorHolder
+                && JavascriptUtils.isJavascriptAllowed(facesContext
+                        .getExternalContext()))
+        {
+            behaviors = ((ClientBehaviorHolder) uiComponent)
+                    .getClientBehaviors();
+            long commonPropertiesMarked = 0L;
+            if (isCommonPropertiesOptimizationEnabled(facesContext))
+            {
+                commonPropertiesMarked = CommonPropertyUtils.getCommonPropertiesMarked(uiComponent);
+            }
+            if (behaviors.isEmpty() && isCommonPropertiesOptimizationEnabled(facesContext))
+            {
+                CommonPropertyUtils.renderChangeEventProperty(writer, 
+                        commonPropertiesMarked, uiComponent);
+                CommonPropertyUtils.renderEventProperties(writer, 
+                        commonPropertiesMarked, uiComponent);
+                CommonPropertyUtils.renderFieldEventPropertiesWithoutOnchange(writer, 
+                        commonPropertiesMarked, uiComponent);
+            }
+            else
+            {
+                HtmlRendererUtils.renderBehaviorizedOnchangeEventHandler(facesContext, writer,
+                        uiComponent, behaviors);
+                if (isCommonEventsOptimizationEnabled(facesContext))
+                {
+                    Long commonEventsMarked = CommonEventUtils.getCommonEventsMarked(uiComponent);
+                    CommonEventUtils.renderBehaviorizedEventHandlers(facesContext, writer, 
+                            commonPropertiesMarked, commonEventsMarked, uiComponent, behaviors);
+                    CommonEventUtils.renderBehaviorizedFieldEventHandlersWithoutOnchange(
+                        facesContext, writer, commonPropertiesMarked, commonEventsMarked, uiComponent, behaviors);
+                }
+                else
+                {
+                    HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, uiComponent,
+                            behaviors);
+                    HtmlRendererUtils.renderBehaviorizedFieldEventHandlersWithoutOnchange(facesContext,
+                            writer, uiComponent, behaviors);
+                }
+            }
+            if (isCommonPropertiesOptimizationEnabled(facesContext))
+            {
+                CommonPropertyUtils.renderSelectPassthroughPropertiesWithoutDisabledAndEvents(writer, 
+                        CommonPropertyUtils.getCommonPropertiesMarked(uiComponent), uiComponent);
+            }
+            else
+            {
+                HtmlRendererUtils.renderHTMLAttributes(
+                        writer,
+                        uiComponent,
+                        HTML.SELECT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED_AND_EVENTS);
+            }
+        }
+        else
+        {
+            if (isCommonPropertiesOptimizationEnabled(facesContext))
+            {
+                CommonPropertyUtils.renderSelectPassthroughPropertiesWithoutDisabled(writer, 
+                        CommonPropertyUtils.getCommonPropertiesMarked(uiComponent), uiComponent);
+            }
+            else
+            {
+                HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent,
+                        HTML.SELECT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED);
+            }
+        }
+
+        if (disabled)
+        {
+            writer.writeAttribute(HTML.DISABLED_ATTR, Boolean.TRUE, null);
+        }
+
+        if (HtmlRendererUtils.isReadOnly(uiComponent))
+        {
+            writer.writeAttribute(HTML.READONLY_ATTR, HTML.READONLY_ATTR, null);
+        }
+
+        Set lookupSet = HtmlRendererUtils.getSubmittedOrSelectedValuesAsSet(selectMany,
+                uiComponent, facesContext, converter);
+
+        HtmlRendererUtils.renderSelectOptions(facesContext, uiComponent, converter, lookupSet,
+                selectItemList);
+        // bug #970747: force separate end tag
+        writer.writeText(HtmlRendererUtils.STR_EMPTY, null);
+        writer.endElement(HTML.SELECT_ELEM);
+    }
+    
+}

Propchange: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlSelectableRendererBase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTableRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTableRendererBase.java?rev=1239799&r1=1239798&r2=1239799&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTableRendererBase.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTableRendererBase.java Thu Feb  2 20:00:42 2012
@@ -19,7 +19,6 @@
 package org.apache.myfaces.shared.renderkit.html;
 
 import java.io.IOException;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.logging.Logger;
@@ -68,7 +67,8 @@ public class HtmlTableRendererBase exten
      * @param component dataTable
      * @return number of layout columns
      */
-    protected int getNewspaperColumns(UIComponent component) {
+    protected int getNewspaperColumns(UIComponent component)
+    {
         return 1;
     }
 
@@ -76,7 +76,8 @@ public class HtmlTableRendererBase exten
      * @param component dataTable
      * @return component to display between layout columns
      */
-    protected UIComponent getNewspaperTableSpacer(UIComponent component) {
+    protected UIComponent getNewspaperTableSpacer(UIComponent component)
+    {
         return null;
     }
 
@@ -84,7 +85,8 @@ public class HtmlTableRendererBase exten
      * @param component dataTable
      * @return whether dataTable has component to display between layout columns
      */
-    protected boolean hasNewspaperTableSpacer(UIComponent component) {
+    protected boolean hasNewspaperTableSpacer(UIComponent component)
+    {
         return false;
     }
 
@@ -92,7 +94,8 @@ public class HtmlTableRendererBase exten
      * @param component dataTable
      * @return whether dataTable has newspaper columns layed out horizontally
      */
-    protected boolean isNewspaperHorizontalOrientation(UIComponent component) {
+    protected boolean isNewspaperHorizontalOrientation(UIComponent component)
+    {
         return false;
     }
 
@@ -138,7 +141,8 @@ public class HtmlTableRendererBase exten
         writer.startElement(HTML.TABLE_ELEM, uiComponent);
         
         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();
             if (!behaviors.isEmpty())
@@ -149,7 +153,24 @@ public class HtmlTableRendererBase exten
             {
                 HtmlRendererUtils.writeIdIfNecessary(writer, uiComponent, facesContext);
             }
-            HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, uiComponent, behaviors);
+            if (behaviors.isEmpty() && isCommonPropertiesOptimizationEnabled(facesContext))
+            {
+                CommonPropertyUtils.renderEventProperties(writer, 
+                        CommonPropertyUtils.getCommonPropertiesMarked(uiComponent), uiComponent);
+            }
+            else
+            {
+                if (isCommonEventsOptimizationEnabled(facesContext))
+                {
+                    CommonEventUtils.renderBehaviorizedEventHandlers(facesContext, writer, 
+                           CommonPropertyUtils.getCommonPropertiesMarked(uiComponent),
+                           CommonEventUtils.getCommonEventsMarked(uiComponent), uiComponent, behaviors);
+                }
+                else
+                {
+                    HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, uiComponent, behaviors);
+                }
+            }
             if (isCommonPropertiesOptimizationEnabled(facesContext))
             {
                 HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, HTML.TABLE_ATTRIBUTES);
@@ -158,7 +179,8 @@ public class HtmlTableRendererBase exten
             }
             else
             {
-                HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, HTML.TABLE_PASSTHROUGH_ATTRIBUTES_WITHOUT_EVENTS);
+                HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, 
+                        HTML.TABLE_PASSTHROUGH_ATTRIBUTES_WITHOUT_EVENTS);
             }
         }
         else
@@ -172,7 +194,8 @@ public class HtmlTableRendererBase exten
             }
             else
             {
-                HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, HTML.TABLE_PASSTHROUGH_ATTRIBUTES);
+                HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, 
+                        HTML.TABLE_PASSTHROUGH_ATTRIBUTES);
             }
         }
     }
@@ -232,13 +255,17 @@ public class HtmlTableRendererBase exten
     /**
      * Gets styles for the specified component.
      */
-    protected static Styles getStyles(UIData uiData) {
+    protected static Styles getStyles(UIData uiData)
+    {
         String rowClasses;
         String columnClasses;
-        if(uiData instanceof HtmlDataTable) {
+        if(uiData instanceof HtmlDataTable) 
+        {
             rowClasses = ((HtmlDataTable)uiData).getRowClasses();
             columnClasses = ((HtmlDataTable)uiData).getColumnClasses();
-        } else {
+        }
+        else
+        {
             rowClasses = (String)uiData.getAttributes().get(JSFAttr.ROW_CLASSES_ATTR);
             columnClasses = (String)uiData.getAttributes().get(JSFAttr.COLUMN_CLASSES_ATTR);
         }
@@ -248,12 +275,14 @@ public class HtmlTableRendererBase exten
     /**
      * Class manages the styles from String lists.
      */
-    protected static class Styles {
+    protected static class Styles
+    {
 
         private String[] _columnStyle;
         private String[] _rowStyle;
 
-        Styles(String rowStyles, String columnStyles) {
+        Styles(String rowStyles, String columnStyles)
+        {
             _rowStyle = (rowStyles == null)
                 ? ArrayUtils.EMPTY_STRING_ARRAY
                 : StringUtils.trim(
@@ -264,15 +293,19 @@ public class HtmlTableRendererBase exten
                     StringUtils.splitShortString(columnStyles, ','));
         }
 
-        public String getRowStyle(int idx) {
-            if(!hasRowStyle()) {
+        public String getRowStyle(int idx)
+        {
+            if(!hasRowStyle())
+            {
                 return null;
             }
             return _rowStyle[idx % _rowStyle.length];
         }
 
-        public String getColumnStyle(int idx) {
-            if(!hasColumnStyle()) {
+        public String getColumnStyle(int idx)
+        {
+            if(!hasColumnStyle())
+            {
                 return null;
             }
             //return _columnStyle[idx % _columnStyle.length];
@@ -283,11 +316,13 @@ public class HtmlTableRendererBase exten
             return null;   
         }
 
-        public boolean hasRowStyle() {
+        public boolean hasRowStyle()
+        {
             return _rowStyle.length > 0;
         }
 
-        public boolean hasColumnStyle() {
+        public boolean hasColumnStyle()
+        {
             return _columnStyle.length > 0;
         }
     }
@@ -300,14 +335,16 @@ public class HtmlTableRendererBase exten
      * This method is separated from the encodeChildren so that it can be overridden by
      * subclasses. One class that uses this functionality is autoUpdateDataTable.
      */
-     public void encodeInnerHtml(FacesContext facesContext, UIComponent component)throws IOException{
+     public void encodeInnerHtml(FacesContext facesContext, UIComponent component)throws IOException
+     {
 
         UIData uiData = (UIData) component;
         ResponseWriter writer = facesContext.getResponseWriter();
 
         int rowCount = uiData.getRowCount();
 
-        if (rowCount == 0) {
+        if (rowCount == 0)
+        {
             //nothing to render, to get valid xhtml we render an empty dummy row
             writer.startElement(HTML.TBODY_ELEM, uiData);
             writer.writeAttribute(HTML.ID_ATTR, component.getClientId(facesContext) + ":tbody_element", null);
@@ -343,8 +380,13 @@ public class HtmlTableRendererBase exten
         int newspaperColumns = getNewspaperColumns(component);
         int newspaperRows;
         if((last - first) % newspaperColumns == 0)
+        {
             newspaperRows = (last - first) / newspaperColumns;
-        else newspaperRows = ((last - first) / newspaperColumns) + 1;
+        }
+        else
+        {
+            newspaperRows = ((last - first) / newspaperColumns) + 1;
+        }
         boolean newspaperHorizontalOrientation = isNewspaperHorizontalOrientation(component);
         
         // get the row indizes for which a new TBODY element should be created
@@ -373,26 +415,36 @@ public class HtmlTableRendererBase exten
         {
             boolean rowStartRendered = false;
             // walk through the newspaper columns
-            for(int nc = 0; nc < newspaperColumns; nc++) {
+            for(int nc = 0; nc < newspaperColumns; nc++)
+            {
 
                 // the current row in the 'real' table
                 int currentRow;
                 if (newspaperHorizontalOrientation)
+                {
                     currentRow = nr * newspaperColumns + nc + first;
+                }
                 else
+                {
                     currentRow = nc * newspaperRows + nr + first;
+                }
                 
                 // if this row is not to be rendered
-                if(currentRow >= last) continue;
+                if(currentRow >= last)
+                {
+                    continue;
+                }
 
                 // bail if any row does not exist
                 uiData.setRowIndex(currentRow);
-                if(!uiData.isRowAvailable()) {
+                if(!uiData.isRowAvailable())
+                {
                     log.severe("Row is not available. Rowindex = " + currentRow);
                     break;
                 }
     
-                if (nc == 0) {
+                if (nc == 0)
+                {
                     // first column in table, start new row
                     beforeRow(facesContext, uiData);
 
@@ -427,19 +479,27 @@ public class HtmlTableRendererBase exten
                         boolean columnRendering = child instanceof UIColumn;
                         
                         if (columnRendering)
+                        {
                             beforeColumn(facesContext, uiData, j);
+                        }
                            
-                        encodeColumnChild(facesContext, writer, uiData, child, styles, nc * uiData.getChildCount() + j);                    
+                        encodeColumnChild(facesContext, writer, uiData, child, 
+                                styles, nc * uiData.getChildCount() + j);                    
                        
                         if (columnRendering)
+                        {
                             afterColumn(facesContext, uiData, j);
+                        }
                     }
                 }
 
                 if (hasNewspaperTableSpacer(uiData))
                 {
                     // draw the spacer facet
-                    if(nc < newspaperColumns - 1) renderSpacerCell(facesContext, writer, uiData);
+                    if(nc < newspaperColumns - 1)
+                    {
+                        renderSpacerCell(facesContext, writer, uiData);
+                    }
                 }
             }
             if (rowStartRendered)
@@ -539,9 +599,11 @@ public class HtmlTableRendererBase exten
         }
     }
 
-    protected void renderRowStyle(FacesContext facesContext, ResponseWriter writer, UIData uiData, Styles styles, int rowStyleIndex) throws IOException
+    protected void renderRowStyle(FacesContext facesContext, ResponseWriter writer, 
+            UIData uiData, Styles styles, int rowStyleIndex) throws IOException
     {
-        if(styles.hasRowStyle()) {
+        if(styles.hasRowStyle())
+        {
             String rowStyle = styles.getRowStyle(rowStyleIndex);
             writer.writeAttribute(HTML.CLASS_ATTR, rowStyle, null);
         }
@@ -643,7 +705,8 @@ public class HtmlTableRendererBase exten
      * @param header true if the header of the column child is rendered
      * @param columnIndex the index of the currenly rendered column
      */
-    protected void beforeColumnHeaderOrFooter(FacesContext facesContext, UIData uiData, boolean header, int columnIndex) throws IOException
+    protected void beforeColumnHeaderOrFooter(FacesContext facesContext, UIData uiData, boolean header,
+            int columnIndex) throws IOException
     {         
     }
     /**
@@ -654,7 +717,8 @@ public class HtmlTableRendererBase exten
      * @param header true if the header of the column child is rendered
      * @param columnIndex the index of the currenly rendered column
      */
-    protected void afterColumnHeaderOrFooter(FacesContext facesContext, UIData uiData, boolean header, int columnIndex) throws IOException
+    protected void afterColumnHeaderOrFooter(FacesContext facesContext, UIData uiData, boolean header,
+            int columnIndex) throws IOException
     {         
     }
 
@@ -737,9 +801,10 @@ public class HtmlTableRendererBase exten
     {
         int colspan = 0;
         boolean hasColumnFacet = false;
-        for (Iterator it = getChildren(component).iterator(); it.hasNext();)
+        int childCount = component.getChildCount();
+        for (int i = 0; i < childCount; i++)
         {
-            UIComponent uiComponent = (UIComponent) it.next();
+            UIComponent uiComponent = component.getChildren().get(i);
             if(uiComponent.isRendered())
             {
                 // a UIColumn has a span of 1, anything else has a span of 0
@@ -749,11 +814,12 @@ public class HtmlTableRendererBase exten
                 // the specified type.
                 if (!hasColumnFacet)
                 {
-                     hasColumnFacet = hasFacet(header, uiComponent);
+                    hasColumnFacet = hasFacet(header, uiComponent);
                 }
             }
         }
 
+
         UIComponent facet = header ? (UIComponent) component.getFacets().get(HEADER_FACET_NAME)
                 : (UIComponent) component.getFacets().get(FOOTER_FACET_NAME);
         if (facet != null || hasColumnFacet)
@@ -771,17 +837,25 @@ public class HtmlTableRendererBase exten
             {
                 String headerStyleClass = getHeaderClass(component);
                 if (facet != null)
+                {
                     renderTableHeaderRow(facesContext, writer, component, facet, headerStyleClass, colspan);
+                }
                 if (hasColumnFacet)
+                {
                     renderColumnHeaderRow(facesContext, writer, component, headerStyleClass);
+                }
             }
             else
             {
                 String footerStyleClass = getFooterClass(component);
                 if (hasColumnFacet)
+                {
                     renderColumnFooterRow(facesContext, writer, component, footerStyleClass);
+                }
                 if (facet != null)
+                {
                     renderTableFooterRow(facesContext, writer, component, facet, footerStyleClass, colspan);
+                }
             }
             if (elemName != null)
             {
@@ -843,7 +917,8 @@ public class HtmlTableRendererBase exten
     protected void renderTableHeaderRow(FacesContext facesContext, ResponseWriter writer, UIComponent component,
             UIComponent headerFacet, String headerStyleClass, int colspan) throws IOException
     {
-        renderTableHeaderOrFooterRow(facesContext, writer, component, headerFacet, headerStyleClass, determineHeaderCellTag(facesContext, component),
+        renderTableHeaderOrFooterRow(facesContext, writer, component, headerFacet, headerStyleClass, 
+                determineHeaderCellTag(facesContext, component),
                 colspan, true);
     }
 
@@ -896,8 +971,10 @@ public class HtmlTableRendererBase exten
         renderColumnHeaderOrFooterRow(facesContext, writer, component, footerStyleClass, false);
     }
 
-    protected void renderTableHeaderOrFooterRow(FacesContext facesContext, ResponseWriter writer, UIComponent component,
-            UIComponent facet, String styleClass, String colElementName, int colspan, boolean isHeader) throws IOException
+    protected void renderTableHeaderOrFooterRow(FacesContext facesContext, ResponseWriter writer, 
+            UIComponent component,
+            UIComponent facet, String styleClass, String colElementName, int colspan, boolean isHeader)
+            throws IOException
     {
         HtmlRendererUtils.writePrettyLineSeparator(facesContext);
         writer.startElement(HTML.TR_ELEM, component);
@@ -945,18 +1022,22 @@ public class HtmlTableRendererBase exten
         int newspaperColumns = getNewspaperColumns(component);
         for(int nc = 0; nc < newspaperColumns; nc++)
         {
-            for (Iterator it = getChildren(component).iterator(); it.hasNext();)
+            for (int i = 0, childCount = component.getChildCount(); i < childCount; i++)
             {
-                UIComponent uiComponent = (UIComponent) it.next();
+                UIComponent uiComponent = component.getChildren().get(i);
                 if (uiComponent.isRendered())
                 {
                     if (component instanceof UIData && uiComponent instanceof UIColumn)
-                        beforeColumnHeaderOrFooter(facesContext, (UIData)component, header, columnIndex);
+                    {
+                        beforeColumnHeaderOrFooter(facesContext, (UIData) component, header, columnIndex);
+                    }
                 
                     renderColumnChildHeaderOrFooterRow(facesContext, writer, uiComponent, styleClass, header);
                     
                     if (component instanceof UIData && uiComponent instanceof UIColumn)
-                        afterColumnHeaderOrFooter(facesContext, (UIData)component, header, columnIndex);
+                    {
+                        afterColumnHeaderOrFooter(facesContext, (UIData) component, header, columnIndex);
+                    }
                 }
                 columnIndex += 1;
             }
@@ -964,7 +1045,10 @@ public class HtmlTableRendererBase exten
             if (hasNewspaperTableSpacer(component))
             {
                 // draw the spacer facet
-                if(nc < newspaperColumns - 1) renderSpacerCell(facesContext, writer, component);
+                if(nc < newspaperColumns - 1)
+                {
+                    renderSpacerCell(facesContext, writer, component);
+                }
             }
         }
         writer.endElement(HTML.TR_ELEM);
@@ -973,9 +1057,14 @@ public class HtmlTableRendererBase exten
       /**
       * Renders a spacer between adjacent newspaper columns.
       */
-    protected void renderSpacerCell(FacesContext facesContext, ResponseWriter writer, UIComponent component) throws IOException {
+    protected void renderSpacerCell(FacesContext facesContext, ResponseWriter writer, UIComponent component)
+        throws IOException 
+    {
         UIComponent spacer = getNewspaperTableSpacer(component);
-        if(spacer == null) return;
+        if(spacer == null)
+        {
+            return;
+        }
          
          writer.startElement(HTML.TD_ELEM, component);
          //RendererUtils.renderChild(facesContext, spacer);
@@ -989,26 +1078,38 @@ public class HtmlTableRendererBase exten
         if (uiComponent instanceof UIColumn)
         {
             // allow column to override style class, new in JSF 1.2
-            if (uiComponent instanceof HtmlColumn) {
+            if (uiComponent instanceof HtmlColumn)
+            {
                 HtmlColumn column = (HtmlColumn)uiComponent;
                 if (isHeader && column.getHeaderClass()!=null)
+                {
                     styleClass = column.getHeaderClass();
+                }
                 else if (!isHeader && column.getFooterClass()!=null)
+                {
                     styleClass = column.getFooterClass();
-            }else{
+                }
+            }
+            else
+            {
                 //This code corrects MYFACES-1790, because HtmlColumnTag
                 //has as component type javax.faces.Column, so as side
                 //effect it not create HtmlColumn, it create UIColumn
                 //classes.
                 UIColumn column = (UIColumn) uiComponent;                
-                if (isHeader){
+                if (isHeader)
+                {
                     String headerClass = (String) column.getAttributes().get("headerClass");
-                    if (headerClass != null){
+                    if (headerClass != null)
+                    {
                         styleClass = (String) headerClass;
                     }
-                }else{
+                }
+                else
+                {
                     String footerClass = (String) column.getAttributes().get("footerClass");
-                    if (footerClass != null){
+                    if (footerClass != null)
+                    {
                         styleClass = (String) footerClass;
                     }
                 }
@@ -1146,7 +1247,8 @@ public class HtmlTableRendererBase exten
         }
         else
         {
-            return (String) component.getAttributes().get(org.apache.myfaces.shared.renderkit.JSFAttr.HEADER_CLASS_ATTR);
+            return (String) component.getAttributes().get(
+                    org.apache.myfaces.shared.renderkit.JSFAttr.HEADER_CLASS_ATTR);
         }
     }
 
@@ -1163,7 +1265,8 @@ public class HtmlTableRendererBase exten
         }
         else
         {
-            return (String) component.getAttributes().get(org.apache.myfaces.shared.renderkit.JSFAttr.FOOTER_CLASS_ATTR);
+            return (String) component.getAttributes().get(
+                    org.apache.myfaces.shared.renderkit.JSFAttr.FOOTER_CLASS_ATTR);
         }
     }
 

Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTextRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTextRendererBase.java?rev=1239799&r1=1239798&r2=1239799&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTextRendererBase.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTextRendererBase.java Thu Feb  2 20:00:42 2012
@@ -90,7 +90,10 @@ public class HtmlTextRendererBase
     {
         
         String text = org.apache.myfaces.shared.renderkit.RendererUtils.getStringValue(facesContext, component);
-        if (log.isLoggable(Level.FINE)) log.fine("renderOutput '" + text + "'");
+        if (log.isLoggable(Level.FINE))
+        {
+            log.fine("renderOutput '" + text + "'");
+        }
         boolean escape;
         if (component instanceof HtmlOutputText || component instanceof EscapeCapable)
         {
@@ -98,7 +101,8 @@ public class HtmlTextRendererBase
         }
         else
         {
-            escape = RendererUtils.getBooleanAttribute(component, org.apache.myfaces.shared.renderkit.JSFAttr.ESCAPE_ATTR,
+            escape = RendererUtils.getBooleanAttribute(component, 
+                    org.apache.myfaces.shared.renderkit.JSFAttr.ESCAPE_ATTR,
                                                        true); //default is to escape
         }
         if (text != null)
@@ -152,7 +156,10 @@ public class HtmlTextRendererBase
 
             if (escape)
             {
-                if (log.isLoggable(Level.FINE)) log.fine("renderOutputText writing '" + text + "'");
+                if (log.isLoggable(Level.FINE))
+                {
+                    log.fine("renderOutputText writing '" + text + "'");
+                }
                 writer.writeText(text, org.apache.myfaces.shared.renderkit.JSFAttr.VALUE_ATTR);
             }
             else
@@ -188,7 +195,10 @@ public class HtmlTextRendererBase
 
         String clientId = component.getClientId(facesContext);
         String value = org.apache.myfaces.shared.renderkit.RendererUtils.getStringValue(facesContext, component);
-        if (log.isLoggable(Level.FINE)) log.fine("renderInput '" + value + "'");
+        if (log.isLoggable(Level.FINE))
+        {
+            log.fine("renderInput '" + value + "'");
+        }
         writer.startElement(HTML.INPUT_ELEM, component);
         writer.writeAttribute(HTML.ID_ATTR, clientId, null);
         writer.writeAttribute(HTML.NAME_ATTR, clientId, null);
@@ -203,21 +213,52 @@ public class HtmlTextRendererBase
         }
 
         Map<String, List<ClientBehavior>> behaviors = null;
-        if (component instanceof ClientBehaviorHolder && JavascriptUtils.isJavascriptAllowed(facesContext.getExternalContext()))
+        if (component instanceof ClientBehaviorHolder && JavascriptUtils.isJavascriptAllowed(
+                facesContext.getExternalContext()))
         {
             behaviors = ((ClientBehaviorHolder) component).getClientBehaviors();
             
-            HtmlRendererUtils.renderBehaviorizedOnchangeEventHandler(facesContext, writer, component, behaviors);
-            HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, component, behaviors);
-            HtmlRendererUtils.renderBehaviorizedFieldEventHandlersWithoutOnchange(facesContext, writer, component, behaviors);
+            long commonPropertiesMarked = 0L;
+            if (isCommonPropertiesOptimizationEnabled(facesContext))
+            {
+                commonPropertiesMarked = CommonPropertyUtils.getCommonPropertiesMarked(component);
+            }
+            if (behaviors.isEmpty() && isCommonPropertiesOptimizationEnabled(facesContext))
+            {
+                CommonPropertyUtils.renderChangeEventProperty(writer, 
+                        commonPropertiesMarked, component);
+                CommonPropertyUtils.renderEventProperties(writer, 
+                        commonPropertiesMarked, component);
+                CommonPropertyUtils.renderFieldEventPropertiesWithoutOnchange(writer, 
+                        commonPropertiesMarked, component);
+            }
+            else
+            {
+                HtmlRendererUtils.renderBehaviorizedOnchangeEventHandler(facesContext, writer, component, behaviors);
+                if (isCommonEventsOptimizationEnabled(facesContext))
+                {
+                    Long commonEventsMarked = CommonEventUtils.getCommonEventsMarked(component);
+                    CommonEventUtils.renderBehaviorizedEventHandlers(facesContext, writer, 
+                            commonPropertiesMarked, commonEventsMarked, component, behaviors);
+                    CommonEventUtils.renderBehaviorizedFieldEventHandlersWithoutOnchange(
+                        facesContext, writer, commonPropertiesMarked, commonEventsMarked, component, behaviors);
+                }
+                else
+                {
+                    HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, component, behaviors);
+                    HtmlRendererUtils.renderBehaviorizedFieldEventHandlersWithoutOnchange(
+                            facesContext, writer, component, behaviors);
+                }
+            }
             if (isCommonPropertiesOptimizationEnabled(facesContext))
             {
                 CommonPropertyUtils.renderInputPassthroughPropertiesWithoutDisabledAndEvents(writer, 
-                        CommonPropertyUtils.getCommonPropertiesMarked(component), component);
+                        commonPropertiesMarked, component);
             }
             else
             {
-                HtmlRendererUtils.renderHTMLAttributes(writer, component, HTML.INPUT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED_AND_EVENTS);
+                HtmlRendererUtils.renderHTMLAttributes(writer, component, 
+                        HTML.INPUT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED_AND_EVENTS);
             }
         }
         else
@@ -229,7 +270,8 @@ public class HtmlTextRendererBase
             }
             else
             {
-                HtmlRendererUtils.renderHTMLAttributes(writer, component, HTML.INPUT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED);
+                HtmlRendererUtils.renderHTMLAttributes(writer, component, 
+                        HTML.INPUT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED);
             }
         }
 
@@ -259,7 +301,8 @@ public class HtmlTextRendererBase
             return ((HtmlInputText)component).isDisabled();
         }
 
-        return org.apache.myfaces.shared.renderkit.RendererUtils.getBooleanAttribute(component, HTML.DISABLED_ATTR, false);
+        return org.apache.myfaces.shared.renderkit.RendererUtils.getBooleanAttribute(component, 
+                HTML.DISABLED_ATTR, false);
         
     }
 
@@ -305,7 +348,8 @@ public class HtmlTextRendererBase
     }
 
 
-    public Object getConvertedValue(FacesContext facesContext, UIComponent component, Object submittedValue) throws ConverterException
+    public Object getConvertedValue(FacesContext facesContext, UIComponent component, Object submittedValue)
+        throws ConverterException
     {
         org.apache.myfaces.shared.renderkit.RendererUtils.checkParamValidity(facesContext, component, UIOutput.class);
         return RendererUtils.getConvertedUIOutputValue(facesContext,
@@ -357,7 +401,9 @@ public class HtmlTextRendererBase
             if (escape)
             {
                 if (log.isLoggable(Level.FINE))
+                {
                     log.fine("renderOutputText writing '" + text + "'");
+                }
                 writer.writeText(text,
                         org.apache.myfaces.shared.renderkit.JSFAttr.VALUE_ATTR);
             }

Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTextareaRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTextareaRendererBase.java?rev=1239799&r1=1239798&r2=1239799&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTextareaRendererBase.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTextareaRendererBase.java Thu Feb  2 20:00:42 2012
@@ -96,10 +96,38 @@ public class HtmlTextareaRendererBase
                 HtmlRendererUtils.writeIdIfNecessary(writer, uiComponent, facesContext);
                 writer.writeAttribute(HTML.NAME_ATTR, uiComponent.getClientId(facesContext), null);
             }
-            HtmlRendererUtils.renderBehaviorizedOnchangeEventHandler(facesContext, writer, uiComponent, behaviors);
-            HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, uiComponent, behaviors);
-            HtmlRendererUtils.renderBehaviorizedFieldEventHandlersWithoutOnchange(
-                    facesContext, writer, uiComponent, behaviors);
+            long commonPropertiesMarked = 0L;
+            if (isCommonPropertiesOptimizationEnabled(facesContext))
+            {
+                commonPropertiesMarked = CommonPropertyUtils.getCommonPropertiesMarked(uiComponent);
+            }
+            if (behaviors.isEmpty() && isCommonPropertiesOptimizationEnabled(facesContext))
+            {
+                CommonPropertyUtils.renderChangeEventProperty(writer, 
+                        commonPropertiesMarked, uiComponent);
+                CommonPropertyUtils.renderEventProperties(writer, 
+                        commonPropertiesMarked, uiComponent);
+                CommonPropertyUtils.renderFieldEventPropertiesWithoutOnchange(writer, 
+                        commonPropertiesMarked, uiComponent);
+            }
+            else
+            {
+                HtmlRendererUtils.renderBehaviorizedOnchangeEventHandler(facesContext, writer, uiComponent, behaviors);
+                if (isCommonEventsOptimizationEnabled(facesContext))
+                {
+                    Long commonEventsMarked = CommonEventUtils.getCommonEventsMarked(uiComponent);
+                    CommonEventUtils.renderBehaviorizedEventHandlers(facesContext, writer, 
+                            commonPropertiesMarked, commonEventsMarked, uiComponent, behaviors);
+                    CommonEventUtils.renderBehaviorizedFieldEventHandlersWithoutOnchange(
+                        facesContext, writer, commonPropertiesMarked, commonEventsMarked, uiComponent, behaviors);
+                }
+                else
+                {
+                    HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, uiComponent, behaviors);
+                    HtmlRendererUtils.renderBehaviorizedFieldEventHandlersWithoutOnchange(
+                            facesContext, writer, uiComponent, behaviors);
+                }
+            }
             if (isCommonPropertiesOptimizationEnabled(facesContext))
             {
                 CommonPropertyUtils.renderCommonFieldPassthroughPropertiesWithoutDisabledAndEvents(writer, 

Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/JavascriptContext.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/JavascriptContext.java?rev=1239799&r1=1239798&r2=1239799&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/JavascriptContext.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/JavascriptContext.java Thu Feb  2 20:00:42 2012
@@ -30,7 +30,7 @@ public class JavascriptContext
     private static final char TABULATOR = '\t';
 
     private long currentIndentationLevel;
-    private StringBuffer buffer = new StringBuffer();
+    private StringBuilder buffer = new StringBuilder();
     private boolean prettyPrint = false;
     /**
      * automatic formatting will render
@@ -50,7 +50,7 @@ public class JavascriptContext
         this.prettyPrint = prettyPrint;
     }
 
-    public JavascriptContext(StringBuffer buf, boolean prettyPrint)
+    public JavascriptContext(StringBuilder buf, boolean prettyPrint)
     {
         this.prettyPrint = prettyPrint;
         this.buffer = buf;

Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/HTMLEncoder.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/HTMLEncoder.java?rev=1239799&r1=1239798&r2=1239799&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/HTMLEncoder.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/HTMLEncoder.java Thu Feb  2 20:00:42 2012
@@ -156,6 +156,144 @@ public abstract class HTMLEncoder
             return sb.toString();
         }
     }
+    
+    /**
+     * Variant of {@link #encode} where encodeNewline is false and encodeNbsp is true.
+     */
+    public static void encode (Writer writer, String string) throws IOException
+    {
+        encode(writer, string, false, true);
+    }
+
+    /**
+     * Variant of {@link #encode} where encodeNbsp is true.
+     */
+    public static void encode (Writer writer, String string, boolean encodeNewline) throws IOException
+    {
+        encode(writer, string, encodeNewline, true);
+    }
+
+    /**
+     * Variant of {@link #encode} where encodeNbsp and encodeNonLatin are true 
+     */
+    public static void encode (Writer writer, String string, 
+            boolean encodeNewline, boolean encodeSubsequentBlanksToNbsp) throws IOException
+    {
+        encode(writer, string, encodeNewline, encodeSubsequentBlanksToNbsp, true);
+    }
+    
+    public static void encode (Writer writer, String string,
+                                 boolean encodeNewline,
+                                 boolean encodeSubsequentBlanksToNbsp,
+                                 boolean encodeNonLatin) throws IOException
+    {
+        if (string == null)
+        {
+            return;
+        }
+
+        int start = 0;
+        String app;
+        char c;
+        for (int i = 0; i < string.length (); ++i)
+        {
+            app = null;
+            c = string.charAt(i);
+            
+            // All characters before letters
+            if ((int)c < 0x41)
+            {
+                switch (c)
+                {
+                    case '"': app = "&quot;"; break;    //"
+                    case '&': app = "&amp;"; break;     //&
+                    case '<': app = "&lt;"; break;      //<
+                    case '>': app = "&gt;"; break;      //>
+                    case ' ':
+                        if (encodeSubsequentBlanksToNbsp &&
+                                (i == 0 || (i - 1 >= 0 && string.charAt(i - 1) == ' ')))
+                        {
+                            //Space at beginning or after another space
+                            app = "&#160;";
+                        }
+                        break;
+                    case '\n':
+                        if (encodeNewline)
+                        {
+                            app = "<br/>";
+                        }
+                        break;
+                    default:
+                        break;
+                }
+            }
+            else if (encodeNonLatin && (int)c > 0x80)
+            {
+                 switch(c)
+                 {
+                    //german umlauts
+                    case '\u00E4' : app = "&auml;";  break;
+                    case '\u00C4' : app = "&Auml;";  break;
+                    case '\u00F6' : app = "&ouml;";  break;
+                    case '\u00D6' : app = "&Ouml;";  break;
+                    case '\u00FC' : app = "&uuml;";  break;
+                    case '\u00DC' : app = "&Uuml;";  break;
+                    case '\u00DF' : app = "&szlig;"; break;
+
+                    //misc
+                    //case 0x80: app = "&euro;"; break;  sometimes euro symbol is ascii 128, should we suport it?
+                    case '\u20AC': app = "&euro;";  break;
+                    case '\u00AB': app = "&laquo;"; break;
+                    case '\u00BB': app = "&raquo;"; break;
+                    case '\u00A0': app = "&#160;"; break;
+
+                    default :
+                        //encode all non basic latin characters
+                        app = "&#" + ((int)c) + ";";
+                    break;
+                }
+            }
+            if (app != null)
+            {
+                //if (sb == null)
+                //{
+                //    sb = new StringBuilder(string.substring(0, i));
+                //}
+                //sb.append(app);
+                if (start < i)
+                {
+                    writer.write(string, start, i-start);
+                }
+                start = i+1;
+                writer.write(app);
+            }
+            //else
+            //{
+            //    if (sb != null)
+            //    {
+            //        sb.append(c);
+            //    }
+            //}
+        }
+
+        //if (sb == null)
+        //{
+        //    return string;
+        //}
+        //else
+        //{
+        //    return sb.toString();
+        //}
+        if (start == 0)
+        {
+            writer.write(string);
+        }
+        else if (start < string.length())
+        {
+            writer.write(string,start,string.length()-start);
+        }
+    }
+
 
     /**
      * Variant of {@link #encode} where encodeNewline is false and encodeNbsp is true.
@@ -203,9 +341,10 @@ public abstract class HTMLEncoder
         offset = Math.max(0, offset);
         int realLength = Math.min(length, string.length - offset);
 
-        StringBuilder sb = null;    //create later on demand
+        //StringBuilder sb = null;    //create later on demand
         String app;
         char c;
+        int start = offset;
         
         for (int i = offset; i < offset + realLength; ++i)
         {
@@ -267,29 +406,44 @@ public abstract class HTMLEncoder
             }
             if (app != null)
             {
-                if (sb == null)
+                //if (sb == null)
+                //{
+                //    sb = new StringBuilder(realLength*2);
+                //    sb.append(string, offset, i - offset);
+                //}
+                //sb.append(app);
+                if (start < i)
                 {
-                    sb = new StringBuilder(realLength*2);
-                    sb.append(string, offset, i - offset);
+                    writer.write(string, start, i-start);
                 }
-                sb.append(app);
+                start = i+1;
+                writer.write(app);
             }
+            /*
             else
             {
                 if (sb != null)
                 {
                     sb.append(c);
                 }
-            }
+            }*/
         }
 
-        if (sb == null)
+        //if (sb == null)
+        //{
+        //    writer.write(string, offset, realLength);
+        //}
+        //else
+        //{
+        //    writer.write(sb.toString());
+        //}
+        if (start == offset)
         {
             writer.write(string, offset, realLength);
         }
-        else
+        else if (start < offset+realLength)
         {
-            writer.write(sb.toString());
+            writer.write(string,start,offset+realLength-start);
         }
     }
     
@@ -546,7 +700,7 @@ public abstract class HTMLEncoder
     private static String percentEncodeNonUsAsciiCharacter(char c, String characterEncoding)
     {
         ByteArrayOutputStream baos = new ByteArrayOutputStream(10);
-        StringBuffer builder = new StringBuffer();
+        StringBuilder builder = new StringBuilder();
         try
         {
             OutputStreamWriter writer = new OutputStreamWriter(baos,characterEncoding);
@@ -687,4 +841,481 @@ public abstract class HTMLEncoder
             return sb.toString();
         }
     }
+
+    /**
+     * Encode an URI, escaping or percent-encoding all required characters and
+     * following the rules mentioned on RFC 3986.  
+     * 
+     * @param string
+     * @param encodeNonLatin
+     * @return
+     * @throws IOException
+     */
+    public static void encodeURIAtributte(Writer writer, final String string, final String characterEncoding)
+        throws IOException
+    {
+        //StringBuilder sb = null;    //create later on demand
+        int start = 0;
+        String app;
+        char c;
+        boolean endLoop = false;
+        for (int i = 0; i < string.length (); ++i)
+        {
+            app = null;
+            c = string.charAt(i);
+            
+            // This are the guidelines to be taken into account by this algorithm to encode:
+            
+            // RFC 2396 Section 2.4.3 Excluded US-ASCII Characters
+            //
+            // control     = <US-ASCII coded characters 00-1F and 7F hexadecimal>
+            // space       = <US-ASCII coded character 20 hexadecimal>
+            // delims      = "<" | ">" | "#" | "%" | <">
+            //               %3C   %3E   %23   %25   %22
+            // unwise      = "{" | "}" | "|" | "\" | "^" | "[" | "]" | "`"
+            //               %7D   %7B   %7C   %5C   %5E   %5B   %5D   %60
+            //
+            // ".... Data corresponding to excluded characters must be escaped in order to
+            // be properly represented within a URI....."
+            
+            // RFC 3986 Section 3.  Syntax Components
+            //
+            // "... The generic URI syntax consists of a hierarchical sequence of
+            // components referred to as the scheme, authority, path, query, and
+            // fragment.
+            //
+            //   URI         = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
+            //
+            //   hier-part   = "//" authority path-abempty
+            //               / path-absolute
+            //               / path-rootless
+            //               / path-empty
+            // ...."
+            
+            // RFC 3986 Section 2.2:
+            // Reserved characters (should not be percent-encoded)
+            // reserved    = gen-delims / sub-delims
+            // gen-delims  = ":" / "/" / "?" / "#" / "[" / "]" / "@"
+            //               %3A   %2F   %3F   %23   %5B   %5D   %40
+            // sub-delims  = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
+            //               %21   %24   %26   %27   %28   %29   %2A   %2B   %2C   %3B   %3D
+            
+            // Note than chars "[" and "]" are mentioned as they should be escaped on RFC 2396,
+            // but on the part D. Changes from RFC 2396 says about this chars (used on IPv6) 
+            // "...those rules were redefined to directly specify the characters allowed...."
+            // There is also other characters moved from excluded list to reserved:
+            // "[" / "]" / "#"  
+            
+            // RFC 3986 Section 2.3:
+            // "... for consistency, percent-encoded octets in the ranges of ALPHA
+            // (%41-%5A and %61-%7A), DIGIT (%30-%39), hyphen (%2D), period (%2E),
+            // underscore (%5F), or tilde (%7E) should not be created by URI
+            // producers...."
+            
+            // RFC 3986 Section  3.2.2.  Host
+
+            // host = IP-literal / IPv4address / reg-name
+
+            // The reg-name syntax allows percent-encoded octets in order to
+            // represent non-ASCII registered names in a uniform way that is
+            // independent of the underlying name resolution technology.  Non-ASCII
+            // characters must first be encoded according to UTF-8 [STD63], and then
+            // each octet of the corresponding UTF-8 sequence must be percent-
+            // encoded to be represented as URI characters.  URI producing
+            // applications must not use percent-encoding in host unless it is used
+            // to represent a UTF-8 character sequence.
+            
+            // RFC 3986 Section 3.4 Query 
+            //         query       = *( pchar / "/" / "?" )
+            //
+            // "...  However, as query components are often used to carry identifying information 
+            // in the form of "key=value" pairs and one frequently used value is a reference to
+            // another URI, it is sometimes better for usability to avoid percent-encoding those characters....."
+            //
+            // RFC 3986 Section 2.5 Identifying Data (Apply to query section)
+            //
+            // When a new URI scheme defines a component that represents textual
+            // data consisting of characters from the Universal Character Set [UCS],
+            // the data should first be encoded as octets according to the UTF-8
+            // character encoding [STD63]; then only those octets that do not
+            // correspond to characters in the unreserved set should be percent-
+            // encoded.  For example, the character A would be represented as "A",
+            // the character LATIN CAPITAL LETTER A WITH GRAVE would be represented
+            // as "%C3%80", and the character KATAKANA LETTER A would be represented
+            // as "%E3%82%A2".
+            //
+            // RFC 3986 Section 3.5 Fragment
+            //         fragment    = *( pchar / "/" / "?" )
+            //
+            // Note that follows the same as query
+            
+            // Based on the extracts the strategy to apply on this method is:
+            // 
+            // On scheme ":" hier-part
+            //
+            // Escape or percent encode chars inside :
+            // 
+            // - From %00 to %20, 
+            // - <"> %22, "%" %25 (If there is encode of "%", there is a risk of 
+            //                     duplicate encoding, encode it when we are sure 
+            //                     that there are not encoded twice)
+            // - "<" %3C, ">" %3E
+            // - "\" %5C, "^" %5E, "`" %60 
+            // - "{" %7B, "|" %7C, "}" %7D
+            // - From %7F ad infinitum (characters from %100 to infinitum should not be used in this
+            //   part of an URI, but it is preferred to encode it that omit it).
+            //
+            // The remaining characters must not be encoded
+            //
+            // Characters after ? or # should be percent encoding but only the necessary ones:
+            //
+            // - From %00 to %20 (' ' %20 could encode as +, but %20 also works, so we keep %20)
+            // - <"> %22, "%" %25 (If there is encode of "%", there is a risk of 
+            //                     duplicate encoding, encode it when we are sure 
+            //                     that there are not encoded twice)
+            // - "<" %3C, ">" %3E,
+            // - "\" %5C, "^" %5E, "`" %60 
+            // - "{" %7B, "|" %7C, "}" %7D
+            // - From %7F ad infinitum (each character as many bytes as necessary but take into account
+            //   that a single char should contain 2,3 or more bytes!. This data should be encoded 
+            //   translating from the document character encoding to percent encoding, because this values
+            //   could be retrieved from httpRequest.getParameter() and it uses the current character encoding
+            //   for decode values)
+            //
+            // "&" should be encoded as "&amp;" because this link is inside an html page, and 
+            // put only & is invalid in this context.
+
+            if (   (c <= (char)0x20) || (c >= (char)0x7F) || 
+                    c == '"' || c == '<' ||
+                    c == '>' || c == '\\' || c == '^' || c == '`' ||
+                    c == '{' || c == '|' || c == '}')
+            {
+                // The percent encoding on this part should be done using UTF-8 charset
+                // as RFC 3986 Section 3.2.2 says.
+                // Also there is a reference on 
+                // http://www.w3.org/TR/html40/appendix/notes.html#non-ascii-chars
+                // that recommend use of UTF-8 instead the document character encoding.
+                // Jetty set by default UTF-8 (see http://jira.codehaus.org/browse/JETTY-113)
+                //app = percentEncode(c, "UTF-8");
+                if (start < i)
+                {
+                    writer.write(string, start, i-start);
+                }
+                start = i+1;
+                percentEncode(writer, c, "UTF-8");
+            }
+            else if (c == '%')
+            {
+                if (i + 2 < string.length())
+                {
+                    char c1 = string.charAt(i+1);
+                    char c2 = string.charAt(i+2);
+                    if ((( c1 >= '0' && c1 <='9') || (c1 >='A' && c1 <='Z')) &&
+                        (( c2 >= '0' && c2 <='9') || (c2 >='A' && c2 <='Z')))
+                    {
+                        // do not percent encode, because it could be already encoded
+                        // and we don't want encode it twice
+                    }
+                    else
+                    {
+                        //app = percentEncode(c, UTF8);
+                        if (start < i)
+                        {
+                            writer.write(string, start, i-start);
+                        }
+                        start = i+1;
+                        percentEncode(writer, c, UTF8);
+                    }
+                }
+                else
+                {
+                    //app = percentEncode(c, UTF8);
+                    if (start < i)
+                    {
+                        writer.write(string, start, i-start);
+                    }
+                    start = i+1;
+                    percentEncode(writer, c, UTF8);
+                }
+            }
+            else if (c == '?' || c == '#')
+            {
+                if (i+1 < string.length())
+                {
+                    // The remaining part of the URI are data that should be encoded
+                    // using the document character encoding.
+                    //app = c + encodeURIQuery(string.substring(i+1), characterEncoding);
+                    if (start < i)
+                    {
+                        writer.write(string, start, i-start);
+                    }
+                    start = i+1;
+                    writer.write(c);
+                    //encodeURIQuery(writer, string.substring(i+1), characterEncoding);
+                    encodeURIQuery(writer, string, i+1, characterEncoding);
+                    endLoop = true;
+                }
+            }
+            else
+            {
+                //No encoding, just do nothing, char will be added later.
+            }
+                        
+            if (app != null)
+            {
+                //if (sb == null)
+                //{
+                //    sb = new StringBuilder(string.substring(0, i));
+                //}
+                //sb.append(app);
+                if (start < i)
+                {
+                    writer.write(string, start, i-start);
+                }
+                start = i+1;
+                writer.write(app);
+            }
+            //else
+            //{
+            //    if (sb != null)
+            //    {
+            //        sb.append(c);
+            //    }
+            //}
+            if (endLoop)
+            {
+                start = string.length();
+                break;
+            }
+        }
+        //if (sb == null)
+        //{
+        //    return string;
+        //}
+        //else
+        //{
+        //    return sb.toString();
+        //}
+        if (start == 0)
+        {
+            writer.write(string);
+        }
+        else if (start < string.length())
+        {
+            writer.write(string,start,string.length()-start);
+        }
+    }
+
+    /**
+     * Encode a unicode char value in percentEncode, decoding its bytes using a specified 
+     * characterEncoding.
+     * 
+     * @param c
+     * @param characterEncoding
+     * @return
+     */
+    private static void percentEncode(Writer writer, char c, String characterEncoding) throws IOException
+    {
+        String app = null;
+        if (c > (char)((short)0x007F))
+        {
+            //percent encode in the proper encoding to be consistent
+            //app = percentEncodeNonUsAsciiCharacter(writer c, characterEncoding);
+            percentEncodeNonUsAsciiCharacter(writer, c, characterEncoding);
+        }
+        else
+        {
+            //percent encode US-ASCII char (0x00-0x7F range)
+            //app = "%" + HEX_CHARSET.charAt( ((c >> 0x4) % 0x10)) +HEX_CHARSET.charAt(c % 0x10);
+            writer.write('%');
+            writer.write(HEX_CHARSET.charAt( ((c >> 0x4) % 0x10)));
+            writer.write(HEX_CHARSET.charAt(c % 0x10));
+        }
+        //return app;
+    }
+    
+    private static void percentEncodeNonUsAsciiCharacter(Writer currentWriter, char c, String characterEncoding) 
+        throws IOException
+    {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream(10);
+        StringBuilder builder = new StringBuilder();
+        try
+        {
+            OutputStreamWriter writer = new OutputStreamWriter(baos,characterEncoding);
+            writer.write(c);
+            writer.flush();
+        }
+        catch(IOException e)
+        {
+            baos.reset();
+            return;
+        }
+        
+        byte [] byteArray =  baos.toByteArray();
+        for (int i=0; i < byteArray.length; i++)
+        {
+            //builder.append('%');
+            //builder.append(HEX_CHARSET.charAt( (( ((short) byteArray[i] & 0xFF ) >> 0x4) % 0x10)) );
+            //builder.append(HEX_CHARSET.charAt( ((short) byteArray[i] & 0xFF ) % 0x10));
+            currentWriter.write('%');
+            currentWriter.write(HEX_CHARSET.charAt( (( ((short) byteArray[i] & 0xFF ) >> 0x4) % 0x10)) );
+            currentWriter.write(HEX_CHARSET.charAt( ((short) byteArray[i] & 0xFF ) % 0x10));
+        }
+        
+        //return builder.toString();
+    }
+    
+    /**
+     * Encode the query part using the document charset encoding provided.
+     * 
+     * 
+     * @param string
+     * @param characterEncoding
+     * @return
+     */
+    private static void encodeURIQuery(Writer writer, final String string, int offset, final String characterEncoding)
+            throws IOException
+    {
+        //StringBuilder sb = null;    //create later on demand
+        int start = offset;
+        int realLength = string.length()-offset;
+        String app;
+        char c;
+        //boolean endLoop = false;
+        for (int i = offset; i < offset+realLength; ++i)
+        {
+            app = null;
+            c = string.charAt(i);
+            
+            // - From %00 to %20 (' ' %20 could encode as +, but %20 also works, so we keep %20)
+            // - <"> %22 (If there is encode of "%", there is a risk of duplicate encoding, so 
+            //            we make easier and omit this one)
+            // - "<" %3C, ">" %3E,
+            // - "\" %5C, "^" %5E, "`" %60 
+            // - "{" %7B, "|" %7C, "}" %7D
+            // - From %7F ad infinitum (each character as many bytes as necessary but take into account
+            //   that a single char should contain 2,3 or more bytes!. This data should be encoded 
+            //   translating from the document character encoding to percent encoding)
+            //
+            // "&" should be encoded as "&amp;" because this link is inside an html page, and 
+            // put & is invalid in this context   
+            
+            if (   (c <= (char)0x20) || (c >= (char)0x7F) || 
+                    c == '"' || c == '<' ||
+                    c == '>' || c == '\\' || c == '^' || c == '`' ||
+                    c == '{' || c == '|' || c == '}')
+            {
+                // The percent encoding on this part should be done using UTF-8 charset
+                // as RFC 3986 Section 3.2.2 says
+                //app = percentEncode(c, characterEncoding);
+                if (start < i)
+                {
+                    writer.write(string, start, i-start);
+                }
+                start = i+1;
+                percentEncode(writer, c, characterEncoding);
+            }
+            else if (c == '%')
+            {
+                if (i + 2 < string.length())
+                {
+                    char c1 = string.charAt(i+1);
+                    char c2 = string.charAt(i+2);
+                    if ((( c1 >= '0' && c1 <='9') || (c1 >='A' && c1 <='Z')) &&
+                        (( c2 >= '0' && c2 <='9') || (c2 >='A' && c2 <='Z')))
+                    {
+                        // do not percent encode, because it could be already encoded
+                    }
+                    else
+                    {
+                        //app = percentEncode(c, characterEncoding);
+                        if (start < i)
+                        {
+                            writer.write(string, start, i-start);
+                        }
+                        start = i+1;
+                        percentEncode(writer, c, characterEncoding);
+                    }
+                }
+                else
+                {
+                    //app = percentEncode(c, characterEncoding);
+                    if (start < i)
+                    {
+                        writer.write(string, start, i-start);
+                    }
+                    start = i+1;
+                    percentEncode(writer, c, characterEncoding);
+                }
+            }
+            else if (c == '&')
+            {
+                if (i+4 < string.length() )
+                {
+                    if ('a' == string.charAt(i+1) &&
+                        'm' == string.charAt(i+2) &&
+                        'p' == string.charAt(i+3) &&
+                        ';' == string.charAt(i+4))
+                    {
+                        //Skip
+                    }
+                    else
+                    {
+                        app = "&amp;";
+                    }
+                }
+                else
+                {
+                    app = "&amp;";
+                }
+            }
+            else
+            {
+                //No encoding, just do nothing, char will be added later.
+            }
+                        
+            if (app != null)
+            {
+                //if (sb == null)
+                //{
+                //    sb = new StringBuilder(string.substring(0, i));
+                //}
+                //sb.append(app);
+                if (start < i)
+                {
+                    writer.write(string, start, i-start);
+                }
+                start = i+1;
+                writer.write(app);
+            }
+            //else
+            //{
+            //    if (sb != null)
+            //    {
+            //        sb.append(c);
+            //    }
+            //}
+            //if (endLoop)
+            //{
+            //    break;
+            //}
+        }
+        
+        //if (sb == null)
+        //{
+        //    return string;
+        //}
+        //else
+        //{
+        //    return sb.toString();
+        //}
+        if (start == offset)
+        {
+            writer.write(string, offset, realLength);
+        }
+        else if (start < offset+realLength)
+        {
+            writer.write(string,start,offset+realLength-start);
+        }
+    }
 }

Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/JavascriptUtils.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/JavascriptUtils.java?rev=1239799&r1=1239798&r2=1239799&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/JavascriptUtils.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/JavascriptUtils.java Thu Feb  2 20:00:42 2012
@@ -125,7 +125,7 @@ public final class JavascriptUtils
             return s + "_";
         }
 
-        StringBuffer buf = null;
+        StringBuilder buf = null;
         for (int i = 0, len = s.length(); i < len; i++)
         {
             char c = s.charAt(i);
@@ -133,13 +133,16 @@ public final class JavascriptUtils
             if (Character.isLetterOrDigit(c))
             {
                 // allowed char
-                if (buf != null) buf.append(c);
+                if (buf != null)
+                {
+                    buf.append(c);
+                }
             }
             else
             {
                 if (buf == null)
                 {
-                    buf = new StringBuffer(s.length() + 10);
+                    buf = new StringBuilder(s.length() + 10);
                     buf.append(s.substring(0, i));
                 }
 
@@ -197,7 +200,7 @@ public final class JavascriptUtils
         {
             return "";
         }
-        StringBuffer sb = null;    //create later on demand
+        StringBuilder sb = null;    //create later on demand
         String app;
         char c;
         for (int i = 0; i < string.length (); ++i)
@@ -211,15 +214,18 @@ public final class JavascriptUtils
                 case '\'' : app = "\\'";  break;
                 case '\n' : app = "\\n";  break;
                 case '\r' : app = "\\r";  break;
+                default:
             }
             if (app != null)
             {
                 if (sb == null)
                 {
-                    sb = new StringBuffer(string.substring(0, i));
+                    sb = new StringBuilder(string.substring(0, i));
                 }
                 sb.append(app);
-            } else {
+            }
+            else
+            {
                 if (sb != null)
                 {
                     sb.append(c);

Added: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/SharedStringBuilder.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/SharedStringBuilder.java?rev=1239799&view=auto
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/SharedStringBuilder.java (added)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/SharedStringBuilder.java Thu Feb  2 20:00:42 2012
@@ -0,0 +1,77 @@
+/*
+ * 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.util;
+
+import java.util.Map;
+import javax.faces.context.FacesContext;
+
+/**
+ *
+ * @author lu4242
+ */
+public class SharedStringBuilder
+{
+    public static StringBuilder get(String stringBuilderKey)
+    {
+        return get(FacesContext.getCurrentInstance(), stringBuilderKey);
+    }
+
+    // TODO checkstyle complains; does this have to lead with __ ?
+    public static StringBuilder get(FacesContext facesContext, String stringBuilderKey)
+    {
+        Map<Object, Object> attributes = facesContext.getAttributes();
+
+        StringBuilder sb = (StringBuilder) attributes.get(stringBuilderKey);
+
+        if (sb == null)
+        {
+            sb = new StringBuilder();
+            attributes.put(stringBuilderKey, sb);
+        }
+        else
+        {
+
+            // clear out the stringBuilder by setting the length to 0
+            sb.setLength(0);
+        }
+
+        return sb;
+    }
+    
+    public static StringBuilder get(FacesContext facesContext, String stringBuilderKey, int initialSize)
+    {
+        Map<Object, Object> attributes = facesContext.getAttributes();
+
+        StringBuilder sb = (StringBuilder) attributes.get(stringBuilderKey);
+
+        if (sb == null)
+        {
+            sb = new StringBuilder(initialSize);
+            attributes.put(stringBuilderKey, sb);
+        }
+        else
+        {
+
+            // clear out the stringBuilder by setting the length to 0
+            sb.setLength(0);
+        }
+
+        return sb;
+    }
+}

Propchange: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/SharedStringBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/UnicodeEncoder.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/UnicodeEncoder.java?rev=1239799&r1=1239798&r2=1239799&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/UnicodeEncoder.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/UnicodeEncoder.java Thu Feb  2 20:00:42 2012
@@ -18,6 +18,9 @@
  */
 package org.apache.myfaces.shared.renderkit.html.util;
 
+import java.io.IOException;
+import java.io.Writer;
+
 /**
  * Converts characters outside of latin-1 set in a string to numeric character references.
  * 
@@ -60,6 +63,112 @@ public abstract class UnicodeEncoder
 
         return sb != null ? sb.toString() : string;
     }
+    
+    public static void encode (Writer writer, String string) throws IOException
+    {
+        if (string == null)
+        {
+            return;
+        }
+
+        int start = 0;
+        char c;
+        for (int i = 0; i < string.length (); ++i)
+        {
+            c = string.charAt(i);
+            if (((int)c) >= 0x80)
+            {
+                if (start < i)
+                {
+                    writer.write(string, start, i-start);
+                }
+                start = i+1;
+                //encode all non basic latin characters
+                writer.write("&#");
+                writer.write(Integer.toString((int)c));
+                writer.write(";");
+            }
+        }
+
+        if (start == 0)
+        {
+            writer.write(string);
+        }
+        else if (start < string.length())
+        {
+            writer.write(string,start,string.length()-start);
+        }
+    }
+
+    public static void encode (Writer writer, char[] cbuf, int off, int len) throws IOException
+    {
+        if (cbuf == null)
+        {
+            return;
+        }
+
+        int start = off;
+        char c;
+        for (int i = off; i < off+len; ++i)
+        {
+            c = cbuf[i];
+            if (((int)c) >= 0x80)
+            {
+                if (start < i)
+                {
+                    writer.write(cbuf, start, i-start);
+                }
+                start = i+1;
+                //encode all non basic latin characters
+                writer.write("&#");
+                writer.write(Integer.toString((int)c));
+                writer.write(";");
+            }
+        }
+
+        if (start == off)
+        {
+            writer.write(cbuf, off, len);
+        }
+        else if (start < off+len)
+        {
+            writer.write(cbuf,start,off+len-start);
+        }
+    }
+    
+    public static void encode (Writer writer, String cbuf, int off, int len) throws IOException
+    {
+        if (cbuf == null)
+        {
+            return;
+        }
 
+        int start = off;
+        char c;
+        for (int i = off; i < off+len; ++i)
+        {
+            c = cbuf.charAt(i);
+            if (((int)c) >= 0x80)
+            {
+                if (start < i)
+                {
+                    writer.write(cbuf, start, i-start);
+                }
+                start = i+1;
+                //encode all non basic latin characters
+                writer.write("&#");
+                writer.write(Integer.toString((int)c));
+                writer.write(";");
+            }
+        }
 
+        if (start == off)
+        {
+            writer.write(cbuf, off, len);
+        }
+        else if (start < off+len)
+        {
+            writer.write(cbuf,start,off+len-start);
+        }
+    }
 }

Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/resource/ResourceLoaderWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/resource/ResourceLoaderWrapper.java?rev=1239799&r1=1239798&r2=1239799&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/resource/ResourceLoaderWrapper.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/resource/ResourceLoaderWrapper.java Thu Feb  2 20:00:42 2012
@@ -1,100 +1,100 @@
-/*
- * 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.resource;
-
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Comparator;
-
-import javax.faces.FacesWrapper;
-
-/**
- * 
- * @author Leonardo Uribe
- *
- */
-public abstract class ResourceLoaderWrapper extends ResourceLoader implements FacesWrapper<ResourceLoader>
-{
-    
-    public ResourceLoaderWrapper()
-    {
-        super(null);
-    }
-
-    public String getResourceVersion(String path)
-    {
-        return getWrapped().getResourceVersion(path);
-    }
-
-    public String getLibraryVersion(String path)
-    {
-        return getWrapped().getLibraryVersion(path);
-    }
-
-    public URL getResourceURL(ResourceMeta resourceMeta)
-    {
-        return getWrapped().getResourceURL(resourceMeta);
-    }
-
-    public InputStream getResourceInputStream(ResourceMeta resourceMeta)
-    {
-        return getWrapped().getResourceInputStream(resourceMeta);
-    }
-
-    public ResourceMeta createResourceMeta(String prefix, String libraryName,
-            String libraryVersion, String resourceName, String resourceVersion)
-    {
-        return getWrapped().createResourceMeta(prefix, libraryName, libraryVersion,
-                resourceName, resourceVersion);
-    }
-
-    public boolean libraryExists(String libraryName)
-    {
-        return getWrapped().libraryExists(libraryName);
-    }
-
-    public String getPrefix()
-    {
-        return getWrapped().getPrefix();
-    }
-
-    public void setPrefix(String prefix)
-    {
-        getWrapped().setPrefix(prefix);
-    }
-
-    @Override
-    public boolean resourceExists(ResourceMeta resourceMeta)
-    {
-        return getWrapped().resourceExists(resourceMeta);
-    }
-
-    @Override
-    protected Comparator<String> getVersionComparator()
-    {
-        return getWrapped().getVersionComparator();
-    }
-
-    @Override
-    protected void setVersionComparator(Comparator<String> versionComparator)
-    {
-        getWrapped().setVersionComparator(versionComparator);
-    }
-    
-}
+/*
+ * 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.resource;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Comparator;
+
+import javax.faces.FacesWrapper;
+
+/**
+ * 
+ * @author Leonardo Uribe
+ *
+ */
+public abstract class ResourceLoaderWrapper extends ResourceLoader implements FacesWrapper<ResourceLoader>
+{
+    
+    public ResourceLoaderWrapper()
+    {
+        super(null);
+    }
+
+    public String getResourceVersion(String path)
+    {
+        return getWrapped().getResourceVersion(path);
+    }
+
+    public String getLibraryVersion(String path)
+    {
+        return getWrapped().getLibraryVersion(path);
+    }
+
+    public URL getResourceURL(ResourceMeta resourceMeta)
+    {
+        return getWrapped().getResourceURL(resourceMeta);
+    }
+
+    public InputStream getResourceInputStream(ResourceMeta resourceMeta)
+    {
+        return getWrapped().getResourceInputStream(resourceMeta);
+    }
+
+    public ResourceMeta createResourceMeta(String prefix, String libraryName,
+            String libraryVersion, String resourceName, String resourceVersion)
+    {
+        return getWrapped().createResourceMeta(prefix, libraryName, libraryVersion,
+                resourceName, resourceVersion);
+    }
+
+    public boolean libraryExists(String libraryName)
+    {
+        return getWrapped().libraryExists(libraryName);
+    }
+
+    public String getPrefix()
+    {
+        return getWrapped().getPrefix();
+    }
+
+    public void setPrefix(String prefix)
+    {
+        getWrapped().setPrefix(prefix);
+    }
+
+    @Override
+    public boolean resourceExists(ResourceMeta resourceMeta)
+    {
+        return getWrapped().resourceExists(resourceMeta);
+    }
+
+    @Override
+    protected Comparator<String> getVersionComparator()
+    {
+        return getWrapped().getVersionComparator();
+    }
+
+    @Override
+    protected void setVersionComparator(Comparator<String> versionComparator)
+    {
+        getWrapped().setVersionComparator(versionComparator);
+    }
+    
+}



Mime
View raw message