Author: abelevich
Date: 2007-05-23 13:56:30 -0400 (Wed, 23 May 2007)
New Revision: 853
Added:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/OnCompleteFunctionBuilder.java
Modified:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java
Log:
Added:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/OnCompleteFunctionBuilder.java
===================================================================
---
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/OnCompleteFunctionBuilder.java
(rev 0)
+++
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/OnCompleteFunctionBuilder.java 2007-05-23
17:56:30 UTC (rev 853)
@@ -0,0 +1,48 @@
+/**
+ *
+ */
+package org.richfaces.renderkit.html;
+
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.framework.renderer.RendererBase;
+import org.ajax4jsf.framework.util.javascript.JSFunction;
+import org.ajax4jsf.framework.util.javascript.JSFunctionDefinition;
+import org.ajax4jsf.framework.util.javascript.JSReference;
+import org.richfaces.component.UIScrollableGrid;
+
+
+public class OnCompleteFunctionBuilder {
+
+// public static final String DATA_READY = ;
+
+ private static final JSReference request = new JSReference("request");
+ private static final JSReference event = new JSReference("event");
+ private static final JSReference data = new JSReference("data");
+
+ public static JSFunction createFunction(String name) {
+ JSFunction function = new JSFunction(name);
+ function.addParameter(request);
+ function.addParameter(event);
+ function.addParameter(data);
+
+ return function;
+ }
+
+ public static JSFunctionDefinition getOnDataReady(FacesContext context, UIScrollableGrid
grid, RendererBase renderer) {
+
+ ScrollableGridBaseRenderer sr = (ScrollableGridBaseRenderer)renderer;
+ JSFunction function = createFunction(sr.getJavaScriptVarName(context, grid) +
".onCompleteGridInvalidation");
+// JSFunction function = createFunction(sr.getJavaScriptVarName(context, grid) +
".getModel().fireEvent");
+ JSFunctionDefinition functionDefinition = new JSFunctionDefinition();
+ functionDefinition.addToBody(function);
+ functionDefinition.addParameter(request);
+ functionDefinition.addParameter(event);
+ functionDefinition.addParameter(data);
+
+ return functionDefinition;
+ }
+
+}
\ No newline at end of file
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-23
17:56:13 UTC (rev 852)
+++
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java 2007-05-23
17:56:30 UTC (rev 853)
@@ -188,13 +188,13 @@
public void renderContent(FacesContext context, UIScrollableGridColumn column,
ResponseWriter writer, GridRendererState state) throws IOException {
writer.startElement(HTML.SPAN_ELEM, column);
- String columnWidth = (String)column.getAttributes().get("width");
+// String columnWidth = (String)column.getAttributes().get("width");
String cell_id = state.getClientId() + ":" + CELL_ID_PREFFIX +
state.getRowIndex()+ "_" + state.getCellIndex();
getUtils().writeAttribute(writer, "id",cell_id);
getUtils().writeAttribute(writer, "class",
"ClientUI_Grid_BCBody");
- getUtils().writeAttribute(writer, "style", "width:" +
columnWidth);
- System.out.println("rendering cell: " + cell_id);
+// getUtils().writeAttribute(writer, "style", "width:" +
columnWidth);
+// System.out.println("cell index: " + cell_id);
renderChildren(context, column);
writer.endElement(HTML.SPAN_ELEM);
AjaxContext ajaxContext = state.getAjaxContext();
@@ -212,13 +212,14 @@
grid.setRowKey(rowKey);
ResponseWriter writer = context.getResponseWriter();
state.setFrozenColumnCount(((Integer)grid.getAttributes().get("frozenColCount")).intValue());
+ System.out.println("row index: " + grid.getRowIndex());
ColumnWalker.iterateOverColumns(context, grid, ajaxCellRenderer, writer, state);
state.nextRow();
}
};
- protected String getJavaScriptVarName(FacesContext context, UIScrollableGrid grid) {
+ public String getJavaScriptVarName(FacesContext context, UIScrollableGrid grid) {
String id = grid.getBaseClientId(context);
return "Richfaces_ScrollableGrid_" + id.replaceAll("[^A-Za-z0-9_]",
"_");
}
@@ -303,8 +304,9 @@
JSFunction function = AjaxRendererUtils.buildAjaxFunction(grid, context);
Map options = AjaxRendererUtils.buildEventOptions(context, grid);
-
+ options.put("oncomplete", OnCompleteFunctionBuilder.getOnDataReady(context,
grid, this));
function.addParameter(options);
+
String completeFunction = function.toScript()+"; return false;";
return completeFunction;
@@ -359,6 +361,7 @@
state.setAjaxContext(ajaxContext);
state.setRowIndex(start_row);
grid.walk(context, ajaxRowsRenderer, state);
+ ajaxContext.getAjaxRenderedAreas().remove(grid.getClientId(context));
grid.setRows(old);
}
Show replies by date