Author: awiner
Date: Mon Sep 18 10:12:23 2006
New Revision: 447475
URL: http://svn.apache.org/viewvc?view=rev&rev=447475
Log:
Fix ADFFACES-160: tr:table's footer facet is required for tr:column's footer
facet to work. We now use a compromise between the old rendering and the new,
which tries to use as little screen real-estate as possible and won't change
behavior of older pages. If there is a table footer, but no footer in the
first column, the table footer gets inserted there. Otherwise, the table
footer is put in a new row at the end. While fixing this, noticed and filed
issue 181 on some bad style names for the footer facets in the table and column
Modified:
incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/desktop/DesktopTableRenderer.java
incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/table/ColumnData.java
Modified:
incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/desktop/DesktopTableRenderer.java
URL:
http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/desktop/DesktopTableRenderer.java?view=diff&rev=447475&r1=447474&r2=447475
==============================================================================
---
incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/desktop/DesktopTableRenderer.java
(original)
+++
incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/desktop/DesktopTableRenderer.java
Mon Sep 18 10:12:23 2006
@@ -994,7 +994,10 @@
tContext.getRenderStage().setStage(RenderStage.COLUMN_FOOTER_STAGE);
final ColumnData colData = tContext.getColumnData();
UIComponent footer = getFacet(component, CoreTable.FOOTER_FACET);
- if (footer != null)
+ boolean hasColumnFooters = colData.getPhysicalIndexOfFirstFooter() >= 0;
+
+ // If there's a table footer, or column footers, we've got work to do
+ if ((footer != null) || hasColumnFooters)
{
ResponseWriter writer = context.getResponseWriter();
writer.startElement(XhtmlConstants.TABLE_ROW_ELEMENT, null);
@@ -1008,7 +1011,6 @@
"left:-1px", null);
}
- writer.startElement(XhtmlConstants.TABLE_HEADER_ELEMENT, null);
// total rows may need an ID. see bug 3211593:
/* Need new scheme for generateUniqueId()?
String rowID = XhtmlLafUtils.generateUniqueID(tContext);
@@ -1016,12 +1018,31 @@
tContext.getRowData().setCurrentRowHeaderID(rowID);
*/
final int firstFooterPhysicalIndex =
colData.getPhysicalIndexOfFirstFooter();
- final int colSpan = (firstFooterPhysicalIndex > 0)?
firstFooterPhysicalIndex: tContext.getActualColumnCount();
- writer.writeAttribute(XhtmlConstants.COLSPAN_ATTRIBUTE,
IntegerUtils.getString(colSpan), null);
- renderStyleClass(context, arc,
XhtmlConstants.AF_TABLE_COLUMN_FOOTER_STYLE);
- encodeChild(context, footer);
- writer.endElement(XhtmlConstants.TABLE_HEADER_ELEMENT);
- if (firstFooterPhysicalIndex > 0)
+ // By default, we try to render the table footer in the same row
+ // as the column footers; this is to save on screen real-estate,
+ // and do something with that space in the table if the first N
+ // columns have no footer content.
+ // When the first column does have a footer, we'll need to push
+ // the table footer down to an extra row
+
+ // If there isn't a column footer in the first row, render a TH
+ // with a sufficient colspan - and put the table footer in there
+ // if it exists.
+ // (Note this does need to be != 0, not > 0. Negative numbers
+ // mean there's no column footers, in which case we'll handle
+ // outputting the table footer right here)
+ if (firstFooterPhysicalIndex != 0)
+ {
+ writer.startElement(XhtmlConstants.TABLE_HEADER_ELEMENT, null);
+ final int colSpan = (firstFooterPhysicalIndex > 0)?
firstFooterPhysicalIndex: tContext.getActualColumnCount();
+ writer.writeAttribute(XhtmlConstants.COLSPAN_ATTRIBUTE,
IntegerUtils.getString(colSpan), null);
+ renderStyleClass(context, arc,
XhtmlConstants.AF_TABLE_COLUMN_FOOTER_STYLE);
+ if (footer != null)
+ encodeChild(context, footer);
+ writer.endElement(XhtmlConstants.TABLE_HEADER_ELEMENT);
+ }
+
+ if (firstFooterPhysicalIndex >= 0)
{
colData.setColumnIndex(tContext.getSpecialColumnCount(),
0/*logicalColumnIndex*/);
@@ -1035,6 +1056,22 @@
}
}
writer.endElement(XhtmlConstants.TABLE_ROW_ELEMENT);
+
+ // OK, we need to put the table footer at the end in its own row,
+ // because the first column is already taken
+ if ((firstFooterPhysicalIndex == 0) && (footer != null))
+ {
+ writer.startElement(XhtmlConstants.TABLE_ROW_ELEMENT, null);
+
+ writer.startElement(XhtmlConstants.TABLE_HEADER_ELEMENT, null);
+ // Make it span the whole table
+ writer.writeAttribute(XhtmlConstants.COLSPAN_ATTRIBUTE,
tContext.getActualColumnCount(), null);
+
+ renderStyleClass(context, arc,
XhtmlConstants.AF_TABLE_COLUMN_FOOTER_STYLE);
+ encodeChild(context, footer);
+ writer.endElement(XhtmlConstants.TABLE_HEADER_ELEMENT);
+ writer.endElement(XhtmlConstants.TABLE_ROW_ELEMENT);
+ }
}
}
Modified:
incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/table/ColumnData.java
URL:
http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/table/ColumnData.java?view=diff&rev=447475&r1=447474&r2=447475
==============================================================================
---
incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/table/ColumnData.java
(original)
+++
incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/table/ColumnData.java
Mon Sep 18 10:12:23 2006
@@ -120,12 +120,7 @@
if ((_firstFooterPhysicalColumn == -1) ||
(_physicalColumn < _firstFooterPhysicalColumn))
{
- if (_physicalColumn > 0) // bug 4190038
- {
- _firstFooterPhysicalColumn = _physicalColumn;
- }
- else
- _LOG.warning("The very first column in a table cannot show a footer!");
+ _firstFooterPhysicalColumn = _physicalColumn;
}
}