Author: abelevich
Date: 2009-10-23 12:29:45 -0400 (Fri, 23 Oct 2009)
New Revision: 15750
Added:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/IteratorBase.java
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/config/component/tables.xml
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/ColumnsIterator.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/DataIterator.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/FixedChildrenIterator.java
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/renderkit/SimpleColgroupRenderer.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/faces-config.xml
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/tables.taglib.xml
Log:
add IteratorBase abstract class for the columns/data iterators impl, add SubTabel
renderer, fix Iterators
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/config/component/tables.xml
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/config/component/tables.xml 2009-10-23
07:17:21 UTC (rev 15749)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/config/component/tables.xml 2009-10-23
16:29:45 UTC (rev 15750)
@@ -96,5 +96,25 @@
<test/>
</tag>
</component>
-
+ <component>
+ <name>org.richfaces.SubTable</name>
+ <family>org.richfaces.SubTable</family>
+ <classname>org.richfaces.component.html.HtmlSubTable</classname>
+ <superclass>org.richfaces.component.UISubTable</superclass>
+ <test/>
+ <description>
+ </description>
+ <renderer generate="false" override="false">
+ <name>org.richfaces.renderkit.SubTableRenderer</name>
+ <classname>org.richfaces.renderkit.SubTableRenderer</classname>
+ </renderer>
+ <tag>
+ <name>subTable</name>
+ <classname>org.richfaces.taglib.SubTableTag</classname>
+ <superclass>
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
+ </superclass>
+ <test/>
+ </tag>
+ </component>
</components>
\ No newline at end of file
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/ColumnsIterator.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/ColumnsIterator.java 2009-10-23
07:17:21 UTC (rev 15749)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/ColumnsIterator.java 2009-10-23
16:29:45 UTC (rev 15750)
@@ -21,7 +21,6 @@
package org.richfaces.component;
import java.util.Iterator;
-import java.util.NoSuchElementException;
import javax.faces.component.UIColumn;
import javax.faces.component.UIComponent;
@@ -31,13 +30,9 @@
* @author asmirnov
*
*/
-class ColumnsIterator implements Iterator <javax.faces.component.UIColumn> {
+class ColumnsIterator extends IteratorBase<javax.faces.component.UIColumn> {
- private javax.faces.component.UIColumn next;
-
- private boolean initialized = false;
-
protected Iterator<UIComponent> childrenIterator;
@@ -45,28 +40,7 @@
this.childrenIterator = dataTable.getChildren().iterator();
}
- public boolean hasNext() {
- if(!initialized){
- next = nextColumn();
- initialized = true;
- }
- return null != next;
- }
-
- public javax.faces.component.UIColumn next() {
- if (!hasNext()) {
- throw new NoSuchElementException();
- }
- javax.faces.component.UIColumn result = next;
- next = nextColumn();
- return result;
- }
-
- public void remove() {
- throw new UnsupportedOperationException("Iterator is read-only");
- }
-
- protected javax.faces.component.UIColumn nextColumn(){
+ protected javax.faces.component.UIColumn nextComponent(){
while (childrenIterator != null && childrenIterator.hasNext()) {
UIComponent child = childrenIterator.next();
if(child instanceof javax.faces.component.UIColumn){
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/DataIterator.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/DataIterator.java 2009-10-23
07:17:21 UTC (rev 15749)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/DataIterator.java 2009-10-23
16:29:45 UTC (rev 15750)
@@ -24,7 +24,7 @@
import javax.faces.component.UIComponent;
-class DataIterator implements Iterator <UIComponent> {
+class DataIterator extends IteratorBase <UIComponent> {
private Iterator<UIComponent> facetsIterator;
@@ -36,28 +36,25 @@
this.facetsIterator = dataTable.getFacets().values().iterator();
}
- public boolean hasNext() {
- return (facetsIterator.hasNext() || childrenIterator.hasNext());
- }
-
- public UIComponent next() {
- UIComponent next = null;
-
- while (next == null && childrenIterator.hasNext()) {
- UIComponent child = (UIComponent) childrenIterator.next();
+ protected UIComponent nextComponent() {
+ UIComponent nextColumn = null;
+ while (nextColumn == null && childrenIterator.hasNext()) {
+ UIComponent child = childrenIterator.next();
if((child instanceof UIColumn) && child.isRendered()) {
- next = child;
+ nextColumn = child;
+ } else if(checkAjaxComponent(child)) {
+ nextColumn = child;
}
}
- while (next == null && facetsIterator.hasNext()) {
- UIComponent child = (UIComponent) facetsIterator.next();
- if(child.isRendered()) {
- next = child;
+ while (nextColumn == null && facetsIterator.hasNext()) {
+ UIComponent component = facetsIterator.next();
+ if(checkAjaxComponent(component)){
+ nextColumn = component;
}
}
- return next;
+ return nextColumn;
}
protected Iterator<UIComponent> getFacetsIterator() {
@@ -68,7 +65,8 @@
return this.childrenIterator;
}
- public void remove() {
- throw new UnsupportedOperationException("Iterator is read-only");
+ protected boolean checkAjaxComponent(UIComponent child) {
+ return false;
}
+
}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/FixedChildrenIterator.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/FixedChildrenIterator.java 2009-10-23
07:17:21 UTC (rev 15749)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/FixedChildrenIterator.java 2009-10-23
16:29:45 UTC (rev 15750)
@@ -34,7 +34,7 @@
}
@Override
- public UIComponent next() {
+ protected UIComponent nextComponent() {
UIComponent next = null;
if(currentColumnIterator != null && currentColumnIterator.hasNext()) {
@@ -44,11 +44,13 @@
if(next == null) {
Iterator <UIComponent> childrenIterator = getChildrenIterator();
- while(childrenIterator.hasNext()) {
+ while(next == null && childrenIterator.hasNext()) {
UIComponent child = childrenIterator.next();
if((child instanceof UIColumn) && child.isRendered()) {
- currentColumnIterator = getChildrenIterator(child);
- next = next();
+ currentColumnIterator = getChildFacetIterator(child);
+ next = nextComponent();
+ } else if(checkAjaxComponent(child)) {
+ next = child;
}
}
}
@@ -56,7 +58,6 @@
if (next == null) {
next = getNextFacet();
}
-
return next;
}
@@ -74,8 +75,8 @@
}
}
- protected Iterator<UIComponent> getChildrenIterator(UIComponent component) {
- return component.getChildren().iterator();
+ protected Iterator<UIComponent> getChildFacetIterator(UIComponent component) {
+ return component.getFacets().values().iterator();
}
}
Added:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/IteratorBase.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/IteratorBase.java
(rev 0)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/IteratorBase.java 2009-10-23
16:29:45 UTC (rev 15750)
@@ -0,0 +1,39 @@
+package org.richfaces.component;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+/**
+ * @author Anton Belevich
+ *
+ */
+public abstract class IteratorBase<E> implements Iterator<E> {
+
+ private boolean initialized = false;
+
+ private E next;
+
+
+ public boolean hasNext() {
+ if(!initialized){
+ next = nextComponent();
+ initialized = true;
+ }
+ return null != next;
+ }
+
+ public E next() {
+ if (!hasNext()) {
+ throw new NoSuchElementException();
+ }
+ E result = next;
+ next = nextComponent();
+ return result;
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException("Iterator is read-only");
+ }
+
+ abstract protected E nextComponent();
+}
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-10-23
07:17:21 UTC (rev 15749)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTable.java 2009-10-23
16:29:45 UTC (rev 15750)
@@ -11,6 +11,17 @@
return new ColumnsIterator(this);
}
+ @Override
+ protected Iterator<UIComponent> fixedChildren() {
+ return new FixedChildrenIterator(this);
+ }
+
+ @Override
+ protected Iterator<UIComponent> dataChildren() {
+
+ return new DataIterator(this);
+ }
+
public UIComponent getHeader() {
return getFacet("header");
}
@@ -23,4 +34,5 @@
return getFacet("caption");
}
+
}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SimpleColgroupRenderer.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SimpleColgroupRenderer.java 2009-10-23
07:17:21 UTC (rev 15749)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SimpleColgroupRenderer.java 2009-10-23
16:29:45 UTC (rev 15750)
@@ -70,8 +70,8 @@
Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
while (iter.hasNext()) {
+
UIColumn column = iter.next();
-
if (column instanceof Column) {
boolean breakBefore = ((Column) column).isBreakBefore();
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java 2009-10-23
07:17:21 UTC (rev 15749)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java 2009-10-23
16:29:45 UTC (rev 15750)
@@ -1,5 +1,4 @@
/**
- * License Agreement.
*
* JBoss RichFaces - Ajax4jsf Component Library
*
@@ -39,36 +38,23 @@
*/
public class SubTableRenderer extends AbstractTableRenderer {
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.renderkit.RendererBase#doEncodeBegin(javax.faces.context.ResponseWriter,
- * javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- protected void doEncodeBegin(ResponseWriter writer, FacesContext context,
- UIComponent component) throws IOException {
+ protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
encodeHeaderRow(writer, context, component,"header");
}
/**
* Encode one row with header/footer facets from columns.
- * @param writer
- * @param context
- * @param component
- * @param facetName
- * @throws IOException
*/
private void encodeHeaderRow(ResponseWriter writer, FacesContext context, UIComponent
component,String facetName) throws IOException {
UIDataTable dataTable = (UIDataTable) component;
- Iterator<UIColumn> columns =
dataTable.columns();//columnFacets(dataTable,facetName);
int colCount = getColumnsCount(dataTable);
- String headerClass = (String) component.getAttributes().get(
- facetName+"Class");
+ String headerClass = (String)
component.getAttributes().get(facetName+"Class");
+
if (isColumnFacetPresent(dataTable, facetName)) {
writer.startElement(HTML.TR_ELEMENT, dataTable);
- encodeStyleClass(writer, null, "rich-subtable-"+facetName, null,
headerClass);
- encodeHeaderFacets(context, writer, columns,
"rich-subtable-"+facetName+"cell", headerClass,
- facetName, "td",colCount);
+ encodeStyleClass(writer, null, "rich-subtable-"+facetName, null,
headerClass);
+ Iterator<UIColumn> columns = dataTable.columns();
+ encodeHeaderFacets(context, writer, columns,
"rich-subtable-"+facetName+"cell", headerClass, facetName,
"td",colCount);
writer.endElement(HTML.TR_ELEMENT);
}
}
@@ -78,43 +64,23 @@
//stub for test only!!
}
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.renderkit.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter,
- * javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- protected void doEncodeEnd(ResponseWriter writer, FacesContext context,
- UIComponent component) throws IOException {
+ protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
encodeHeaderRow(writer, context, component,"footer");
}
- /**
- * @return
- */
protected String getRowSkinClass() {
return "rich-subtable-row";
}
- /**
- * @return
- */
+
protected String getFirstRowSkinClass() {
return "rich-subtable-firstrow";
}
- /* (non-Javadoc)
- * @see org.richfaces.renderkit.AbstractTableRenderer#getCellSkinClass()
- */
protected String getCellSkinClass() {
return "rich-subtable-cell";
}
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.renderkit.RendererBase#getComponentClass()
- */
+
protected Class<? extends UIComponent> getComponentClass() {
- // TODO Auto-generated method stub
return UISubTable.class;
}
@@ -124,30 +90,21 @@
}
@Override
- public void encodeTBody(FacesContext context, UIDataTable table)
- throws IOException {
- // TODO Auto-generated method stub
-
+ public void encodeTBody(FacesContext context, UIDataTable table) throws IOException {
}
@Override
- public void doProcess(FacesContext facesContext, TableHolder holder)
- throws IOException {
- // TODO Auto-generated method stub
-
+ public void doProcess(FacesContext facesContext, TableHolder holder) throws IOException
{
+ System.out.println("SubTableRenderer.doProcess()");
}
@Override
- public void encodeCell(FacesContext context, UIComponent cell)
- throws IOException {
- // TODO Auto-generated method stub
-
+ public void encodeCell(FacesContext context, UIComponent cell) throws IOException {
+ System.out.println("SubTableRenderer.encodeCell()");
}
@Override
- public void encodeOneRow(FacesContext context, TableHolder holder)
- throws IOException {
- // TODO Auto-generated method stub
-
+ public void encodeOneRow(FacesContext context, TableHolder holder) throws IOException {
+ System.out.println("SubTableRenderer.encodeOneRow()");
}
}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/faces-config.xml
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/faces-config.xml 2009-10-23
07:17:21 UTC (rev 15749)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/faces-config.xml 2009-10-23
16:29:45 UTC (rev 15750)
@@ -20,8 +20,11 @@
<component-type>org.richfaces.Colgroup</component-type>
<component-class>org.richfaces.component.html.HtmlColumnGroup</component-class>
</component>
+ <component>
+ <component-type>org.richfaces.SubTable</component-type>
+ <component-class>org.richfaces.component.html.HtmlSubTable</component-class>
+ </component>
-
<render-kit>
<render-kit-id>HTML_BASIC</render-kit-id>
<renderer>
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/tables.taglib.xml
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/tables.taglib.xml 2009-10-23
07:17:21 UTC (rev 15749)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/tables.taglib.xml 2009-10-23
16:29:45 UTC (rev 15750)
@@ -30,4 +30,11 @@
<renderer-type>org.richfaces.ColumnGroupRenderer</renderer-type>
</component>
</tag>
+ <tag>
+ <tag-name>subTable</tag-name>
+ <component>
+ <component-type>org.richfaces.SubTable</component-type>
+ <renderer-type>org.richfaces.renderkit.SubTableRenderer</renderer-type>
+ </component>
+ </tag>
</facelet-taglib>