Author: nbelaevski
Date: 2009-04-24 13:09:52 -0400 (Fri, 24 Apr 2009)
New Revision: 13837
Modified:
trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModel.java
Log:
https://jira.jboss.org/jira/browse/RF-6924
Modified: trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModel.java
===================================================================
---
trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModel.java 2009-04-24
16:41:21 UTC (rev 13836)
+++
trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModel.java 2009-04-24
17:09:52 UTC (rev 13837)
@@ -37,8 +37,6 @@
import org.ajax4jsf.model.Range;
import org.apache.commons.collections.Predicate;
import org.apache.commons.collections.iterators.FilterIterator;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.w3c.dom.NamedNodeMap;
/**
@@ -292,25 +290,28 @@
if (treeRange == null || treeRange.processNode(argumentKey)) {
StackingTreeModel rootModel = getRoot();
- rootModel.setRowKey(context, argumentKey);
-
if (argumentKey != null) {
processElement(context, dataVisitor, argument, argumentKey, last);
}
-
- //setup key in order for nested components to initialize data models
- rootModel.setRowKey(context, argumentKey);
-
+
final ShiftingDataVisitor shiftingDataVisitor = new ShiftingDataVisitor(
new Visitor1(dataVisitor));
if (treeRange == null || treeRange.processChildren(argumentKey)) {
+
+ Object savedRowKey = rootModel.getRowKey();
+ //setup key in order for nested components to initialize data models
+ rootModel.setRowKey(context, argumentKey);
Iterator<StackingTreeModel> iterator = this.getInternalModelsIterator();
+ rootModel.setRowKey(context, savedRowKey);
+
while (iterator.hasNext()) {
final StackingTreeModel model = iterator.next();
+ savedRowKey = rootModel.getRowKey();
rootModel.setRowKey(context, argumentKey);
final ExtendedDataModel scalarModel = model.getDataModel();
+ rootModel.setRowKey(context, savedRowKey);
Argument argument2 = new Argument();
argument2.listRowKey = argumentKey;
@@ -369,69 +370,21 @@
return models.values().iterator();
}
- private static final Log keyBackupVisitorLog =
LogFactory.getLog(KeyBackupVisitor.class);
-
- private class KeyBackupVisitor implements DataVisitor, LastElementAware {
-
- private ExtendedDataModel dataModel;
-
- private Object rowKey;
-
- private DataVisitor dataVisitor;
-
- private boolean last;
-
- public KeyBackupVisitor(ExtendedDataModel dataModel,
- DataVisitor dataVisitor) {
- super();
-
- this.dataModel = dataModel;
- this.rowKey = dataModel.getRowKey();
- this.dataVisitor = dataVisitor;
- }
-
- public void process(FacesContext context, Object rowKey, Object argument)
- throws IOException {
-
- this.dataModel.setRowKey(this.rowKey);
- try {
- processElement(context, this.dataVisitor, argument, (TreeRowKey<?>) rowKey,
this.last);
- } finally {
- try {
- this.rowKey = this.dataModel.getRowKey();
- } catch (Exception e) {
- keyBackupVisitorLog.error(e.getMessage(), e);
- }
- }
- }
-
- public void resetLastElement() {
- this.last = false;
- }
-
- public void setLastElement() {
- this.last = true;
- }
-
- }
-
public void walk(FacesContext context, DataVisitor dataVisitor,
Range range, Object rowKey, Object argument,
boolean last) throws IOException {
-
StackingTreeModel rootModel = getRoot();
- KeyBackupVisitor backupVisitor = new KeyBackupVisitor(rootModel, dataVisitor);
if (rowKey != null) {
ListRowKey listRowKey = (ListRowKey) rowKey;
StackingTreeModel treeModel = rootModel.setupKey(listRowKey, context);
- treeModel.doWalk(context, backupVisitor, range, listRowKey, argument,
+ treeModel.doWalk(context, dataVisitor, range, listRowKey, argument,
last);
} else {
- doWalk(context, backupVisitor, range,
+ doWalk(context, dataVisitor, range,
(ListRowKey) rowKey, argument, last);
}
}