Author: abelevich
Date: 2007-06-05 13:55:18 -0400 (Tue, 05 Jun 2007)
New Revision: 1026
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:
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-05
15:33:33 UTC (rev 1025)
+++
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/GridRendererState.java 2007-06-05
17:55:18 UTC (rev 1026)
@@ -39,8 +39,6 @@
private Integer sepOffset;
- private int _loadedRowsCount;
-
private String _cell_id_prefix;
private int sumWidth = 0;
@@ -67,17 +65,11 @@
private GridRendererState _previousState = null;
-// private AjaxContainer _region = null;
-
-// private boolean _rowSelected;
-
private Object rowKey;
private static final long serialVersionUID = 2129605586975025578L;
-// private Set _renderedAreas = null;
-
/**
* Get current grid state from JSF context
* @param context
@@ -221,7 +213,7 @@
* @return Returns the rowIndex.
*/
public int getRowIndex() {
- if(_rowIndex >= _loadedRowsCount){
+ if(_rowIndex >= _grid.getRows()){
_rowIndex = 0;
}
return _rowIndex;
@@ -360,14 +352,6 @@
this.sumWidth = sumWidth;
}
- public int getLoadedRowsCount() {
- return _loadedRowsCount;
- }
-
- public void setLoadedRowsCount(int loadedRowsCount) {
- _loadedRowsCount = loadedRowsCount;
- }
-
public Integer getSepOffset() {
return sepOffset;
}
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-05
15:33:33 UTC (rev 1025)
+++
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java 2007-06-05
17:55:18 UTC (rev 1026)
@@ -45,6 +45,8 @@
private final String COLUMN_NORMAL_TYPE = "normal";
+ private String CLIENT_ROW_KEY = "clientIndex";
+
private RendererBase cellTemplate = null;
private RendererBase headerCellTemplate = null;
@@ -214,10 +216,16 @@
private final DataVisitor ajaxRowsRenderer = new DataVisitor(){
+
public void process(FacesContext context, Object rowKey, Object argument) throws
IOException {
+ int columnsCount = 0;
+
+ boolean frozenTRRendered = false;
+
+ boolean normalTRRendered = false;
+
GridRendererState state = (GridRendererState)argument;
-
AjaxContext ajaxContext = state.getAjaxContext();
ajaxContext.getResponseData();
@@ -229,14 +237,12 @@
String row_id = null;
- int columnsCount = 0;
- boolean frozenTRRendered = false;
+
+ System.out.println("row data index: " + grid.getRowIndex());
+ System.out.println("rows count " + grid.getRows());
+ System.out.println("local rows " + state.getRowIndex());
- boolean normalTRRendered = false;
-
- //System.out.println("row index: " + grid.getRowIndex());
-
for (Iterator iter = grid.getChildren().iterator(); iter.hasNext(); ) {
UIComponent kid = (UIComponent) iter.next();
@@ -312,14 +318,13 @@
state.setColumType(COLUMN_NORMAL_TYPE);
}
- if (log.isDebugEnabled()) {
- log.debug("ScrollableGridBaseRenderer.renderGridBody()");
- }
+ 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);
}
@@ -448,8 +453,8 @@
parameters.containsKey(clientId + ":sortOrder")){
int sortColumn = Integer.parseInt((String)parameters.get(clientId +
":sortColumn"));
- int sortStartRow = Integer.parseInt((String)parameters.get(clientId +
":sortStartRow"));
int sortDataIndex = Integer.parseInt((String)parameters.get(clientId +
":sortIndex"));
+ Integer sortStartRow = Integer.valueOf((String)parameters.get(clientId +
":sortStartRow"));
String sortOrder = (String)parameters.get(clientId + ":sortOrder");
boolean asc = true;
@@ -457,14 +462,21 @@
asc = false;
}
UIScrollableGridColumn column =
(UIScrollableGridColumn)grid.getChildren().get(sortColumn);
+
if(column.isSortable()){
- grid.setDataIndex(new Integer(sortDataIndex));
- grid.setStartRow(new Integer(sortStartRow));
- grid.setRequestedRows(new Integer(grid.getRows()));
+
+ grid.getAttributes().put(CLIENT_ROW_KEY,sortStartRow);
+ grid.setFirst(sortDataIndex);
+ grid.setRows(grid.getDefaultRows());
+
+ System.out.println("rows " + grid.getRows() );
+ System.out.println("client start index" +
grid.getAttributes().get(CLIENT_ROW_KEY));
+ System.out.println("data index " + grid.getFirst());
+
sorted = true;
-
- SortEvent sortEvent = new SortEvent(grid,sortColumn, sortStartRow, sortDataIndex,
asc );
+ SortEvent sortEvent = new SortEvent(grid,sortColumn, sortStartRow.intValue(),
sortDataIndex, asc );
grid.queueEvent(sortEvent);
+
}
}
@@ -488,19 +500,19 @@
}
if(!isEmpty){
- grid.setRequestedRows(new Integer(Integer.parseInt(values[0])));
- grid.setDataIndex(new Integer(Integer.parseInt(values[1])));
- grid.setStartRow(new Integer(Integer.parseInt(values[2])));
+
+ grid.setRows(Integer.parseInt(values[0]));
+ grid.setFirst(Integer.parseInt(values[1]));
+ grid.getAttributes().put(CLIENT_ROW_KEY,Integer.valueOf(values[2]));
+
}else{
- grid.setRequestedRows(new Integer(grid.getRows()));
- grid.setDataIndex(new Integer(0));
- grid.setStartRow(new Integer(grid.getFirst()));
+ grid.getAttributes().put(CLIENT_ROW_KEY, new Integer(0));
}
if (log.isDebugEnabled()) {
log.debug("");
- log.debug("row count: " + grid.getRequestedRows());
- log.debug("data index: " + grid.getDataIndex());
- log.debug("start row: " + grid.getStartRow());
+ log.debug("row count: " + grid.getRows());
+ log.debug("data index: " + grid.getFirst()) ;
+ log.debug("start row: " + grid.getAttributes().get(CLIENT_ROW_KEY));
}
}
@@ -509,33 +521,33 @@
UIScrollableGrid grid = (UIScrollableGrid)component;
GridRendererState state = GridRendererState.createState(context, grid);
- grid.setFirst(grid.getDataIndex().intValue());
- int old = grid.getRows();
- state.setLoadedRowsCount(old);
- grid.setRows(grid.getRequestedRows().intValue());
-
- int start_row = grid.getStartRow().intValue();
-
+
AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
String client_id = grid.getClientId(context);
+
state.setClientId(client_id);
state.setAjaxContext(ajaxContext);
- state.setRowIndex(start_row);
+ state.setRowIndex(((Integer)grid.getAttributes().get(CLIENT_ROW_KEY)).intValue());
if (log.isDebugEnabled()) {
log.debug("ScrollableGridBaseRenderer.renderAjaxChildren()");
}
grid.getResponseData().clear();
+
ResponseWriter writer = context.getResponseWriter();
writer.startElement("table", grid);
writer.startElement("tbody", grid);
+
grid.walk(context, ajaxRowsRenderer, state);
+
writer.endElement("tbody");
writer.endElement("table");
+
ajaxContext.setResponseData(grid.getResponseData());
ajaxContext.getAjaxRenderedAreas().remove(grid.getClientId(context));
- grid.setRows(old);
+
+ grid.setRows(grid.getDefaultRows());
}
public void encodeChildren(FacesContext context, UIComponent component
@@ -558,23 +570,20 @@
}
AjaxContext ajaxContext = AjaxContext.getCurrentInstance();
- if(ajaxContext.isAjaxRequest()){
- }else{
+
+ if(!ajaxContext.isAjaxRequest()){
super.encodeBegin(context, component);
- }
-
+ }
}
public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
if(component instanceof UIScrollableGrid){
- UIScrollableGrid grid = (UIScrollableGrid)component;
AjaxContext ajaxContext = AjaxContext.getCurrentInstance();
if(!ajaxContext.isAjaxRequest()){
super.encodeEnd(context, component);
-
}
}
}
@@ -610,4 +619,5 @@
}
return footerCellTemplate;
}
+
}