Author: alexsmirnov
Date: 2007-03-15 16:04:25 -0400 (Thu, 15 Mar 2007)
New Revision: 81
Modified:
trunk/richfaces-samples/dataTableDemo/pom.xml
trunk/richfaces-samples/dataTableDemo/src/main/java/org/richfaces/Bean.java
trunk/richfaces-samples/dataTableDemo/src/main/java/org/richfaces/Data.java
trunk/richfaces-samples/dataTableDemo/src/main/webapp/pages/ajax.jsp
trunk/richfaces-samples/dataTableDemo/src/main/webapp/pages/index.jsp
trunk/richfaces/dataTable/src/main/java/org/richfaces/component/UIDataTable.java
trunk/richfaces/dataTable/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
trunk/richfaces/dataTable/src/main/java/org/richfaces/renderkit/html/ColgroupRenderer.java
Log:
Fix issues :
RF-19 - properly handle 'rendered' columns attribute.
FR-14 - re-render iteration components by AJAX
RF-4 - store current row key value in EL-variable.
Fiv versions in data table demo application.
Modified:
trunk/richfaces/dataTable/src/main/java/org/richfaces/component/UIDataTable.java
===================================================================
---
trunk/richfaces/dataTable/src/main/java/org/richfaces/component/UIDataTable.java 2007-03-15
19:50:08 UTC (rev 80)
+++
trunk/richfaces/dataTable/src/main/java/org/richfaces/component/UIDataTable.java 2007-03-15
20:04:25 UTC (rev 81)
@@ -35,14 +35,13 @@
/**
* JSF component class
- *
+ *
*/
public abstract class UIDataTable extends UIRepeat {
-
/**
* @author shura
- *
+ *
*/
private static final class NotColumnPredicate implements Predicate {
public boolean evaluate(Object input) {
@@ -52,7 +51,7 @@
/**
* @author shura
- *
+ *
*/
private static final class ColumnPredicate implements Predicate {
public boolean evaluate(Object input) {
@@ -62,51 +61,70 @@
/**
* @author shura
- *
+ *
*/
private static final class AjaxSupportPredicate implements Predicate {
public boolean evaluate(Object input) {
- return (input instanceof AjaxSupport||input instanceof Dropzone);
+ 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)
+ /*
+ * (non-Javadoc)
+ *
* @see org.ajax4jsf.ajax.repeat.UIDataAdaptor#dataChildren()
*/
public Iterator dataChildren() {
- IteratorChain dataChildren = new IteratorChain(columns());
- dataChildren.addIterator(new
FilterIterator(getFacets().values().iterator(),isAjaxSupport));
+ IteratorChain dataChildren = new IteratorChain();
+ dataChildren.addIterator(new FilterIterator(getFacets().values()
+ .iterator(), isAjaxSupport));
+ // Append all columns children.
+ for (Iterator iter = columns(); iter.hasNext();) {
+ UIComponent column = (UIComponent) iter.next();
+ if (column.isRendered()) {
+ dataChildren.addIterator(column.getChildren()
+ .iterator());
+
+ }
+ }
return dataChildren;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.ajax4jsf.ajax.repeat.UIDataAdaptor#fixedChildren()
*/
public Iterator 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 ));
+ IteratorChain fixedChildren = new IteratorChain(getFacets().values()
+ .iterator());
+ fixedChildren.addIterator(new FilterIterator(getChildren().iterator(),
+ isNotColumn));
// Append all columns facets.
for (Iterator iter = columns(); iter.hasNext();) {
UIComponent column = (UIComponent) iter.next();
- fixedChildren.addIterator(column.getFacets().values().iterator());
+ if (column.isRendered()) {
+ fixedChildren.addIterator(column.getFacets().values()
+ .iterator());
+
+ }
}
return fixedChildren;
}
-
- public Iterator columns(){
- return new FilterIterator(getChildren().iterator(),isColumn);
+
+ public Iterator columns() {
+ return new FilterIterator(getChildren().iterator(), isColumn);
}
private static final String COMPONENT_TYPE = "org.richfaces.DataTable";
-
+
private static final String COMPONENT_FAMILY = "org.richfaces.DataTable";
-
+
}
Modified:
trunk/richfaces/dataTable/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
===================================================================
---
trunk/richfaces/dataTable/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2007-03-15
19:50:08 UTC (rev 80)
+++
trunk/richfaces/dataTable/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2007-03-15
20:04:25 UTC (rev 81)
@@ -43,24 +43,28 @@
public abstract class AbstractTableRenderer extends AbstractRowsRenderer {
/**
- * Encode all table structure - colgroups definitions, caption, header, footer
+ * Encode all table structure - colgroups definitions, caption, header,
+ * footer
+ *
* @param context
* @param table
* @throws IOException
*/
- public void encodeTableStructure(FacesContext context, UIDataTable table) throws
IOException {
+ public void encodeTableStructure(FacesContext context, UIDataTable table)
+ throws IOException {
ResponseWriter writer = context.getResponseWriter();
int columns = getColumnsCount(table);
// Encode colgroup definition.
writer.startElement("colgroup", table);
writer.writeAttribute("span", String.valueOf(columns), null);
- String columnsWidth = (String)table.getAttributes().get("columnsWidth");
- if(null!=columnsWidth){
+ String columnsWidth = (String) table.getAttributes()
+ .get("columnsWidth");
+ if (null != columnsWidth) {
String[] widths = columnsWidth.split(",");
for (int i = 0; i < widths.length; i++) {
writer.startElement("col", table);
writer.writeAttribute("width", widths[i], null);
- writer.endElement("col");
+ writer.endElement("col");
}
}
writer.endElement("colgroup");
@@ -68,10 +72,9 @@
encodeHeader(context, table, columns);
encodeFooter(context, table, columns);
}
-
-
- public void encodeHeader(FacesContext context, UIDataTable table, int columns)
- throws IOException {
+
+ public void encodeHeader(FacesContext context, UIDataTable table,
+ int columns) throws IOException {
ResponseWriter writer = context.getResponseWriter();
UIComponent header = table.getHeader();
Iterator headers = columnFacets(table, "header");
@@ -80,27 +83,38 @@
String headerClass = (String) table.getAttributes().get(
"headerClass");
if (header != null) {
- encodeTableHeaderFacet(context, columns, writer, header, "dr-table-header
rich-table-header","dr-table-header-continue rich-table-header-continue",
"dr-table-headercell rich-table-headercell", headerClass, "td");
+ encodeTableHeaderFacet(context, columns, writer, header,
+ "dr-table-header rich-table-header",
+ "dr-table-header-continue rich-table-header-continue",
+ "dr-table-headercell rich-table-headercell",
+ headerClass, "td");
}
if (headers.hasNext()) {
writer.startElement("tr", table);
- encodeStyleClass(writer, null, "dr-table-subheader rich-table-subheader",
null, headerClass);
- encodeHeaderFacets(context, writer, headers, "dr-table-subheadercell
rich-table-subheadercell",headerClass,"header", "td");
+ encodeStyleClass(writer, null,
+ "dr-table-subheader rich-table-subheader", null,
+ headerClass);
+ encodeHeaderFacets(context, writer, headers,
+ "dr-table-subheadercell rich-table-subheadercell",
+ headerClass, "header", "td");
writer.endElement("tr");
}
writer.endElement("thead");
}
}
-
- protected void encodeHeaderFacets(FacesContext context, ResponseWriter writer, Iterator
headers, String skinCellClass,String headerClass, String facetName, String element) throws
IOException {
+ protected void encodeHeaderFacets(FacesContext context,
+ ResponseWriter writer, Iterator headers, String skinCellClass,
+ String headerClass, String facetName, String element)
+ throws IOException {
while (headers.hasNext()) {
UIComponent column = (UIComponent) headers.next();
- String classAttribute = facetName+"Class";
- String columnHeaderClass = (String) column.getAttributes()
- .get(classAttribute);
+ String classAttribute = facetName + "Class";
+ String columnHeaderClass = (String) column.getAttributes().get(
+ classAttribute);
writer.startElement(element, column);
- encodeStyleClass(writer, null, skinCellClass, headerClass, columnHeaderClass);
+ encodeStyleClass(writer, null, skinCellClass, headerClass,
+ columnHeaderClass);
writer.writeAttribute("scope", "col", null);
getUtils().encodeAttribute(context, column, "colspan");
UIComponent facet = column.getFacet(facetName);
@@ -111,8 +125,8 @@
}
}
- public void encodeFooter(FacesContext context, UIDataTable table, int columns)
- throws IOException {
+ public void encodeFooter(FacesContext context, UIDataTable table,
+ int columns) throws IOException {
ResponseWriter writer = context.getResponseWriter();
UIComponent footer = table.getFooter();
Iterator footers = columnFacets(table, "footer");
@@ -122,19 +136,26 @@
"footerClass");
if (footers.hasNext()) {
writer.startElement("tr", table);
- encodeStyleClass(writer, null, "dr-table-subfooter rich-table-subfooter",
null, footerClass);
- encodeHeaderFacets(context, writer, footers, "dr-table-subfootercell
rich-table-subfootercell",footerClass,"footer", "td");
+ encodeStyleClass(writer, null,
+ "dr-table-subfooter rich-table-subfooter", null,
+ footerClass);
+ encodeHeaderFacets(context, writer, footers,
+ "dr-table-subfootercell rich-table-subfootercell",
+ footerClass, "footer", "td");
writer.endElement("tr");
}
if (footer != null) {
- encodeTableHeaderFacet(context, columns, writer, footer, "dr-table-footer
rich-table-footer","dr-table-footer-continue rich-table-footer-continue",
"dr-table-footercell rich-table-footercell", footerClass, "td");
+ encodeTableHeaderFacet(context, columns, writer, footer,
+ "dr-table-footer rich-table-footer",
+ "dr-table-footer-continue rich-table-footer-continue",
+ "dr-table-footercell rich-table-footercell",
+ footerClass, "td");
}
writer.endElement("tfoot");
}
}
-
public void encodeOneRow(FacesContext context, TableHolder holder)
throws IOException {
UIDataTable table = (UIDataTable) holder.getTable();
@@ -148,7 +169,8 @@
// Start new row for first column - expect a case of the detail
// table, wich will be insert own row.
if (first && !(column instanceof Row)) {
- encodeRowStart(context,getFirstRowSkinClass() ,holder.getRowClass(), table, writer);
+ encodeRowStart(context, getFirstRowSkinClass(), holder
+ .getRowClass(), table, writer);
}
if (column instanceof Column) {
boolean breakBefore = ((Column) column).isBreakBefore()
@@ -162,24 +184,30 @@
// will be insert own row.
if (!(column instanceof Row)) {
holder.nextRow();
- encodeRowStart(context, holder.getRowClass(), table, writer);
+ encodeRowStart(context, holder.getRowClass(), table,
+ writer);
}
}
- encodeCellChildren(context,
column,first?getFirstRowSkinClass():null,getRowSkinClass(), holder.getRowClass(),
getCellSkinClass(), holder.getColumnClass(currentColumn));
-// renderChild(context, column);
+ encodeCellChildren(context, column,
+ first ? getFirstRowSkinClass() : null,
+ getRowSkinClass(), holder.getRowClass(),
+ getCellSkinClass(), holder
+ .getColumnClass(currentColumn));
+ // renderChild(context, column);
if ((column instanceof Row) && iter.hasNext()) {
// Start new row for remained columns.
- holder.nextRow();
- encodeRowStart(context, holder.getRowClass(), table, writer);
- // reset columns counter.
- currentColumn = -1;
+ holder.nextRow();
+ encodeRowStart(context, holder.getRowClass(), table, writer);
+ // reset columns counter.
+ currentColumn = -1;
}
- } else {
+ } else if (column.isRendered()) {
// UIColumn don't have own renderer
writer.startElement(HTML.td_ELEM, table);
getUtils().encodeId(context, column);
String columnClass = holder.getColumnClass(currentColumn);
- encodeStyleClass(writer, null, getCellSkinClass(), null, columnClass);
+ encodeStyleClass(writer, null, getCellSkinClass(), null,
+ columnClass);
// TODO - encode column attributes.
renderChildren(context, column);
writer.endElement(HTML.td_ELEM);
@@ -197,7 +225,7 @@
UIDataTable table, ResponseWriter writer) throws IOException {
encodeRowStart(context, getRowSkinClass(), rowClass, table, writer);
}
-
+
/**
* @return
*/
@@ -211,6 +239,7 @@
protected String getFirstRowSkinClass() {
return "dr-table-firstrow rich-table-firstrow";
}
+
/**
* @return
*/
@@ -218,9 +247,9 @@
return "dr-table-cell rich-table-cell";
}
-
- protected void encodeRowStart(FacesContext context,String skinClass, String rowClass,
- UIDataTable table, ResponseWriter writer) throws IOException {
+ protected void encodeRowStart(FacesContext context, String skinClass,
+ String rowClass, UIDataTable table, ResponseWriter writer)
+ throws IOException {
writer.startElement(HTML.TR_ELEMENT, table);
encodeStyleClass(writer, null, skinClass, null, rowClass);
encodeRowEvents(context, table);
@@ -230,8 +259,10 @@
return new FilterIterator(table.columns(), new Predicate() {
public boolean evaluate(Object input) {
+ UIComponent component = (UIComponent) input;
// accept only components with requested facet.
- return ((UIComponent) input).getFacet(name) != null;
+ return component.isRendered()
+ && component.getFacet(name) != null;
}
});
@@ -259,8 +290,11 @@
}
/**
- * Calculate max number of columns per row. For rows, recursive calculate max length.
- * @param col - Iterator other all columns in table.
+ * Calculate max number of columns per row. For rows, recursive calculate
+ * max length.
+ *
+ * @param col -
+ * Iterator other all columns in table.
* @return
*/
protected int calculateRowColumns(Iterator col) {
@@ -268,38 +302,43 @@
int currentLength = 0;
while (col.hasNext()) {
UIComponent column = (UIComponent) col.next();
- if (column instanceof Row) {
- // Store max calculated value of previsous rows.
- if (currentLength > count) {
- count = currentLength;
- }
- // Calculate number of columns in row.
- currentLength = calculateRowColumns(((Row) column).columns());
- // Store max calculated value
- if (currentLength > count) {
- count = currentLength;
- }
- currentLength = 0;
- } else if (column instanceof Column) {
- Column tableColumn = (Column) column;
- // For new row, save length of previsous.
- if (tableColumn.isBreakBefore()) {
+ if (column.isRendered()) {
+ if (column instanceof Row) {
+ // Store max calculated value of previsous rows.
if (currentLength > count) {
count = currentLength;
}
+ // Calculate number of columns in row.
+ currentLength = calculateRowColumns(((Row) column)
+ .columns());
+ // Store max calculated value
+ if (currentLength > count) {
+ count = currentLength;
+ }
currentLength = 0;
- }
- Integer colspan = (Integer) column.getAttributes().get(
- "colspan");
- // Append colspan of this column
- if (null != colspan && colspan.intValue() != Integer.MIN_VALUE) {
- currentLength += colspan.intValue();
- } else {
+ } else if (column instanceof Column) {
+ Column tableColumn = (Column) column;
+ // For new row, save length of previsous.
+ if (tableColumn.isBreakBefore()) {
+ if (currentLength > count) {
+ count = currentLength;
+ }
+ currentLength = 0;
+ }
+ Integer colspan = (Integer) column.getAttributes().get(
+ "colspan");
+ // Append colspan of this column
+ if (null != colspan
+ && colspan.intValue() != Integer.MIN_VALUE) {
+ currentLength += colspan.intValue();
+ } else {
+ currentLength++;
+ }
+ } else if (column instanceof UIColumn) {
+ // UIColumn always have colspan == 1.
currentLength++;
}
- } else if (column instanceof UIColumn) {
- // UIColumn always have colspan == 1.
- currentLength++;
+
}
}
if (currentLength > count) {
Modified:
trunk/richfaces/dataTable/src/main/java/org/richfaces/renderkit/html/ColgroupRenderer.java
===================================================================
---
trunk/richfaces/dataTable/src/main/java/org/richfaces/renderkit/html/ColgroupRenderer.java 2007-03-15
19:50:08 UTC (rev 80)
+++
trunk/richfaces/dataTable/src/main/java/org/richfaces/renderkit/html/ColgroupRenderer.java 2007-03-15
20:04:25 UTC (rev 81)
@@ -39,14 +39,18 @@
* @author shura
*
*/
-public class ColgroupRenderer extends AbstractRowsRenderer {
+public class ColgroupRenderer extends AbstractRowsRenderer {
- private static final String[] STYLE_ATTRS = {"style","class"};
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.framework.renderer.RendererBase#doEncodeBegin(javax.faces.context.ResponseWriter,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ private static final String[] STYLE_ATTRS = { "style", "class" };
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.renderer.RendererBase#doEncodeBegin(javax.faces.context.ResponseWriter,
+ * javax.faces.context.FacesContext, javax.faces.component.UIComponent)
*/
- protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent
colgroup) throws IOException {
+ protected void doEncodeBegin(ResponseWriter writer, FacesContext context,
+ UIComponent colgroup) throws IOException {
encodeRowStart(context, colgroup, writer, 0);
}
@@ -55,8 +59,9 @@
UIColumnGroup colgroup = (UIColumnGroup) component;
ResponseWriter writer = context.getResponseWriter();
String[] classes = null;
- String columnClasses = (String)
component.getAttributes().get("columnClasses");
- if(null != columnClasses){
+ String columnClasses = (String) component.getAttributes().get(
+ "columnClasses");
+ if (null != columnClasses) {
classes = columnClasses.split(",");
}
Iterator iter = colgroup.columns();
@@ -80,64 +85,87 @@
encodeRowStart(context, colgroup, writer, currentRow);
}
String styleClass = null;
- if(null!= classes){
- styleClass = classes[currentColumn%classes.length];
+ if (null != classes) {
+ styleClass = classes[currentColumn % classes.length];
}
- encodeCellChildren(context, column, null, null, null, (String)
requestMap.get(AbstractRowsRenderer.SKIN_CELL_CLASS_KEY), styleClass);
-// renderChild(context, column);
+ encodeCellChildren(context, column, null, null, null,
+ (String) requestMap
+ .get(AbstractRowsRenderer.SKIN_CELL_CLASS_KEY),
+ styleClass);
+ // renderChild(context, column);
} else {
// UIColumn don't have own renderer
- writer.startElement(HTML.td_ELEM, column);
- getUtils().encodeId(context, column);
- String styleClass;
- if(null!= classes){
- styleClass = classes[currentColumn%classes.length];
- }else {
- styleClass = (String) column.getAttributes().get("styleClass");
+ if (column.isRendered()) {
+ writer.startElement(HTML.td_ELEM, column);
+ getUtils().encodeId(context, column);
+ String styleClass;
+ if (null != classes) {
+ styleClass = classes[currentColumn % classes.length];
+ } else {
+ styleClass = (String) column.getAttributes().get(
+ "styleClass");
+ }
+ encodeStyleClass(context.getResponseWriter(), requestMap
+ .get(AbstractRowsRenderer.SKIN_CELL_CLASS_KEY),
+ "dr-table-cell rich-table-cell", requestMap
+ .get(AbstractRowsRenderer.CELL_CLASS_KEY),
+ styleClass);
+ // TODO - encode column attributes.
+ renderChildren(context, column);
+ writer.endElement(HTML.td_ELEM);
+
}
- encodeStyleClass(context.getResponseWriter(),
requestMap.get(AbstractRowsRenderer.SKIN_CELL_CLASS_KEY), "dr-table-cell
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;
}
}
- /* (non-Javadoc)
- * @see
org.ajax4jsf.framework.renderer.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.renderer.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 {
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){
+ if (null != rowClasses) {
String[] classes = rowClasses.split(",");
- styleClass = classes[currentRow%classes.length];
+ styleClass = classes[currentRow % classes.length];
} else {
- styleClass = (String) colspan.getAttributes().get("styleClass");
+ styleClass = (String) colspan.getAttributes().get("styleClass");
}
Map 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, "dr-tablerow
rich-tablerow", requestMap.get(AbstractRowsRenderer.ROW_CLASS_KEY), styleClass);
+ Object skinRowClass = currentRow == 0 ? requestMap
+ .get(AbstractRowsRenderer.SKIN_FIRST_ROW_CLASS_KEY)
+ : requestMap.get(AbstractRowsRenderer.SKIN_ROW_CLASS_KEY);
+ encodeStyleClass(context.getResponseWriter(), skinRowClass,
+ "dr-tablerow rich-tablerow", requestMap
+ .get(AbstractRowsRenderer.ROW_CLASS_KEY), styleClass);
getUtils().encodePassThru(context, colspan);
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see javax.faces.render.Renderer#getRendersChildren()
*/
public boolean getRendersChildren() {
-
+
return true;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.ajax4jsf.framework.renderer.RendererBase#getComponentClass()
*/
protected Class getComponentClass() {
@@ -145,11 +173,15 @@
return UIColumnGroup.class;
}
- /* (non-Javadoc)
- * @see
org.richfaces.renderkit.AbstractRowsRenderer#encodeOneRow(javax.faces.context.FacesContext,
org.richfaces.renderkit.TableHolder)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.richfaces.renderkit.AbstractRowsRenderer#encodeOneRow(javax.faces.context.FacesContext,
+ * org.richfaces.renderkit.TableHolder)
*/
- public void encodeOneRow(FacesContext context, TableHolder holder) throws IOException {
+ public void encodeOneRow(FacesContext context, TableHolder holder)
+ throws IOException {
// this method don't used in columnGroup component.
-
+
}
}
Modified: trunk/richfaces-samples/dataTableDemo/pom.xml
===================================================================
--- trunk/richfaces-samples/dataTableDemo/pom.xml 2007-03-15 19:50:08 UTC (rev 80)
+++ trunk/richfaces-samples/dataTableDemo/pom.xml 2007-03-15 20:04:25 UTC (rev 81)
@@ -17,7 +17,7 @@
<dependency>
<groupId>org.richfaces</groupId>
<artifactId>dataTable</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.richfaces</groupId>
Modified: trunk/richfaces-samples/dataTableDemo/src/main/java/org/richfaces/Bean.java
===================================================================
--- trunk/richfaces-samples/dataTableDemo/src/main/java/org/richfaces/Bean.java 2007-03-15
19:50:08 UTC (rev 80)
+++ trunk/richfaces-samples/dataTableDemo/src/main/java/org/richfaces/Bean.java 2007-03-15
20:04:25 UTC (rev 81)
@@ -24,6 +24,8 @@
import java.util.ArrayList;
import java.util.List;
+import javax.faces.event.ValueChangeEvent;
+
/**
* @author $Autor$
*
@@ -89,6 +91,7 @@
* @return the checked
*/
public boolean isChecked() {
+ System.out.println("Invoke get checked for mounth "+getMounth()+",
checked:"+checked);
return this.checked;
}
@@ -96,6 +99,7 @@
* @param checked the checked to set
*/
public void setChecked(boolean checked) {
+ System.out.println("Invoke set checked for mounth "+getMounth()+",
checked:"+checked);
this.checked = checked;
}
@@ -105,4 +109,7 @@
return null;
}
+ public void checkChanged(ValueChangeEvent event) {
+ System.out.println("Checked changed for mounth "+getMounth());
+ }
}
\ No newline at end of file
Modified: trunk/richfaces-samples/dataTableDemo/src/main/java/org/richfaces/Data.java
===================================================================
--- trunk/richfaces-samples/dataTableDemo/src/main/java/org/richfaces/Data.java 2007-03-15
19:50:08 UTC (rev 80)
+++ trunk/richfaces-samples/dataTableDemo/src/main/java/org/richfaces/Data.java 2007-03-15
20:04:25 UTC (rev 81)
@@ -36,8 +36,30 @@
private List mounths = new ArrayList();
private List numbers = new ArrayList();
+
+ private boolean c3rendered=true;
+ private boolean c2rendered=true;
+
/**
+ * @return the c3rendered
+ */
+ public boolean isC3rendered() {
+ return this.c3rendered;
+ }
+
+ /**
+ * @param c3rendered the c3rendered to set
+ */
+ public void setC3rendered(boolean c3rendered) {
+ this.c3rendered = c3rendered;
+ }
+
+ public String toggleColumn() {
+ this.c3rendered = !this.c3rendered;
+ return null;
+ }
+ /**
* @return the numbers
*/
public List getNumbers() {
@@ -88,4 +110,26 @@
this.mounths = mounths;
}
+ /**
+ * @return the c2rendered
+ */
+ public boolean isC2rendered() {
+ return this.c2rendered;
+ }
+
+ /**
+ * @param c2rendered the c2rendered to set
+ */
+ public void setC2rendered(boolean c2rendered) {
+ this.c2rendered = c2rendered;
+ }
+
+ public int getC2span(){
+ return c3rendered?1:2;
+ }
+
+ public int getC1span(){
+ int i = c2rendered?1:c3rendered?2:3;
+ return i;
+ }
}
Modified: trunk/richfaces-samples/dataTableDemo/src/main/webapp/pages/ajax.jsp
===================================================================
--- trunk/richfaces-samples/dataTableDemo/src/main/webapp/pages/ajax.jsp 2007-03-15
19:50:08 UTC (rev 80)
+++ trunk/richfaces-samples/dataTableDemo/src/main/webapp/pages/ajax.jsp 2007-03-15
20:04:25 UTC (rev 81)
@@ -10,8 +10,17 @@
<f:view >
<h:form>
<h:selectOneRadio binding="#{skinBean.component}" />
- <h:commandLink action="#{skinBean.change}" value="set skin"
/>
-
+ <h:commandLink action="#{skinBean.change}" value="set skin"
/>
+ <h:panelGrid columns="2">
+ <h:selectBooleanCheckbox id="c2rendered"
value="#{data.c2rendered}" >
+ <a4j:support event="onchange"
reRender="master"></a4j:support>
+ </h:selectBooleanCheckbox>
+ <h:outputLabel value="Show 2-d column"
for="c2rendered"></h:outputLabel>
+ <h:selectBooleanCheckbox id="c3rendered"
value="#{data.c3rendered}" >
+ <a4j:support event="onchange"
reRender="master"></a4j:support>
+ </h:selectBooleanCheckbox>
+ <h:outputLabel value="Show 3-d column"
for="c3rendered"></h:outputLabel>
+ </h:panelGrid>
<data:dataTable id="master" var="master"
value="#{data.mounths}"
styleClass="table" captionClass="caption"
rowClasses="rowa,rowb,rowc rowcc"
headerClass="header" footerClass="footer">
@@ -21,59 +30,52 @@
<f:facet name="caption"><h:outputText value="caption"
/></f:facet>
<f:facet name="header">
<data:columnGroup columnClasses="cola, colb ,rowc rowcc">
- <data:column rowspan="2">
+ <data:column rowspan="2" colspan="#{data.c1span}" >
<h:outputText value="2-row head" />
</data:column>
- <data:column rowspan="2">
+ <data:column rowspan="2" colspan="#{data.c2span}"
rendered="#{data.c2rendered}">
<h:outputText value="2-row head" />
</data:column>
- <h:column >
+ <h:column rendered="#{data.c3rendered}" >
<h:outputText value="head in UIColumn" />
</h:column>
- <data:column breakBefore="true">
+ <data:column breakBefore="true"
rendered="#{data.c3rendered}">
<h:outputText value="2-d row head" />
</data:column>
</data:columnGroup>
</f:facet>
<f:facet name="footer"><h:outputText value="table
foot" /></f:facet>
- <data:column id="mounth" styleClass="column"
colspan="1"
+ <data:column id="mounth" styleClass="column"
colspan="#{data.c1span}"
headerClass="cheader" footerClass="cfooter" >
<f:facet name="header"><h:outputText value="mounth"
/></f:facet>
<f:facet name="footer"><h:outputText value="-//-"
/></f:facet>
<h:outputText value="#{master.mounth}" />
</data:column>
- <data:column id="cell2" styleClass="column"
colspan="1"
- headerClass="dheader" footerClass="dfooter" >
+ <data:column id="cell2" styleClass="column"
colspan="#{data.c2span}"
+ headerClass="dheader" footerClass="dfooter"
rendered="#{data.c2rendered}">
<f:facet name="header"><h:outputText value="cell 2
head" /></f:facet>
<f:facet name="footer"><h:outputText value="-//-"
/></f:facet>
<h:outputText value="cell 2" />
</data:column>
- <data:column id="cell3" styleClass="column"
colspan="1"
- headerClass="eheader" footerClass="efooter" >
- <f:facet name="header"><h:outputText value="cell 3
head" /></f:facet>
+ <h:column id="cell3" rendered="#{data.c3rendered}" >
+ <f:facet name="header">
+ <h:outputText id="c3head" value="cell 3 head" >
+ <a4j:support event="onclick" action="#{data.toggleColumn}"
reRender="master,c3rendered"></a4j:support>
+ </h:outputText>
+ </f:facet>
<f:facet name="footer"><h:outputText value="-//-"
/></f:facet>
<h:outputText value="cell 3" />
+ </h:column>
+ <data:column breakBefore="true" colspan="2">
+ <h:selectBooleanCheckbox id="checked"
value="#{master.checked}"
+ valueChangeListener="#{master.checkChanged}"/>
+ <h:outputLabel value="Click to toggle"
for="checked"></h:outputLabel>
</data:column>
- <data:subTable id="detail" var="detail"
value="#{master.detail}">
- <data:column id="name" colspan="2">
- <f:facet name="header"><h:outputText value="property"
/></f:facet>
- <f:facet name="footer"><h:outputText value="-/-/-"
/></f:facet>
- <h:outputText value="#{detail.name}" />
+ <data:column id="total" styleClass="total"
colspan="1">
+ <h:outputText value="#{master.total}" />
</data:column>
- <data:column id="qty">
- <f:facet name="header"><h:outputText value="qty"
/></f:facet>
- <f:facet name="footer"><h:outputText value="total"
/></f:facet>
- <h:outputText value="#{detail.qty}" />
- </data:column>
- </data:subTable>
- <data:column>
- <h:selectBooleanCheckbox id="checked"
value="#{master.checked}" />
- </data:column>
- <data:column id="total" styleClass="total"
colspan="2">
- <h:outputText value="#{master.total}" />
- </data:column>
</data:dataTable>
- </h:form>
+ </h:form>
<a4j:log hotkey="D"/>
</f:view>
</body>
Modified: trunk/richfaces-samples/dataTableDemo/src/main/webapp/pages/index.jsp
===================================================================
--- trunk/richfaces-samples/dataTableDemo/src/main/webapp/pages/index.jsp 2007-03-15
19:50:08 UTC (rev 80)
+++ trunk/richfaces-samples/dataTableDemo/src/main/webapp/pages/index.jsp 2007-03-15
20:04:25 UTC (rev 81)
@@ -1,13 +1,15 @@
<%@ taglib
uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib
uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib
uri="http://richfaces.ajax4jsf.org/dataTable"
prefix="data" %>
+<%@ taglib
uri="https://ajax4jsf.dev.java.net/ajax" prefix="a4j"
%>
<html>
<head>
<title></title>
</head>
<body>
- <f:view >
- <h:panelGrid columns="4" border="1">
+ <f:view >
+ <h:form>
+ <h:panelGrid columns="3" border="1">
<data:dataTable id="master" var="master"
value="#{data.mounths}"
styleClass="table" captionClass="caption"
rowClasses="rowa,rowb,rowc rowcc"
headerClass="header" footerClass="footer">
@@ -79,8 +81,13 @@
<h:outputText value="#{detail.qty}" />
</data:column>
</data:subTable>
- </data:dataTable>
- </h:panelGrid>
- </f:view>
+ </data:dataTable>
+ <a4j:commandButton value="Re-render table"
reRender="master"></a4j:commandButton>
+ <a4j:commandButton value="Re-render table"
reRender="master1"></a4j:commandButton>
+ <a4j:commandButton value="Re-render table"
reRender="master2"></a4j:commandButton>
+ </h:panelGrid>
+ </h:form>
+ <a4j:log hotkey="D"/>
+ </f:view>
</body>
</html>