Author: alexsmirnov
Date: 2008-03-28 19:23:36 -0400 (Fri, 28 Mar 2008)
New Revision: 7397
Added:
trunk/ui/dataTable/src/main/java/org/richfaces/component/ColumnsIterator.java
trunk/ui/dataTable/src/main/java/org/richfaces/component/DataIterator.java
trunk/ui/dataTable/src/main/java/org/richfaces/component/FixedChildrenIterator.java
Removed:
trunk/ui/dataTable/src/main/java/org/richfaces/component/Row.java
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/component/UIDataAdaptor.java
trunk/ui/dataTable/src/main/java/org/richfaces/component/UIColumnGroup.java
trunk/ui/dataTable/src/main/java/org/richfaces/component/UIDataTable.java
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/html/SubTableRenderer.java
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/html/iconimages/DataTableIconSortNone.java
trunk/ui/dataTable/src/test/java/org/richfaces/component/DataTableComponentTest.java
Log:
fix
http://jira.jboss.com/jira/browse/RF-2490
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/component/UIDataAdaptor.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/component/UIDataAdaptor.java 2008-03-28
20:33:36 UTC (rev 7396)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/component/UIDataAdaptor.java 2008-03-28
23:23:36 UTC (rev 7397)
@@ -97,8 +97,15 @@
if (isRowAvailable()) {
Iterator<UIComponent> childIterator = dataChildren();
while (childIterator.hasNext()) {
- UIComponent component = (UIComponent) childIterator.next();
- processComponent(context, component, argument);
+ UIComponent component = childIterator.next();
+ // Special case for a Standard UIColumn component.
+ if (component instanceof UIColumn ) {
+ for (UIComponent child : component.getChildren() ) {
+ processComponent(context, child, argument);
+ }
+ } else {
+ processComponent(context, component, argument);
+ }
}
}
@@ -116,14 +123,7 @@
public void processComponent(FacesContext context, UIComponent c,
Object argument) {
- if (c instanceof UIColumn || c instanceof Column) {
- for (Iterator<UIComponent> children = c.getChildren().iterator();
children.hasNext(); ) {
- UIComponent child = (UIComponent) children.next();
- child.processDecodes(context);;
- }
- } else {
c.processDecodes(context);
- }
}
};
@@ -135,14 +135,7 @@
public void processComponent(FacesContext context, UIComponent c,
Object argument) {
- if (c instanceof UIColumn || c instanceof Column) {
- for (Iterator<UIComponent> children = c.getChildren().iterator();
children.hasNext(); ) {
- UIComponent child = (UIComponent) children.next();
- child.processValidators(context);
- }
- } else {
c.processValidators(context);
- }
}
};
@@ -154,14 +147,7 @@
public void processComponent(FacesContext context, UIComponent c,
Object argument) {
- if (c instanceof UIColumn || c instanceof Column) {
- for (Iterator<UIComponent> children = c.getChildren().iterator();
children.hasNext(); ) {
- UIComponent child = (UIComponent) children.next();
- child.processUpdates(context);
- }
- } else {
c.processUpdates(context);
- }
}
};
Added: trunk/ui/dataTable/src/main/java/org/richfaces/component/ColumnsIterator.java
===================================================================
--- trunk/ui/dataTable/src/main/java/org/richfaces/component/ColumnsIterator.java
(rev 0)
+++
trunk/ui/dataTable/src/main/java/org/richfaces/component/ColumnsIterator.java 2008-03-28
23:23:36 UTC (rev 7397)
@@ -0,0 +1,60 @@
+package org.richfaces.component;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+import javax.faces.component.UIColumn;
+import javax.faces.component.UIComponent;
+
+/**
+ * Iterator for all children table columns.
+ * @author asmirnov
+ *
+ */
+class ColumnsIterator implements Iterator<UIComponent>{
+
+
+ private UIComponent next;
+
+ private boolean initialized = false;
+
+ protected Iterator<UIComponent> childrenIterator;
+
+ public ColumnsIterator(UIComponent dataTable) {
+ this.childrenIterator = dataTable.getChildren().iterator();
+ }
+
+ public boolean hasNext() {
+ if(!initialized){
+ next = nextColumn();
+ initialized = true;
+ }
+ return null != next;
+ }
+
+ public UIComponent next() {
+ if (!hasNext()) {
+ throw new NoSuchElementException();
+ }
+ UIComponent result = next;
+ next = nextColumn();
+ return result;
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException("Iterator is read-only");
+ }
+
+ protected UIComponent nextColumn(){
+ UIComponent nextColumn = null;
+ while (childrenIterator.hasNext()) {
+ UIComponent child = childrenIterator.next();
+ if(child instanceof UIColumn || child instanceof Column){
+ nextColumn = child;
+ break;
+ }
+ }
+ return nextColumn;
+ }
+
+}
\ No newline at end of file
Property changes on:
trunk/ui/dataTable/src/main/java/org/richfaces/component/ColumnsIterator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Revision Author
Added: trunk/ui/dataTable/src/main/java/org/richfaces/component/DataIterator.java
===================================================================
--- trunk/ui/dataTable/src/main/java/org/richfaces/component/DataIterator.java
(rev 0)
+++ trunk/ui/dataTable/src/main/java/org/richfaces/component/DataIterator.java 2008-03-28
23:23:36 UTC (rev 7397)
@@ -0,0 +1,65 @@
+/**
+ *
+ */
+package org.richfaces.component;
+
+import java.util.Iterator;
+
+import javax.faces.component.UIColumn;
+import javax.faces.component.UIComponent;
+
+import org.ajax4jsf.component.AjaxSupport;
+
+class DataIterator extends ColumnsIterator {
+
+ protected Iterator<UIComponent> facetsIterator;
+
+ public DataIterator(UIComponent dataTable) {
+ super(dataTable);
+ facetsIterator = dataTable.getFacets().values().iterator();
+ }
+
+ @Override
+ protected UIComponent nextColumn() {
+ UIComponent nextColumn = null;
+ while (childrenIterator.hasNext()) {
+ UIComponent child = childrenIterator.next();
+ if (child.isRendered()) {
+ if (child instanceof UIColumn || child instanceof Column) {
+ nextColumn = child;
+ break;
+ } else if (checkAjaxComponent(child)) {
+ nextColumn = child;
+ break;
+ }
+ }
+ }
+ if (null == nextColumn) {
+ while (facetsIterator.hasNext()) {
+ UIComponent child = facetsIterator.next();
+ if (checkAjaxComponent(child)) {
+ nextColumn = child;
+ break;
+ }
+ }
+ }
+ return nextColumn;
+ }
+
+ /**
+ * @param child
+ * @return
+ */
+ protected Iterator<UIComponent> getColumnChildrenIterator(UIComponent child) {
+ return child.getChildren().iterator();
+ }
+
+ /**
+ * @param child
+ * @return
+ */
+ protected boolean checkAjaxComponent(UIComponent child) {
+ return child instanceof AjaxSupport || child instanceof Dropzone;
+ }
+
+}
\ No newline at end of file
Property changes on:
trunk/ui/dataTable/src/main/java/org/richfaces/component/DataIterator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Revision Author
Added:
trunk/ui/dataTable/src/main/java/org/richfaces/component/FixedChildrenIterator.java
===================================================================
--- trunk/ui/dataTable/src/main/java/org/richfaces/component/FixedChildrenIterator.java
(rev 0)
+++
trunk/ui/dataTable/src/main/java/org/richfaces/component/FixedChildrenIterator.java 2008-03-28
23:23:36 UTC (rev 7397)
@@ -0,0 +1,82 @@
+/**
+ *
+ */
+package org.richfaces.component;
+
+import java.util.Iterator;
+
+import javax.faces.component.UIColumn;
+import javax.faces.component.UIComponent;
+
+class FixedChildrenIterator extends DataIterator {
+
+ private Iterator<UIComponent> currentColumnIterator;
+
+
+ public FixedChildrenIterator(UIComponent dataTable) {
+ super(dataTable);
+ }
+
+ @Override
+ protected UIComponent nextColumn() {
+ UIComponent nextColumn = null;
+ if(null != currentColumnIterator){
+ nextColumn = currentColumnIterator.next();
+ checkNextColumnChild();
+ } else {
+ while (childrenIterator.hasNext()) {
+ UIComponent child = childrenIterator.next();
+ if ( child instanceof UIColumn || child instanceof Column ) {
+ boolean rendered = true;
+ try {
+ rendered = child.isRendered();
+ } catch (Exception e) {
+ // This exception can be thrown for a header/footer facets
+ // there column rendered attribute was binded to a row variable.
+ }
+ if (rendered) {
+ Iterator<UIComponent> iterator = getColumnChildrenIterator(child);
+ if (iterator.hasNext()) {
+ currentColumnIterator = iterator;
+ nextColumn = currentColumnIterator.next();
+ checkNextColumnChild();
+ break;
+ }
+
+ }
+ } else if (checkAjaxComponent(child)) {
+ nextColumn = child;
+ break;
+ }
+ }
+ }
+ if(null == nextColumn){
+ while (facetsIterator.hasNext()) {
+ UIComponent child = facetsIterator.next();
+ if(checkAjaxComponent(child)){
+ nextColumn = child;
+ break;
+ }
+ }
+ }
+ return nextColumn;
+ }
+
+ @Override
+ protected boolean checkAjaxComponent(UIComponent child) {
+ return !super.checkAjaxComponent(child);
+ }
+
+ @Override
+ protected Iterator<UIComponent> getColumnChildrenIterator(
+ UIComponent child) {
+ return child.getFacets().values().iterator();
+ }
+
+ protected void checkNextColumnChild() {
+ if(!currentColumnIterator.hasNext()){
+ currentColumnIterator = null;
+ }
+ }
+
+}
\ No newline at end of file
Property changes on:
trunk/ui/dataTable/src/main/java/org/richfaces/component/FixedChildrenIterator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Revision Author
Deleted: trunk/ui/dataTable/src/main/java/org/richfaces/component/Row.java
===================================================================
--- trunk/ui/dataTable/src/main/java/org/richfaces/component/Row.java 2008-03-28 20:33:36
UTC (rev 7396)
+++ trunk/ui/dataTable/src/main/java/org/richfaces/component/Row.java 2008-03-28 23:23:36
UTC (rev 7397)
@@ -1,41 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component;
-
-import java.util.Iterator;
-
-import javax.faces.component.UIComponent;
-
-/**
- * Marker interface for table columns, rendered as entire row.
- * @author shura
- *
- */
-public interface Row extends Column {
-
- /**
- * Get iterator for all columns contained in this row.
- * @return
- */
- public Iterator<UIComponent> columns();
-
-}
\ No newline at end of file
Modified: trunk/ui/dataTable/src/main/java/org/richfaces/component/UIColumnGroup.java
===================================================================
--- trunk/ui/dataTable/src/main/java/org/richfaces/component/UIColumnGroup.java 2008-03-28
20:33:36 UTC (rev 7396)
+++ trunk/ui/dataTable/src/main/java/org/richfaces/component/UIColumnGroup.java 2008-03-28
23:23:36 UTC (rev 7397)
@@ -40,7 +40,7 @@
@SuppressWarnings("unchecked")
public Iterator<UIComponent> columns(){
- return new FilterIterator(getChildren().iterator(),UIDataTable.isColumn);
+ return new ColumnsIterator(this);
}
/* (non-Javadoc)
Modified: trunk/ui/dataTable/src/main/java/org/richfaces/component/UIDataTable.java
===================================================================
--- trunk/ui/dataTable/src/main/java/org/richfaces/component/UIDataTable.java 2008-03-28
20:33:36 UTC (rev 7396)
+++ trunk/ui/dataTable/src/main/java/org/richfaces/component/UIDataTable.java 2008-03-28
23:23:36 UTC (rev 7397)
@@ -33,16 +33,11 @@
import javax.el.ELException;
import javax.el.ValueExpression;
import javax.faces.FacesException;
-import javax.faces.component.UIColumn;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
-import org.ajax4jsf.component.AjaxSupport;
import org.ajax4jsf.component.SequenceDataAdaptor;
import org.ajax4jsf.model.ExtendedDataModel;
-import org.apache.commons.collections.Predicate;
-import org.apache.commons.collections.iterators.FilterIterator;
-import org.apache.commons.collections.iterators.IteratorChain;
import org.richfaces.model.FilterField;
import org.richfaces.model.ModifiableModel;
import org.richfaces.model.SortField2;
@@ -56,50 +51,7 @@
Collection<Object> sortPriority = new ArrayList<Object>();
- /**
- * @author shura
- *
- */
- private static final class NotColumnPredicate implements Predicate {
- public boolean evaluate(Object input) {
- return !(input instanceof UIColumn || input instanceof Column);
- }
- }
-
- /**
- * @author shura
- *
- */
- private static final class ColumnPredicate implements Predicate {
- public boolean evaluate(Object input) {
-// if (input instanceof UIComponent) {
-// UIComponent component = (UIComponent) input;
-//
-// if (!component.isRendered()) {
-// return false;
-// }
-// }
-//
- return (input instanceof UIColumn || input instanceof Column);
- }
- }
-
- /**
- * @author shura
- *
- */
- private static final class AjaxSupportPredicate implements Predicate {
- public boolean evaluate(Object input) {
- return (input instanceof AjaxSupport || input instanceof Dropzone);
- }
- }
-
- public static final Predicate isColumn = new ColumnPredicate();
-
- public static final Predicate isNotColumn = new NotColumnPredicate();
-
- public static final Predicate isAjaxSupport = new AjaxSupportPredicate();
-
+
/*
* (non-Javadoc)
*
@@ -107,28 +59,8 @@
*/
@SuppressWarnings("unchecked")
public Iterator<UIComponent> dataChildren() {
- IteratorChain dataChildren = new IteratorChain();
- dataChildren.addIterator(new FilterIterator(getFacets().values()
- .iterator(), isAjaxSupport));
-
-
- // Append all columns children.
- dataChildren.addIterator(columns());
-
-// for (Iterator iter = columns(); iter.hasNext();) {
-// UIComponent column = (UIComponent) iter.next();
-// if (column.isRendered()) {
-// dataChildren.addIterator(column.getChildren()
-// .iterator());
-//
-// }
-// }
-
- //commons-collections 2.x bug workaround
- dataChildren.hasNext();
-
- return dataChildren;
+ return new DataIterator(this);
}
/*
@@ -138,29 +70,13 @@
*/
@SuppressWarnings("unchecked")
public Iterator<UIComponent> fixedChildren() {
- // Iterate over facets, non-column childrens and column's facets.
- IteratorChain fixedChildren = new IteratorChain(getFacets().values().iterator());
- fixedChildren.addIterator(new FilterIterator(getChildren().iterator(),
- isNotColumn));
- // Append all columns facets.
- for (Iterator<UIComponent> iter = columns(); iter.hasNext();) {
- UIComponent column = (UIComponent) iter.next();
- if (column.isRendered()) {
- fixedChildren.addIterator(column.getFacets().values()
- .iterator());
-
- }
- }
- //commons-collections 2.x bug workaround
- fixedChildren.hasNext();
-
- return fixedChildren;
+ return new FixedChildrenIterator(this);
}
@SuppressWarnings("unchecked")
public Iterator<UIComponent> columns() {
- return new FilterIterator(getChildren().iterator(), isColumn);
+ return new ColumnsIterator(this);
}
public static final String COMPONENT_TYPE = "org.richfaces.DataTable";
@@ -256,4 +172,6 @@
super.restoreState(context, states[0]);
sortPriority = (Collection<Object>)states[1];
}
+
+
}
\ No newline at end of file
Modified:
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
===================================================================
---
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2008-03-28
20:33:36 UTC (rev 7396)
+++
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2008-03-28
23:23:36 UTC (rev 7397)
@@ -93,35 +93,34 @@
}
public void encodeHeader(FacesContext context, UIDataTable table,
- int columns) throws IOException {
+ int numberOfColumns) throws IOException {
ResponseWriter writer = context.getResponseWriter();
UIComponent header = table.getHeader();
- Iterator<UIComponent> headers = columnFacets(table,"header");
+ boolean columnFacetPresent = isColumnFacetPresent(table, "header");
Iterator<UIComponent> colums = table.columns();
- int colCount = calculateRowColumns(table.columns());
- if (header != null ||headers.hasNext()) {
+ if (header != null ||columnFacetPresent) {
writer.startElement("thead", table);
writer.writeAttribute(HTML.class_ATTRIBUTE, "dr-table-thead", null);
String headerClass = (String) table.getAttributes().get(
"headerClass");
if (header != null) {
- encodeTableHeaderFacet(context, columns, writer, header,
+ encodeTableHeaderFacet(context, numberOfColumns, writer, header,
"dr-table-header rich-table-header",
"dr-table-header-continue rich-table-header-continue",
"dr-table-headercell rich-table-headercell",
headerClass, "th");
}
- if (headers.hasNext()) {
+ if (columnFacetPresent) {
writer.startElement("tr", table);
encodeStyleClass(writer, null,
"dr-table-subheader rich-table-subheader", null,
headerClass);
encodeHeaderFacets(context, writer, colums,
"dr-table-subheadercell rich-table-subheadercell",
- headerClass, "header", "th", colCount);
+ headerClass, "header", "th", numberOfColumns);
writer.endElement("tr");
}
@@ -129,56 +128,91 @@
}
}
- public boolean findFacet(UIDataTable table, String facetName) {
- return columnFacets(table,facetName).hasNext();
+ public boolean isColumnFacetPresent(UIDataTable table, String facetName) {
+ Iterator<UIComponent> columns = table.columns();
+ boolean result = false;
+ while(columns.hasNext() && !result) {
+ UIComponent component = columns.next();
+ if(isColumnRendered(component)){
+ if(null != component.getFacet(facetName)){
+ result = true;
+ } /*else if(component instanceof Column) {
+ Column column = (Column)component;
+ result = column.isSelfSorted();
+ }*/
+ }
+ }
+ return result;
}
+
+ /**
+ * @param component
+ * @return
+ */
+ protected boolean isColumnRendered(UIComponent component) {
+ boolean rendered = true;
+ try {
+ rendered = component.isRendered();
+ } catch(Exception e){
+ // DO nothing, rendered binded to row variable;
+ }
+ return rendered;
+ }
protected void encodeHeaderFacets(FacesContext context,
- ResponseWriter writer, Iterator<UIComponent> headers, String skinCellClass,
- String headerClass, String facetName, String element, int colCount)
- throws IOException {
+ ResponseWriter writer, Iterator<UIComponent> headers,
+ String skinCellClass, String headerClass, String facetName,
+ String element, int colCount) throws IOException {
int t_colCount = 0;
-
+
HeaderEncodeStrategy richEncodeStrategy = new RichHeaderEncodeStrategy();
HeaderEncodeStrategy simpleEncodeStrategy = new SimpleHeaderEncodeStrategy();
-
+
while (headers.hasNext()) {
UIComponent column = (UIComponent) headers.next();
- if((Integer)column.getAttributes().get("colspan")!=null){
- t_colCount = t_colCount +
((Integer)column.getAttributes().get("colspan")).intValue();
- }else{
- t_colCount++;
- }
- if(t_colCount>colCount){
- break;
+ if (isColumnRendered(column)) {
+ if ((Integer) column.getAttributes().get("colspan") != null) {
+ t_colCount = t_colCount
+ + ((Integer) column.getAttributes().get("colspan"))
+ .intValue();
+ } else {
+ t_colCount++;
+ }
+ if (t_colCount > colCount) {
+ break;
+ }
+
+ String classAttribute = facetName + "Class";
+ String columnHeaderClass = (String) column.getAttributes().get(
+ classAttribute);
+ writer.startElement(element, column);
+ encodeStyleClass(writer, null, skinCellClass, headerClass,
+ columnHeaderClass);
+ writer.writeAttribute("scope", "col", null);
+ getUtils().encodeAttribute(context, column, "colspan");
+
+ boolean sortableColumn = column
+ .getValueExpression("comparator") != null
+ || column.getValueExpression("sortBy") != null;
+
+ HeaderEncodeStrategy strategy = (column instanceof org.richfaces.component.UIColumn
&& "header"
+ .equals(facetName)) ? richEncodeStrategy
+ : simpleEncodeStrategy;
+
+ strategy.encodeBegin(context, writer, column, facetName,
+ sortableColumn);
+
+ UIComponent facet = column.getFacet(facetName);
+ if (facet != null && isColumnRendered(facet)) {
+ renderChild(context, facet);
+ }
+
+ strategy.encodeEnd(context, writer, column, facetName,
+ sortableColumn);
+
+ writer.endElement(element);
+
}
-
- String classAttribute = facetName + "Class";
- String columnHeaderClass = (String) column.getAttributes().get(
- classAttribute);
- writer.startElement(element, column);
- encodeStyleClass(writer, null, skinCellClass, headerClass,
- columnHeaderClass);
- writer.writeAttribute("scope", "col", null);
- getUtils().encodeAttribute(context, column, "colspan");
-
- boolean sortableColumn = column.getValueExpression("comparator") != null
- || column.getValueExpression("sortBy") != null;
-
- HeaderEncodeStrategy strategy = (column instanceof org.richfaces.component.UIColumn
- && "header".equals(facetName)) ? richEncodeStrategy :
simpleEncodeStrategy;
-
- strategy.encodeBegin(context, writer, column, facetName, sortableColumn);
-
- UIComponent facet = column.getFacet(facetName);
- if (facet != null) {
- renderChild(context, facet);
- }
-
- strategy.encodeEnd(context, writer, column, facetName, sortableColumn);
-
- writer.endElement(element);
-
}
}
@@ -187,15 +221,14 @@
int columns) throws IOException {
ResponseWriter writer = context.getResponseWriter();
UIComponent footer = table.getFooter();
- Iterator<UIComponent> footers = columnFacets(table,"footer");
+ boolean columnFacetPresent = isColumnFacetPresent(table,"footer");
Iterator<UIComponent> tableColumns =
table.columns();//columnFacets(table,"footer");
- int colCount = calculateRowColumns(table.columns());
- if (footer != null || footers.hasNext()) {
+ if (footer != null || columnFacetPresent) {
writer.startElement("tfoot", table);
String footerClass = (String) table.getAttributes().get(
"footerClass");
- if (footers.hasNext()&&findFacet(table,"footer")) {
+ if (columnFacetPresent) {
writer.startElement("tr", table);
encodeStyleClass(writer, null,
"dr-table-subfooter rich-table-subfooter", null,
@@ -203,7 +236,7 @@
encodeHeaderFacets(context, writer, tableColumns,
"dr-table-subfootercell rich-table-subfootercell",
- footerClass, "footer", "td",colCount);
+ footerClass, "footer", "td",columns);
writer.endElement("tr");
}
@@ -318,30 +351,6 @@
encodeRowEvents(context, table);
}
- /*
- * protected Iterator columnFacets(UIDataTable table) { return
- * table.columns();
- *
- * Changed by Alexej Kushunin
- */
- @SuppressWarnings("unchecked")
- protected Iterator<UIComponent> columnFacets(UIDataTable table,final String
name){
- return new FilterIterator(table.columns(), new Predicate() {
-
- public boolean evaluate(Object input) {
- UIComponent component = (UIComponent) input;
- // accept only columns with corresponding facets.
- boolean ret = component.isRendered()&&(component.getFacet(name) != null);
- if (!ret && component instanceof Column) {
- Column column = (Column)component;
- ret = column.isSelfSorted() || (column.getFilterMethod() == null
- && component.getValueExpression("filterExpression") == null
- && component.getValueExpression("filterBy") != null);
- }
- return ret;
- }});
- }
-
/**
* Calculate total number of columns in table.
*
@@ -490,7 +499,7 @@
throws IOException {
super.encodeEnd(context, component);
String clientId = component.getClientId(context);
- Set ajaxRenderedAreas = AjaxContext.getCurrentInstance().getAjaxRenderedAreas();
+ Set<String> ajaxRenderedAreas =
AjaxContext.getCurrentInstance().getAjaxRenderedAreas();
if(ajaxRenderedAreas.contains(clientId+ ":tb")) {
ajaxRenderedAreas.remove(clientId);
}
Modified:
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/html/SubTableRenderer.java
===================================================================
---
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/html/SubTableRenderer.java 2008-03-28
20:33:36 UTC (rev 7396)
+++
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/html/SubTableRenderer.java 2008-03-28
23:23:36 UTC (rev 7397)
@@ -61,11 +61,10 @@
private void encodeHeaderRow(ResponseWriter writer, FacesContext context, UIComponent
component,String facetName) throws IOException {
UIDataTable dataTable = (UIDataTable) component;
Iterator<UIComponent> columns =
dataTable.columns();//columnFacets(dataTable,facetName);
- Iterator<UIComponent> headers = columnFacets(dataTable,facetName);
- int colCount = calculateRowColumns(dataTable.columns());
+ int colCount = getColumnsCount(dataTable);
String headerClass = (String) component.getAttributes().get(
facetName+"Class");
- if (headers.hasNext()) {
+ if (isColumnFacetPresent(dataTable, facetName)) {
writer.startElement(HTML.TR_ELEMENT, dataTable);
encodeStyleClass(writer, null, "dr-subtable-"+facetName+"
rich-subtable-"+facetName, null, headerClass);
encodeHeaderFacets(context, writer, columns,
"dr-subtable-"+facetName+"cell
rich-subtable-"+facetName+"cell", headerClass,
Modified:
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/html/iconimages/DataTableIconSortNone.java
===================================================================
---
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/html/iconimages/DataTableIconSortNone.java 2008-03-28
20:33:36 UTC (rev 7396)
+++
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/html/iconimages/DataTableIconSortNone.java 2008-03-28
23:23:36 UTC (rev 7397)
@@ -24,8 +24,6 @@
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-import java.awt.geom.GeneralPath;
import org.ajax4jsf.resource.ResourceContext;
import org.richfaces.renderkit.html.images.TriangleIconBase;
Modified:
trunk/ui/dataTable/src/test/java/org/richfaces/component/DataTableComponentTest.java
===================================================================
---
trunk/ui/dataTable/src/test/java/org/richfaces/component/DataTableComponentTest.java 2008-03-28
20:33:36 UTC (rev 7396)
+++
trunk/ui/dataTable/src/test/java/org/richfaces/component/DataTableComponentTest.java 2008-03-28
23:23:36 UTC (rev 7397)
@@ -227,31 +227,6 @@
}
}
- /**
- * Test for Predicate classes of UIDataTable class.
- *
- * @throws Exception
- */
- public void testPredicates() throws Exception {
-
- Predicate columnPredicate = UIDataTable.isColumn;
- Predicate notColumnPredicate = UIDataTable.isNotColumn;
- Predicate ajaxSupportPredicate = UIDataTable.isAjaxSupport;
-
- UIComponent notColumn = createComponent(HtmlOutputText.COMPONENT_TYPE,
- HtmlOutputText.class.getName(), null, null, null);
- UIComponent column = column1;
- UIComponent notAjaxSupport = notColumn;
-
-
- assertTrue(columnPredicate.evaluate(column));
- assertTrue(!columnPredicate.evaluate(notColumn));
-
- assertTrue(notColumnPredicate.evaluate(notColumn));
- assertTrue(!notColumnPredicate.evaluate(column));
-
- assertTrue(!ajaxSupportPredicate.evaluate(notAjaxSupport));
- }
/**
* Tests if component accepts request parameters and stores them