Author: abelevich
Date: 2011-01-13 04:33:20 -0500 (Thu, 13 Jan 2011)
New Revision: 20978
Modified:
trunk/ui/iteration/ui/src/main/java/org/richfaces/component/UIDataTableBase.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/AbstractTableBaseRenderer.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/CollapsibleSubTableRenderer.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ColumnGroupRenderer.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/RowHolder.java
Log:
RF-9777 rich:dataTable Attributes columnClasses and headerClass not working
-rowClasses and columnClasses attribute were applied.
Modified:
trunk/ui/iteration/ui/src/main/java/org/richfaces/component/UIDataTableBase.java
===================================================================
---
trunk/ui/iteration/ui/src/main/java/org/richfaces/component/UIDataTableBase.java 2011-01-13
02:10:19 UTC (rev 20977)
+++
trunk/ui/iteration/ui/src/main/java/org/richfaces/component/UIDataTableBase.java 2011-01-13
09:33:20 UTC (rev 20978)
@@ -112,6 +112,30 @@
@Attribute
public abstract String getFilterVar();
+
+ @Attribute
+ public abstract String getRowClass();
+
+ @Attribute
+ public abstract String getCaptionClass();
+
+ @Attribute
+ public abstract String getHeaderClass();
+
+ @Attribute
+ public abstract String getFooterClass();
+
+ @Attribute
+ public abstract String getColumnClasses();
+
+ @Attribute
+ public abstract String getRowClasses();
+
+ @Attribute
+ public abstract String getStyle();
+
+ @Attribute
+ public abstract String getStyleClass();
@Attribute
public abstract Collection<Object> getSelection();
@@ -121,7 +145,7 @@
@Attribute
public abstract SortMode getSortMode();
-
+
public Iterator<UIComponent> columns() {
return new DataTableColumnsIterator(this);
}
Modified:
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/AbstractTableBaseRenderer.java
===================================================================
---
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/AbstractTableBaseRenderer.java 2011-01-13
02:10:19 UTC (rev 20977)
+++
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/AbstractTableBaseRenderer.java 2011-01-13
09:33:20 UTC (rev 20978)
@@ -42,14 +42,27 @@
public static final String ROW_CLASS_KEY = "rowClass";
- public static final String FIRST_ROW_CLASS_KEY = "firstRowClass";
-
- public static final String CELL_CLASS_KEY = "cellClass";
-
public static final String CELL_ELEMENT_KEY = "cellElement";
public static final String BREAK_ROW_BEFORE = "breakRowBefore";
+ public static final String COLUMN_CLASS = "userColumnClass";
+
+ public static final String ROW_CLASS = "userRowClass";
+
+ protected static final String FIRST_ROW_CLASS_KEY = "firstRowClass";
+
+ protected static final String CELL_CLASS_KEY = "cellClass";
+
+ public String getColumnClass(RowHolder rowHolder, int columnNumber) {
+ String styleClass = "";
+ if (rowHolder.getColumnClasses().length > columnNumber) {
+ styleClass = rowHolder.getColumnClasses()[columnNumber];
+ }
+
+ return styleClass;
+ }
+
public void encodeColumn(FacesContext context, ResponseWriter writer, UIColumn
component, RowHolder rowHolder) throws IOException {
String parentId = rowHolder.getParentClientId();
@@ -64,7 +77,11 @@
if (rowHolder.isRowStart()) {
int currentRow = rowHolder.getCurrentRow();
-
+ if (rowHolder.getRowClasses().length > 0) {
+ int indeStyleClass = currentRow % rowHolder.getRowClasses().length;
+ String rowClass = rowHolder.getRowClasses()[indeStyleClass];
+ component.getAttributes().put(ROW_CLASS, rowClass);
+ }
if (rowHolder.getCurrentRow() == 0) {
encodeFirstRowStart(writer, context, parentId, currentRow, component);
} else {
@@ -86,6 +103,7 @@
writer.startElement(element, component);
getUtils().encodeId(context, component);
String cellClass = getCellClass(context, parentId);
+ cellClass = concatClasses(cellClass,
component.getAttributes().get(COLUMN_CLASS));
encodeStyleClass(writer, context, component, HtmlConstants.STYLE_CLASS_ATTR,
cellClass);
if (component instanceof org.richfaces.component.AbstractColumn) {
@@ -109,7 +127,7 @@
public void encodeFirstRowStart(ResponseWriter writer, FacesContext context, String
parentId, int currentRow, UIComponent component) throws IOException {
writer.startElement(HtmlConstants.TR_ELEMENT, component);
- String styleClass = concatClasses(getRowClass(context, parentId),
getFirstRowClass(context, parentId));
+ String styleClass = concatClasses(getRowClass(context, parentId),
getFirstRowClass(context, parentId), component.getAttributes().get(ROW_CLASS));
encodeStyleClass(writer, context, component, HtmlConstants.STYLE_CLASS_ATTR,
styleClass);
}
@@ -119,7 +137,7 @@
public void encodeRowStart(ResponseWriter writer, FacesContext context, String
parentId, int currentRow, UIComponent component) throws IOException {
writer.startElement(HtmlConstants.TR_ELEMENT, component);
- String styleClass = getRowClass(context, parentId);
+ String styleClass = concatClasses(getRowClass(context, parentId),
component.getAttributes().get(ROW_CLASS));
encodeStyleClass(writer, context, component, HtmlConstants.STYLE_CLASS_ATTR,
styleClass);
}
Modified:
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/CollapsibleSubTableRenderer.java
===================================================================
---
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/CollapsibleSubTableRenderer.java 2011-01-13
02:10:19 UTC (rev 20977)
+++
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/CollapsibleSubTableRenderer.java 2011-01-13
09:33:20 UTC (rev 20978)
@@ -121,7 +121,7 @@
public void encodeFirstRowStart(ResponseWriter writer, FacesContext context, String
parentId, int currentRow, UIComponent component) throws IOException {
writer.startElement(HtmlConstants.TR_ELEMENT, component);
writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, parentId + ":" +
currentRow + ":b", null);
- String styleClass = getFirstRowClass(context, parentId);
+ String styleClass = concatClasses(getFirstRowClass(context, parentId),
component.getAttributes().get(ROW_CLASS));
encodeStyleClass(writer, context, component, HtmlConstants.STYLE_CLASS_ATTR,
styleClass);
}
@@ -129,7 +129,7 @@
public void encodeRowStart(ResponseWriter writer, FacesContext context, String
parentId, int currentRow, UIComponent component) throws IOException {
writer.startElement(HtmlConstants.TR_ELEMENT, component);
writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, parentId + ":" +
currentRow + ":b", null);
- String styleClass = getRowClass(context, parentId);
+ String styleClass = concatClasses(getRowClass(context, parentId),
component.getAttributes().get(ROW_CLASS));
encodeStyleClass(writer, context, component, HtmlConstants.STYLE_CLASS_ATTR,
styleClass);
}
@@ -192,12 +192,14 @@
partialStart(facesContext,((AbstractCollapsibleSubTable)
row).getRelativeClientId(facesContext) + ":b");
}
+ int columnNumber = 0;
while (components.hasNext()) {
UIComponent component = components.next();
if(component.isRendered()) {
if(component instanceof UIColumn ) {
+ component.getAttributes().put(COLUMN_CLASS, getColumnClass(rowHolder,
columnNumber));
encodeColumn(facesContext, writer, (UIColumn)component , rowHolder);
-
+ columnNumber++;
} else if (component instanceof AbstractCollapsibleSubTable) {
if(component.isRendered()) {
encodeRowEnd(writer);
Modified:
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ColumnGroupRenderer.java
===================================================================
---
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ColumnGroupRenderer.java 2011-01-13
02:10:19 UTC (rev 20977)
+++
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ColumnGroupRenderer.java 2011-01-13
09:33:20 UTC (rev 20978)
@@ -50,11 +50,13 @@
rowHolder.setRowStart(true);
Iterator<UIComponent> components = row.columns();
-
+ int columnNumber = 0;
while(components.hasNext()){
UIColumn column = (UIColumn)components.next();
if(column.isRendered()) {
- encodeColumn(facesContext, writer, column,rowHolder);
+ column.getAttributes().put(COLUMN_CLASS, getColumnClass(rowHolder,
columnNumber));
+ encodeColumn(facesContext, writer, column, rowHolder);
+ columnNumber++;
}
}
encodeRowEnd(writer);
Modified:
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java
===================================================================
---
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java 2011-01-13
02:10:19 UTC (rev 20977)
+++
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java 2011-01-13
09:33:20 UTC (rev 20978)
@@ -154,6 +154,7 @@
rowHolder.setRowStart(true);
Iterator<UIComponent> components = row.columns();
+ int columnNumber = 0;
while (components.hasNext()) {
UIComponent child = components.next();
if (child.isRendered()) {
@@ -198,8 +199,10 @@
tbodyStart = true;
}
+ child.getAttributes().put(COLUMN_CLASS, getColumnClass(rowHolder,
columnNumber));
encodeColumn(facesContext, writer, (UIColumn) child, rowHolder);
-
+ columnNumber++;
+
if (!components.hasNext()) {
encodeRowEnd(writer);
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/RowHolder.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/RowHolder.java 2011-01-13
02:10:19 UTC (rev 20977)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/RowHolder.java 2011-01-13
09:33:20 UTC (rev 20978)
@@ -25,6 +25,7 @@
import javax.faces.context.FacesContext;
import org.richfaces.component.Row;
+import org.richfaces.component.UIDataTableBase;
/**
* @author Anton Belevich
@@ -41,8 +42,11 @@
private boolean updatePartial;
private boolean encodeParentTBody;
-
-
+
+ private String[] rowClasses = new String[0];
+
+ private String[] columnClasses = new String[0];
+
public RowHolder(FacesContext context, Row row) {
this(context, row, 0, true);
}
@@ -51,6 +55,17 @@
super(context);
this.row = row;
this.parentClientId = row.getClientId(context);
+
+ if (row instanceof UIDataTableBase) {
+ String classes = ((UIDataTableBase)row).getRowClasses();
+ if(null != classes){
+ rowClasses=classes.split(",");
+ }
+ classes = (String) ((UIDataTableBase)row).getColumnClasses();
+ if(null != classes){
+ columnClasses=classes.split(",");
+ }
+ }
}
public boolean isEncodeParentTBody() {
@@ -88,4 +103,12 @@
public void setRowStart(boolean isRowStart) {
this.isRowStart = isRowStart;
}
+
+ public String[] getRowClasses() {
+ return this.rowClasses;
+ }
+
+ public String[] getColumnClasses() {
+ return this.columnClasses;
+ }
}