Author: abelevich
Date: 2010-07-19 10:47:20 -0400 (Mon, 19 Jul 2010)
New Revision: 18150
Modified:
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UIDataGrid.java
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/DataGridRenderer.java
Log:
RF-8923, RF-8924
Modified:
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UIDataGrid.java
===================================================================
---
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UIDataGrid.java 2010-07-19
14:09:07 UTC (rev 18149)
+++
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UIDataGrid.java 2010-07-19
14:47:20 UTC (rev 18150)
@@ -71,7 +71,8 @@
}
public int getColumns() {
- return (Integer)getStateHelper().eval(PropertyKeys.columns, 1);
+ int columns = (Integer)getStateHelper().eval(PropertyKeys.columns, 1);
+ return (columns < 1 ? 1 : columns);
}
public void setColumns(int count) {
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-07-19
14:09:07 UTC (rev 18149)
+++
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java 2010-07-19
14:47:20 UTC (rev 18150)
@@ -68,7 +68,13 @@
public void processRows(ResponseWriter writer, FacesContext facesContext, UIComponent
component, Object[] options) throws IOException {
RowHolderBase rowHolder = createRowHolder(facesContext, component, options);
encodeRows(facesContext, rowHolder);
+ doCleanup(facesContext, rowHolder);
}
+
+
+ protected void doCleanup(FacesContext context, RowHolderBase rowHolder) throws
IOException {
+ //Hook method
+ }
protected void doEncodeChildren(ResponseWriter writer, FacesContext facesContext,
UIComponent component) throws IOException {
processRows(writer, facesContext, component, null);
Modified:
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/DataGridRenderer.java
===================================================================
---
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/DataGridRenderer.java 2010-07-19
14:09:07 UTC (rev 18149)
+++
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/DataGridRenderer.java 2010-07-19
14:47:20 UTC (rev 18150)
@@ -24,13 +24,16 @@
import java.io.IOException;
+import javax.faces.FacesException;
import javax.faces.application.ResourceDependencies;
import javax.faces.application.ResourceDependency;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
+import org.ajax4jsf.model.DataVisitResult;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.richfaces.component.Row;
import org.richfaces.component.UIDataGrid;
import org.richfaces.component.UIDataTableBase;
@@ -97,7 +100,7 @@
}
writer.startElement(HTML.TFOOT_ELEMENT, component);
-
+ writer.writeAttribute(HTML.ID_ATTRIBUTE, clientId , null);
writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "rf-dg-tfoot", null);
writer.startElement(HTML.TR_ELEMENT, component);
writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "rf-dg-f", null);
@@ -154,11 +157,13 @@
UIDataGrid dataGrid = (UIDataGrid) rowHolder.getRow();
int columns = dataGrid.getColumns();
- int processRow = rowHolder.getCurrentRow();
+ int processCell = rowHolder.getProcessCell();
- if (columns > 0 && (processRow % columns == 0)) {
- if (processRow != 0) {
+ if (columns > 0 && (processCell % columns == 0)) {
+ if (processCell != 0) {
writer.endElement(HTML.TR_ELEMENT);
+ rowHolder.resetProcessCell();
+ rowHolder.nextRow();
}
writer.startElement(HTML.TR_ELEMENT, dataGrid);
writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "rf-dg-r", null);
@@ -166,14 +171,13 @@
writer.startElement(HTML.TD_ELEM, dataGrid);
writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "rf-dg-c", null);
- getUtils().encodeId(facesContext, dataGrid);
renderChildren(facesContext, dataGrid);
writer.endElement(HTML.TD_ELEM);
}
public void encodeHeader(ResponseWriter writer, FacesContext facesContext,
UIDataGrid dataGrid, boolean partial) throws IOException {
- UIComponent footerFacet = dataGrid.getHeaderFacet();
- encodeFacet(writer, facesContext, footerFacet, THEAD, dataGrid, new Object[]
{partial});
+ UIComponent headerFacet = dataGrid.getHeaderFacet();
+ encodeFacet(writer, facesContext, headerFacet, THEAD, dataGrid, new Object[]
{partial});
}
public void encodeFooter(ResponseWriter writer, FacesContext facesContext, UIDataGrid
dataGrid, boolean partial) throws IOException {
@@ -260,4 +264,42 @@
throw new IllegalArgumentException("Unsupported metaComponentIdentifier:
" + metaComponentId);
}
}
+
+ @Override
+ protected void doCleanup(FacesContext context, RowHolderBase rowHolder) throws
IOException {
+ ResponseWriter writer = context.getResponseWriter();
+ UIDataGrid dataGrid = (UIDataGrid)rowHolder.getRow();
+
+ int cell = rowHolder.getProcessCell();
+ int columns = dataGrid.getColumns();
+ int rest = columns - cell;
+
+ if(rest != 0) {
+ for (int i = 0; i < rest; i++) {
+ writer.startElement(HTML.TD_ELEM, dataGrid);
+ writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "rf-dg-c", null);
+ writer.endElement(HTML.TD_ELEM);
+ }
+ }
+
+ if(rest != 0){
+ writer.endElement(HTML.TR_ELEMENT);
+ }
+ }
+
+ public DataVisitResult process(FacesContext facesContext, Object rowKey, Object
argument) {
+ RowHolderBase holder = (RowHolderBase) argument;
+ Row row = holder.getRow();
+ row.setRowKey(facesContext, rowKey);
+
+ try {
+ ResponseWriter writer = facesContext.getResponseWriter();
+ encodeRow(writer, facesContext, holder);
+ } catch (IOException e) {
+ throw new FacesException(e);
+ }
+
+ holder.nextCell();
+ return DataVisitResult.CONTINUE;
+ }
}