Author: abelevich
Date: 2009-11-06 13:14:18 -0500 (Fri, 06 Nov 2009)
New Revision: 15849
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTable.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UISubTable.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ElementEncodeListener.java
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/table.css
Log:
add subTable header facet support
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTable.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTable.java 2009-11-06
17:32:08 UTC (rev 15848)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTable.java 2009-11-06
18:14:18 UTC (rev 15849)
@@ -1,5 +1,7 @@
package org.richfaces.component;
+import javax.faces.component.UIComponent;
+
/**
* @author Anton Belevich
*
@@ -18,4 +20,55 @@
public String getFirstRowSkinClass() {
return "rich-table-firstrow";
}
-}
\ No newline at end of file
+
+ public String getHeaderCellSkinClass() {
+ return "rich-table-header-cell";
+ }
+
+ public String getHeaderRowSkinClass() {
+ return "rich-table-header-continue";
+ }
+
+ public String getHeaderFirstRowSkinClass() {
+ return "rich-table-header";
+ }
+
+ public String getColumnHeaderCellSkinClass() {
+ return "rich-table-subheader-cell";
+ }
+
+ public String getColumnHeaderSkinClass() {
+ return "rich-table-subheader";
+ }
+
+ @Override
+ public String getFooterCellSkinClass() {
+ return "rich-table-footer-cell";
+ }
+
+ @Override
+ public String getFooterRowSkinClass() {
+ return "rich-table-footer-continue";
+ }
+
+ @Override
+ public String getFooterFirstRowSkinClass() {
+ return "rich-table-footer";
+ }
+
+ @Override
+ public String getColumnFooterCellSkinClass() {
+ return "rich-table-subfooter-cell";
+ }
+
+ @Override
+ public String getColumnFooterSkinClass() {
+ return "rich-table-subfooter-cell";
+ }
+
+
+
+ public UIComponent getCaption() {
+ return getFacet("caption");
+ }
+}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java 2009-11-06
17:32:08 UTC (rev 15848)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java 2009-11-06
18:14:18 UTC (rev 15849)
@@ -29,10 +29,28 @@
return getFacet("footer");
}
- public UIComponent getCaption() {
- return getFacet("caption");
- }
+ public abstract String getHeaderCellSkinClass();
+ public abstract String getHeaderRowSkinClass();
+
+ public abstract String getHeaderFirstRowSkinClass();
+
+ public abstract String getColumnHeaderCellSkinClass();
+
+ public abstract String getColumnHeaderSkinClass();
+
+ public abstract String getFooterCellSkinClass();
+
+ public abstract String getFooterRowSkinClass();
+
+ public abstract String getFooterFirstRowSkinClass();
+
+ public abstract String getColumnFooterCellSkinClass();
+
+ public abstract String getColumnFooterSkinClass();
+
+
+
@Override
public boolean getRendersChildren() {
return true;
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UISubTable.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UISubTable.java 2009-11-06
17:32:08 UTC (rev 15848)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UISubTable.java 2009-11-06
18:14:18 UTC (rev 15849)
@@ -84,7 +84,52 @@
}
public String getFirstRowSkinClass() {
- return "rich-subtable-firstrow";
+ return "rich-subtable-first-row";
}
+ public String getHeaderCellSkinClass() {
+ return "rich-subtable-header-cell";
+ }
+
+ public String getHeaderRowSkinClass() {
+ return "rich-subtable-header-continue";
+ }
+
+ public String getHeaderFirstRowSkinClass() {
+ return "rich-subtable-header";
+ }
+
+ public String getColumnHeaderCellSkinClass() {
+ return "rich-subtable-subheader-cell";
+ }
+
+ public String getColumnHeaderSkinClass() {
+ return "rich-subtable-subheader";
+ }
+
+ @Override
+ public String getFooterCellSkinClass() {
+ return "rich-subtable-footer-cell";
+ }
+
+ @Override
+ public String getFooterRowSkinClass() {
+ return "rich-subtable-footer-continue";
+ }
+
+ @Override
+ public String getFooterFirstRowSkinClass() {
+ return "rich-subtable-header";
+ }
+
+ @Override
+ public String getColumnFooterCellSkinClass() {
+ return "rich-subtable-subfooter-cell";
+ }
+
+ @Override
+ public String getColumnFooterSkinClass() {
+ return "rich-subtable-subfooter-cell";
+ }
+
}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java 2009-11-06
17:32:08 UTC (rev 15848)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java 2009-11-06
18:14:18 UTC (rev 15849)
@@ -14,6 +14,7 @@
import org.richfaces.component.Row;
import org.richfaces.component.UIDataTableBase;
import org.richfaces.component.UIDataTable;
+import org.richfaces.component.UISubTable;
@ResourceDependencies({
@ResourceDependency(name = "datatable.js"),
@@ -27,35 +28,37 @@
Object key = dataTable.getRowKey();
dataTable.captureOrigValue(context);
dataTable.setRowKey(context, null);
+
+ if(dataTable instanceof UIDataTable) {
+ encodeCaption(writer, context, (UIDataTable)dataTable);
+ //TODO nick - do we need this element if "columnsWidth" is absent?
+ //TODO nick - use constants from HTML class for attribute/element names
+ writer.startElement("colgroup", dataTable);
+ int columns = getColumnsCount(dataTable);
- encodeCaption(writer, context, dataTable);
+ writer.writeAttribute(HTML.SPAN_ELEM, String.valueOf(columns), null);
+ String columnsWidth = (String)
dataTable.getAttributes().get("columnsWidth");
- //TODO nick - do we need this element if "columnsWidth" is absent?
- //TODO nick - use constants from HTML class for attribute/element names
- writer.startElement("colgroup", dataTable);
- int columns = getColumnsCount(dataTable);
-
- writer.writeAttribute(HTML.SPAN_ELEM, String.valueOf(columns), null);
- String columnsWidth = (String)
dataTable.getAttributes().get("columnsWidth");
-
- if (null != columnsWidth) {
- String[] widths = columnsWidth.split(",");
- for (int i = 0; i < widths.length; i++) {
- writer.startElement("col", dataTable);
- writer.writeAttribute("width", widths[i], null);
- writer.endElement("col");
- }
+ if (null != columnsWidth) {
+ String[] widths = columnsWidth.split(",");
+ for (int i = 0; i < widths.length; i++) {
+ writer.startElement("col", dataTable);
+ writer.writeAttribute("width", widths[i], null);
+ writer.endElement("col");
+ }
+ }
+ writer.endElement("colgroup");
+
}
- writer.endElement("colgroup");
- encodeHeader(writer, context, dataTable, columns);
- encodeFooter(writer, context, dataTable, columns);
+ encodeHeader(writer, context, dataTable);
+ encodeFooter(writer, context, dataTable);
dataTable.setRowKey(context, key);
dataTable.restoreOrigValue(context);
-
}
+
public void encodeRows(FacesContext context, UIDataTableBase dataTable) throws
IOException {
RowHolder holder = new RowHolder(dataTable);
@@ -98,6 +101,10 @@
childRowHolder.setCellClass(childRow.getCellSkinClass());
}
childRowHolder.setHeaderRow(rowHolder.isHeaderRow());
+
+ if(child instanceof UISubTable) {
+ encodeHeader(writer, context, (UISubTable)child);
+ }
encodeRows(context, childRow, childRowHolder);
} else if(child instanceof UIColumn) {
@@ -245,7 +252,7 @@
encodeStyleClass(writer, context, component, HTML.STYLE_CLASS_ATTR, styleClass);
}
- public void encodeCaption(ResponseWriter writer, FacesContext context, UIDataTableBase
dataTable) throws IOException {
+ public void encodeCaption(ResponseWriter writer, FacesContext context, UIDataTable
dataTable) throws IOException {
UIComponent caption = dataTable.getCaption();
@@ -275,78 +282,108 @@
writer.endElement(HTML.CAPTION_ELEMENT);
}
+
+ public void encodeFooter(ResponseWriter writer, FacesContext context, UIDataTableBase
dataTable) throws IOException {
- public void encodeFooter(ResponseWriter writer, FacesContext context, UIDataTableBase
dataTable, int columns) throws IOException {
-
Iterator<UIComponent> tableColumns = dataTable.columns();
UIComponent footer = dataTable.getFooter();
-
boolean columnFacetPresent = isColumnFacetPresent(dataTable, "footer");
-
+
if ((footer != null && footer.isRendered()) || columnFacetPresent) {
-
- writer.startElement(HTML.TFOOT_ELEMENT, dataTable);
+ boolean encodeTfoot = (dataTable instanceof UIDataTable);
+ String cellElement = HTML.TD_ELEM;
+
+ if(encodeTfoot) {
+ writer.startElement(HTML.TFOOT_ELEMENT, dataTable);
+ writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "rich-table-tfoot", null);
+ cellElement = HTML.TH_ELEM;
+ }
+
String footerClass = (String) dataTable.getAttributes().get("footerClass");
-
+ int columns = getColumnsCount(dataTable);
+
if (columnFacetPresent) {
writer.startElement(HTML.TR_ELEMENT, dataTable);
- encodeStyleClass(writer, context, dataTable, "footerClass",
"rich-table-subfooter");
- //TODO nick - use "th" instead of "td"?
- //TODO nick - rename method "encodeHeaderFacets"
- encodeHeaderFacets(context, writer, tableColumns,
"rich-table-subfootercell",
- footerClass, "footer", HTML.TD_ELEM, columns);
- writer.endElement(HTML.TR_ELEMENT);
+ encodeStyleClass(writer, context, dataTable, "footerClass",
dataTable.getColumnFooterSkinClass());
+ //TODO nick - rename method "encodeHeaderFacets"
+ encodeHeaderFacets(context, writer, tableColumns,
dataTable.getColumnFooterCellSkinClass(),
+ footerClass, "footer", cellElement, columns);
+ writer.endElement(HTML.TR_ELEMENT);
}
-
if (footer != null && footer.isRendered()) {
- //TODO nick - use "th" instead of "td"?
//TODO nick - rename method "encodeTableHeaderFacet"
encodeTableHeaderFacet(context, columns, writer, footer,
- "rich-table-footer",
- "rich-table-footer-continue",
- "rich-table-footercell",
- footerClass, HTML.TH_ELEM);
+ dataTable.getFooterFirstRowSkinClass(),
+ dataTable.getFooterRowSkinClass(),
+ dataTable.getFooterCellSkinClass(),
+ footerClass, cellElement);
}
-
- writer.endElement(HTML.TFOOT_ELEMENT);
- }
- }
+
+ if(encodeTfoot) {
+ writer.endElement(HTML.TFOOT_ELEMENT);
+ }
+ }
+
+ }
- public void encodeHeader(ResponseWriter writer, FacesContext context, UIDataTableBase
dataTable, int columns) throws IOException {
+ public void encodeHeader(ResponseWriter writer, FacesContext context, UIDataTableBase
dataTable) throws IOException {
UIComponent header = dataTable.getHeader();
- boolean isEncodeHeaders = isEncodeHeaders(dataTable);
-
+ boolean isEncodeHeaders = isEncodeHeaders(dataTable);
+
+ boolean encodeThead = (dataTable instanceof UIDataTable);
+
if ((header != null && header.isRendered()) || isEncodeHeaders) {
- writer.startElement(HTML.THEAD_ELEMENT, dataTable);
- writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "rich-table-thead", null);
-
+ String cellElement = HTML.TD_ELEM;
+
+ if(encodeThead) {
+ writer.startElement(HTML.THEAD_ELEMENT, dataTable);
+ writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "rich-table-thead", null);
+ cellElement = HTML.TH_ELEM;
+
+ }
+ // TODO anton - maybe we should have separate css class for column header???
String headerClass = (String) dataTable.getAttributes().get("headerClass");
-
+
+ int columns = getColumnsCount(dataTable);
+
if (header != null && header.isRendered()) {
- encodeTableHeaderFacet(context, columns, writer, header,
- "rich-table-header",
- //TODO nick - rename classes!!!
- "rich-table-header-continue",
- "rich-table-headercell",
- headerClass, HTML.TH_ELEM);
+
+ encodeTableHeaderFacet(context, columns, writer, header,
+ dataTable.getHeaderFirstRowSkinClass(),
+ dataTable.getHeaderRowSkinClass(),
+ dataTable.getHeaderCellSkinClass(),
+// "rich-table-header",
+ //TODO nick - rename classes!!!
+// "rich-table-header-continue",
+// "rich-table-headercell",
+ headerClass, cellElement);
}
if (isEncodeHeaders) {
writer.startElement(HTML.TR_ELEMENT, dataTable);
- encodeStyleClass(writer, context, dataTable, "headerClass",
"rich-table-subheader");
- encodeHeaderFacets(context, writer, dataTable.columns(),
"rich-table-subheadercell", headerClass, "header", HTML.TH_ELEM,
columns);
+ encodeStyleClass(writer, context, dataTable, "headerClass",
dataTable.getColumnHeaderSkinClass());//"rich-table-subheader");
+ encodeHeaderFacets(context, writer, dataTable.columns(),
dataTable.getColumnHeaderCellSkinClass()/*"rich-table-subheadercell"*/,
headerClass, "header", cellElement, columns);
writer.endElement(HTML.TR_ELEMENT);
}
-
- writer.endElement(HTML.THEAD_ELEMENT);
+
+ if(encodeThead) {
+ writer.endElement(HTML.THEAD_ELEMENT);
+ }
}
+
}
+ public void encodeSubTableHeader(ResponseWriter writer, FacesContext context,
UIDataTable table){
+ }
+
+ public void encodeSubTableFooter(ResponseWriter writer, FacesContext context,
UIDataTable table) {
+ }
+
protected void encodeTableHeaderFacet(FacesContext context, int columns,
ResponseWriter writer, UIComponent footer,
String skinFirstRowClass, String skinRowClass, String skinCellClass, String
footerClass, String element)
throws IOException {
@@ -383,6 +420,7 @@
if(columns > 0) {
writer.writeAttribute("colspan", String.valueOf(columns), null);
}
+
writer.writeAttribute("scope", "colgroup", null);
renderChild(context, footer);
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ElementEncodeListener.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ElementEncodeListener.java 2009-11-06
17:32:08 UTC (rev 15848)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ElementEncodeListener.java 2009-11-06
18:14:18 UTC (rev 15849)
@@ -34,10 +34,10 @@
public void encodeTableBodyEnd(ResponseWriter writer, FacesContext context,
UIDataTableBase dataTable) throws IOException;
- public void encodeCaption(ResponseWriter writer, FacesContext context, UIDataTableBase
dataTable) throws IOException;
+// public void encodeCaption(ResponseWriter writer, FacesContext context, UIDataTableBase
dataTable) throws IOException;
- public void encodeHeader(ResponseWriter writer, FacesContext context, UIDataTableBase
dataTable, int columns) throws IOException;
+ public void encodeHeader(ResponseWriter writer, FacesContext context, UIDataTableBase
dataTable) throws IOException;
- public void encodeFooter(ResponseWriter writer, FacesContext context, UIDataTableBase
dataTable, int columns) throws IOException;
+ public void encodeFooter(ResponseWriter writer, FacesContext context, UIDataTableBase
dataTable) throws IOException;
}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/table.css
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/table.css 2009-11-06
17:32:08 UTC (rev 15848)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/table.css 2009-11-06
18:14:18 UTC (rev 15849)
@@ -44,7 +44,7 @@
.rich-table-header-continue{
}
-.rich-table-headercell{
+.rich-table-header-cell{
border-bottom:1px solid #C0C0C0;
border-right:1px solid #C0C0C0;
color:#000000;
@@ -58,7 +58,7 @@
.rich-table-subheader{
}
-.rich-table-subheadercell{
+.rich-table-subheader-cell{
border-bottom:1px solid #C0C0C0;
border-right:1px solid #C0C0C0;
color:#00000;
@@ -67,7 +67,7 @@
padding:4px;
}
-.rich-table-subfootercell{
+.rich-table-subfooter-cell{
border-bottom:1px solid #C0C0C0;
border-right:1px solid #C0C0C0;
color:#00000;
@@ -86,7 +86,7 @@
.rich-table-footer-continue{
}
-.rich-table-footercell{
+.rich-table-footer-cell{
border-bottom:1px solid #C0C0C0;
border-right:1px solid #C0C0C0;
color:#000000;
@@ -100,9 +100,25 @@
.rich-subtable-footer{
}
-.rich-subtable-footercell{
+.rich-subtable-footer-cell{
+}
+
+.rich-subtable-header {
+ background-color: grey;
+
}
+
+.rich-subtable-header-cell {
+ border-bottom:1px solid #C0C0C0;
+ border-right:1px solid #C0C0C0;
+ color:#000000;
+ font-family:Arial,Verdana,sans-serif;
+ font-size:11px;
+ font-weight:bold;
+ padding:4px;
+ text-align:left;
+}
<?xml version="1.0" encoding="UTF-8"?>