Author: maksimkaszynski
Date: 2007-06-14 10:33:59 -0400 (Thu, 14 Jun 2007)
New Revision: 1184
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/SelectionRendererContributor.java
Log:
correct ajax updates
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-14
14:22:57 UTC (rev 1183)
+++
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java 2007-06-14
14:33:59 UTC (rev 1184)
@@ -12,7 +12,6 @@
import org.ajax4jsf.ajax.repeat.DataVisitor;
import org.ajax4jsf.framework.ajax.AjaxContext;
-import org.ajax4jsf.framework.ajax.AjaxEvent;
import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
import org.ajax4jsf.framework.renderer.ComponentVariables;
import org.ajax4jsf.framework.renderer.ComponentsVariableResolver;
@@ -42,6 +41,8 @@
public abstract class ScrollableGridBaseRenderer extends CompositeRenderer {
+ public final String PARTIAL_UPDATE= "partialUpdate";
+
private final String FOOTER_PART = "footer";
private final String HEADER_PART = "header";
@@ -486,6 +487,10 @@
protected void doDecode(FacesContext context, UIComponent component) {
super.doDecode(context, component);
+
+ component.getAttributes().remove(PARTIAL_UPDATE);
+
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
if(component instanceof UIScrollableGrid){
@@ -529,6 +534,9 @@
SortEvent sortEvent = new SortEvent(grid,sortColumn, sortStartRow.intValue(),
sortDataIndex, asc );
grid.queueEvent(sortEvent);
+ if (ajaxContext.isAjaxRequest()) {
+ component.getAttributes().put(PARTIAL_UPDATE, Boolean.TRUE);
+ }
}
}
@@ -557,6 +565,10 @@
ScrollEvent scrollEvent = new ScrollEvent(grid,rows,first);
grid.queueEvent(scrollEvent);
+
+ if (ajaxContext.isAjaxRequest()) {
+ component.getAttributes().put(PARTIAL_UPDATE, Boolean.TRUE);
+ }
}
}
@@ -618,11 +630,17 @@
return options;
}
+ private boolean onlyPartialUpdateNeeded(UIComponent grid) {
+ Boolean b = (Boolean) grid.getAttributes().get(PARTIAL_UPDATE);
+ return b != null && b.booleanValue();
+ }
+
public void encodeChildren(FacesContext context, UIComponent component
) throws IOException {
AjaxContext ajaxContext = AjaxContext.getCurrentInstance();
- if(ajaxContext.isAjaxRequest()){
+
+ if(ajaxContext.isAjaxRequest() && onlyPartialUpdateNeeded(component)){
renderAjaxChildren(context, component);
}else{
super.encodeChildren(context, component);
@@ -639,7 +657,7 @@
AjaxContext ajaxContext = AjaxContext.getCurrentInstance();
- if(!ajaxContext.isAjaxRequest()){
+ if(!ajaxContext.isAjaxRequest() && !onlyPartialUpdateNeeded(component)){
super.encodeBegin(context, component);
}
}
@@ -650,7 +668,7 @@
AjaxContext ajaxContext = AjaxContext.getCurrentInstance();
- if(!ajaxContext.isAjaxRequest()){
+ if(!ajaxContext.isAjaxRequest() && !onlyPartialUpdateNeeded(component)){
super.encodeEnd(context, component);
}
}
Modified:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/SelectionRendererContributor.java
===================================================================
---
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/SelectionRendererContributor.java 2007-06-14
14:22:57 UTC (rev 1183)
+++
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/SelectionRendererContributor.java 2007-06-14
14:33:59 UTC (rev 1184)
@@ -159,8 +159,8 @@
ScriptOptions scriptOptions = new ScriptOptions(component);
scriptOptions.addOption("selectionInput", getSelectionInputName(
context, (UIScrollableGrid) component));
- scriptOptions.addOption("selectedClass",
component.getAttributes().get("selectedClass"));
- scriptOptions.addOption("activeClass",
component.getAttributes().get("activeClass"));
+ scriptOptions.addOption("selectedClass");
+ scriptOptions.addOption("activeClass");
return scriptOptions;
}
Show replies by date