Author: abelevich
Date: 2009-10-22 05:59:40 -0400 (Thu, 22 Oct 2009)
New Revision: 15746
Added:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlColumnGroup.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/CellEncoder.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SimpleCellEncoder.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/resources/table.css
root/ui-sandbox/trunk/components/tables/ui/src/main/templates/org/richfaces/renderkit/html/colgroup.template.xml
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/UIColumnGroup.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/AbstractRowsRenderer.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
Log:
add support for the colGroup
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-22
07:22:02 UTC (rev 15745)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/config/component/tables.xml 2009-10-22
09:59:40 UTC (rev 15746)
@@ -22,6 +22,25 @@
</superclass>
</tag>
</component>
+ <component>
+ <name>org.richfaces.Colgroup</name>
+ <family>org.richfaces.Colgroup</family>
+ <classname>org.richfaces.component.html.HtmlColumnGroup</classname>
+ <superclass>org.richfaces.component.UIColumnGroup</superclass>
+ <renderer generate="true">
+ <name>org.richfaces.renderkit.html.SimpleColgroupRenderer</name>
+ <template>org/richfaces/renderkit/html/colgroup.template.xml</template>
+ </renderer>
+ <tag>
+ <name>colGroup</name>
+ <classname>
+ org.richfaces.taglib.ColumnGroupTag
+ </classname>
+ <superclass>
+ org.ajax4jsf.webapp.taglib.UIComponentTagBase
+ </superclass>
+ </tag>
+ </component>
<component>
<name>org.richfaces.SimpleDataTable</name>
<family>javax.faces.SimpleDataTable</family>
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIColumnGroup.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIColumnGroup.java 2009-10-22
07:22:02 UTC (rev 15745)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIColumnGroup.java 2009-10-22
09:59:40 UTC (rev 15746)
@@ -24,7 +24,6 @@
import java.util.Iterator;
import javax.faces.component.UIColumn;
-import javax.faces.component.UIComponent;
import javax.faces.component.UIPanel;
/**
@@ -41,16 +40,10 @@
return new ColumnsIterator(this);
}
- /* (non-Javadoc)
- * @see org.richfaces.component.Column#isBreakBefore()
- */
public boolean isBreakBefore() {
return true;
}
- /* (non-Javadoc)
- * @see org.richfaces.component.Column#setBreakBefore(boolean)
- */
public void setBreakBefore(boolean newBreakBefore) {
throw new IllegalStateException("Property 'breakBefore' for subtable is
read-only");
}
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-10-22
07:22:02 UTC (rev 15745)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UISubTable.java 2009-10-22
09:59:40 UTC (rev 15746)
@@ -23,7 +23,6 @@
import java.util.Iterator;
-import javax.faces.component.UIColumn;
import javax.faces.component.UIComponent;
@@ -43,38 +42,19 @@
return new SubtableFixedChildrenIterator(this);
}
- /* (non-Javadoc)
- * @see org.richfaces.component.Column#isBreakBefore()
- */
public boolean isBreakBefore() {
return true;
}
- /* (non-Javadoc)
- * @see org.richfaces.component.Column#setBreakBefore(boolean)
- */
public void setBreakBefore(boolean newBreakBefore) {
throw new IllegalStateException("Property 'breakBefore' for subtable is
read-only");
}
- /* (non-Javadoc)
- * @see org.richfaces.component.UIDataTable#columns()
- */
-// public Iterator<UIComponent> columns() {
-// return super.columns();
-// }
-
- /**
- * @return the sortExpression
- */
public String getSortExpression() {
// SubTable is not sortable element.
return null;
}
- /**
- * @param sortExpression the sortExpression to set
- */
public void setSortExpression(String sortExpression) {
// Do nothing - subtable is not sortable element;
}
Added:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlColumnGroup.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlColumnGroup.java
(rev 0)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlColumnGroup.java 2009-10-22
09:59:40 UTC (rev 15746)
@@ -0,0 +1,75 @@
+package org.richfaces.component.html;
+
+import javax.el.MethodExpression;
+
+import org.richfaces.component.UIColumnGroup;
+import org.richfaces.model.Ordering;
+
+public class HtmlColumnGroup extends UIColumnGroup{
+
+ public MethodExpression getFilterMethod() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getFilterValue() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getSortExpression() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Ordering getSortOrder() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean isSelfSorted() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean isSortable() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void setFilterMethod(MethodExpression methodExpression) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setFilterValue(String filterValue) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setSelfSorted(boolean selfSorted) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setSortExpression(String sortExpression) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setSortOrder(Ordering sortOrder) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setSortable(boolean sortable) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
+}
Modified:
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 2009-10-22
07:22:02 UTC (rev 15745)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java 2009-10-22
09:59:40 UTC (rev 15746)
@@ -24,6 +24,7 @@
import java.io.IOException;
import java.util.Map;
+import javax.faces.component.UIColumn;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
@@ -69,7 +70,34 @@
public abstract void encodeOneRow(FacesContext context, TableHolder holder) throws
IOException;
public abstract void encodeCell(FacesContext context, UIComponent cell) throws
IOException;
+
+ protected abstract String getCellSkinClass();
+
+ protected String getCellStyleClasses(FacesContext context, UIComponent component) {
+ StringBuffer styleClass = new StringBuffer();
+ // Construct predefined classes
+ Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
+ Object parentPredefined = requestMap.get(AbstractRowsRenderer.SKIN_CELL_CLASS_KEY);
+ if (null != parentPredefined) {
+ styleClass.append(parentPredefined).append(" ");
+ } else {
+ styleClass.append(getCellSkinClass());
+ }
+ // Append class from parent component.
+ Object parent = requestMap.get(AbstractRowsRenderer.CELL_CLASS_KEY);
+ if (null != parent) {
+ styleClass.append(parent).append(" ");
+ }
+
+ Object custom = component.getAttributes().get("styleClass");
+ if (null != custom) {
+ styleClass.append(custom);
+ }
+ return styleClass.toString();
+
+ }
+
public DataVisitResult process(FacesContext facesContext, Object rowKey, Object
argument) {
TableHolder holder = (TableHolder) argument;
UIDataAdaptor table = holder.getTable();
@@ -235,7 +263,7 @@
}
- if(cell instanceof Column) {
+ if((cell instanceof Column) && (cell instanceof UIColumn)) {
encodeCell(context, cell);
} else {
renderChild(context, cell);
@@ -249,28 +277,6 @@
requestMap.put(SKIN_CELL_CLASS_KEY, savedSkinCellClass);
}
-
- protected String cellStyleClass(FacesContext context , UIComponent component){
- StringBuffer styleClass = new StringBuffer();
- // Construct predefined classes
- Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
- Object parentPredefined = requestMap.get(AbstractRowsRenderer.SKIN_CELL_CLASS_KEY);
- if (null != parentPredefined) {
- styleClass.append(parentPredefined).append(" ");
- } else {
- styleClass.append("rich-table-cell ");
- }
- // Append class from parent component.
- Object parent = requestMap.get(AbstractRowsRenderer.CELL_CLASS_KEY);
- if (null != parent) {
- styleClass.append(parent).append(" ");
- }
- Object custom = component.getAttributes().get("styleClass");
- if (null != custom) {
- styleClass.append(custom);
- }
- return styleClass.toString();
- }
}
Added:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/CellEncoder.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/CellEncoder.java
(rev 0)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/CellEncoder.java 2009-10-22
09:59:40 UTC (rev 15746)
@@ -0,0 +1,28 @@
+package org.richfaces.renderkit;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+/**
+ * @author Anton Belevich
+ *
+ */
+public interface CellEncoder {
+
+ public static String [] CELL_ATTRIBUTES = {
+ "abbr" , "align" , "axis" , "bgcolor" ,
"char" , "charoff" , "colspan" , "dir" ,
+ "headers" , "height" , "lang" , "nowrap" ,
"onclick" , "ondblclick" , "onkeydown" ,
+ "onkeypress" , "onkeyup" , "onmousedown" ,
"onmousemove" , "onmouseout" , "onmouseover" ,
+ "onmouseup" , "rowspan" , "scope" , "style"
, "title" , "valign" , "width" , "xml:lang" };
+
+ public void encodeBegin(FacesContext context, UIComponent component) throws
IOException;
+
+ public void encodeEnd(FacesContext context, UIComponent component) throws IOException;
+
+ public void setStyleClasses(String styleClasses);
+
+ public String getStyleClasses();
+
+}
Added:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SimpleCellEncoder.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SimpleCellEncoder.java
(rev 0)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SimpleCellEncoder.java 2009-10-22
09:59:40 UTC (rev 15746)
@@ -0,0 +1,65 @@
+package org.richfaces.renderkit;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.renderkit.RendererUtils;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+
+/**
+ * @author Anton Belevich
+ *
+ */
+public class SimpleCellEncoder implements CellEncoder {
+
+ RendererUtils utils;
+ String styleClasses;
+
+
+ public SimpleCellEncoder(RendererUtils utils) {
+ this(utils, null);
+ }
+
+ SimpleCellEncoder(RendererUtils utils, String styleClasses) {
+ this.utils = utils;
+ this.styleClasses = styleClasses;
+ }
+
+ public void encodeBegin(FacesContext context, UIComponent component) throws
IOException{
+
+ ResponseWriter writer = context.getResponseWriter();
+ String classes = getStyleClasses();
+
+ String element = getElement();
+ writer.startElement(element, component);
+
+ String clientId = component.getClientId(context);
+
+ utils.writeAttribute(writer, "class",classes);
+ utils.writeAttribute(writer, "id", clientId );
+ utils.encodeAttributesFromArray(context,component,CELL_ATTRIBUTES);
+
+ }
+
+ public void encodeEnd(FacesContext context, UIComponent component) throws IOException{
+ ResponseWriter writer = context.getResponseWriter();
+ String element = getElement();
+ writer.endElement(element);
+ }
+
+ protected String getElement() {
+ boolean isHeader = styleClasses != null ? styleClasses.contains("header") :
false;
+ return isHeader ? HTML.th_ELEM : HTML.td_ELEM;
+ }
+
+ public String getStyleClasses() {
+ return styleClasses;
+ }
+
+ public void setStyleClasses(String styleClasses) {
+ this.styleClasses = styleClasses;
+ }
+}
Added:
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
(rev 0)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SimpleColgroupRenderer.java 2009-10-22
09:59:40 UTC (rev 15746)
@@ -0,0 +1,189 @@
+/**
+ * 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.Iterator;
+import java.util.Map;
+
+import javax.faces.component.UIColumn;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.richfaces.component.Column;
+import org.richfaces.component.UIColumnGroup;
+
+/**
+ * @author shura
+ *
+ */
+public class SimpleColgroupRenderer extends AbstractRowsRenderer {
+
+ public static final String[] EVENT_ATTRS ;
+
+ static {
+ EVENT_ATTRS = new String[AbstractRowsRenderer.TABLE_EVENT_ATTRS.length];
+ for (int i = 0; i < AbstractRowsRenderer.TABLE_EVENT_ATTRS.length; i++) {
+ EVENT_ATTRS[i]=AbstractRowsRenderer.TABLE_EVENT_ATTRS[i][0];
+ }
+ }
+
+
+ protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent
colgroup) throws IOException {
+ encodeRowStart(context, colgroup, writer, 0);
+ }
+
+ public void encodeChildren(FacesContext context, UIComponent component) throws
IOException {
+ UIColumnGroup colgroup = (UIColumnGroup) component;
+
+ String columnClasses = (String)
component.getAttributes().get("columnClasses");
+ String[] classes = columnClasses != null ? columnClasses.split(",") : null;
+
+ Iterator<UIColumn> iter = colgroup.columns();
+
+ int currentColumn = 0;
+ int currentRow = 0;
+ boolean first = true;
+
+ ResponseWriter writer = context.getResponseWriter();
+ Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
+
+ while (iter.hasNext()) {
+ UIColumn column = iter.next();
+
+ if (column instanceof Column) {
+
+ boolean breakBefore = ((Column) column).isBreakBefore();
+ if (breakBefore && !first) {
+ // close current row
+ writer.endElement(HTML.TR_ELEMENT);
+ // reset columns counter.
+ currentColumn = 0;
+ currentRow++;
+ // Start new row, expect a case of the detail table, wich
+ // will be insert own row.
+ encodeRowStart(context, colgroup, writer, currentRow);
+ }
+
+ String styleClass = classes != null ? classes[currentColumn % classes.length] : null;
+ encodeCellChildren(context, column, null, null, null,
+ (String) requestMap.get(AbstractRowsRenderer.SKIN_CELL_CLASS_KEY),styleClass);
+ } else {
+ // UIColumn don't have own renderer
+ if (column.isRendered()) {
+ writer.startElement(HTML.td_ELEM, column);
+ getUtils().encodeId(context, column);
+ String styleClass = classes != null ? classes[currentColumn % classes.length] :
+ (String) column.getAttributes().get("styleClass");
+
+ encodeStyleClass(context.getResponseWriter(),
requestMap.get(AbstractRowsRenderer.SKIN_CELL_CLASS_KEY),
+ "rich-table-cell",
requestMap.get(AbstractRowsRenderer.CELL_CLASS_KEY), styleClass);
+ // TODO - encode column attributes.
+ renderChildren(context, column);
+ writer.endElement(HTML.td_ELEM);
+
+ }
+
+ }
+
+ currentColumn++;
+ first = false;
+ }
+ }
+
+ protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
+ writer.endElement(HTML.TR_ELEMENT);
+ }
+
+ private void encodeRowStart(FacesContext context, UIComponent colspan, ResponseWriter
writer, int currentRow) throws IOException {
+ writer.startElement(HTML.TR_ELEMENT, colspan);
+
+ String styleClass;
+ String rowClasses = (String) colspan.getAttributes().get("rowClasses");
+ if (null != rowClasses) {
+ String[] classes = rowClasses.split(",");
+ styleClass = classes[currentRow % classes.length];
+ } else {
+ styleClass = (String) colspan.getAttributes().get("styleClass");
+ }
+
+ Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
+ Object skinRowClass = currentRow == 0 ?
requestMap.get(AbstractRowsRenderer.SKIN_FIRST_ROW_CLASS_KEY):
+ requestMap.get(AbstractRowsRenderer.SKIN_ROW_CLASS_KEY);
+
+ encodeStyleClass(context.getResponseWriter(), skinRowClass, "rich-tablerow",
requestMap
+ .get(AbstractRowsRenderer.ROW_CLASS_KEY), styleClass);
+
+ String style = (String) colspan.getAttributes().get("style");
+ encodeStyle(context.getResponseWriter(),null, null, null, style);
+
+ getUtils().encodePassThruWithExclusionsArray(context, colspan,EVENT_ATTRS, null);
+ // Search for enclosed DataAdaptor.
+ UIComponent parent = colspan.getParent();
+ // ENCODE event attributes. If component don't have own attribute, search in the
parent table.
+ boolean inRow = null != parent && parent.getChildren().contains(colspan);
+ for (int i = 0; i < AbstractRowsRenderer.TABLE_EVENT_ATTRS.length; i++) {
+
+ String[] attrs = AbstractRowsRenderer.TABLE_EVENT_ATTRS[i];
+ String event = (String) colspan.getAttributes().get(attrs[0]);
+
+ if(null == event && inRow){
+ event = (String) parent.getAttributes().get(attrs[1]);
+ }
+
+ if(null != event){
+ writer.writeAttribute(attrs[0], event, attrs[0]);
+ }
+ }
+ }
+
+ public boolean getRendersChildren() {
+ return true;
+ }
+
+ protected Class<? extends UIComponent> getComponentClass() {
+ return UIColumnGroup.class;
+ }
+
+ public void encodeOneRow(FacesContext context, TableHolder holder) throws IOException {
+ }
+
+ @Override
+ public void doProcess(FacesContext facesContext, TableHolder holder) throws IOException
{
+ }
+
+ @Override
+ public void encodeCell(FacesContext context, UIComponent cell) throws IOException {
+ CellEncoder cellEncode = new SimpleCellEncoder(getUtils(), getCellStyleClasses(context,
cell));
+ cellEncode.encodeBegin(context, cell);
+ renderChildren(context, cell);
+ cellEncode.encodeEnd(context, cell);
+ }
+
+ @Override
+ protected String getCellSkinClass() {
+ //TODO: for test use.
+ return "rich-table-cell";
+ }
+}
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-10-22
07:22:02 UTC (rev 15745)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SimpleDataTableRendererBase.java 2009-10-22
09:59:40 UTC (rev 15746)
@@ -21,33 +21,15 @@
})
public abstract class SimpleDataTableRendererBase extends AbstractTableRenderer {
- public static String [] CELL_ATTRIBUTES = {
- "abbr" , "align" , "axis" , "bgcolor" ,
"char" , "charoff" , "colspan" , "dir" ,
- "headers" , "height" , "lang" , "nowrap" ,
"onclick" , "ondblclick" , "onkeydown" ,
- "onkeypress" , "onkeyup" , "onmousedown" ,
"onmousemove" , "onmouseout" , "onmouseover" ,
- "onmouseup" , "rowspan" , "scope" , "style"
, "title" , "valign" , "width" , "xml:lang" };
-
@Override
public void encodeCell(FacesContext context, UIComponent component) throws IOException
{
- ResponseWriter writer = context.getResponseWriter();
-
- java.lang.String clientId = component.getClientId(context);
- String styleClasses = cellStyleClass(context, component);
- boolean isHeader = styleClasses.contains("header");
-
- String element = isHeader ? HTML.th_ELEM : HTML.td_ELEM;
- writer.startElement(element, component);
-
- getUtils().writeAttribute(writer, "class",styleClasses);
- getUtils().writeAttribute(writer, "id", clientId );
- getUtils().encodeAttributesFromArray(context,component,CELL_ATTRIBUTES);
-
+ CellEncoder cellEncode = new SimpleCellEncoder(getUtils(), getCellStyleClasses(context,
component));
+ cellEncode.encodeBegin(context, component);
renderChildren(context, component);
-
- writer.endElement(element);
-
+ cellEncode.encodeEnd(context, component);
+
}
public void encodeTableStructure(FacesContext context, UIDataTable table) throws
IOException{
Added:
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
(rev 0)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java 2009-10-22
09:59:40 UTC (rev 15746)
@@ -0,0 +1,153 @@
+/**
+ * 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.Iterator;
+
+import javax.faces.component.UIColumn;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.richfaces.component.UIDataTable;
+import org.richfaces.component.UISubTable;
+
+/**
+ * @author shura
+ *
+ */
+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 {
+ 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");
+ 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);
+ writer.endElement(HTML.TR_ELEMENT);
+ }
+ }
+
+ protected void encodeHeaderFacets(FacesContext context, ResponseWriter writer,
Iterator<UIColumn> headers,
+ String skinCellClass, String headerClass, String facetName, String element, int
colCount) throws IOException {
+ //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 {
+ 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;
+ }
+
+ @Override
+ public void encodeChildren(FacesContext context, UIComponent component) throws
IOException {
+ encodeRows(context, (UIDataTable) component);
+ }
+
+ @Override
+ public void encodeTBody(FacesContext context, UIDataTable table)
+ throws IOException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void doProcess(FacesContext facesContext, TableHolder holder)
+ throws IOException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void encodeCell(FacesContext context, UIComponent cell)
+ throws IOException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void encodeOneRow(FacesContext context, TableHolder holder)
+ throws IOException {
+ // TODO Auto-generated method stub
+
+ }
+}
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-22
07:22:02 UTC (rev 15745)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/faces-config.xml 2009-10-22
09:59:40 UTC (rev 15746)
@@ -16,6 +16,10 @@
<component-type>org.richfaces.Column</component-type>
<component-class>org.richfaces.component.html.HtmlColumn</component-class>
</component>
+ <component>
+ <component-type>org.richfaces.Colgroup</component-type>
+ <component-class>org.richfaces.component.html.HtmlColumnGroup</component-class>
+ </component>
<render-kit>
@@ -30,5 +34,11 @@
<renderer-type>org.richfaces.ExtendedDataTableRenderer</renderer-type>
<renderer-class>org.richfaces.renderkit.html.ExtendedDataTableRenderer</renderer-class>
</renderer>
+ <renderer>
+ <component-family>org.richfaces.Colgroup</component-family>
+ <renderer-type>org.richfaces.ColumnGroupRenderer</renderer-type>
+ <renderer-class>org.richfaces.renderkit.html.ColgroupRenderer</renderer-class>
+ </renderer>
+
</render-kit>
</faces-config>
\ No newline at end of file
Added:
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
(rev 0)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/table.css 2009-10-22
09:59:40 UTC (rev 15746)
@@ -0,0 +1,230 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<f:template
xmlns:f='http:/jsf.exadel.com/template'
+
xmlns:u='http:/jsf.exadel.com/template/util'
+
xmlns="http://www.w3.org/1999/xhtml" >
+<u:selector name=".rich-table" >
+ <u:style name="border-top" value="solid">
<!--tableBorderColor-->
+ <f:verbatim skin="tableBorderWidth" />
+ <f:verbatim skin="tableBorderColor" />
+ </u:style>
+ <u:style name="border-left" value="solid">
<!--tableBorderColor-->
+ <f:verbatim skin="tableBorderWidth" />
+ <f:verbatim skin="tableBorderColor" />
+ </u:style>
+ <u:style name="background-color" skin="tableBackgroundColor"
/> <!--tableBackgroundColor-->
+ <!-- <u:style name="border-collapse" value="inherit" /> fix
RF-535 -->
+ <u:style name="empty-cells" value="show" />
+ <u:style name="border-collapse" value="collapse" />
+</u:selector>
+
+<u:selector name=".rich-table-cell" >
+ <u:style name="border-right" value="solid">
<!--tableBorderColor-->
+ <f:verbatim skin="tableBorderWidth" />
+ <f:verbatim skin="tableBorderColor" />
+ </u:style>
+ <u:style name="border-bottom" value="solid">
<!--tableBorderColor-->
+ <f:verbatim skin="tableBorderWidth" />
+ <f:verbatim skin="tableBorderColor" />
+ </u:style>
+ <u:style name="padding" value="4px 4px 4px 4px"/>
+ <u:style name="font-size" skin="generalSizeFont"/>
<!--generalSizeFont-->
+ <u:style name="color" skin="generalTextColor"/>
<!--generalTextColor-->
+ <u:style name="font-family" skin="generalFamilyFont"/>
<!--generalFamilyFont-->
+</u:selector>
+
+<u:selector name=".rich-subtable-cell" >
+ <u:style name="border-right" value="solid">
<!--tableBorderColor-->
+ <f:verbatim skin="tableBorderWidth" />
+ <f:verbatim skin="tableBorderColor" />
+ </u:style>
+ <u:style name="border-bottom" value="solid">
<!--tableBorderColor-->
+ <f:verbatim skin="tableBorderWidth" />
+ <f:verbatim skin="tableBorderColor" />
+ </u:style>
+ <u:style name="padding" value="4px 4px 4px 4px"/>
+ <u:style name="font-size" skin="generalSizeFont"/>
<!--generalSizeFont-->
+ <u:style name="color" skin="generalTextColor"/>
<!--generalTextColor-->
+ <u:style name="font-family" skin="generalFamilyFont"/>
<!--generalFamilyFont-->
+</u:selector>
+
+<u:selector name=".rich-table-header" >
+ <u:style name="background-color"
skin="headerBackgroundColor"/> <!--headerBackgroundColor-->
+ <u:style name="background-image" > <!--from headerGradientColor to
headerBackgroundColor-->
+ <f:resource f:key="org.richfaces.renderkit.html.GradientA"/>
+ </u:style>
+ <u:style name="background-position" value="top left"/>
+ <u:style name="background-repeat" value="repeat-x"/>
+</u:selector>
+
+<u:selector name=".rich-table-header-continue" >
+ <u:style name="background-color"
skin="headerBackgroundColor"/> <!--headerBackgroundColor-->
+</u:selector>
+
+<u:selector name=".rich-table-headercell" >
+ <u:style name="border-right" value="solid">
<!--tableBorderColor-->
+ <f:verbatim skin="tableBorderWidth" />
+ <f:verbatim skin="tableBorderColor" />
+ </u:style>
+ <u:style name="border-bottom" value="solid">
<!--tableBorderColor-->
+ <f:verbatim skin="tableBorderWidth" />
+ <f:verbatim skin="tableBorderColor" />
+ </u:style>
+ <u:style name="padding" value="4px 4px 4px 4px"/>
+ <u:style name="color" skin="headerTextColor"/>
<!--headerTextColor-->
+ <u:style name="text-align" value="center"/>
+ <u:style name="font-weight" skin="headerWeightFont"/>
+ <u:style name="font-size" skin="generalSizeFont"/>
<!--generalSizeFont-->
+ <u:style name="font-family" skin="generalFamilyFont"/>
<!--generalFamilyFont-->
+</u:selector>
+
+<u:selector name=".rich-table-subheader" >
+ <u:style name="background-color"
skin="additionalBackgroundColor"/> <!--additionalBackgroundColor-->
+</u:selector>
+
+<u:selector name=".rich-table-thead" >
+ <u:style name="border-bottom" value="solid">
<!--tableBorderColor-->
+ <f:verbatim skin="tableBorderWidth" />
+ <f:verbatim skin="tableBorderColor" />
+ </u:style>
+</u:selector>
+
+<u:selector name=".rich-table-subheadercell" >
+ <u:style name="border-right" value="solid">
<!--tableBorderColor-->
+ <f:verbatim skin="tableBorderWidth" />
+ <f:verbatim skin="tableBorderColor" />
+ </u:style>
+ <u:style name="padding" value="4px 4px 4px 4px"/>
+ <u:style name="text-align" value="center"/>
+ <u:style name="font-size" skin="generalSizeFont"/>
<!--generalSizeFont-->
+ <u:style name="color" skin="generalTextColor"/>
<!--generalTextColor-->
+ <u:style name="font-family" skin="generalFamilyFont"/>
<!--generalFamilyFont-->
+ <u:style name="white-space" value="nowrap"/>
+</u:selector>
+
+<f:verbatim>
+ .rich-table-sortable-header {
+ background-position: right center;
+ background-repeat: no-repeat;
+ white-space : nowrap;
+ }
+
+ .rich-table-cursor-pointer {
+ cursor: pointer;
+ }
+
+ .rich-inplace-edit, .rich-inplace-view {
+ cursor: default;
+ }
+
+ .rich-sort-icon {
+ vertical-align: middle;
+ }
+</f:verbatim>
+
+<u:selector name=".rich-table-footer" >
+ <u:style name="background-color"
skin="tableFooterBackgroundColor"/> <!--tableFooterBackgroundColor-->
+</u:selector>
+
+
+<u:selector name=".rich-table-footer-continue" >
+ <u:style name="background-color"
skin="tableFooterBackgroundColor"/> <!--tableFooterBackgroundColor-->
+</u:selector>
+
+<u:selector name=".rich-table-footercell" >
+ <u:style name="border-right" value="solid">
<!--tableBorderColor-->
+ <f:verbatim skin="tableBorderWidth" />
+ <f:verbatim skin="tableBorderColor" />
+ </u:style>
+ <u:style name="border-bottom" value="solid">
<!--tableBorderColor-->
+ <f:verbatim skin="tableBorderWidth" />
+ <f:verbatim skin="tableBorderColor" />
+ </u:style>
+ <u:style name="padding" value="4px 4px 4px 4px"/>
+ <u:style name="color" skin="generalTextColor"/>
<!--headerTextColor-->
+ <u:style name="text-align" value="left"/>
+ <u:style name="font-weight" skin="headerWeightFont"/>
+ <u:style name="font-size" skin="generalSizeFont"/>
<!--generalSizeFont-->
+ <u:style name="font-family" skin="generalFamilyFont"/>
<!--generalFamilyFont-->
+</u:selector>
+
+<u:selector name=".rich-table-subfooter" >
+ <u:style name="background-color"
skin="tableSubfooterBackgroundColor"/>
<!--tableSubfooterBackgroundColor-->
+</u:selector>
+
+<u:selector name=".rich-table-subfootercell" >
+ <u:style name="border-right" value="solid">
<!--tableBorderColor-->
+ <f:verbatim skin="tableBorderWidth" />
+ <f:verbatim skin="tableBorderColor" />
+ </u:style>
+ <u:style name="border-bottom" value="solid">
<!--tableBorderColor-->
+ <f:verbatim skin="tableBorderWidth" />
+ <f:verbatim skin="tableBorderColor" />
+ </u:style>
+ <u:style name="padding" value="4px 4px 4px 4px"/>
+ <u:style name="text-align" value="left"/>
+ <u:style name="font-size" skin="generalSizeFont"/>
<!--generalSizeFont-->
+ <u:style name="color" skin="generalTextColor"/>
<!--generalTextColor-->
+ <u:style name="font-family" skin="generalFamilyFont"/>
<!--generalFamilyFont-->
+</u:selector>
+
+<u:selector name=".rich-table-firstrow .rich-table-cell" >
+<!-- <u:style name="border-top" value="2px solid">
+ <f:verbatim skin="tableBorderColor" />
+ </u:style> -->
+</u:selector>
+
+<u:selector name=".rich-subtable-firstrow .rich-subtable-cell" >
+ <!-- <u:style name="border" value="2px solid
#c0c0c0"/>-->
+</u:selector>
+
+<u:selector name=".rich-subtable-header" >
+ <u:style name="background-color"
skin="additionalBackgroundColor"/> <!--additionalBackgroundColor-->
+</u:selector>
+
+<u:selector name=".rich-subtable-headercell" >
+ <u:style name="border-right" value="solid">
<!--tableBorderColor-->
+ <f:verbatim skin="tableBorderWidth" />
+ <f:verbatim skin="tableBorderColor" />
+ </u:style>
+ <u:style name="border-bottom" value="solid">
<!--tableBorderColor-->
+ <f:verbatim skin="tableBorderWidth" />
+ <f:verbatim skin="tableBorderColor" />
+ </u:style>
+ <u:style name="padding" value="4px 4px 4px 4px"/>
+ <u:style name="text-align" value="center"/>
+ <u:style name="font-size" skin="generalSizeFont"/>
<!--generalSizeFont-->
+ <u:style name="color" skin="generalTextColor"/>
<!--generalTextColor-->
+ <u:style name="font-family" skin="generalFamilyFont"/>
<!--generalFamilyFont-->
+</u:selector>
+
+
+<u:selector name=".rich-subtable-footer" >
+ <u:style name="background-color"
skin="tableSubfooterBackgroundColor"/>
<!--tableSubfooterBackgroundColor-->
+</u:selector>
+
+<u:selector name=".rich-subtable-footercell" >
+ <u:style name="border-right" value="solid">
<!--tableBorderColor-->
+ <f:verbatim skin="tableBorderWidth" />
+ <f:verbatim skin="tableBorderColor" />
+ </u:style>
+ <u:style name="border-bottom" value="solid">
<!--tableBorderColor-->
+ <f:verbatim skin="tableBorderWidth" />
+ <f:verbatim skin="tableBorderColor" />
+ </u:style>
+ <u:style name="padding" value="4px 4px 4px 4px"/>
+ <u:style name="text-align" value="left"/>
+</u:selector>
+
+<u:selector name=".rich-sort-asc">
+ <u:style name="background-image">
+ <f:resource
f:key="org.richfaces.renderkit.html.iconimages.DataTableIconSortAsc"/>
+ </u:style>
+</u:selector>
+<u:selector name=".rich-sort-desc">
+ <u:style name="background-image">
+ <f:resource
f:key="org.richfaces.renderkit.html.iconimages.DataTableIconSortDesc"/>
+ </u:style>
+</u:selector>
+
+
+</f:template>
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-22
07:22:02 UTC (rev 15745)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/tables.taglib.xml 2009-10-22
09:59:40 UTC (rev 15746)
@@ -23,4 +23,11 @@
<component-type>org.richfaces.Column</component-type>
</component>
</tag>
+ <tag>
+ <tag-name>colGroup</tag-name>
+ <component>
+ <component-type>org.richfaces.Colgroup</component-type>
+ <renderer-type>org.richfaces.ColumnGroupRenderer</renderer-type>
+ </component>
+ </tag>
</facelet-taglib>
Added:
root/ui-sandbox/trunk/components/tables/ui/src/main/templates/org/richfaces/renderkit/html/colgroup.template.xml
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/templates/org/richfaces/renderkit/html/colgroup.template.xml
(rev 0)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/templates/org/richfaces/renderkit/html/colgroup.template.xml 2009-10-22
09:59:40 UTC (rev 15746)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<cdk:root
xmlns="http://richfaces.org/xhtml-el"
xmlns:cdk="http://richfaces.org/cdk"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ class="org.richfaces.renderkit.html.ColgroupRenderer"
+ superclass="org.richfaces.renderkit.SimpleColgroupRenderer"
+ componentclass="org.richfaces.component.UIColumnGroup" >
+ <tr id="#{clientId}">
+ <cdk:body>
+ <cdk:call expression="super.encodeChildren(context,component);"/>
+ </cdk:body>
+ </tr>
+</cdk:root>
\ No newline at end of file