Author: abelevich
Date: 2007-06-25 12:31:51 -0400 (Mon, 25 Jun 2007)
New Revision: 1302
Modified:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java
Log:
remember visited rows, and walk through it on validate and updates phases
Modified:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java
===================================================================
---
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java 2007-06-25
16:29:09 UTC (rev 1301)
+++
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java 2007-06-25
16:31:51 UTC (rev 1302)
@@ -47,10 +47,14 @@
public static final String COMPONENT_TYPE =
"org.richfaces.component.ScrollableGrid";
+ private boolean MODEL_RANGE = false;
+
private final static Log log = LogFactory.getLog(UIScrollableGrid.class);
private transient Collection partialUpdateChildren;
-
+
+ private List ranges;
+
private Collection responseData = new ArrayList();
private int reqRowsCount = -1;
@@ -110,6 +114,33 @@
}
};
}
+
+
+ public void processDecodes(FacesContext faces) {
+ MODEL_RANGE = true;
+ System.out.println("UIScrollableGrid.processDecodes()");
+ super.processDecodes(faces);
+ }
+
+ public void processValidators(FacesContext faces) {
+ MODEL_RANGE = false;
+ System.out.println("UIScrollableGrid.processValidators()");
+ super.processValidators(faces);
+ }
+
+ public void processUpdates(FacesContext faces) {
+ MODEL_RANGE = false;
+ System.out.println("UIScrollableGrid.processUpdates()");
+ super.processUpdates(faces);
+ ranges.clear();
+ }
+
+ public void encodeBegin(FacesContext context) throws IOException {
+ System.out.println("UIScrollableGrid.encodeBegin()");
+ MODEL_RANGE = true;
+ super.encodeBegin(context);
+ }
+
protected ExtendedDataModel createDataModel() {
Object value = getValue();
@@ -121,7 +152,6 @@
if (log.isDebugEnabled()) {
log.debug("Found instanceof " + value.getClass() + " will use it
unwrapped");
}
-
model = (GridDataModel) value;
} else if (value instanceof List) {
@@ -170,16 +200,19 @@
public Object saveState(FacesContext context) {
- Object values[] = new Object[5];
+ Object values[] = new Object[2];
values[0] = super.saveState(context);
+ values[1] = getRanges();
+
return (Object)values;
}
public void restoreState(FacesContext context, Object state) {
-
Object values[] = (Object[])state;
super.restoreState(context, values[0]);
+ setRanges((List)values[1]);
+
}
protected Iterator dataChildren() {
@@ -236,9 +269,9 @@
event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
}else if(event instanceof SortEvent){
new AjaxEvent(this).queue();
- event.setPhaseId(PhaseId.INVOKE_APPLICATION);
+ event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
}else if(event instanceof ScrollEvent){
- event.setPhaseId(PhaseId.INVOKE_APPLICATION);
+ event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
new AjaxEvent(this).queue();
}
super.queueEvent(event);
@@ -271,8 +304,29 @@
getFacesContext().renderResponse();
}
- public void walk(FacesContext context, DataVisitor visitor, Object argument) throws
IOException {
- super.walk(context, visitor, argument);
+ public void walk(FacesContext faces, DataVisitor visitor, Object argument) throws
IOException {
+
+ Range visitedRange = getComponentState().getRange();
+
+ if(ranges == null){
+ ranges = new ArrayList();
+ }
+
+ if(!ranges.contains(visitedRange)){
+ ranges.add(visitedRange);
+ }
+
+ if(!MODEL_RANGE){
+
+ for (Iterator iter = ranges.iterator(); iter.hasNext();) {
+ ScrollableGridRange range = (ScrollableGridRange) iter.next();
+ System.out.println("Range is: " + range.getFirst() + " - " +
range.getLast() + " sortOrder: " + range.getSortOrder() );
+ getExtendedDataModel().walk(faces, visitor,range, argument);
+ }
+
+ }else{
+ super.walk(faces, visitor, argument);
+ }
}
public Collection getPartialUpdateChildren() {
@@ -293,4 +347,12 @@
public boolean isCacheable() {
return true;
}
+
+ public List getRanges() {
+ return ranges;
+ }
+
+ public void setRanges(List ranges) {
+ this.ranges = ranges;
+ }
}
Show replies by date