JBoss Rich Faces SVN: r877 - trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/event/sort.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-05-24 14:36:06 -0400 (Thu, 24 May 2007)
New Revision: 877
Modified:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/event/sort/SortEvent.java
Log:
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/event/sort/SortEvent.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/event/sort/SortEvent.java 2007-05-24 18:35:53 UTC (rev 876)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/event/sort/SortEvent.java 2007-05-24 18:36:06 UTC (rev 877)
@@ -22,8 +22,10 @@
private static final long serialVersionUID = -1453867412542792281L;
- private String sortField;
+ private int sortColumnIndex;
+ private boolean sortAsc;
+
/**
* @param component
* @param sortField
@@ -31,11 +33,22 @@
*/
public SortEvent(
UIComponent component,
- String sortField) {
+ int sortColumnIndex,
+ boolean sortAsc) {
+
super(component);
- this.sortField = sortField;
+ this.sortColumnIndex = sortColumnIndex;
+ this.sortAsc = sortAsc;
}
+ public boolean isSortAsc() {
+ return sortAsc;
+ }
+
+ public void setSortAsc(boolean sortAsc) {
+ this.sortAsc = sortAsc;
+ }
+
public boolean isAppropriateListener(FacesListener listener) {
return (listener instanceof SortListener);
}
@@ -47,14 +60,14 @@
/**
* @return the sortField
*/
- public String getSortField() {
- return sortField;
+ public int getSortField() {
+ return sortColumnIndex;
}
/**
* @see java.util.EventObject#toString()
*/
public String toString() {
- return "SortEvent: {sortField: " + sortField + "}";
+ return "SortEvent: {sortField: " + sortColumnIndex + "}";
}
}
17 years, 7 months
JBoss Rich Faces SVN: r876 - trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-05-24 14:35:53 -0400 (Thu, 24 May 2007)
New Revision: 876
Added:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/DataRange.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/GridRange.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/IterationBounds.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/SequenceRange.java
Modified:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/ScrollableGridDataModel.java
Log:
Added: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/DataRange.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/DataRange.java (rev 0)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/DataRange.java 2007-05-24 18:35:53 UTC (rev 876)
@@ -0,0 +1,75 @@
+/*
+ * Copyright
+ * Copyright (c) Exadel,Inc. 2006
+ * All rights reserved.
+ *
+ * History
+ * $Source: /cvs-master/intralinks-jsf-comps/components/data-view-grid/src/component/com/exadel/jsf/model/DataRange.java,v $
+ * $Revision: 1.5 $
+ */
+
+package org.richfaces.model;
+
+
+/**
+ * Data window wrapper.
+ * Instance should be able to access any object within current data window.
+ * Subclasses can be built around any data source, (e.g. ResultSet, ScrollableResult or simple List).
+ *
+ *
+ * @author Maksim Kaszynski
+ */
+public abstract class DataRange {
+ private SortOrder sortOrder;
+ private int startRow;
+ private int endRow;
+
+ /**
+ * Construct a DataRange object.
+ * @param startRow
+ * @param endRow
+ * @param sortOrder
+ */
+ public DataRange(int startRow, int endRow, SortOrder sortOrder) {
+ super();
+ this.sortOrder = sortOrder;
+ this.startRow = startRow;
+ this.endRow = endRow;
+ }
+ /**
+ * @return the endRow
+ */
+ public int getEndRow() {
+ return endRow;
+ }
+ /**
+ * @return the sortOrder
+ */
+ public SortOrder getSortOrder() {
+ return sortOrder;
+ }
+ /**
+ * @return the startRow
+ */
+ public int getStartRow() {
+ return startRow;
+ }
+
+ /**
+ * test if specified absolute index lies within this data range
+ * @param index
+ * @return
+ */
+ public boolean hit(int index) {
+ return index >= startRow && index < endRow;
+ }
+
+ /**
+ * Implementations should define this method to get object at given absolute position.
+ *
+ * @param index - absolute index of record within entire recordset, NOT relative to the start of data range.
+ * @return object at given position within whole recordset.
+ */
+ public abstract Object getRowData(int index);
+
+}
Added: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/GridRange.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/GridRange.java (rev 0)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/GridRange.java 2007-05-24 18:35:53 UTC (rev 876)
@@ -0,0 +1,28 @@
+/**
+ *
+ */
+package org.richfaces.model;
+
+import org.ajax4jsf.ajax.repeat.Range;
+
+/**
+ * @author maksim
+ *
+ */
+public abstract class GridRange implements Range {
+
+ private SortOrder sortOrder;
+
+ public abstract IterationBounds getIterationBounds(int rowCount);
+
+ public SortOrder getSortOrder() {
+ return sortOrder;
+ }
+
+ public void setSortOrder(SortOrder sortOrder) {
+ this.sortOrder = sortOrder;
+ }
+
+
+
+}
Added: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/IterationBounds.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/IterationBounds.java (rev 0)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/IterationBounds.java 2007-05-24 18:35:53 UTC (rev 876)
@@ -0,0 +1,63 @@
+/*
+ * Copyright
+ * Copyright (c) Exadel,Inc. 2006
+ * All rights reserved.
+ *
+ * History
+ * $Source: /cvs-master/intralinks-jsf-comps/components/data-view-grid/src/component/com/exadel/jsf/model/IterationBounds.java,v $
+ * $Revision: 1.3 $
+ */
+
+package org.richfaces.model;
+
+import java.io.Serializable;
+
+public class IterationBounds implements Serializable {
+
+ public interface RowVisitor {
+ public void visit(int rowIndex);
+ }
+
+ private static final long serialVersionUID = 1L;
+
+ private int startRow;
+ private int endRow;
+
+ public IterationBounds() {
+ }
+ public IterationBounds(int startRow, int endRow) {
+ super();
+ this.startRow = startRow;
+ this.endRow = endRow;
+ }
+
+ public boolean within(int i) {
+ return i >= startRow && i < endRow;
+ }
+
+ public void iterate(RowVisitor rowVisitor) {
+ for (int i = startRow; i < endRow; i++) {
+ rowVisitor.visit(i);
+ }
+ }
+
+ public int size() {
+ return endRow - startRow;
+ }
+
+ public int getEndRow() {
+ return endRow;
+ }
+
+ public int getStartRow() {
+ return startRow;
+ }
+ /**
+ * @see java.lang.Object#toString()
+ */
+
+ public String toString() {
+ // TODO Auto-generated method stub
+ return "[" + startRow + "," + endRow + "]";
+ }
+}
\ No newline at end of file
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/ScrollableGridDataModel.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/ScrollableGridDataModel.java 2007-05-24 18:35:20 UTC (rev 875)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/ScrollableGridDataModel.java 2007-05-24 18:35:53 UTC (rev 876)
@@ -11,6 +11,9 @@
public class ScrollableGridDataModel extends SequenceDataModel{
+ private SortOrder sortOrder;
+
+
public ScrollableGridDataModel(DataModel model) {
super(model);
}
@@ -19,4 +22,12 @@
super.walk(context, visitor, range, argument);
}
+
+ public SortOrder getSortOrder(){
+ return sortOrder;
+ }
+
+ public void setSortOrder(SortOrder sortOrder){
+ this.sortOrder = sortOrder;
+ }
}
Added: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/SequenceRange.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/SequenceRange.java (rev 0)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/SequenceRange.java 2007-05-24 18:35:53 UTC (rev 876)
@@ -0,0 +1,65 @@
+/**
+ *
+ */
+package org.richfaces.model;
+
+/**
+ * @author maksim
+ *
+ */
+public class SequenceRange extends GridRange {
+
+ private int start;
+ private int end;
+
+ public SequenceRange(int start, int end) {
+ super();
+ this.start = start;
+ this.end = end;
+ }
+
+ public int getStart() {
+ return start;
+ }
+
+ public void setStart(int start) {
+ this.start = start;
+ }
+
+ public int getEnd() {
+ return end;
+ }
+
+ public void setEnd(int end) {
+ this.end = end;
+ }
+
+ /* (non-Javadoc)
+ * @see com.exadel.jsf.model.GridRange#getIterationBounds(int)
+ */
+ public IterationBounds getIterationBounds(int rowCount) {
+ int a = start, b = end;
+
+ if (start > rowCount) {
+ a = rowCount;
+ }
+
+ if (end > rowCount) {
+ b = rowCount;
+ }
+ if (b < 0) {
+ b = rowCount;
+ }
+
+ if (a > b) {
+ int c = a;
+
+ a = b;
+ b = c;
+ }
+
+
+ return new IterationBounds(a,b);
+ }
+
+}
17 years, 7 months
JBoss Rich Faces SVN: r875 - trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-05-24 14:35:20 -0400 (Thu, 24 May 2007)
New Revision: 875
Added:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/AjaxFunctionBuilder.java
Removed:
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/GridRendererState.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java
Log:
Copied: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/AjaxFunctionBuilder.java (from rev 853, trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/OnCompleteFunctionBuilder.java)
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/AjaxFunctionBuilder.java (rev 0)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/AjaxFunctionBuilder.java 2007-05-24 18:35:20 UTC (rev 875)
@@ -0,0 +1,47 @@
+/**
+ *
+ */
+package org.richfaces.renderkit.html;
+
+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 AjaxFunctionBuilder {
+
+// 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/GridRendererState.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/GridRendererState.java 2007-05-24 18:34:56 UTC (rev 874)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/GridRendererState.java 2007-05-24 18:35:20 UTC (rev 875)
@@ -218,6 +218,9 @@
* @return Returns the rowIndex.
*/
public int getRowIndex() {
+ if(_rowIndex >= _loadedRowsCount){
+ _rowIndex = 0;
+ }
return _rowIndex;
}
@@ -226,12 +229,7 @@
* @return new row number.
*/
public int nextRow(){
- if(_rowIndex > _loadedRowsCount)
- _rowIndex = 0;
- else{
- _rowIndex ++;
- }
-
+ _rowIndex = _rowIndex + 1;
return _rowIndex;
}
@@ -359,12 +357,12 @@
this.sumWidth = sumWidth;
}
- public int get_loadedRowsCount() {
+ public int getLoadedRowsCount() {
return _loadedRowsCount;
}
- public void set_loadedRowsCount(int rowsCount) {
- _loadedRowsCount = rowsCount;
+ public void setLoadedRowsCount(int loadedRowsCount) {
+ _loadedRowsCount = loadedRowsCount;
}
public Integer getSepOffset() {
Deleted: 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 2007-05-24 18:34:56 UTC (rev 874)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/OnCompleteFunctionBuilder.java 2007-05-24 18:35:20 UTC (rev 875)
@@ -1,48 +0,0 @@
-/**
- *
- */
-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-24 18:34:56 UTC (rev 874)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java 2007-05-24 18:35:20 UTC (rev 875)
@@ -17,8 +17,10 @@
import org.ajax4jsf.framework.renderer.RendererBase;
import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
import org.ajax4jsf.framework.util.javascript.JSFunction;
+import org.ajax4jsf.framework.util.javascript.JSReference;
import org.richfaces.component.UIScrollableGrid;
import org.richfaces.component.UIScrollableGridColumn;
+import org.richfaces.event.sort.SortEvent;
import org.richfaces.renderkit.CompositeRenderer;
import org.richfaces.utils.TemplateLoader;
@@ -134,6 +136,7 @@
public void renderContent(FacesContext context, UIScrollableGridColumn column, ResponseWriter writer, GridRendererState state) throws IOException {
String cell_id = state.getRowIndex()+ "_" + state.getCellIndex();
+ System.out.println("cell_index: " + cell_id);
String client_id = state.getClientId();
int cell_index = state.getCellIndex();
cellTemplate = getCellTemplate();
@@ -169,8 +172,12 @@
state.setFrozenColumnCount(((Integer)grid.getAttributes().get("frozenColCount")).intValue());
getUtils().writeAttribute(writer, "id",row_id);
getUtils().writeAttribute(writer, "class","ClientUI_Grid_BR");
+
+ System.out.println("rowIndex : " + index);
+
ColumnWalker.iterateOverColumns(context, grid, cellRenderer, writer, state);
writer.endElement(HTML.TR_ELEMENT);
+ state.nextRow();
}
}
@@ -193,8 +200,7 @@
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("cell index: " + cell_id);
+ System.out.println("cell index: " + cell_id);
renderChildren(context, column);
writer.endElement(HTML.SPAN_ELEM);
AjaxContext ajaxContext = state.getAjaxContext();
@@ -242,9 +248,14 @@
state.setColumType(COLUMN_NORMAL_TYPE);
}
+ System.out.println("");
+ System.out.println("ScrollableGridBaseRenderer.renderGridBody()");
+ System.out.println("");
+
state.setFrozenColumnCount(((Integer)grid.getAttributes().get("frozenColCount")).intValue());
state.setFrozenPart(isFrozen);
state.setClientId(grid.getClientId(context));
+ state.setLoadedRowsCount(grid.getRows());
grid.walk(context, rowsRenderer, state);
grid.setRowKey(null);
}
@@ -304,13 +315,33 @@
JSFunction function = AjaxRendererUtils.buildAjaxFunction(grid, context);
Map options = AjaxRendererUtils.buildEventOptions(context, grid);
- options.put("oncomplete", OnCompleteFunctionBuilder.getOnDataReady(context, grid, this));
+ options.put("oncomplete", AjaxFunctionBuilder.getOnDataReady(context, grid, this));
function.addParameter(options);
-
String completeFunction = function.toScript()+"; return false;";
+
return completeFunction;
}
+
+ public String onSortAjaxUpdate(FacesContext context, UIScrollableGrid grid){
+
+ JSReference index = new JSReference("index");
+ JSReference order = new JSReference("order");
+ Map options = AjaxRendererUtils.buildEventOptions(context, grid);
+
+ Map parametersMap = (Map)options.get("parameters");
+ String id = grid.getClientId(context);
+ parametersMap.put(id + ":index", index);
+ parametersMap.put(id + ":order", order);
+
+ options.put("parameters", parametersMap);
+
+ JSFunction function = AjaxRendererUtils.buildAjaxFunction(grid, context);
+ function.addParameter(options);
+ String completeFunction = function.toScript() + "; return false;";
+
+ return completeFunction;
+ }
protected void doDecode(FacesContext context, UIComponent component) {
@@ -320,21 +351,25 @@
UIScrollableGrid grid = (UIScrollableGrid)component;
ExternalContext externalContext = context.getExternalContext();
- String clientId = grid.getClientId(context) + "_state_input";
+ String clientId = grid.getClientId(context);
Map parameters = externalContext.getRequestParameterMap();
- if(parameters.containsKey(clientId)){
+
+ if(parameters.containsKey(clientId + ":order") && parameters.containsKey(clientId + ":index")){
+
+ boolean isAsc = false;
+ String order = (String)parameters.get(clientId + ":order");
+ int index = Integer.parseInt((String)parameters.get(clientId + ":index"));
+ if(order.equals("asc")){
+ isAsc = true;
+ }
+ SortEvent sortEvent = new SortEvent(grid,index, isAsc);
+ grid.queueEvent(sortEvent);
+ }
- String submitedState = (String)parameters.get(clientId);
- String [] values = submitedState.split(",");
- grid.setRow_count(new Integer(Integer.parseInt(values[0])));
- grid.setDataIndex(new Integer(Integer.parseInt(values[1])));
- grid.setStartRow(new Integer(Integer.parseInt(values[2])));
-
- System.out.println("row count: " + grid.getRow_count());
- System.out.println("data index: " + grid.getDataIndex());
- System.out.println("start row: " + grid.getStartRow());
-
+ if(parameters.containsKey(clientId + "_state_input")){
+ String submitedState = (String)parameters.get(clientId + "_state_input");
+ decodeScrolling(submitedState, grid);
grid.queueEvent(new AjaxEvent(grid));
}
@@ -343,16 +378,40 @@
}
+ private void decodeScrolling(String submitedState, UIScrollableGrid grid){
+
+ boolean isEmpty = true;
+
+
+ String [] values = submitedState.split(",");
+ for (int i = 0; i < values.length; i++) {
+ isEmpty = isEmpty && values[i].equals("");
+ }
+
+ if(!isEmpty){
+ grid.setRow_count(new Integer(Integer.parseInt(values[0])));
+ grid.setDataIndex(new Integer(Integer.parseInt(values[1])));
+ grid.setStartRow(new Integer(Integer.parseInt(values[2])));
+ }else{
+ grid.setRow_count(new Integer(grid.getRows()));
+ grid.setDataIndex(new Integer(0));
+ grid.setStartRow(new Integer(grid.getFirst()));
+ }
+ System.out.println("");
+ System.out.println("row count: " + grid.getRow_count());
+ System.out.println("data index: " + grid.getDataIndex());
+ System.out.println("start row: " + grid.getStartRow());
+ }
+
+
public void renderAjaxChildren(FacesContext context, UIComponent component)throws IOException{
UIScrollableGrid grid = (UIScrollableGrid)component;
-
GridRendererState state = GridRendererState.createState(context, grid);
grid.setFirst(grid.getDataIndex().intValue());
int old = grid.getRows();
- state.set_loadedRowsCount(old);
-
- grid.setRows(grid.getRow_count().intValue());
+ state.setLoadedRowsCount(old);
+ grid.setRows(grid.getRow_count().intValue() + 1);
int start_row = grid.getStartRow().intValue();
AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
@@ -360,6 +419,11 @@
state.setClientId(client_id);
state.setAjaxContext(ajaxContext);
state.setRowIndex(start_row);
+
+ System.out.println("");
+ System.out.println("ScrollableGridBaseRenderer.renderAjaxChildren()");
+ System.out.println("");
+
grid.walk(context, ajaxRowsRenderer, state);
ajaxContext.getAjaxRenderedAreas().remove(grid.getClientId(context));
grid.setRows(old);
17 years, 7 months
JBoss Rich Faces SVN: r874 - trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-05-24 14:34:56 -0400 (Thu, 24 May 2007)
New Revision: 874
Modified:
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody2.js
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader2.js
Log:
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody2.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody2.js 2007-05-24 18:34:31 UTC (rev 873)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody2.js 2007-05-24 18:34:56 UTC (rev 874)
@@ -203,8 +203,6 @@
var totalWidth = this.grid.getColumnsTotalWidth();
this.scrollBox.moveTo(0, 0);
- this.scrollBox.setWidth(this.getWidth()+1);
- this.scrollBox.setHeight(this.getHeight()+1);
this.scrollBox.setWidth(this.getWidth());
this.scrollBox.setHeight(this.getHeight());
@@ -229,12 +227,16 @@
this.frozenContentBox.setWidth(frozenContentWidth);
this.frozenContentBox.setHeight(height - fixH);
+ this.scrollBox.setWidth(this.getWidth()+1);
+ this.scrollBox.setHeight(this.getHeight()+1);
+ this.scrollBox.setWidth(this.getWidth());
+ this.scrollBox.setHeight(this.getHeight());
+
var scrollPos = Math.min(totalWidth - frozenContentWidth - this.contentBox.getWidth(), scrollLeft);
this.grid.adjustScrollPosition(scrollPos);
this.dataVisible = parseInt(this.contentBox.getHeight() / this.defaultRowHeight, 10) + 1;
this.dataVisible = Math.min(this.dataVisible, this.rowsCount);
- //this.dataVisible = this.rowsCount;
if(height > 0) {
this.adjustDataPosition(this.currentPos);
}
@@ -253,9 +255,9 @@
return;
}
- // 1. calculate direction and range to load next data
+ // 1. calculate direction and range to load next data
+ this.processedPos = pos;
var forwardDir = (this.currentPos <= pos) ? true : false;
- this.currentPos = pos;
// first visible row index
var first = parseInt(pos / this.defaultRowHeight) - 1;
@@ -277,6 +279,7 @@
task.from = from;
task.to = to;
task.first = first;
+ task.pos = pos;
this._setPendingTask(task);
}
},
@@ -288,13 +291,15 @@
rowsToLoadIdx: [],
from: 0,
to: 0,
- first: 0
+ first: 0,
+ pos: 0
};
}
return this.pendingTask;
},
_setPendingTask: function(task) {
clearTimeout(this.pendingTask.timer);
+ this.pendingTask.timer = null;
this.pendingTask = task;
// and plan other agjusting over the time
@@ -325,15 +330,19 @@
});
},
startLoadData: function() {
- if(this.updateStarted) return;
+ if(this.updateStarted) {
+ this._setPendingTask(this._getPendingTask());
+ return;
+ }
+
+ this.updateStarted = true;
+ this.taskStartTime = (new Date()).getTime();
- this.taskStartTime = (new Date()).getTime();
-
var task = this._getPendingTask();
var range = $R(task.from, task.to);
var switchType = 5;
var startIndex = 0;
- var startRow = 0;
+ var startRowIndx = 0;
var countToLoad = 0;
// if we have intersepted ranges than rearrange rows
@@ -344,7 +353,7 @@
}
if(switchType === 0) {
- startRow = this.templFrozen.getElement().rows[0].index;
+ startRowIndx = this.templFrozen.getElement().rows[0].index;
startIndex = range.start;
countToLoad = range.end - range.start;
}
@@ -358,7 +367,7 @@
switchType = 1;
countToLoad = range.start - this.currRange.start;
if(countToLoad > 0) {
- startRow = frozenTbl.rows[0].index;
+ startRowIndx = frozenTbl.rows[0].index;
startIndex = this.currRange.end;
}
}
@@ -368,7 +377,7 @@
if(countToLoad > 0) {
startIndex = range.start;
var restCount = this.rowsCount - countToLoad;
- startRow = frozenTbl.rows[restCount].index;
+ startRowIndx = frozenTbl.rows[restCount].index;
}
}
}
@@ -383,28 +392,31 @@
if(countToLoad > 0 && process) {
this.updateStarted = true;
ClientUILib.log(ClientUILogger.WARNING, "Start loading...");
+ this.currRange = range;
+ this.currentPos = task.pos;
+
+ this.taskDefineTime = (new Date()).getTime();
+
this.showSplash();
- this.taskDefineTime = (new Date()).getTime();
- var task = this._getPendingTask();
// Make timer to handle quick clicks on scrollbar arrows
- task.timer = setTimeout(function() {
+ setTimeout(function() {
// 4. start data loading
//this.container.hide();
- //Element.setStyle(this.container.getElement(), {visibility: "hidden"});
-
- screen.updateInterval = 1000;
+ this.updateInterval = screen.updateInterval;
+ screen.updateInterval = 500;
this.grid.dataModel.loadRows({
index: startIndex,
count: countToLoad,
- startRow: startRow,
+ startRow: startRowIndx,
switchType: switchType});
-
- this.currRange = range;
}.bind(this), 10);
}
+ else {
+ this.updateStarted = false;
+ }
},
setProgressCtrl: function(ctrl) {
@@ -426,93 +438,113 @@
* @param {Object} options
*/
invalidate: function(options) {
-
- //Element.setStyle(this.container.getElement(), {visibility: "inherit"});
- //this.container.show();
-
+
ClientUILib.log(ClientUILogger.WARNING, "Stop loading.");
var frozenTbl = this.templFrozen.getElement();
var normalTbl = this.templNormal.getElement();
- if(options.switchType === 0) {
- var pos = this.defaultRowHeight * options.index;
- this.templFrozen.moveToY(pos);
- this.templNormal.moveToY(pos);
- }
- else if(options.switchType === 1 || options.switchType === 2) {
- // store visible row pos to restore after rows reerrange
- var visibleRowPos = 0;
- var count = frozenTbl.rows.length;
- var frows = new Array(count), nrows = new Array(count);
- var j = 0;
-
- if(options.switchType === 1) {
- visibleRowPos = this.templFrozen.getY() + options.count * this.defaultRowHeight;
- for(i=options.count; i<this.rowsCount; i++) {
- frows[j] = frozenTbl.rows[i];
- nrows[j] = normalTbl.rows[i];
- j++;
+ screen.updateInterval = this.updateInterval;
+ //this.container.show();
+
+ setTimeout(function (){
+ if(options.switchType === 0) {
+ var visibleRowPos = this.defaultRowHeight * options.index;
+ this.templFrozen.moveToY(visibleRowPos);
+ this.templNormal.moveToY(visibleRowPos);
+ }
+ else if(options.switchType === 1 || options.switchType === 2) {
+ // store visible row pos to restore after rows reerrange
+ var count = frozenTbl.rows.length;
+ var frows = new Array(count), nrows = new Array(count);
+ var j = 0;
+
+ if(options.switchType === 1) {
+ for(i=options.count; i<this.rowsCount; i++) {
+ frows[j] = frozenTbl.rows[i];
+ nrows[j] = normalTbl.rows[i];
+ j++;
+ }
+ for(i=0; i<options.count; i++) {
+ frows[j] = frozenTbl.rows[i];
+ nrows[j] = normalTbl.rows[i];
+ j++;
+ }
}
- for(i=0; i<options.count; i++) {
- frows[j] = frozenTbl.rows[i];
- nrows[j] = normalTbl.rows[i];
- j++;
+ else {
+ for(i=this.rowsCount - options.count; i<this.rowsCount; i++) {
+ frows[j] = frozenTbl.rows[i];
+ nrows[j] = normalTbl.rows[i];
+ j++;
+ }
+ for(i=0; i<this.rowsCount - options.count; i++) {
+ frows[j] = frozenTbl.rows[i];
+ nrows[j] = normalTbl.rows[i];
+ j++;
+ }
}
- }
- else {
- visibleRowPos = options.index * this.defaultRowHeight;
- for(i=this.rowsCount - options.count; i<this.rowsCount; i++) {
- frows[j] = frozenTbl.rows[i];
- nrows[j] = normalTbl.rows[i];
- j++;
+
+
+ // Mozilla is faster when doing the DOM manipulations on
+ // an orphaned element. MSIE is not
+ var removeChilds = navigator.product == "Gecko";
+ var fbody = frozenTbl.tBodies[0];
+ var nbody = normalTbl.tBodies[0];
+ var fnextSibling = fbody.nextSibling;
+ var nnextSibling = nbody.nextSibling;
+
+ if (removeChilds) { // remove all rows
+ fp = fbody.parentNode;
+ fp.removeChild(fbody);
+ np = nbody.parentNode;
+ np.removeChild(nbody);
}
- for(i=0; i<this.rowsCount - options.count; i++) {
- frows[j] = frozenTbl.rows[i];
- nrows[j] = normalTbl.rows[i];
- j++;
+
+ if(options.switchType === 2) {
+ var visibleRowPos = options.index * this.defaultRowHeight;
+ this.templFrozen.moveToY(visibleRowPos);
+ this.templNormal.moveToY(visibleRowPos);
}
+
+ // insert in the new order
+ for (i = 0; i < count; i++) {
+ fbody.appendChild(frows[i]);
+ nbody.appendChild(nrows[i]);
+ }
+
+ if(removeChilds) {
+ fp.insertBefore(fbody, fnextSibling);
+ np.insertBefore(nbody, nnextSibling);
+ }
+
+ if(options.switchType === 1) {
+ var visibleRowPos = this.currRange.start * this.defaultRowHeight;
+ this.templFrozen.moveToY(visibleRowPos);
+ this.templNormal.moveToY(visibleRowPos);
+ }
}
+ this.splash.hide();
+ this.updateStarted = false;
- // Mozilla is faster when doing the DOM manipulations on
- // an orphaned element. MSIE is not
- var removeChilds = navigator.product == "Gecko";
- var fbody = frozenTbl.tBodies[0];
- var nbody = normalTbl.tBodies[0];
- var fnextSibling = fbody.nextSibling;
- var nnextSibling = nbody.nextSibling;
-
- if (removeChilds) { // remove all rows
- fp = fbody.parentNode;
- fp.removeChild(fbody);
- np = nbody.parentNode;
- np.removeChild(nbody);
- }
+ }.bind(this), 10);
+
- if(options.switchType === 2) {
- this.templFrozen.moveToY(visibleRowPos);
- this.templNormal.moveToY(visibleRowPos);
- }
-
- // insert in the new order
- for (i = 0; i < count; i++) {
- fbody.appendChild(frows[i]);
- nbody.appendChild(nrows[i]);
- }
-
- if(removeChilds) {
- fp.insertBefore(fbody, fnextSibling);
- np.insertBefore(nbody, nnextSibling);
- }
-
- if(options.switchType === 1) {
- this.templFrozen.moveToY(visibleRowPos);
- this.templNormal.moveToY(visibleRowPos);
- }
+ if(this.processedPos != this.currentPos) {
+ this.currentPos = this.processedPos;
+ setTimeout(function (){
+ this.pendedUpdate();
+ }.bind(this), this.grid.dataModel.getRequestDelay());
}
-
- screen.updateInterval = 0;
- this.splash.hide();
- this.updateStarted = false;
+ },
+ pendedUpdate: function() {
+ if(this.processedPos != this.currentPos) {
+ this.currentPos = this.processedPos;
+ setTimeout(function (){
+ this.pendedUpdate();
+ }.bind(this), this.grid.dataModel.getRequestDelay());
+ }
+ else {
+ this.adjustDataPosition(this.processedPos);
+ }
}
});
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader2.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader2.js 2007-05-24 18:34:31 UTC (rev 873)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader2.js 2007-05-24 18:34:56 UTC (rev 874)
@@ -229,7 +229,7 @@
agjustSeparators: function() {
var offset = 0;
var fcnt = this.headerFrozenRow.getElement().rows[0].cells.length;
- for(var i=0; i<this._columns.length; i++) {
+ for(var i=0; i<this._columns.length - 1; i++) {
if(i == fcnt) offset = 0;
offset += this._columns[i].width;
this._columns[i].sep.moveToX(offset - 4);
17 years, 7 months
JBoss Rich Faces SVN: r873 - trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-05-24 14:34:31 -0400 (Thu, 24 May 2007)
New Revision: 873
Modified:
trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid.jspx
Log:
Modified: trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid.jspx
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid.jspx 2007-05-24 18:34:16 UTC (rev 872)
+++ trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid.jspx 2007-05-24 18:34:31 UTC (rev 873)
@@ -55,9 +55,10 @@
renderHeaders(context, component, false);
]]>
</jsp:scriptlet>
+ <td style="width: 1000px"></td>
</tr>
</tbody>
- </table>
+ </table>
</span>
</div>
</div>
@@ -207,6 +208,8 @@
function onSorted(index, order) {
alert("onSorted column: " + index + " by order: " + order);
+ var event = null;
+ #{this:onSortAjaxUpdate(context,component)}
}
dataModel = new ClientUI.controls.grid.FakeArrayDataModel(rows_count, columns_count, clientId);
@@ -237,15 +240,7 @@
//Event.observe(grid.eventOnResizeColumn, "", onColumnResize);
// ClientUILib.log(ClientUILogger.WARNING, "Grid control created over " + ((new Date()).getTime() - currTime) + " miliseconds.");
-
- grid.updateLayout();
-
- setTimeout(
- function() {
- currTime = (new Date()).getTime();
- //grid.loadData();
- }.bind(this), 100);
- // ClientUILib.log(ClientUILogger.WARNING, "Done.");
+
},
onCompleteGridInvalidation : function(request, event, data){
17 years, 7 months
JBoss Rich Faces SVN: r872 - trunk/sandbox/scrollable-grid.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-05-24 14:34:16 -0400 (Thu, 24 May 2007)
New Revision: 872
Modified:
trunk/sandbox/scrollable-grid/.classpath
Log:
Modified: trunk/sandbox/scrollable-grid/.classpath
===================================================================
--- trunk/sandbox/scrollable-grid/.classpath 2007-05-24 17:05:56 UTC (rev 871)
+++ trunk/sandbox/scrollable-grid/.classpath 2007-05-24 18:34:16 UTC (rev 872)
@@ -39,6 +39,6 @@
<classpathentry kind="var" path="M2_REPO/com/ibm/icu/icu4j/2.6.1/icu4j-2.6.1.jar"/>
<classpathentry kind="var" path="M2_REPO/commons-httpclient/commons-httpclient/3.0.1/commons-httpclient-3.0.1.jar"/>
<classpathentry kind="var" path="M2_REPO/jaxen/jaxen/1.1-beta-11/jaxen-1.1-beta-11.jar"/>
- <classpathentry kind="lib" path="/ajax4jsf/framework/target/ajax4jsf-1.1.1-SNAPSHOT.jar"/>
+ <classpathentry kind="lib" path="/ajax4jsf/framework/target/ajax4jsf-1.1.1-SNAPSHOT.jar" sourcepath="/ajax4jsf"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
17 years, 7 months
JBoss Rich Faces SVN: r871 - trunk/richfaces/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts.
by richfaces-svn-commits@lists.jboss.org
Author: sergeyhalipov
Date: 2007-05-24 13:05:56 -0400 (Thu, 24 May 2007)
New Revision: 871
Modified:
trunk/richfaces/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js
Log:
http://jira.jboss.com/jira/browse/RF-208
Modified: trunk/richfaces/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js
===================================================================
--- trunk/richfaces/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js 2007-05-24 14:40:13 UTC (rev 870)
+++ trunk/richfaces/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js 2007-05-24 17:05:56 UTC (rev 871)
@@ -255,6 +255,7 @@
//this.disableDocumentFocusElements();
if (!this.floatedToBody) {
+ this.parent = this.id.parentNode;
document.body.appendChild(this.id.parentNode.removeChild(this.id));
this.floatedToBody = true;
}
@@ -436,6 +437,12 @@
}
Element.hide(this.id);
+
+ if (this.floatedToBody && this.parent) {
+ document.body.removeChild(this.id);
+ this.parent.appendChild(this.id);
+ this.floatedToBody = false;
+ }
},
doResizeOrMove: function(diff) {
17 years, 7 months
JBoss Rich Faces SVN: r870 - trunk/docs/userguide/en/included.
by richfaces-svn-commits@lists.jboss.org
Author: smukhina
Date: 2007-05-24 10:40:13 -0400 (Thu, 24 May 2007)
New Revision: 870
Modified:
trunk/docs/userguide/en/included/modalPanel.xml
Log:
Modified: trunk/docs/userguide/en/included/modalPanel.xml
===================================================================
--- trunk/docs/userguide/en/included/modalPanel.xml 2007-05-24 14:29:12 UTC (rev 869)
+++ trunk/docs/userguide/en/included/modalPanel.xml 2007-05-24 14:40:13 UTC (rev 870)
@@ -62,7 +62,7 @@
<para>Here is a simple example as it might be used in a page:</para>
<programlisting role="XML">...
- <rich:modalPanel id="panel">
+ <rich:modalPanel id="panel">
<f:facet name="header">
<h:outputText value="header">
</f:facet>
@@ -202,7 +202,7 @@
<property>"resizeable"</property>
</emphasis> and <emphasis role="italic">
<property>"moveable"</property>
- </emphasis> attributes to �true� or �false� values. Window resizing is
+ </emphasis> attributes to "true" or "false" values. Window resizing is
also limited by <emphasis role="italic">
<property>"minWidth"</property>
</emphasis> and <emphasis role="italic">
17 years, 7 months
JBoss Rich Faces SVN: r869 - trunk/richfaces/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts.
by richfaces-svn-commits@lists.jboss.org
Author: a.izobov
Date: 2007-05-24 10:29:12 -0400 (Thu, 24 May 2007)
New Revision: 869
Modified:
trunk/richfaces/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js
Log:
RF-205
Modified: trunk/richfaces/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js
===================================================================
--- trunk/richfaces/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js 2007-05-24 14:09:14 UTC (rev 868)
+++ trunk/richfaces/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js 2007-05-24 14:29:12 UTC (rev 869)
@@ -41,9 +41,14 @@
update.style.position = 'absolute';
Exadel.Position.smartClone(element, update, options);
}
- Effect.Appear(update, {duration:0.15});
- if (options.iframeId) {
- Effect.Appear($(options.iframeId), {duration:0.15});
+ if (!window.opera) {
+ Effect.Appear(update, {duration:0.15});
+ if (options.iframeId) {
+ Effect.Appear($(options.iframeId), {duration:0.15});
+ }
+ } else {
+ // workaround for RF-205
+ Effect.Appear(update, {duration:0.15, to: 0.999999});
}
};
this.options.onHide = this.options.onHide ||
@@ -333,16 +338,16 @@
var entry = this.getEntry(this.index);
Element.addClassName(entry, this.options.selectedClass);
// Calc scroll position :
- var scroll = document.getElementsByClassName("_suggestion_size_", this.update)[0]
- || this.update;
- var item = entry;
- var realOffset = 0;
- while (item && (item != scroll)) {
- realOffset += item.offsetTop;
- if (item.parentNode == scroll) break;
- item = item.offsetParent;
- }
if (this.keyEvent) {
+ var scroll = document.getElementsByClassName("_suggestion_size_", this.update)[0]
+ || this.update;
+ var item = entry;
+ var realOffset = 0;
+ while (item && (item != scroll)) {
+ realOffset += item.offsetTop;
+ if (item.parentNode == scroll) break;
+ item = item.offsetParent;
+ }
this.keyEvent = false;
LOG.debug("Scroll = " + scroll.scrollTop
+ " , reallOffset= " + realOffset
17 years, 7 months
JBoss Rich Faces SVN: r868 - trunk/docs/userguide/en/included.
by richfaces-svn-commits@lists.jboss.org
Author: afedosik
Date: 2007-05-24 10:09:14 -0400 (Thu, 24 May 2007)
New Revision: 868
Modified:
trunk/docs/userguide/en/included/dataDefinitionList.xml
Log:
Modified: trunk/docs/userguide/en/included/dataDefinitionList.xml
===================================================================
--- trunk/docs/userguide/en/included/dataDefinitionList.xml 2007-05-24 13:56:15 UTC (rev 867)
+++ trunk/docs/userguide/en/included/dataDefinitionList.xml 2007-05-24 14:09:14 UTC (rev 868)
@@ -6,6 +6,7 @@
<keyword>rich:dataDefinitionList</keyword>
</keywordset>
</sectioninfo>
+
<table>
<title>Component identification parameters </title>
<tgroup cols="2">
@@ -39,7 +40,7 @@
</tbody>
</tgroup>
</table>
- </section>
+
<section>
<title>Creating the Component with a Page Tag</title>
<para>To create the simplest variant of <property>dataDefinitionList</property> on a page, use the following syntax:</para>
@@ -50,6 +51,7 @@
</rich:dataDefinitionList>
...
]]></programlisting>
+ </section>
<section>
<title>Creating the Component Dynamically Using Java</title>
@@ -140,5 +142,4 @@
<para>To redefine an appearance of all <property>dataDefinitionLists</property> on a page, just redefine one of this classes.</para>
<para>To redefine a style of a particular <property>dataDefinitionList</property>, use corresponding class attributes on the component.</para>
</section>
- </section>
-
\ No newline at end of file
+ </section>
17 years, 7 months