myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r815603 - in /myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit: JSFAttr.java html/HTML.java html/HtmlGridRendererBase.java html/HtmlTableRendererBase.java
Date Wed, 16 Sep 2009 04:34:49 GMT
Author: lu4242
Date: Wed Sep 16 04:34:49 2009
New Revision: 815603

URL: http://svn.apache.org/viewvc?rev=815603&view=rev
Log:
MYFACES-2278 Render columns with th instead td, according to HtmlColumn.isRowHeader (Thanks
to Jakob Korherr for provide this patch)

Modified:
    myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/JSFAttr.java
    myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HTML.java
    myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlGridRendererBase.java
    myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTableRendererBase.java

Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/JSFAttr.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/JSFAttr.java?rev=815603&r1=815602&r2=815603&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/JSFAttr.java
(original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/JSFAttr.java
Wed Sep 16 04:34:49 2009
@@ -132,6 +132,9 @@
     String ROW_ID                      = "rowId";
     String ROW_STYLECLASS_ATTR         = "rowStyleClass";
     String ROW_STYLE_ATTR              = "rowStyle";
+    
+    // HtmlColumn attributes
+    String ROW_HEADER_ATTR             = "rowHeader";
 
     // Alternate locations (instead of using AddResource)
     String JAVASCRIPT_LOCATION         = "javascriptLocation";

Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HTML.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HTML.java?rev=815603&r1=815602&r2=815603&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HTML.java
(original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HTML.java
Wed Sep 16 04:34:49 2009
@@ -449,6 +449,7 @@
 
     //HTML attributes values
     String SCOPE_COLGROUP_VALUE = "colgroup";
+    String SCOPE_ROW_VALUE = "row";
 
     //HTML element constants
     String SPAN_ELEM = "span";

Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlGridRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlGridRendererBase.java?rev=815603&r1=815602&r2=815603&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlGridRendererBase.java
(original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlGridRendererBase.java
Wed Sep 16 04:34:49 2009
@@ -222,14 +222,33 @@
                         }
                     }
 
-                    writer.startElement(HTML.TD_ELEM, component);
+                    // Get the rowHeader attribute from the attribute map, because of MYFACES-1790
+                    Object rowHeaderAttr = child.getAttributes().get(JSFAttr.ROW_HEADER_ATTR);
+                    boolean rowHeader = rowHeaderAttr != null && ((Boolean) rowHeaderAttr);
+                    
+                    if(rowHeader) 
+                    {
+                        writer.startElement(HTML.TH_ELEM, component);   
+                        writer.writeAttribute(HTML.SCOPE_ATTR, HTML.SCOPE_ROW_VALUE, null);
+                    }
+                    else 
+                    {
+                        writer.startElement(HTML.TD_ELEM, component);
+                    }
                     if (columnIndex < columnClassesCount)
                     {
                         writer.writeAttribute(HTML.CLASS_ATTR, columnClassesArray[columnIndex],
null);
                     }
                     columnIndex = childAttributes(context, writer, child, columnIndex);
                     RendererUtils.renderChild(context, child);
-                    writer.endElement(HTML.TD_ELEM);
+                    if(rowHeader) 
+                    {
+                        writer.endElement(HTML.TH_ELEM);   
+                    }
+                    else 
+                    {
+                        writer.endElement(HTML.TD_ELEM);
+                    }
 
                     columnIndex++;
                     if (columnIndex >= columns) {

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=815603&r1=815602&r2=815603&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
Wed Sep 16 04:34:49 2009
@@ -361,14 +361,32 @@
             UIComponent component,
             Styles styles, int columnStyleIndex) throws IOException
     {
-        writer.startElement(HTML.TD_ELEM, uiData);
+        // Get the rowHeader attribute from the attribute map, because of MYFACES-1790
+        Object rowHeaderAttr = component.getAttributes().get(JSFAttr.ROW_HEADER_ATTR);
+        boolean rowHeader = rowHeaderAttr != null && ((Boolean) rowHeaderAttr);
+        
+        if(rowHeader) 
+        {
+            writer.startElement(HTML.TH_ELEM, uiData);   
+            writer.writeAttribute(HTML.SCOPE_ATTR, HTML.SCOPE_ROW_VALUE, null);
+        }
+        else 
+        {
+            writer.startElement(HTML.TD_ELEM, uiData);
+        }
         if (styles.hasColumnStyle())
         {
             writer.writeAttribute(HTML.CLASS_ATTR, styles.getColumnStyle(columnStyleIndex),
null);
         }
-    
         RendererUtils.renderChild(facesContext, component);
-        writer.endElement(HTML.TD_ELEM);
+        if(rowHeader) 
+        {
+            writer.endElement(HTML.TH_ELEM);   
+        }
+        else 
+        {
+            writer.endElement(HTML.TD_ELEM);
+        }
     }
 
     /**



Mime
View raw message