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 2008/06/14 02:01:23 UTC
svn commit: r667697 - in /myfaces/tomahawk/trunk:
core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java
core12/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java
Author: lu4242
Date: Fri Jun 13 17:01:23 2008
New Revision: 667697
URL: http://svn.apache.org/viewvc?rev=667697&view=rev
Log:
TOMAHAWK-1116 ColumnClasses styles is ignored (UIColumns counts as one, but each element in UIColumns should count)
Modified:
myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java
myfaces/tomahawk/trunk/core12/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java
Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java?rev=667697&r1=667696&r2=667697&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java Fri Jun 13 17:01:23 2008
@@ -585,19 +585,51 @@
protected void encodeColumnChild(FacesContext facesContext,
ResponseWriter writer, UIData uiData,
UIComponent component, Styles styles, int columnStyleIndex)
- throws IOException {
+ throws IOException {
+ //columnStyleIndex param does not takes into
+ //consideration UIColumns, since it is called from HtmlTableRendererBase.
+ //So we need to recalculate its index taking into account that
+ //UIColumns component count as ((UIColumns) child).getRowCount() instead 1
+ columnStyleIndex = getColumnStyleIndex(uiData, columnStyleIndex);
super.encodeColumnChild(facesContext, writer, uiData, component,
styles, columnStyleIndex);
- if (component instanceof UIColumns) {
+ if (component instanceof UIColumns)
+ {
UIColumns columns = (UIColumns) component;
- for (int k = 0, colSize = columns.getRowCount(); k < colSize; k++) {
+ for (int k = 0, colSize = columns.getRowCount(); k < colSize; k++)
+ {
columns.setRowIndex(k);
renderColumnBody(facesContext, writer, uiData, component,
- styles, columnStyleIndex);
+ styles, columnStyleIndex + k);
}
columns.setRowIndex(-1);
}
}
+
+ /**
+ * This method calculates the correct columnStyleIndex taking the dynamic columns
+ * of <b>UIColumns</b> into consideration
+ *
+ * @param uiData
+ * @param columnStyleIndex
+ * @return the correct columnStyleIndex
+ */
+ private int getColumnStyleIndex(UIData uiData, int columnStyleIndex)
+ {
+ int colStyleIndex = 0;
+ for (int i = 0; i < columnStyleIndex; i++)
+ {
+ UIComponent child = (UIComponent) uiData.getChildren().get(i);
+ if (child instanceof UIColumns)
+ {
+ colStyleIndex += ((UIColumns) child).getRowCount();
+ continue;
+ }
+ colStyleIndex++;
+ }
+ return colStyleIndex;
+ }
+
/**
* @see org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlTableRendererBase#renderColumnBody(javax.faces.context.FacesContext, javax.faces.context.ResponseWriter, javax.faces.component.UIData, javax.faces.component.UIComponent, org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlTableRendererBase.Styles, int)
Modified: myfaces/tomahawk/trunk/core12/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core12/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java?rev=667697&r1=667696&r2=667697&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core12/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java (original)
+++ myfaces/tomahawk/trunk/core12/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java Fri Jun 13 17:01:23 2008
@@ -585,19 +585,51 @@
protected void encodeColumnChild(FacesContext facesContext,
ResponseWriter writer, UIData uiData,
UIComponent component, Styles styles, int columnStyleIndex)
- throws IOException {
+ throws IOException {
+ //columnStyleIndex param does not takes into
+ //consideration UIColumns, since it is called from HtmlTableRendererBase.
+ //So we need to recalculate its index taking into account that
+ //UIColumns component count as ((UIColumns) child).getRowCount() instead 1
+ columnStyleIndex = getColumnStyleIndex(uiData, columnStyleIndex);
super.encodeColumnChild(facesContext, writer, uiData, component,
styles, columnStyleIndex);
- if (component instanceof UIColumns) {
+ if (component instanceof UIColumns)
+ {
UIColumns columns = (UIColumns) component;
- for (int k = 0, colSize = columns.getRowCount(); k < colSize; k++) {
+ for (int k = 0, colSize = columns.getRowCount(); k < colSize; k++)
+ {
columns.setRowIndex(k);
renderColumnBody(facesContext, writer, uiData, component,
- styles, columnStyleIndex);
+ styles, columnStyleIndex + k);
}
columns.setRowIndex(-1);
}
}
+
+ /**
+ * This method calculates the correct columnStyleIndex taking the dynamic columns
+ * of <b>UIColumns</b> into consideration
+ *
+ * @param uiData
+ * @param columnStyleIndex
+ * @return the correct columnStyleIndex
+ */
+ private int getColumnStyleIndex(UIData uiData, int columnStyleIndex)
+ {
+ int colStyleIndex = 0;
+ for (int i = 0; i < columnStyleIndex; i++)
+ {
+ UIComponent child = (UIComponent) uiData.getChildren().get(i);
+ if (child instanceof UIColumns)
+ {
+ colStyleIndex += ((UIColumns) child).getRowCount();
+ continue;
+ }
+ colStyleIndex++;
+ }
+ return colStyleIndex;
+ }
+
/**
* @see org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlTableRendererBase#renderColumnBody(javax.faces.context.FacesContext, javax.faces.context.ResponseWriter, javax.faces.component.UIData, javax.faces.component.UIComponent, org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlTableRendererBase.Styles, int)