Author: nbelaevski
Date: 2008-08-05 12:37:45 -0400 (Tue, 05 Aug 2008)
New Revision: 9924
Modified:
trunk/ui/tree/src/main/java/org/richfaces/component/UITree.java
Log:
https://jira.jboss.org/jira/browse/RF-3812
Modified: trunk/ui/tree/src/main/java/org/richfaces/component/UITree.java
===================================================================
--- trunk/ui/tree/src/main/java/org/richfaces/component/UITree.java 2008-08-05 16:14:55
UTC (rev 9923)
+++ trunk/ui/tree/src/main/java/org/richfaces/component/UITree.java 2008-08-05 16:37:45
UTC (rev 9924)
@@ -88,6 +88,8 @@
public abstract class UITree extends UIDataAdaptor implements
TreeListenerEventsProducer, Draggable, Dropzone, AjaxComponent {
+ private transient boolean allowCachedModel = false;
+
public static final String COMPONENT_TYPE = "org.richfaces.Tree";
public static final String COMPONENT_FAMILY = "org.richfaces.Tree";
@@ -358,6 +360,8 @@
*/
public void resetDataModel() {
+ this.allowCachedModel = false;
+
super.resetDataModel();
TreeState state = (TreeState) getComponentState();
@@ -365,8 +369,6 @@
state.transferQueuedNodes();
// re-set stopInCollapsed to handle AJAX switch type change
state.setStopInCollapsed(isStopInCollapsed());
-
- setExtendedDataModel(createDataModel(false));
}
public void walk(FacesContext faces, DataVisitor visitor)
@@ -646,14 +648,22 @@
}
}
- private ExtendedDataModel createDataModel(boolean allowCached) {
+ public void processUpdates(FacesContext faces) {
+ super.processUpdates(faces);
+ if (getExtendedDataModel() instanceof CacheableTreeDataModel) {
+ this.allowCachedModel = false;
+ setExtendedDataModel(createDataModel());
+ }
+ }
+
+ protected ExtendedDataModel createDataModel() {
Object value = this.getValue();
if (value != null) {
if (value instanceof TreeNode) {
TreeDataModel<TreeNode> treeDataModel = new ClassicTreeDataModel();
treeDataModel.setWrappedData(value);
- if (allowCached && PRESERVE_MODEL_REQUEST.equals(getPreserveModel())) {
+ if (this.allowCachedModel &&
PRESERVE_MODEL_REQUEST.equals(getPreserveModel())) {
treeDataModel = new ClassicCacheableTreeDataModel(treeDataModel);
}
@@ -662,7 +672,7 @@
TreeDataModel<javax.swing.tree.TreeNode> swingTreeDataModel = new
SwingTreeDataModel();
swingTreeDataModel.setWrappedData(value);
- if (allowCached && PRESERVE_MODEL_REQUEST.equals(getPreserveModel())) {
+ if (this.allowCachedModel &&
PRESERVE_MODEL_REQUEST.equals(getPreserveModel())) {
swingTreeDataModel = new SwingCacheableTreeDataModel(swingTreeDataModel);
}
@@ -686,17 +696,6 @@
}
}
- public void processUpdates(FacesContext faces) {
- super.processUpdates(faces);
- if (getExtendedDataModel() instanceof CacheableTreeDataModel) {
- setExtendedDataModel(createDataModel(false));
- }
- }
-
- protected ExtendedDataModel createDataModel() {
- return createDataModel(true);
- }
-
/**
* Queues expansion command for node whose row key is equal to rowKey
* parameter
@@ -942,6 +941,8 @@
public void restoreState(FacesContext faces, Object object) {
+ this.allowCachedModel = true;
+
Object[] state = (Object[]) object;
super.restoreState(faces, state[0]);