Author: konstantin.mishin
Date: 2010-03-19 13:31:27 -0400 (Fri, 19 Mar 2010)
New Revision: 16637
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/renderkit/AbstractTableRenderer.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java
root/ui-sandbox/trunk/components/tables/ui/src/test/java/org/richfaces/component/UIDataTableBaseTest.java
Log:
RF-7865 change superclass of ExtendedDataTableRenderer
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 2010-03-19
14:50:31 UTC (rev 16636)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java 2010-03-19
17:31:27 UTC (rev 16637)
@@ -69,6 +69,16 @@
return getFacet("footer");
}
+ public boolean isColumnFacetPresent(String facetName) {
+ Iterator<UIComponent> columns = columns();
+ boolean result = false;
+ while (columns.hasNext() && !result) {
+ UIComponent component = columns.next();
+ result = (component.isRendered() && null !=
component.getFacet(facetName));
+ }
+ return result;
+ }
+
@Override
public boolean getRendersChildren() {
return true;
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2010-03-19
14:50:31 UTC (rev 16636)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2010-03-19
17:31:27 UTC (rev 16637)
@@ -28,17 +28,6 @@
public static final String SORTING = "sorting";
- public boolean isColumnFacetPresent(UIDataTableBase table, String facetName) {
- Iterator<UIComponent> columns = table.columns();
- boolean result = false;
- while (columns.hasNext() && !result) {
- UIComponent component = columns.next();
- //TODO nick - only rendered facets should be handled
- result = (component.isRendered() && null !=
component.getFacet(facetName));
- }
- return result;
- }
-
/**
* Returns true if specified attribute (when present on the column) should generate
header even if it is not
* specified on the table
@@ -61,7 +50,7 @@
}
protected boolean isEncodeHeaders(UIDataTableBase table) {
- return isColumnFacetPresent(table, "header") ||
isHeaderFactoryColumnAttributePresent(table, "sortBy")
+ return table.isColumnFacetPresent("header") ||
isHeaderFactoryColumnAttributePresent(table, "sortBy")
|| isHeaderFactoryColumnAttributePresent(table, "comparator")
|| isHeaderFactoryColumnAttributePresent(table, "filterBy");
}
@@ -211,7 +200,7 @@
public void encodeFooterFacet(ResponseWriter writer, FacesContext context,
UIDataTableBase dataTable) throws IOException {
UIComponent footer = dataTable.getFooter();
- boolean columnFacetPresent = isColumnFacetPresent(dataTable,
"footer");
+ boolean columnFacetPresent = dataTable.isColumnFacetPresent("footer");
if ((footer != null && footer.isRendered()) || columnFacetPresent) {
boolean encodeTfoot = containsThead();
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java 2010-03-19
14:50:31 UTC (rev 16636)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java 2010-03-19
17:31:27 UTC (rev 16637)
@@ -42,23 +42,23 @@
import org.ajax4jsf.javascript.JSReference;
import org.ajax4jsf.renderkit.AjaxEventOptions;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
-import org.richfaces.component.UIDataTableBase;
+import org.richfaces.component.UIExtendedDataTable;
import org.richfaces.component.util.HtmlUtil;
@ResourceDependencies({ @ResourceDependency(library = "javax.faces", name =
"jsf.js"),
@ResourceDependency(name = "jquery.js"), @ResourceDependency(name =
"jquery.position.js"),
@ResourceDependency(name = "richfaces.js"), @ResourceDependency(name =
"extendedDataTable.js"),
@ResourceDependency(name = "extendedDataTable.css") })
-public class ExtendedDataTableRenderer extends AbstractTableRenderer {
+public class ExtendedDataTableRenderer extends AbstractRowsRenderer{
private class RendererState extends RowHolderBase {
- private UIDataTableBase table;
+ private UIExtendedDataTable table;
private List<UIComponent> frozenColumns;
private List<UIComponent> columns;
private boolean frozen;
- public RendererState(FacesContext context, UIDataTableBase table) {
+ public RendererState(FacesContext context, UIExtendedDataTable table) {
super(context);
this.table = table;
columns = new ArrayList<UIComponent>();
@@ -81,21 +81,12 @@
for (; iterator.hasNext();) {
columns.add(iterator.next());
}
- int count = getFrozenColumnsCount();
+ int count = Math.min(((Integer)
table.getAttributes().get("frozenColumns")).intValue(), columns.size());
frozenColumns = columns.subList(0, count);
columns = columns.subList(count, columns.size());
}
- private int getFrozenColumnsCount() {
- int count = ((Integer)
table.getAttributes().get("frozenColumns")).intValue();
- int columnsCount = getColumnsCount(table);
- if (count > columnsCount) {
- count = columnsCount;
- }
- return count;
- }
-
- public UIDataTableBase getRow() {
+ public UIExtendedDataTable getRow() {
return table;
}
@@ -118,7 +109,7 @@
@Override
protected Class<? extends UIComponent> getComponentClass() {
- return UIDataTableBase.class;
+ return UIExtendedDataTable.class;
}
@Override
@@ -137,14 +128,20 @@
}
}
+
@Override
+ public RendererState createRowHolder(FacesContext context, UIComponent component) {
+ return new RendererState(context, (UIExtendedDataTable) component);
+ }
+
+ @Override
protected void doEncodeChildren(ResponseWriter writer, FacesContext context,
UIComponent component)
throws IOException {
- UIDataTableBase table = (UIDataTableBase) component;
+ UIExtendedDataTable table = (UIExtendedDataTable) component;
Object key = table.getRowKey();
table.captureOrigValue(context);
table.setRowKey(context, null);
- RendererState state = new RendererState(context, table);
+ RendererState state = createRowHolder(context, table);
encodeStyle(state);
encodeHeaderOrFooter(state, "header");
encodeBody(state);
@@ -215,7 +212,7 @@
private void encodeStyle(RendererState state) throws IOException {
FacesContext context = state.getContext();
ResponseWriter writer = context.getResponseWriter();
- UIDataTableBase table = state.getRow();
+ UIExtendedDataTable table = state.getRow();
writer.startElement("style", table);
writer.writeAttribute(HTML.TYPE_ATTR, "text/css", null);
writer.writeText(".rich-extable-part-width{", null); // TODO
getNormalizedId(context, state.getGrid())
@@ -241,8 +238,8 @@
private void encodeHeaderOrFooter(RendererState state, String name) throws
IOException {
FacesContext context = state.getContext();
ResponseWriter writer = context.getResponseWriter();
- UIDataTableBase table = state.getRow();
- if (isColumnFacetPresent(table, name)) {
+ UIExtendedDataTable table = state.getRow();
+ if (table.isColumnFacetPresent(name)) {
writer.startElement(HTML.DIV_ELEM, table);
writer.writeAttribute(HTML.CLASS_ATTRIBUTE,
HtmlUtil.concatClasses("rich-extable-" + name, (String) table
.getAttributes().get(name + "Class")), null);
@@ -295,7 +292,7 @@
private void encodeBody(RendererState state) throws IOException {
FacesContext context = state.getContext();
ResponseWriter writer = context.getResponseWriter();
- UIDataTableBase table = state.getRow();
+ UIExtendedDataTable table = state.getRow();
writer.startElement(HTML.DIV_ELEM, table);
writer.writeAttribute(HTML.ID_ATTRIBUTE, table.getClientId(context) +
":b", null);
writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "rich-extable-body",
null);
@@ -311,9 +308,6 @@
}
} else {
writer.startElement(HTML.DIV_ELEM, table);
- // writer.startElement(HTML.DIV_ELEM, table); TODO
- // writer.write(" ");
- // writer.endElement(HTML.DIV_ELEM);
writer.startElement(HTML.TABLE_ELEMENT, table);
writer.writeAttribute(HTML.CELLPADDING_ATTRIBUTE, "0", null);
writer.writeAttribute(HTML.CELLSPACING_ATTRIBUTE, "0", null);
@@ -383,7 +377,7 @@
FacesContext context = rowHolder.getContext();
ResponseWriter writer = context.getResponseWriter();
RendererState state = (RendererState) rowHolder;
- UIDataTableBase table = state.getRow();
+ UIExtendedDataTable table = state.getRow();
writer.startElement(HTML.TR_ELEMENT, table);
Iterator<UIComponent> columns = null;
if (state.isFrozen()) {
@@ -453,131 +447,4 @@
}
return width;
}
-
-
-
- @Override
- public void encodeTableStructure(ResponseWriter writer, FacesContext context,
UIDataTableBase dataTable)
- throws IOException {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public RowHolder createRowHolder(FacesContext context, UIComponent component) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public boolean containsThead() {
- return false;
- }
-
- @Override
- public HeaderEncodeStrategy getHeaderEncodeStrategy(UIComponent column, String
tableFacetName) {
- return null;
- }
-
- @Override
- public void encodeClientScript(ResponseWriter writer, FacesContext context,
UIDataTableBase component) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public String getCellSkinClass() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String getColumnFooterCellSkinClass() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String getColumnFooterFirstSkinClass() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String getColumnFooterSkinClass() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String getColumnHeaderCellSkinClass() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String getColumnHeaderFirstSkinClass() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String getColumnHeaderSkinClass() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String getFirstRowSkinClass() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String getFooterCellSkinClass() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String getFooterFirstSkinClass() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String getFooterSkinClass() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String getHeaderCellSkinClass() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String getHeaderFirstSkinClass() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String getHeaderSkinClass() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String getRowSkinClass() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String getTableSkinClass() {
- // TODO Auto-generated method stub
- return null;
- }
}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/test/java/org/richfaces/component/UIDataTableBaseTest.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/test/java/org/richfaces/component/UIDataTableBaseTest.java 2010-03-19
14:50:31 UTC (rev 16636)
+++
root/ui-sandbox/trunk/components/tables/ui/src/test/java/org/richfaces/component/UIDataTableBaseTest.java 2010-03-19
17:31:27 UTC (rev 16637)
@@ -255,4 +255,22 @@
table.setSortMode(SortMode.multi);
Assert.assertEquals(SortMode.multi, table.getSortMode());
}
+
+ /**
+ * Test method for {@link
org.richfaces.component.UIDataTableBase#isColumnFacetPresent(java.lang.String)}.
+ */
+ @Test
+ public void testIsColumnFacetPresent() {
+ String facetName = "header";
+ Assert.assertFalse(table.isColumnFacetPresent(facetName));
+ UIColumn child = new UIColumn();
+ List<UIComponent> children = table.getChildren();
+ children.add(new UIColumn());
+ children.add(child);
+ Assert.assertFalse(table.isColumnFacetPresent(facetName));
+ child.getFacets().put(facetName, new UIOutput());
+ Assert.assertTrue(table.isColumnFacetPresent(facetName));
+ child.setRendered(false);
+ Assert.assertFalse(table.isColumnFacetPresent(facetName));
+ }
}