Author: abelevich
Date: 2007-05-29 13:29:10 -0400 (Tue, 29 May 2007)
New Revision: 939
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-29
17:29:01 UTC (rev 938)
+++
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java 2007-05-29
17:29:10 UTC (rev 939)
@@ -36,6 +36,8 @@
private final String FOOTER_PART = "footer";
private final String HEADER_PART = "header";
+
+ private final String SPLASH_FACET = "splash";
private final String CELL_ID_PREFFIX ="bc_";
@@ -195,7 +197,6 @@
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 cell_id = state.getClientId() + ":" + CELL_ID_PREFFIX +
state.getRowIndex()+ "_" + state.getCellIndex();
getUtils().writeAttribute(writer, "id",cell_id);
@@ -356,9 +357,9 @@
UIScrollableGrid grid = (UIScrollableGrid)component;
ExternalContext externalContext = context.getExternalContext();
String clientId = grid.getClientId(context);
+ boolean sorted = false;
+ Map parameters = externalContext.getRequestParameterMap();
- Map parameters = externalContext.getRequestParameterMap();
-
if(parameters.containsKey(clientId + ":sortColumn") &&
parameters.containsKey(clientId + ":sortStartRow") &&
parameters.containsKey(clientId + ":sortIndex") &&
@@ -366,7 +367,7 @@
int sortColumn = Integer.parseInt((String)parameters.get(clientId +
":sortColumn"));
int sortStartRow = Integer.parseInt((String)parameters.get(clientId +
":sortStartRow"));
- int sortIndex = Integer.parseInt((String)parameters.get(clientId +
":sortIndex"));
+ int sortDataIndex = Integer.parseInt((String)parameters.get(clientId +
":sortIndex"));
String sortOrder = (String)parameters.get(clientId + ":sortOrder");
boolean asc = true;
@@ -374,21 +375,25 @@
asc = false;
}
- SortEvent sortEvent = new SortEvent(grid,sortColumn, sortStartRow, sortIndex, asc );
- grid.queueEvent(sortEvent);
+ grid.setDataIndex(new Integer(sortDataIndex));
+ grid.setStartRow(new Integer(sortStartRow));
+ grid.setRequestedRows(new Integer(grid.getRows()));
+ sorted = true;
+
+ SortEvent sortEvent = new SortEvent(grid,sortColumn, sortStartRow, sortDataIndex, asc
);
+ grid.queueEvent(sortEvent);
+
}
- if(parameters.containsKey(clientId + "_state_input")){
- String submitedState = (String)parameters.get(clientId + "_state_input");
- decodeScrolling(submitedState, grid);
- grid.queueEvent(new AjaxEvent(grid));
-
+ if(parameters.containsKey(clientId + "_state_input") && !sorted){
+ String submitedState = (String)parameters.get(clientId + "_state_input");
+ decodeScrolling(submitedState, grid);
+ grid.queueEvent(new AjaxEvent(grid));
}
-
}
-
}
+
private void decodeScrolling(String submitedState, UIScrollableGrid grid){
boolean isEmpty = true;
@@ -400,17 +405,17 @@
}
if(!isEmpty){
- grid.setRow_count(new Integer(Integer.parseInt(values[0])));
+ grid.setRequestedRows(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.setRequestedRows(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("row count: " + grid.getRequestedRows());
System.out.println("data index: " + grid.getDataIndex());
System.out.println("start row: " + grid.getStartRow());
}
@@ -423,8 +428,8 @@
grid.setFirst(grid.getDataIndex().intValue());
int old = grid.getRows();
state.setLoadedRowsCount(old);
- grid.setRows(grid.getRow_count().intValue());
-// grid.setRows(grid.getRow_count().intValue() + 1);
+ grid.setRows(grid.getRequestedRows().intValue());
+
int start_row = grid.getStartRow().intValue();
AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
@@ -471,12 +476,16 @@
public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
- AjaxContext ajaxContext = AjaxContext.getCurrentInstance();
- if(ajaxContext.isAjaxRequest()){
- }else{
- super.encodeEnd(context, component);
+ if(component instanceof UIScrollableGrid){
+ UIScrollableGrid grid = (UIScrollableGrid)component;
+
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance();
+
+ if(!ajaxContext.isAjaxRequest()){
+ super.encodeEnd(context, component);
+
+ }
}
-
}
public void setUpColumnsWidth(FacesContext context, UIScrollableGrid grid) throws
IOException{
Show replies by date