Author: abelevich
Date: 2011-01-13 06:50:08 -0500 (Thu, 13 Jan 2011)
New Revision: 20981
Modified:
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/AbstractTableBaseRenderer.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.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 to ExtendedDataTable.
Modified:
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java
===================================================================
---
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java 2011-01-13
11:20:56 UTC (rev 20980)
+++
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java 2011-01-13
11:50:08 UTC (rev 20981)
@@ -34,6 +34,7 @@
import org.ajax4jsf.model.DataVisitResult;
import org.ajax4jsf.model.DataVisitor;
import org.richfaces.component.Row;
+import org.richfaces.component.UIDataTableBase;
/**
* @author Anton Belevich
@@ -109,4 +110,46 @@
protected void put(FacesContext context, String key, String value) {
context.getAttributes().put(key, value);
}
+
+ protected String[] getRowClasses(RowHolderBase rowHolder) {
+ String[] rowClasses = new String[0];
+ if (rowHolder.getRow() instanceof UIDataTableBase) {
+ String classes = ((UIDataTableBase)rowHolder.getRow()).getRowClasses();
+ if(null != classes){
+ rowClasses=classes.split(",");
+ }
+ }
+ return rowClasses;
+ }
+
+ protected String[] getColumnClasses(RowHolderBase rowHolder) {
+ String[] columnClasses = new String[0];
+ if (rowHolder.getRow() instanceof UIDataTableBase) {
+ String classes = ((UIDataTableBase)rowHolder.getRow()).getColumnClasses();
+ if(null != classes){
+ columnClasses=classes.split(",");
+ }
+ }
+ return columnClasses;
+ }
+
+ protected String getColumnClass(RowHolderBase rowHolder, int columnNumber) {
+ String styleClass = "";
+ String[] columnClasses = getColumnClasses(rowHolder);
+ if (columnClasses.length > columnNumber) {
+ styleClass = columnClasses[columnNumber];
+ }
+
+ return styleClass;
+ }
+
+ protected String getRowClass(RowHolderBase rowHolder) {
+ String styleClass = "";
+ String[] rowClasses = getRowClasses(rowHolder);
+ if (rowClasses.length > 0) {
+ int styleIndex = rowHolder.getCurrentRow() % rowClasses.length;
+ styleClass = rowClasses[styleIndex];
+ }
+ return styleClass;
+ }
}
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
11:20:56 UTC (rev 20980)
+++
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/AbstractTableBaseRenderer.java 2011-01-13
11:50:08 UTC (rev 20981)
@@ -54,15 +54,6 @@
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();
@@ -77,9 +68,10 @@
if (rowHolder.isRowStart()) {
int currentRow = rowHolder.getCurrentRow();
- if (rowHolder.getRowClasses().length > 0) {
- int indeStyleClass = currentRow % rowHolder.getRowClasses().length;
- String rowClass = rowHolder.getRowClasses()[indeStyleClass];
+ String[] rowClasses = getRowClasses(rowHolder);
+ if (rowClasses.length > 0) {
+ int indeStyleClass = currentRow % rowClasses.length;
+ String rowClass = rowClasses[indeStyleClass];
component.getAttributes().put(ROW_CLASS, rowClass);
}
if (rowHolder.getCurrentRow() == 0) {
Modified:
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java
===================================================================
---
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java 2011-01-13
11:20:56 UTC (rev 20980)
+++
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java 2011-01-13
11:50:08 UTC (rev 20981)
@@ -759,6 +759,12 @@
RendererState state = (RendererState) rowHolder;
UIDataTableBase table = state.getRow();
writer.startElement(HtmlConstants.TR_ELEMENT, table);
+
+ String rowClass = getRowClass(rowHolder);
+ if (!"".equals(rowClass)) {
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, rowClass, null);
+ }
+
StringBuilder builder = new StringBuilder();
Collection<Object> selection = table.getSelection();
if (selection != null && selection.contains(table.getRowKey())) {
@@ -784,10 +790,18 @@
writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE,
table.getClientId(facesContext) + ":" + part.getName().getId(),
null);
columns = part.getColumns().iterator();
+ int columnNumber = 0;
while (columns.hasNext()) {
UIComponent column = (UIComponent) columns.next();
if (column.isRendered()) {
writer.startElement(HtmlConstants.TD_ELEM, table);
+
+ String columnClass = getColumnClass(rowHolder, columnNumber);
+ if (!"".equals(columnClass)) {
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, columnClass,
null);
+ }
+ columnNumber++;
+
writer.startElement(HtmlConstants.DIV_ELEM, table);
writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-edt-c
rf-edt-c-"
+ column.getId(), null);
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
11:20:56 UTC (rev 20980)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/RowHolder.java 2011-01-13
11:50:08 UTC (rev 20981)
@@ -25,7 +25,6 @@
import javax.faces.context.FacesContext;
import org.richfaces.component.Row;
-import org.richfaces.component.UIDataTableBase;
/**
* @author Anton Belevich
@@ -43,10 +42,6 @@
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);
}
@@ -55,17 +50,6 @@
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() {
@@ -103,12 +87,4 @@
public void setRowStart(boolean isRowStart) {
this.isRowStart = isRowStart;
}
-
- public String[] getRowClasses() {
- return this.rowClasses;
- }
-
- public String[] getColumnClasses() {
- return this.columnClasses;
- }
}