Author: abelevich
Date: 2007-05-16 08:36:28 -0400 (Wed, 16 May 2007)
New Revision: 780
Modified:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java
Log:
Modified:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java
===================================================================
---
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java 2007-05-16
12:36:18 UTC (rev 779)
+++
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java 2007-05-16
12:36:28 UTC (rev 780)
@@ -59,7 +59,7 @@
state.setFrozenColumnCount(i-1);
}
- return 0;
+ return 1;
}
public void renderContent(FacesContext context, UIScrollableGridColumn column,
ResponseWriter writer, GridRendererState state) throws IOException {
@@ -209,7 +209,6 @@
final GridRendererState state = GridRendererState.getRendererState(context);
-// setUpScriptModel(context, grid);
writer.startElement(HTML.DIV_ELEM, grid);
getUtils().writeAttribute(writer, "class","GridDataColumns");
@@ -249,12 +248,14 @@
state.setColumType(COLUMN_NORMAL_TYPE);
state.setFrozenPart(false);
+
grid.walk(context, rowsRenderer, state);
+
writer.endElement("tbody");
writer.endElement("table");
writer.endElement(HTML.DIV_ELEM);
grid.setRowKey(null);
-
+
}
public void renderHeaders(FacesContext context, UIScrollableGrid component
@@ -285,8 +286,14 @@
writer.writeText("\n", null);
state.setHeader(false);
- ColumnWalker.iterateOverColumns(context, component, headerFooterRenderer, writer,
state);
+ int colsCount = ColumnWalker.iterateOverColumns(context, component,
headerFooterRenderer, writer, state);
+ int rowsCount = component.getRowCount();
+
+ ComponentVariables variables = ComponentsVariableResolver.getVariables(this,
component);
+ variables.setVariable("rows_count", new Integer(rowsCount));
+ variables.setVariable("columns_count", new Integer(colsCount));
+
writer.endElement(HTML.TR_ELEMENT);
writer.writeText("\n", null);
@@ -333,20 +340,30 @@
}
}
+
public void renderAjaxChildren(FacesContext context, UIComponent component)throws
IOException{
UIScrollableGrid grid = (UIScrollableGrid)component;
grid.setFirst(grid.getDataIndex().intValue());
grid.setRows(grid.getRow_count().intValue());
int start_row = grid.getStartRow().intValue();
+
+ //remode scripts
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
String client_id = grid.getClientId(context);
-
- GridRendererState state = GridRendererState.getRendererState(context);
+ String script_id = client_id + "_model_create_scripts";
+ ajaxContext.removeRenderedArea(client_id);
+ ajaxContext.removeRenderedArea(script_id);
+ script_id = client_id + "_model_create_scripts";
+ ajaxContext.removeRenderedArea(script_id);
+
+ GridRendererState state = GridRendererState.createState(context, grid);
state.setClientId(client_id);
- state.setAjaxContext(AjaxContext.getCurrentInstance(context));
+ state.setAjaxContext(ajaxContext);
state.setRowIndex(start_row);
state.setFrozenPart(true);
state.setCellIdPrefix(CELL_ID_PREFFIX + COLUMN_FROZEN_TYPE);
+
grid.walk(context, ajaxRowsRenderer, state);
state.setRowIndex(start_row);
@@ -367,22 +384,46 @@
}
}
-// public void setUpScriptModel(FacesContext context, UIScrollableGrid grid) throws
IOException{
-//
-// DataModel dataModel = grid.getStoredDataModel();
-// Integer rows_count = new Integer(dataModel.getRowCount());
-//
-// ColumnVisitor visitor = new ColumnVisitor(){
-// public int visit(FacesContext context, UIScrollableGridColumn column, ResponseWriter
writer, GridRendererState state) throws IOException {
-// return 1;
-// }
-// };
-//
-// Integer columns_count = new Integer(ColumnWalker.iterateOverColumns(context, grid,
visitor, null, null));
-// ComponentVariables variables = ComponentsVariableResolver.getVariables(this, grid);
-// variables.setVariable("rows_count", rows_count);
-// variables.setVariable("column_count", columns_count);
-// }
+
+ public void encodeBegin(FacesContext context, UIComponent component) throws IOException
{
+
+ if(component instanceof UIScrollableGrid){
+ UIScrollableGrid grid = (UIScrollableGrid)component;
+ setUpState(context, grid);
+ }
+
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance();
+ if(ajaxContext.isAjaxRequest()){
+ }else{
+ super.encodeBegin(context, component);
+ }
+ }
+
+ public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
+
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance();
+ if(ajaxContext.isAjaxRequest()){
+ }else{
+ super.encodeEnd(context, component);
+ }
+ }
+
+ public void setUpScriptModel(FacesContext context, UIScrollableGrid grid) throws
IOException{
+
+ DataModel dataModel = grid.getStoredDataModel();
+ Integer rows_count = new Integer(dataModel.getRowCount());
+
+ ColumnVisitor visitor = new ColumnVisitor(){
+ public int visit(FacesContext context, UIScrollableGridColumn column, ResponseWriter
writer, GridRendererState state) throws IOException {
+ return 1;
+ }
+ };
+
+ Integer columns_count = new Integer(ColumnWalker.iterateOverColumns(context, grid,
visitor, null, null));
+ ComponentVariables variables = ComponentsVariableResolver.getVariables(this, grid);
+ variables.setVariable("rows_count", rows_count);
+ variables.setVariable("column_count", columns_count);
+ }
private RendererBase getCellTemplate() {
if (cellTemplate == null) {