Author: abelevich
Date: 2007-06-06 08:56:22 -0400 (Wed, 06 Jun 2007)
New Revision: 1043
Modified:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/AjaxFunctionBuilder.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/GridRendererState.java
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/AjaxFunctionBuilder.java
===================================================================
---
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/AjaxFunctionBuilder.java 2007-06-06
12:56:06 UTC (rev 1042)
+++
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/AjaxFunctionBuilder.java 2007-06-06
12:56:22 UTC (rev 1043)
@@ -17,6 +17,8 @@
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 final int SORT = 0;
+ public static final int SCROLL = 1;
public static JSFunction createFunction(String name) {
JSFunction function = new JSFunction(name);
@@ -27,12 +29,20 @@
return function;
}
- public static JSFunctionDefinition getOnDataReady(FacesContext context, UIScrollableGrid
grid, RendererBase renderer) {
+ public static JSFunctionDefinition getOnComplete(FacesContext context, UIScrollableGrid
grid, RendererBase renderer, int type) {
ScrollableGridBaseRenderer sr = (ScrollableGridBaseRenderer)renderer;
+ JSFunction function = null;
- JSFunction function = createFunction(sr.getJavaScriptVarName(context, grid) +
".onCompleteGridInvalidation");
-// JSFunction function = createFunction(sr.getJavaScriptVarName(context, grid) +
".getModel().fireEvent");
+ switch (type) {
+ case SCROLL:
+ function = createFunction(sr.getJavaScriptVarName(context, grid) +
".onScrollComplete");
+ break;
+ case SORT:
+ function = createFunction(sr.getJavaScriptVarName(context, grid) +
".onSortComplete");
+ break;
+ }
+
JSFunctionDefinition functionDefinition = new JSFunctionDefinition();
functionDefinition.addToBody(function);
functionDefinition.addParameter(request);
@@ -41,6 +51,4 @@
return functionDefinition;
}
-
-
}
\ No newline at end of file
Modified:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/GridRendererState.java
===================================================================
---
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/GridRendererState.java 2007-06-06
12:56:06 UTC (rev 1042)
+++
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/GridRendererState.java 2007-06-06
12:56:22 UTC (rev 1043)
@@ -213,7 +213,7 @@
* @return Returns the rowIndex.
*/
public int getRowIndex() {
- if(_rowIndex >= _grid.getRows()){
+ if(_rowIndex >= _grid.getDefaultRows()){
_rowIndex = 0;
}
return _rowIndex;
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-06-06
12:56:06 UTC (rev 1042)
+++
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java 2007-06-06
12:56:22 UTC (rev 1043)
@@ -8,7 +8,6 @@
import javax.faces.application.Application;
import javax.faces.component.UIComponent;
-import javax.faces.component.UIOutput;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
@@ -30,10 +29,10 @@
import org.richfaces.component.UIScrollableGridColumn;
import org.richfaces.event.sort.SortEvent;
import org.richfaces.model.selection.ClientSelection;
-import org.richfaces.model.selection.ClientSelectionConverter;
import org.richfaces.model.selection.Selection;
import org.richfaces.model.selection.SimpleSelection;
import org.richfaces.renderkit.CompositeRenderer;
+import org.richfaces.renderkit.html.response.Options;
import org.richfaces.utils.TemplateLoader;
@@ -63,7 +62,6 @@
private static final String CLIENT_SELECTION = "clientSelection";
-
private final Log log = LogFactory.getLog(ScrollableGridBaseRenderer.class);
private final ColumnVisitor columnsWidthCounter = new ColumnVisitor(){
@@ -248,8 +246,6 @@
String row_id = null;
-
-
System.out.println("row data index: " + grid.getRowIndex());
System.out.println("rows count " + grid.getRows());
System.out.println("local rows " + state.getRowIndex());
@@ -413,7 +409,7 @@
JSFunction function = AjaxRendererUtils.buildAjaxFunction(grid, context);
Map options = AjaxRendererUtils.buildEventOptions(context, grid);
- options.put("oncomplete", AjaxFunctionBuilder.getOnDataReady(context, grid,
this));
+ options.put("oncomplete", AjaxFunctionBuilder.getOnComplete(context, grid,
this, AjaxFunctionBuilder.SCROLL));
function.addParameter(options);
String completeFunction = function.toScript()+"; return false;";
@@ -439,7 +435,7 @@
options.put("parameters", parametersMap);
JSFunction function = AjaxRendererUtils.buildAjaxFunction(grid, context);
- options.put("oncomplete", AjaxFunctionBuilder.getOnDataReady(context, grid,
this));
+ options.put("oncomplete", AjaxFunctionBuilder.getOnComplete(context, grid,
this, AjaxFunctionBuilder.SORT));
function.addParameter(options);
String completeFunction = function.toScript() + "; return false;";
@@ -678,10 +674,22 @@
ajaxContext.setResponseData(grid.getResponseData());
ajaxContext.getAjaxRenderedAreas().remove(grid.getClientId(context));
-
+ Options options = createOptions(grid);
+ ajaxContext.getResponseDataMap().put("options", options);
grid.setRows(grid.getDefaultRows());
}
+ private Options createOptions(UIScrollableGrid grid){
+
+ int index = grid.getRowIndex();
+ int startRow = ((Integer)grid.getAttributes().get(CLIENT_ROW_KEY)).intValue();
+ int count = grid.getRows();
+
+ Options options = new Options(index, startRow, count);
+
+ return options;
+ }
+
public void encodeChildren(FacesContext context, UIComponent component
) throws IOException {