Author: abelevich
Date: 2009-09-25 11:16:55 -0400 (Fri, 25 Sep 2009)
New Revision: 15667
Added:
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/html/HtmlColumn.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/TableHolder.java
Modified:
root/ui-sandbox/trunk/components/tables/pom.xml
root/ui-sandbox/trunk/components/tables/ui/pom.xml
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/UIColumn.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIExtendedDataTable.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UISimpleDataTable.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlSimpleDataTable.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/SimpleDataTableRendererBase.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
root/ui-sandbox/trunk/components/tables/ui/src/main/templates/org/richfaces/renderkit/html/simpletable.template.xml
Log:
add simple table functionality
Modified: root/ui-sandbox/trunk/components/tables/pom.xml
===================================================================
--- root/ui-sandbox/trunk/components/tables/pom.xml 2009-09-24 12:53:53 UTC (rev 15666)
+++ root/ui-sandbox/trunk/components/tables/pom.xml 2009-09-25 15:16:55 UTC (rev 15667)
@@ -22,16 +22,6 @@
<plugin>
<groupId>org.richfaces.cdk</groupId>
<artifactId>maven-cdk-plugin</artifactId>
- <configuration>
- <library>
- <prefix>org.richfaces</prefix>
- <taglib>
- <
uri>http://richfaces.org/sandbox-tables</uri>
- <shortName>tables</shortName>
- <displayName>tables</displayName>
- </taglib>
- </library>
- </configuration>
</plugin>
</plugins>
</build>
Modified: root/ui-sandbox/trunk/components/tables/ui/pom.xml
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/pom.xml 2009-09-24 12:53:53 UTC (rev
15666)
+++ root/ui-sandbox/trunk/components/tables/ui/pom.xml 2009-09-25 15:16:55 UTC (rev
15667)
@@ -14,26 +14,7 @@
<artifactId>${parent.artifactId}-ui</artifactId>
<name>richfaces tables ui</name>
- <build>
- <plugins>
- <plugin>
- <groupId>org.richfaces.cdk</groupId>
- <artifactId>maven-cdk-plugin</artifactId>
- <configuration>
- <library>
- <prefix>org.richfaces</prefix>
- <taglib>
- <
uri>http://richfaces.org/a4j</uri>
- <shortName>a4j</shortName>
- <displayName>Core ajax components tags</displayName>
- </taglib>
- </library>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
+ <dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<version>${project.version}</version>
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-09-24
12:53:53 UTC (rev 15666)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/config/component/tables.xml 2009-09-25
15:16:55 UTC (rev 15667)
@@ -7,6 +7,21 @@
]>
<components>
+ <component>
+ <name>org.richfaces.Column</name>
+ <family>org.richfaces.Column</family>
+ <classname>org.richfaces.component.html.HtmlColumn</classname>
+ <superclass>org.richfaces.component.UIColumn</superclass>
+ <tag>
+ <name>column</name>
+ <classname>
+ org.richfaces.taglib.ColumnTag
+ </classname>
+ <superclass>
+ org.ajax4jsf.webapp.taglib.UIComponentTagBase
+ </superclass>
+ </tag>
+ </component>
<component>
<name>org.richfaces.SimpleDataTable</name>
<family>javax.faces.SimpleDataTable</family>
Added:
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
(rev 0)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/ColumnsIterator.java 2009-09-25
15:16:55 UTC (rev 15667)
@@ -0,0 +1,80 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * 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 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;
+ }
+
+}
Added:
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
(rev 0)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/DataIterator.java 2009-09-25
15:16:55 UTC (rev 15667)
@@ -0,0 +1,77 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * 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.UIColumn;
+import javax.faces.component.UIComponent;
+
+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 (null == nextColumn && childrenIterator.hasNext()) {
+ UIComponent child = childrenIterator.next();
+ if (child.isRendered()) {
+ if (child instanceof UIColumn || child instanceof Column) {
+ nextColumn = child;
+ } else if (checkAjaxComponent(child)) {
+ nextColumn = child;
+ }
+ }
+ }
+ while (null == nextColumn && 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;
+ return false;
+ }
+
+}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIColumn.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIColumn.java 2009-09-24
12:53:53 UTC (rev 15666)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIColumn.java 2009-09-25
15:16:55 UTC (rev 15667)
@@ -1,4 +1,6 @@
package org.richfaces.component;
+
public class UIColumn extends javax.faces.component.UIColumn {
}
+
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIExtendedDataTable.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIExtendedDataTable.java 2009-09-24
12:53:53 UTC (rev 15666)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIExtendedDataTable.java 2009-09-25
15:16:55 UTC (rev 15667)
@@ -1,6 +1,5 @@
package org.richfaces.component;
-import javax.faces.component.UIData;
-public class UIExtendedDataTable extends UIData {
+public abstract class UIExtendedDataTable extends UISimpleDataTable {
}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UISimpleDataTable.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UISimpleDataTable.java 2009-09-24
12:53:53 UTC (rev 15666)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UISimpleDataTable.java 2009-09-25
15:16:55 UTC (rev 15667)
@@ -1,10 +1,29 @@
package org.richfaces.component;
-import javax.faces.component.UIData;
+import java.util.Iterator;
+import javax.faces.component.UIComponent;
+
+import org.ajax4jsf.component.SequenceDataAdaptor;
+
/**
* @author Anton Belevich
*
*/
-public abstract class UISimpleDataTable extends UIData {
+
+public abstract class UISimpleDataTable extends SequenceDataAdaptor {
+
+ @Override
+ protected Iterator<UIComponent> dataChildren() {
+ return new DataIterator(this);
+ }
+
+ @Override
+ protected Iterator<UIComponent> fixedChildren() {
+ return null;
+ }
+
+ public Iterator<UIComponent> getColumnsIterator (){
+ return new ColumnsIterator(this);
+ }
}
Added:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlColumn.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlColumn.java
(rev 0)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlColumn.java 2009-09-25
15:16:55 UTC (rev 15667)
@@ -0,0 +1,8 @@
+package org.richfaces.component.html;
+
+import org.richfaces.component.UIColumn;
+
+public class HtmlColumn extends UIColumn{
+ public static final String COMPONENT_TYPE = "org.richfaces.Column";
+ public static final String COMPONENT_FAMILY = "org.richfaces.Column";
+}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlSimpleDataTable.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlSimpleDataTable.java 2009-09-24
12:53:53 UTC (rev 15666)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlSimpleDataTable.java 2009-09-25
15:16:55 UTC (rev 15667)
@@ -6,7 +6,14 @@
public static final String COMPONENT_TYPE =
"org.richfaces.SimpleDataTable";
+ public static final String COMPONENT_FAMILY =
"org.richfaces.SimpleDataTable";
+
public HtmlSimpleDataTable() {
setRendererType("org.richfaces.SimpleDataTableRenderer");
}
+
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
}
Added:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java
(rev 0)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java 2009-09-25
15:16:55 UTC (rev 15667)
@@ -0,0 +1,323 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - 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.renderkit;
+
+import java.io.IOException;
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.component.SequenceDataAdaptor;
+import org.ajax4jsf.component.UIDataAdaptor;
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.renderkit.RendererBase;
+import org.ajax4jsf.renderkit.RendererUtils;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+
+/**
+ * @author shura
+ *
+ */
+public abstract class AbstractRowsRenderer extends RendererBase implements DataVisitor {
+
+ public static final String[][] TABLE_EVENT_ATTRS = {
+ {"onclick","onRowClick"},
+ {"ondblclick","onRowDblClick"},
+ {"onmousemove","onRowMouseMove"},
+ {"onmouseup","onRowMouseUp"},
+ {"onmousedown","onRowMouseDown"},
+ {"onmouseover","onRowMouseOver"},
+ {"onmouseout","onRowMouseOut"}
+ };
+
+
+ public static final String ROW_CLASS_KEY =
+ AbstractRowsRenderer.class.getName() + ".rowClass";
+
+ public static final String SKIN_ROW_CLASS_KEY =
+ AbstractRowsRenderer.class.getName() + ".skinRowClass";
+
+ public static final String CELL_CLASS_KEY =
+ AbstractRowsRenderer.class.getName() + ".cellClass";
+
+ public static final String SKIN_CELL_CLASS_KEY =
+ AbstractRowsRenderer.class.getName() + ".skinCellClass";
+
+ public static final String SKIN_FIRST_ROW_CLASS_KEY =
+ AbstractRowsRenderer.class.getName() + ".firstRowSkinClass";
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.ajax.repeat.DataVisitor#process(javax.faces.context.FacesContext,
+ * java.lang.Object, java.lang.Object)
+ */
+ public void process(FacesContext facesContext, Object rowKey, Object argument)
+ throws IOException {
+
+ TableHolder holder = (TableHolder) argument;
+ UIDataAdaptor table = holder.getTable();
+ table.setRowKey(facesContext, rowKey);
+ ResponseWriter writer = facesContext.getResponseWriter();
+ writer.startElement(HTML.TR_ELEMENT, table);
+ encodeOneRow(facesContext, holder);
+ writer.endElement(HTML.TR_ELEMENT);
+ holder.nextRow();
+ }
+
+ public void encodeRows(FacesContext facesContext, UIComponent component) throws
IOException {
+ encodeRows(facesContext, component, new TableHolder((UIDataAdaptor) component));
+ }
+
+ /**
+ * Iterate over all rows for this table.
+ *
+ * @param context
+ * @param component
+ * @throws IOException
+ */
+ protected void encodeRows(FacesContext context, UIComponent component, TableHolder
tableHolder)
+ throws IOException {
+ UIDataAdaptor table = (UIDataAdaptor) component;
+ Object key = table.getRowKey();
+ table.captureOrigValue(context);
+
+ table.walk(context, this, tableHolder);
+
+ doCleanup(context, tableHolder);
+ table.setRowKey(key);
+ table.restoreOrigValue(context);
+ }
+
+ /**
+ * @param context
+ * TODO
+ * @param tableHolder
+ * @throws IOException
+ */
+ protected void doCleanup(FacesContext context, TableHolder tableHolder)
+ throws IOException {
+ // Hoock method for perform encoding after all rows is rendered
+
+ }
+
+ public abstract void encodeOneRow(FacesContext context, TableHolder holder)
+ throws IOException;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.render.Renderer#getRendersChildren()
+ */
+ public boolean getRendersChildren() {
+ return true;
+ }
+
+ public void encodeChildren(FacesContext context, UIComponent component)
+ throws IOException {
+ encodeRows(context, component);
+ }
+
+ public void encodeCaption(FacesContext context, SequenceDataAdaptor table)
+ throws IOException {
+ UIComponent caption = table.getFacet("caption");
+ if (caption == null) {
+ return;
+ }
+
+ ResponseWriter writer = context.getResponseWriter();
+ writer.startElement("caption", table);
+
+ String captionClass = (String) table.getAttributes().get("captionClass");
+ if (captionClass != null) {
+ captionClass = "rich-table-caption " + captionClass;
+ } else {
+ captionClass = "rich-table-caption";
+ }
+ writer.writeAttribute("class", captionClass, "captionClass");
+
+ String captionStyle = (String)
table.getAttributes().get("captionStyle");
+ if (captionStyle != null) {
+ writer.writeAttribute("style", captionStyle, "captionStyle");
+ }
+
+ renderChild(context, caption);
+
+ writer.endElement("caption");
+ }
+
+ /**
+ * @param context
+ * @param table
+ * @throws IOException
+ */
+ protected void encodeRowEvents(FacesContext context, UIDataAdaptor table)
+ throws IOException {
+ RendererUtils utils2 = getUtils();
+ for (int i = 0; i < TABLE_EVENT_ATTRS.length; i++) {
+ String[] attrs = TABLE_EVENT_ATTRS[i];
+ utils2.encodeAttribute(context, table, attrs[1], attrs[0]);
+ }
+ }
+
+ /**
+ * Encode HTML "class" attribute, if is not empty. Classes combined from
+ * pre-defined skin classes, class from parent component, and custom
+ * attribute.
+ *
+ * @param writer
+ * @param parentPredefined TODO
+ * @param predefined
+ * predefined skin classes
+ * @param parent
+ * class from parent component
+ * @param custom
+ * custom classes.
+ * @throws IOException
+ */
+ protected void encodeStyleClass(ResponseWriter writer, Object parentPredefined,
+ Object predefined, Object parent, Object custom) throws IOException {
+ StringBuffer styleClass = new StringBuffer();
+
+ // Construct predefined classes
+ if (null != parentPredefined) {
+ styleClass.append(parentPredefined).append(" ");
+ } else if (null != predefined) {
+ styleClass.append(predefined).append(" ");
+ }
+
+ // Append class from parent component.
+ if (null != parent) {
+ styleClass.append(parent).append(" ");
+ }
+ if (null != custom) {
+ styleClass.append(custom);
+ }
+ if (styleClass.length() > 0) {
+ writer.writeAttribute(HTML.class_ATTRIBUTE, styleClass, "styleClass");
+ }
+ }
+ protected void encodeStyle(ResponseWriter writer, Object parentPredefined,
+ Object predefined, Object parent, Object custom) throws IOException {
+ StringBuffer style = new StringBuffer();
+ // Construct predefined styles
+ if (null != parentPredefined) {
+ style.append(parentPredefined).append(" ");
+ } else if (null != predefined) {
+ style.append(predefined).append(" ");
+ }
+ // Append style from parent component.
+ if (null != parent) {
+ style.append(parent).append(" ");
+ }
+ if (null != custom) {
+ style.append(custom);
+ }
+ if (style.length() > 0) {
+ writer.writeAttribute("style", style, "style");
+ }
+ }
+
+
+ /**
+ * Render component and all its children with current row/cell style
+ * classes.
+ *
+ * @param context
+ * @param cell
+ * @param skinFirstRowClass TODO
+ * @param skinRowClass
+ * TODO
+ * @param rowClass
+ * @param skinCellClass
+ * TODO
+ * @param cellClass
+ * @throws IOException
+ */
+ protected void encodeCellChildren(FacesContext context, UIComponent cell,
+ String skinFirstRowClass, String skinRowClass, String rowClass,
+ String skinCellClass, String cellClass) throws IOException {
+
+ Map<String, Object> requestMap =
context.getExternalContext().getRequestMap();
+ // Save top level class parameters ( if any ), and put new for this
+ // component
+ Object savedRowClass = requestMap.get(ROW_CLASS_KEY);
+ if (null != rowClass) {
+ requestMap.put(ROW_CLASS_KEY, rowClass);
+
+ }
+ Object savedSkinFirstRowClass = requestMap.get(SKIN_FIRST_ROW_CLASS_KEY);
+ if (null != skinRowClass) {
+ requestMap.put(SKIN_FIRST_ROW_CLASS_KEY, skinFirstRowClass);
+
+ }
+ Object savedSkinRowClass = requestMap.get(SKIN_ROW_CLASS_KEY);
+ if (null != skinRowClass) {
+ requestMap.put(SKIN_ROW_CLASS_KEY, skinRowClass);
+
+ }
+ Object savedCellClass = requestMap.get(CELL_CLASS_KEY);
+ if (null != cellClass) {
+ requestMap.put(CELL_CLASS_KEY, cellClass);
+ }
+ Object savedSkinCellClass = requestMap.get(SKIN_CELL_CLASS_KEY);
+ if (null != skinCellClass) {
+ requestMap.put(SKIN_CELL_CLASS_KEY, skinCellClass);
+
+ }
+
+ renderChild(context, cell);
+
+ // Restore original values.
+ requestMap.put(ROW_CLASS_KEY, savedRowClass);
+ requestMap.put(CELL_CLASS_KEY, savedCellClass);
+ requestMap.put(SKIN_FIRST_ROW_CLASS_KEY, savedSkinFirstRowClass);
+ requestMap.put(SKIN_ROW_CLASS_KEY, savedSkinRowClass);
+ requestMap.put(SKIN_CELL_CLASS_KEY, savedSkinCellClass);
+
+ }
+
+ protected void encodeTableHeaderFacet(FacesContext context, int columns, ResponseWriter
writer, UIComponent footer, String skinFirstRowClass, String skinRowClass, String
skinCellClass, String footerClass, String element) throws IOException {
+// boolean isColgroup = footer instanceof Row;
+// if (!isColgroup) {
+// writer.startElement("tr", footer);
+// encodeStyleClass(writer, null, skinFirstRowClass, footerClass, null);
+// writer.startElement(element, footer);
+// encodeStyleClass(writer, null, skinCellClass, footerClass, null);
+// if (columns > 0) {
+// writer.writeAttribute("colspan", String.valueOf(columns), null);
+// }
+// writer.writeAttribute("scope", "colgroup", null);
+// }
+//
+// encodeCellChildren(context, footer, skinFirstRowClass, skinRowClass,
+// footerClass, skinCellClass, null);
+//
+// if (!isColgroup) {
+// writer.endElement(element);
+// writer.endElement("tr");
+// }
+ }
+
+}
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 2009-09-24
12:53:53 UTC (rev 15666)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2009-09-25
15:16:55 UTC (rev 15667)
@@ -1,6 +1,7 @@
package org.richfaces.renderkit;
import java.io.IOException;
+import java.util.Iterator;
import javax.faces.application.ResourceDependencies;
import javax.faces.application.ResourceDependency;
@@ -8,17 +9,49 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import org.ajax4jsf.renderkit.RendererBase;
+import org.ajax4jsf.component.UIDataAdaptor;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.richfaces.component.UIColumn;
+import org.richfaces.component.UISimpleDataTable;
@ResourceDependencies({
@ResourceDependency(library = "javax.faces", name = "jsf.js"),
@ResourceDependency(name = "jquery.js"),
@ResourceDependency(name = "richfaces.js")
})
-public abstract class AbstractTableRenderer extends RendererBase {
+public abstract class AbstractTableRenderer extends AbstractRowsRenderer {
public void encodeTableStructure(FacesContext context, UIComponent component) throws
IOException{
ResponseWriter writer = context.getResponseWriter();
- writer.writeText("Encoding dataTable",component, null);
+ writer.writeText("Encoding dataTable caption, colgroup, defenitions, headers
etc",component, null);
}
+
+ @Override
+ public void encodeChildren(FacesContext context, UIComponent component) throws
IOException {
+ encodeTBody(context, (UIDataAdaptor) component);
+ }
+
+ public void encodeTBody (FacesContext context, UIDataAdaptor table) throws IOException
{
+ String clientId = table.getClientId(context);
+ ResponseWriter writer = context.getResponseWriter();
+ writer.startElement("tbody", table);
+ writer.writeAttribute("id", clientId + ":tb", null);
+ encodeRows(context, table);
+ writer.endElement("tbody");
+ }
+
+ @Override
+ public void encodeOneRow(FacesContext facesContext, TableHolder holder) throws
IOException {
+ UISimpleDataTable table = (UISimpleDataTable)holder.getTable();
+ ResponseWriter writer = facesContext.getResponseWriter();
+ Iterator<UIComponent> columns = table.getColumnsIterator();
+ while (columns.hasNext()) {
+ UIComponent child = columns.next();
+ if((child instanceof UIColumn) && child.isRendered()) {
+ writer.startElement(HTML.td_ELEM, child);
+ renderChildren(facesContext, child);
+ writer.endElement(HTML.td_ELEM);
+ }
+ }
+ }
}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SimpleDataTableRendererBase.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SimpleDataTableRendererBase.java 2009-09-24
12:53:53 UTC (rev 15666)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SimpleDataTableRendererBase.java 2009-09-25
15:16:55 UTC (rev 15667)
@@ -1,12 +1,7 @@
package org.richfaces.renderkit;
-import java.io.IOException;
-
import javax.faces.application.ResourceDependencies;
import javax.faces.application.ResourceDependency;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
/**
* @author Anton Belevich
@@ -16,10 +11,5 @@
@ResourceDependencies({
@ResourceDependency(name = "simple-datatable.js")
})
-public abstract class SimpleDataTableRendererBase extends AbstractTableRenderer {
- @Override
- public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
- ResponseWriter writer = context.getResponseWriter();
- writer.writeText("simpleDataTable", null);
- }
+public abstract class SimpleDataTableRendererBase extends AbstractTableRenderer {
}
Added:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/TableHolder.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/TableHolder.java
(rev 0)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/TableHolder.java 2009-09-25
15:16:55 UTC (rev 15667)
@@ -0,0 +1,114 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - 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.renderkit;
+
+import java.util.Map;
+
+import org.ajax4jsf.component.UIDataAdaptor;
+
+/**
+ * Private class for keep reference to table and intermediate iteration values ( current
row styles, events etc )
+ * @author shura
+ *
+ */
+public class TableHolder {
+ private UIDataAdaptor table;
+ private int rowCounter;
+ private int gridRowCounter;
+ private String[] rowClasses;
+ private String[] columnsClasses;
+
+ /**
+ * @param table
+ */
+ public TableHolder(UIDataAdaptor table) {
+ this.table = table;
+ this.rowCounter = 0;
+ this.gridRowCounter = 0;
+ Map<String, Object> attributes = table.getAttributes();
+ String classes = (String) attributes.get("rowClasses");
+ if(null != classes){
+ rowClasses=classes.split(",");
+ }
+ classes = (String) attributes.get("columnClasses");
+ if(null != classes){
+ columnsClasses=classes.split(",");
+ }
+ }
+
+ /**
+ * @return the table
+ */
+ public UIDataAdaptor getTable() {
+ return this.table;
+ }
+
+ /**
+ * @return the rowCounter
+ */
+ public int getRowCounter() {
+ return this.rowCounter;
+ }
+
+ /**
+ * Get current rendered row number, and increment to next value.
+ * @return the rowCounter
+ */
+ public int nextRow() {
+ return ++rowCounter;
+ }
+
+ public String getRowClass() {
+ int row = rowCounter;
+ return getRowClass(row);
+ }
+
+ public String getRowClass(int row) {
+ String rowClass = null;
+ if(null != rowClasses){
+ rowClass = rowClasses[row%rowClasses.length];
+ }
+ return rowClass;
+ }
+
+ public String getColumnClass(int columnNumber) {
+ String columnClass = null;
+ if(null != columnsClasses){
+ columnClass = columnsClasses[columnNumber%columnsClasses.length];
+ }
+ return columnClass;
+ }
+
+ /**
+ * @return the gridRowCounter
+ */
+ public int getGridRowCounter() {
+ return this.gridRowCounter;
+ }
+
+ /**
+ * @param gridRowCounter the gridRowCounter to set
+ */
+ public void setGridRowCounter(int gridRowCounter) {
+ this.gridRowCounter = gridRowCounter;
+ }
+}
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-09-24
12:53:53 UTC (rev 15666)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/faces-config.xml 2009-09-25
15:16:55 UTC (rev 15667)
@@ -12,16 +12,21 @@
<component-type>org.richfaces.ExtendedDataTable</component-type>
<component-class>org.richfaces.component.html.HtmlExtendedDataTable</component-class>
</component>
+ <component>
+ <component-type>org.richfaces.Column</component-type>
+ <component-class>org.richfaces.component.html.HtmlColumn</component-class>
+ </component>
+
<render-kit>
<render-kit-id>HTML_BASIC</render-kit-id>
<renderer>
- <component-family>javax.faces.Data</component-family>
+ <component-family>org.richfaces.SimpleDataTable</component-family>
<renderer-type>org.richfaces.SimpleDataTableRenderer</renderer-type>
<renderer-class>org.richfaces.renderkit.html.SimpleDataTableRenderer</renderer-class>
</renderer>
<renderer>
- <component-family>javax.faces.Data</component-family>
+ <component-family>org.richfaces.ExtendedDataTable</component-family>
<renderer-type>org.richfaces.ExtendedDataTableRenderer</renderer-type>
<renderer-class>org.richfaces.renderkit.html.ExtendedDataTableRenderer</renderer-class>
</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-09-24
12:53:53 UTC (rev 15666)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/tables.taglib.xml 2009-09-25
15:16:55 UTC (rev 15667)
@@ -17,4 +17,10 @@
<renderer-type>org.richfaces.ExtendedDataTableRenderer</renderer-type>
</component>
</tag>
+ <tag>
+ <tag-name>column</tag-name>
+ <component>
+ <component-type>org.richfaces.Column</component-type>
+ </component>
+ </tag>
</facelet-taglib>
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/templates/org/richfaces/renderkit/html/simpletable.template.xml
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/templates/org/richfaces/renderkit/html/simpletable.template.xml 2009-09-24
12:53:53 UTC (rev 15666)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/templates/org/richfaces/renderkit/html/simpletable.template.xml 2009-09-25
15:16:55 UTC (rev 15667)
@@ -7,5 +7,9 @@
componentclass="org.richfaces.component.UISimpleDataTable">
<table id="#{clientId}">
<cdk:call expression="encodeTableStructure(context,component);" />
+ <cdk:body>
+ <cdk:call expression="encodeTBody(context,component);" />
+ </cdk:body>
+
</table>
</cdk:root>
\ No newline at end of file