Author: abelevich
Date: 2010-06-21 07:49:19 -0400 (Mon, 21 Jun 2010)
New Revision: 17650
Modified:
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/ColumnGroupRenderer.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/RowHolder.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/RowHolderBase.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SortingFilteringRowsRenderer.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java
Log:
replace swing SortOrder with our implementation, RF-8718
Modified:
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java
===================================================================
---
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java 2010-06-21
11:47:37 UTC (rev 17649)
+++
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java 2010-06-21
11:49:19 UTC (rev 17650)
@@ -42,7 +42,7 @@
public abstract void encodeRow(ResponseWriter writer, FacesContext facesContext,
RowHolderBase rowHolder) throws IOException;
- public abstract RowHolderBase createRowHolder(FacesContext context, UIComponent
component);
+ public abstract RowHolderBase createRowHolder(FacesContext context, UIComponent
component, Object [] options);
public DataVisitResult process(FacesContext facesContext, Object rowKey, Object
argument) {
RowHolderBase holder = (RowHolderBase) argument;
@@ -51,6 +51,7 @@
try {
ResponseWriter writer = facesContext.getResponseWriter();
+ holder.resetProcessCell();
encodeRow(writer, facesContext, holder);
} catch (IOException e) {
throw new FacesException(e);
@@ -63,14 +64,13 @@
rowHolder.getRow().walk(facesContext, this, rowHolder);
}
- public void processRows(ResponseWriter writer, FacesContext facesContext, UIComponent
component, boolean updatePartial) throws IOException {
- RowHolderBase rowHolder = createRowHolder(facesContext, component);
- rowHolder.setPartialUpdate(updatePartial);
+ public void processRows(ResponseWriter writer, FacesContext facesContext, UIComponent
component, Object[] options) throws IOException {
+ RowHolderBase rowHolder = createRowHolder(facesContext, component, options);
encodeRows(facesContext, rowHolder);
}
protected void doEncodeChildren(ResponseWriter writer, FacesContext facesContext,
UIComponent component) throws IOException {
- processRows(writer, facesContext, component, false);
+ processRows(writer, facesContext, component, null);
}
public boolean getRendersChildren() {
Modified:
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
===================================================================
---
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2010-06-21
11:47:37 UTC (rev 17649)
+++
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2010-06-21
11:49:19 UTC (rev 17650)
@@ -45,8 +45,42 @@
public static final String HIDDEN_CONTAINER_ID =":sc";
+ public abstract EncodeStrategy getHiddenContainerStrategy();
+
+ /**
+ * Returns true if specified attribute (when present on the column) should generate
header even if it is not
+ * specified on the table
+ *
+ * @param table
+ * - rendered UIDataTable
+ * @param attributeName
+ * - attribute name
+ * @return true if specified attribute should generate header on the table
+ */
+ // TODO nick - rename this method
+ public boolean isHeaderFactoryColumnAttributePresent(UIDataTableBase table, String
attributeName) {
+ Iterator<UIComponent> columns = table.columns();
+ boolean result = false;
+ while (columns.hasNext() && !result) {
+ UIComponent component = columns.next();
+ result = (component.isRendered() && (null !=
component.getValueExpression(attributeName)));
+ }
+ return result;
+ }
+
+ @Override
+ public RowHolderBase createRowHolder(FacesContext context, UIComponent component,
Object[] options) {
+ RowHolder rowHolder = null;
+ if(component instanceof UIDataTableBase) {
+ rowHolder = new RowHolder(context, (UIDataTableBase)component);
+ rowHolder.setUpdatePartial((Boolean)options[0]);
+ rowHolder.setEncodeParentTBody((Boolean)options[1]);
+ }
+
+ return rowHolder;
+ }
+
protected class SimpleHeaderEncodeStrategy implements EncodeStrategy {
-
public void begin(ResponseWriter writer, FacesContext context, UIComponent
column, Object [] params)
throws IOException {
}
@@ -55,8 +89,6 @@
throws IOException {
}
}
-
- public abstract EncodeStrategy getHiddenContainerStrategy();
protected void doDecode(FacesContext context, UIComponent component) {
decodeSortingFiltering(context, component);
@@ -75,30 +107,9 @@
firstClass = mergeStyleClasses(FIRST_ROW_CLASS_KEY, firstClass, dataTableBase);
saveRowStyles(facesContext, dataTableBase.getClientId(facesContext), firstClass,
rowClass, cellClass);
+
super.encodeRows(facesContext, rowHolder);
}
-
-
- /**
- * Returns true if specified attribute (when present on the column) should generate
header even if it is not
- * specified on the table
- *
- * @param table
- * - rendered UIDataTable
- * @param attributeName
- * - attribute name
- * @return true if specified attribute should generate header on the table
- */
- // TODO nick - rename this method
- public boolean isHeaderFactoryColumnAttributePresent(UIDataTableBase table, String
attributeName) {
- Iterator<UIComponent> columns = table.columns();
- boolean result = false;
- while (columns.hasNext() && !result) {
- UIComponent component = columns.next();
- result = (component.isRendered() && (null !=
component.getValueExpression(attributeName)));
- }
- return result;
- }
//TODO: anton -> refactor this
protected boolean isEncodeHeaders(UIDataTableBase table) {
@@ -119,10 +130,10 @@
//DataTableRenderer override this method
}
- public void encodeBeforeRows(ResponseWriter writer, FacesContext facesContext, Row
row) throws IOException {
+ public void encodeBeforeRows(ResponseWriter writer, FacesContext facesContext,
UIDataTableBase dataTableBase, boolean encodeParentTBody, boolean partialUpdate) throws
IOException {
}
- public void encodeAfterRows(ResponseWriter writer, FacesContext facesContext, Row
row) throws IOException {
+ public void encodeAfterRows(ResponseWriter writer, FacesContext facesContext,
UIDataTableBase dataTableBase, boolean encodeParentTBody, boolean partialUpdate) throws
IOException {
}
public abstract boolean encodeParentTBody(UIDataTableBase dataTableBase);
@@ -140,28 +151,28 @@
encodeFooterFacet(writer, context, dataTable, false);
dataTable.setRowKey(context, key);
dataTable.restoreOrigValue(context);
-
}
public void encodeTableRows(ResponseWriter writer, FacesContext facesContext,
UIDataTableBase dataTableBase,
boolean encodePartialUpdate) throws IOException {
int rowCount = dataTableBase.getRowCount();
+
put(facesContext, dataTableBase.getClientId(facesContext), CELL_ELEMENT_KEY,
HTML.TD_ELEM);
+ Object key = dataTableBase.getRowKey();
+ dataTableBase.captureOrigValue(facesContext);
+ dataTableBase.setRowKey(facesContext, null);
+
+ boolean encodeParentTBody = encodeParentTBody(dataTableBase);
+ encodeBeforeRows(writer, facesContext, dataTableBase, encodeParentTBody,
encodePartialUpdate);
+
+
if (rowCount > 0) {
- processRows(writer, facesContext, dataTableBase, encodePartialUpdate);
+ processRows(writer, facesContext, dataTableBase, new Object[]
{encodePartialUpdate, encodeParentTBody});
} else {
-
- String noDataTableBodyId = dataTableBase.getClientId(facesContext) +
":ndtb";
- if (encodePartialUpdate) {
-
facesContext.getPartialViewContext().getPartialResponseWriter().startUpdate(noDataTableBodyId);
- }
-
int columns = getColumnsCount(dataTableBase.columns());
- writer.startElement(HTML.TBODY_ELEMENT, dataTableBase);
- writer.writeAttribute(HTML.ID_ATTRIBUTE, noDataTableBodyId, null);
writer.startElement(HTML.TR_ELEMENT, dataTableBase);
writer.startElement(HTML.TD_ELEM, dataTableBase);
writer.writeAttribute("colspan", columns, null);
@@ -183,30 +194,46 @@
writer.endElement(HTML.TD_ELEM);
writer.endElement(HTML.TR_ELEMENT);
- writer.endElement(HTML.TBODY_ELEMENT);
-
- if (encodePartialUpdate) {
-
facesContext.getPartialViewContext().getPartialResponseWriter().endUpdate();
- }
}
+
+ encodeAfterRows(writer, facesContext, dataTableBase, encodeParentTBody,
encodePartialUpdate);
+
if(encodePartialUpdate) {
String id = dataTableBase.getClientId(facesContext) + HIDDEN_CONTAINER_ID;
facesContext.getPartialViewContext().getPartialResponseWriter().startUpdate(id);
}
-
+
encodeHiddens(writer, facesContext, dataTableBase);
-
+
if(encodePartialUpdate) {
facesContext.getPartialViewContext().getPartialResponseWriter().endUpdate();
}
+
+ /*
+ * DataTable
+ * <tbody id="row">
+ * </tbody>
+ * <tbody id="hidden">
+ * </tbody>
+ *
+ * SubTable
+ * <tbody>
+ * <tr id="row">
+ * </tr
+ * <tr id="hidden">
+ * </tr
+ * </tbody>
+ *
+ */
+
+ dataTableBase.setRowKey(facesContext, key);
+ dataTableBase.restoreOrigValue(facesContext);
}
protected void doEncodeChildren(ResponseWriter writer, FacesContext context,
UIComponent component) throws IOException {
if(component instanceof UIDataTableBase) {
- encodeBeforeRows(writer, context, (Row)component);
encodeTableRows(writer, context, (UIDataTableBase)component, false);
- encodeAfterRows(writer, context, (Row)component);
}
}
@@ -239,7 +266,9 @@
throws IOException {
writer.startElement(HTML.TBODY_ELEMENT, dataTableBase);
- writer.writeAttribute(HTML.ID_ATTRIBUTE,
dataTableBase.getRelativeClientId(facesContext) + ":tb", null);
+ String clientId = (dataTableBase.getRelativeRowIndex() < 0) ?
dataTableBase.getClientId(facesContext) :
dataTableBase.getRelativeClientId(facesContext);
+
+ writer.writeAttribute(HTML.ID_ATTRIBUTE, clientId + ":tb", null);
writer.writeAttribute(HTML.CLASS_ATTRIBUTE, getTableSkinClass(), null);
encodeStyle(writer, facesContext, dataTableBase, null);
}
@@ -247,9 +276,7 @@
public void encodeTableBodyEnd(ResponseWriter writer) throws IOException {
writer.endElement(HTML.TBODY_ELEMENT);
}
-
- public abstract RowHolderBase createRowHolder(FacesContext context, UIComponent
component);
-
+
public void encodeFooterFacet(ResponseWriter writer, FacesContext context,
UIDataTableBase dataTable,
boolean encodePartialUpdate) throws IOException {
@@ -445,7 +472,9 @@
while (headers.hasNext()) {
UIComponent column = headers.next();
- if (!column.isRendered()) {
+
+
+ if (!column.isRendered() || (column instanceof Row)) {
continue;
}
@@ -590,4 +619,12 @@
throw new IllegalArgumentException("Unsupported metaComponentIdentifier:
" + metaComponentId);
}
}
+
+ protected void partialStart(FacesContext facesContext, String id) throws IOException
{
+ facesContext.getPartialViewContext().getPartialResponseWriter().startUpdate(id);
+ }
+
+ protected void partialEnd(FacesContext facesContext) throws IOException {
+ facesContext.getPartialViewContext().getPartialResponseWriter().endUpdate();
+ }
}
Modified:
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/ColumnGroupRenderer.java
===================================================================
---
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/ColumnGroupRenderer.java 2010-06-21
11:47:37 UTC (rev 17649)
+++
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/ColumnGroupRenderer.java 2010-06-21
11:49:19 UTC (rev 17650)
@@ -54,7 +54,7 @@
encodeRowEnd(writer);
}
- public RowHolderBase createRowHolder(FacesContext context, UIComponent component) {
+ public RowHolderBase createRowHolder(FacesContext context, UIComponent component,
Object[] options) {
UIComponent parent = component.getParent();
while(parent != null && !(parent instanceof UIDataTableBase)) {
parent = parent.getParent();
Modified:
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java
===================================================================
---
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java 2010-06-21
11:47:37 UTC (rev 17649)
+++
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java 2010-06-21
11:49:19 UTC (rev 17650)
@@ -53,7 +53,6 @@
public class DataTableRenderer extends AbstractTableRenderer {
private class DataTableHiddenEncodeStrategy implements EncodeStrategy {
-
public void begin(ResponseWriter writer, FacesContext context, UIComponent
component, Object[] params) throws IOException {
UIDataTable dataTable = (UIDataTable)component;
@@ -115,89 +114,116 @@
}
}
writer.endElement("colgroup");
-
}
}
- public RowHolder createRowHolder(FacesContext context, UIComponent component) {
- return new RowHolder(context, (UIDataTable) component);
+ @Override
+ public void encodeBeforeRows(ResponseWriter writer, FacesContext
facesContext,UIDataTableBase dataTableBase, boolean encodeParentTBody, boolean
partialUpdate) throws IOException {
+ if(encodeParentTBody) {
+ if(partialUpdate) {
+
facesContext.getPartialViewContext().getPartialResponseWriter().startUpdate(dataTableBase.getClientId(facesContext)
+":tb");
+ }
+ encodeTableBodyStart(writer, facesContext, dataTableBase);
+ }
}
-
+
+ @Override
+ public void encodeAfterRows(ResponseWriter writer, FacesContext facesContext,
UIDataTableBase dataTableBase, boolean encodeParentTBody, boolean partialUpdate) throws
IOException {
+ if(encodeParentTBody) {
+ encodeTableBodyEnd(writer);
+ if(partialUpdate) {
+
facesContext.getPartialViewContext().getPartialResponseWriter().endUpdate();
+ }
+ }
+ }
+
+
public void encodeRow(ResponseWriter writer, FacesContext facesContext, RowHolderBase
holder) throws IOException {
+
RowHolder rowHolder = (RowHolder) holder;
Row row = rowHolder.getRow();
+
+ UIDataTable dataTable = (UIDataTable)row;
- UIDataTable dataTable = (UIDataTable)row;
+ boolean partialUpdate = rowHolder.isUpdatePartial();
+
+ //TODO: try to use rowHolder for storing current <tbody> open/close state
+ boolean parentTbodyStart = rowHolder.isEncodeParentTBody();
+ boolean tbodyStart = parentTbodyStart;
+
+ rowHolder.setRowStart(true);
- if (!encodeParentTBody(dataTable)) {
- if (rowHolder.isPartialUpdate()) {
-
facesContext.getPartialViewContext().getPartialResponseWriter().startUpdate(dataTable.getRelativeClientId(facesContext)
+ ":tb");
- }
- encodeTableBodyStart(writer, facesContext, dataTable);
- }
-
- rowHolder.setRowStart(true);
Iterator<UIComponent> components = row.columns();
-
- boolean isTRopen = false;
-
while (components.hasNext()) {
+
UIComponent child = components.next();
-
- //could be columnGroup or SubTable
- if (child instanceof Row) {
-
+ if(child instanceof Row) {
boolean isSubtable = (child instanceof UISubTable);
-
//new row -> close </tr>
if (rowHolder.getProcessCell() != 0) {
encodeRowEnd(writer);
- isTRopen = false;
-
//only SubTables could have <tbody>
if(isSubtable) {
encodeTableBodyEnd(writer);
- if (rowHolder.isPartialUpdate()) {
-
facesContext.getPartialViewContext().getPartialResponseWriter().endUpdate();
+ tbodyStart = false;
+ if (partialUpdate) {
+ partialEnd(facesContext);
}
}
}
-
+
rowHolder.nextCell();
-
- boolean partial = rowHolder.isPartialUpdate();
+
if(isSubtable){
- UISubTable subTable = (UISubTable)child;
-
- //generate id for the container
- String containerId = dataTable.getRelativeClientId(facesContext) +
":"+ subTable.getId() +":c";
- if(partial) {
-
facesContext.getPartialViewContext().getPartialResponseWriter().startUpdate(containerId);
- }
+ String id = dataTable.getRelativeClientId(facesContext) +
":"+ child.getId() +":c";
+ if(partialUpdate) {
+ partialStart(facesContext, id);
+ }
+
+ writer.startElement(HTML.TBODY_ELEMENT, child);
+ writer.writeAttribute(HTML.ID_ATTRIBUTE, id, null);
}
child.encodeAll(facesContext);
-
- if (partial) {
-
facesContext.getPartialViewContext().getPartialResponseWriter().endUpdate();
+
+ if (isSubtable) {
+ writer.endElement(HTML.TBODY_ELEMENT);
+ if(partialUpdate) {
+ partialEnd(facesContext);
+ }
}
-
- } else if (child instanceof UIColumn) {
- encodeColumn(facesContext, writer, (UIColumn) child, rowHolder);
- isTRopen = true;
+
+ } else if(child instanceof UIColumn) {
+
+ if(!parentTbodyStart && !tbodyStart) {
+ if (partialUpdate) {
+ partialStart(facesContext,
dataTable.getRelativeClientId(facesContext) + ":tb");
+ }
+ encodeTableBodyStart(writer, facesContext, dataTable);
+ tbodyStart = true;
+ }
+
+ encodeColumn(facesContext, writer, (UIColumn)child, rowHolder);
+
+ if(!components.hasNext()) {
+ encodeRowEnd(writer);
+
+ if(!parentTbodyStart && tbodyStart) {
+ encodeTableBodyEnd(writer);
+ tbodyStart = false;
+ if(partialUpdate) {
+ partialEnd(facesContext);
+ }
+ }
+ }
}
}
-
- if (isTRopen) {
- encodeRowEnd(writer);
- }
}
public boolean encodeParentTBody(UIDataTableBase dataTableBase) {
Iterator<UIComponent> iterator = dataTableBase.columns();
while (iterator.hasNext()) {
- UIComponent child = iterator.next();
- if (child instanceof Row) {
+ if (iterator.next() instanceof Row) {
return false;
}
}
@@ -384,4 +410,5 @@
public EncodeStrategy getHiddenContainerStrategy() {
return new DataTableHiddenEncodeStrategy();
}
+
}
Modified:
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java
===================================================================
---
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java 2010-06-21
11:47:37 UTC (rev 17649)
+++
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java 2010-06-21
11:49:19 UTC (rev 17650)
@@ -468,7 +468,7 @@
Object key = table.getRowKey();
table.captureOrigValue(context);
table.setRowKey(context, null);
- final RendererState state = createRowHolder(context, table);
+ final RendererState state = createRowHolder(context, table, null);
// TODO 1. Encode fixed children
for (state.startIterate(); state.hasNextPart();) {
char partNameFirstChar =
state.nextPart().getName().toString().charAt(0);
@@ -529,7 +529,7 @@
try {
context.setResponseWriter(new OnOffResponseWriter(initialWriter));
- RendererState state = createRowHolder(context, component);
+ RendererState state = createRowHolder(context, component, null);
state.setEncoderVariance(EncoderVariance.partial);
PartialResponseWriter writer =
context.getPartialViewContext().getPartialResponseWriter();
@@ -566,7 +566,7 @@
getUtils().writeAttribute(writer, HTML.STYLE_ATTRIBUTE,
attributes.get("style"));
}
- public RendererState createRowHolder(FacesContext context, UIComponent component) {
+ public RendererState createRowHolder(FacesContext context, UIComponent component,
Object[] options) {
return new RendererState(context, (UIDataTableBase) component);
}
@@ -577,7 +577,7 @@
Object key = table.getRowKey();
table.captureOrigValue(context);
table.setRowKey(context, null);
- RendererState state = createRowHolder(context, table);
+ RendererState state = createRowHolder(context, table, null);
encodeStyle(state);
encodeHeader(state);
encodeBody(state);
Modified:
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/RowHolder.java
===================================================================
---
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/RowHolder.java 2010-06-21
11:47:37 UTC (rev 17649)
+++
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/RowHolder.java 2010-06-21
11:49:19 UTC (rev 17650)
@@ -36,11 +36,29 @@
private String parentClientId;
- private int processCell;
-
private boolean isRowStart;
+
+ private boolean updatePartial;
+
+ private boolean encodeParentTBody;
+ public boolean isEncodeParentTBody() {
+ return encodeParentTBody;
+ }
+
+ public void setEncodeParentTBody(boolean encodeParentTBody) {
+ this.encodeParentTBody = encodeParentTBody;
+ }
+
+ public boolean isUpdatePartial() {
+ return updatePartial;
+ }
+
+ public void setUpdatePartial(boolean updatePartial) {
+ this.updatePartial = updatePartial;
+ }
+
public RowHolder(FacesContext context, Row row) {
this(context, row, 0, true);
}
@@ -48,7 +66,6 @@
public RowHolder(FacesContext context, Row row, int processCell, boolean isRowStart)
{
super(context);
this.row = row;
- this.processCell = processCell;
this.parentClientId = row.getClientId(context);
}
@@ -64,18 +81,6 @@
return this.row;
}
- public int getProcessCell() {
- return processCell;
- }
-
- public void resetProcessCell() {
- this.processCell = 0;
- }
-
- public int nextCell() {
- return processCell++;
- }
-
public boolean isRowStart() {
return isRowStart;
}
Modified:
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/RowHolderBase.java
===================================================================
---
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/RowHolderBase.java 2010-06-21
11:47:37 UTC (rev 17649)
+++
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/RowHolderBase.java 2010-06-21
11:49:19 UTC (rev 17650)
@@ -32,7 +32,8 @@
private int currentRow;
- private boolean partialUpdate;
+ private int processCell;
+
public RowHolderBase(FacesContext context) {
this(context, 0);
@@ -43,14 +44,6 @@
this.currentRow = currentRow;
}
- public boolean isPartialUpdate() {
- return partialUpdate;
- }
-
- public void setPartialUpdate(boolean partialUpdate) {
- this.partialUpdate = partialUpdate;
- }
-
public FacesContext getContext() {
return context;
}
@@ -72,4 +65,17 @@
public void resetCurrentRow() {
this.currentRow = 0;
}
+
+ public int getProcessCell() {
+ return processCell;
+ }
+
+ public void resetProcessCell() {
+ this.processCell = 0;
+ }
+
+ public int nextCell() {
+ return processCell++;
+ }
+
}
Modified:
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SortingFilteringRowsRenderer.java
===================================================================
---
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SortingFilteringRowsRenderer.java 2010-06-21
11:47:37 UTC (rev 17649)
+++
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SortingFilteringRowsRenderer.java 2010-06-21
11:49:19 UTC (rev 17650)
@@ -34,8 +34,8 @@
import javax.faces.FacesException;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
-import javax.swing.SortOrder;
+import org.richfaces.component.SortOrder;
import org.richfaces.component.UIDataTableBase;
import org.richfaces.model.SortMode;
Modified:
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java
===================================================================
---
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java 2010-06-21
11:47:37 UTC (rev 17649)
+++
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java 2010-06-21
11:49:19 UTC (rev 17650)
@@ -132,34 +132,35 @@
@Override
public void encodeTableBodyStart(ResponseWriter writer, FacesContext facesContext,
UIDataTableBase dataTableBase) throws IOException {
UISubTable subTable = (UISubTable)dataTableBase;
- UIComponent component = subTable.getParent();
- if (!(component instanceof UIDataTable)) {
- // TODO: anton -> throw exception
+ UIDataTableBase component = findParent(subTable);
+ if(component instanceof UIDataTable) {
+
+// writer.startElement(HTML.TBODY_ELEMENT, null);
+// writer.writeAttribute(HTML.ID_ATTRIBUTE,
dataTable.getRelativeClientId(facesContext) + ":" + subTable.getId() +
":c", null);
+
+ String predefinedStyles = !subTable.isExpanded() ? "display:
none;" : null;
+
+ writer.writeAttribute(HTML.CLASS_ATTRIBUTE, getTableSkinClass(), null);
+ encodeStyle(writer, facesContext, subTable, predefinedStyles);
}
-
- UIDataTable dataTable = (UIDataTable)component;
- writer.startElement(HTML.TBODY_ELEMENT, null);
- writer.writeAttribute(HTML.ID_ATTRIBUTE,
dataTable.getRelativeClientId(facesContext) + ":" + subTable.getId() +
":c", null);
-
- String predefinedStyles = !subTable.isExpanded() ? "display: none;" :
null;
-
- writer.writeAttribute(HTML.CLASS_ATTRIBUTE, getTableSkinClass(), null);
- encodeStyle(writer, facesContext, dataTable, predefinedStyles);
}
- public RowHolderBase createRowHolder(FacesContext context, UIComponent component) {
- return new RowHolder(context, (UISubTable)component);
- }
-
- public void encodeBeforeRows(ResponseWriter writer, FacesContext facesContext, Row
row) throws IOException {
- UISubTable subTable = (UISubTable)row;
+ @Override
+ public void encodeBeforeRows(ResponseWriter writer, FacesContext facesContext,
UIDataTableBase dataTableBase, boolean encodeParentTBody, boolean partialUpdate) throws
IOException {
+ UISubTable subTable = (UISubTable)dataTableBase;
+ UIDataTableBase parent = findParent(subTable);
+
+ if(parent instanceof UISubTable) {
+ encodeTableBodyEnd(writer);
+ }
+
encodeTableBodyStart(writer, facesContext, subTable);
encodeSubTableDomElement(writer, facesContext, subTable);
setupTableStartElement(facesContext, subTable);
encodeHeaderFacet(writer, facesContext, subTable, false);
}
-
+
private void encodeSubTableDomElement(ResponseWriter writer, FacesContext
facesContext, UISubTable subTable) throws IOException{
writer.startElement(HTML.TR_ELEMENT, subTable);
writer.writeAttribute(HTML.STYLE_ATTRIBUTE, "display: none", null);
@@ -167,7 +168,6 @@
writer.startElement(HTML.TD_ELEM, subTable);
writer.endElement(HTML.TD_ELEM);
writer.endElement(HTML.TR_ELEMENT);
-
}
public void encodeRow(ResponseWriter writer, FacesContext context, RowHolderBase
holder) throws IOException {
@@ -176,7 +176,7 @@
rowHolder.setRowStart(true);
Iterator<UIComponent> components = row.columns();
- if (rowHolder.isPartialUpdate()) {
+ if (rowHolder.isUpdatePartial()) {
context.getPartialViewContext().getPartialResponseWriter().startUpdate(
((UISubTable) row).getRelativeClientId(context) + ":b");
}
@@ -187,17 +187,19 @@
encodeRowEnd(writer);
- if (rowHolder.isPartialUpdate()) {
+ if (rowHolder.isUpdatePartial()) {
context.getPartialViewContext().getPartialResponseWriter().endUpdate();
}
}
- public void encodeAfterRows(ResponseWriter writer, FacesContext facesContext, Row
row) throws IOException {
- UISubTable subTable = (UISubTable)row;
+ @Override
+ public void encodeAfterRows(ResponseWriter writer, FacesContext facesContext,
UIDataTableBase dataTableBase,
+ boolean encodeParentTBody, boolean partialUpdate) throws IOException {
+ UISubTable subTable = (UISubTable)dataTableBase;
encodeFooterFacet(writer, facesContext, subTable, false);
- encodeTableBodyEnd(writer);
+// encodeTableBodyEnd(writer);
}
-
+
@Override
public boolean encodeParentTBody(UIDataTableBase dataTableBase) {
return true;
@@ -222,7 +224,6 @@
writer.writeAttribute(HTML.NAME_ATTRIBUTE, optionsId , null);
writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
writer.endElement(HTML.INPUT_ELEM);
-
}
public boolean containsThead() {
@@ -348,25 +349,12 @@
if(UISubTable.SUBTABLE.equals(metaComponentId)) {
ResponseWriter writer = facesContext.getResponseWriter();
+ UIDataTableBase dataTableBase = findParent(subTable);
- UIComponent parent = subTable.getParent();
- while(parent != null && !(parent instanceof UIDataTable)) {
- parent = parent.getParent();
- }
-
- if(parent == null){
- //TODO: anton -> do we need this?
- throw new AbortProcessingException("UISubTable should be a child of
UIDataTable");
- }
-
- UIDataTable dataTable = (UIDataTable)parent;
- String updateId = dataTable.getRelativeClientId(facesContext) + ":"
+ subTable.getId() +":c";
+ String updateId = dataTableBase.getRelativeClientId(facesContext) +
":" + subTable.getId() +":c";
+
facesContext.getPartialViewContext().getPartialResponseWriter().startUpdate(updateId);
-
- encodeBeforeRows(writer, facesContext, subTable);
encodeTableRows(writer, facesContext, subTable, false);
- encodeAfterRows(writer, facesContext, subTable);
-
facesContext.getPartialViewContext().getPartialResponseWriter().endUpdate();
}else {
@@ -382,5 +370,18 @@
protected void setupTableStartElement(FacesContext context, UIComponent component) {
put(context, component.getClientId(context), CELL_ELEMENT_KEY, HTML.TD_ELEM);
}
+
+ protected UIDataTableBase findParent(UISubTable subTable) {
+ UIComponent parent = subTable.getParent();
+ while(parent != null && !(parent instanceof UIDataTableBase)) {
+ parent = parent.getParent();
+ }
+
+ if(parent == null){
+ //TODO: anton -> do we need this?
+ throw new AbortProcessingException("UISubTable should be a child of
UIDataTable or UISubTable");
+ }
+ return (UIDataTableBase)parent;
+ }
}