You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2013/10/17 21:51:29 UTC

svn commit: r1533230 - /myfaces/core/branches/2.1.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTableRendererBase.java

Author: lu4242
Date: Thu Oct 17 19:51:28 2013
New Revision: 1533230

URL: http://svn.apache.org/r1533230
Log:
MYFACES-3749 columnClasses not working correctly in DataTable Component (thanks to Paul Nicolucci for provide this patch)

Modified:
    myfaces/core/branches/2.1.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTableRendererBase.java

Modified: myfaces/core/branches/2.1.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTableRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTableRendererBase.java?rev=1533230&r1=1533229&r2=1533230&view=diff
==============================================================================
--- myfaces/core/branches/2.1.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTableRendererBase.java (original)
+++ myfaces/core/branches/2.1.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTableRendererBase.java Thu Oct 17 19:51:28 2013
@@ -483,6 +483,7 @@ public class HtmlTableRendererBase exten
                 }
 
                 List children = null;
+                int columnStyleIndex = 0;
                 for (int j = 0, size = getChildCount(component); j < size; j++)
                 {
                     if (children == null)
@@ -496,16 +497,18 @@ public class HtmlTableRendererBase exten
                         
                         if (columnRendering)
                         {
-                            beforeColumn(facesContext, uiData, j);
+                            beforeColumn(facesContext, uiData, columnStyleIndex);
                         }
                            
                         encodeColumnChild(facesContext, writer, uiData, child, 
-                                styles, nc * uiData.getChildCount() + j);                    
+                                styles, nc * uiData.getChildCount() + columnStyleIndex);
                        
                         if (columnRendering)
                         {
-                            afterColumn(facesContext, uiData, j);
+                            afterColumn(facesContext, uiData, columnStyleIndex);
                         }
+                        columnStyleIndex = columnStyleIndex + 
+                            getColumnCountForComponent(facesContext, uiData, child);
                     }
                 }
 
@@ -582,6 +585,7 @@ public class HtmlTableRendererBase exten
             renderRowStart(facesContext, writer, uiData, styles, currentRow);
             
             List<UIComponent> children = null;
+            int columnStyleIndex = 0;
             for (int j = 0, size = getChildCount(component); j < size; j++)
             {
                 if (children == null)
@@ -595,16 +599,18 @@ public class HtmlTableRendererBase exten
                     
                     if (columnRendering)
                     {
-                        beforeColumn(facesContext, uiData, j);
+                        beforeColumn(facesContext, uiData, columnStyleIndex);
                     }
                        
                     encodeColumnChild(facesContext, writer, uiData, child, 
-                            styles, j);                    
+                            styles, columnStyleIndex);
                    
                     if (columnRendering)
                     {
-                        afterColumn(facesContext, uiData, j);
+                        afterColumn(facesContext, uiData, columnStyleIndex);
                     }
+                    columnStyleIndex = columnStyleIndex + 
+                            getColumnCountForComponent(facesContext, uiData, child);
                 }
             }
 
@@ -821,6 +827,22 @@ public class HtmlTableRendererBase exten
     {        
     }
     /**
+     * Indicates the number of columns the component represents. By default each UIColumn instance
+     * is 1 column
+     * @param facesContext
+     * @param uiData
+     * @param child
+     * @return 
+     */
+    protected int getColumnCountForComponent(FacesContext facesContext, UIData uiData, UIComponent child)
+    {
+        if (child instanceof UIColumn)
+        {
+            return 1;
+        }
+        return 0;
+    }
+    /**
      *Perform any operations necessary immediately before each column child's header or footer is rendered
      *
      * @param facesContext the <code>FacesContext</code>.