Author: nbelaevski
Date: 2007-10-12 12:33:57 -0400 (Fri, 12 Oct 2007)
New Revision: 3349
Modified:
trunk/ui/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
Log:
http://jira.jboss.com/jira/browse/RF-980
Modified: trunk/ui/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
===================================================================
--- trunk/ui/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2007-10-12
16:17:40 UTC (rev 3348)
+++ trunk/ui/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2007-10-12
16:33:57 UTC (rev 3349)
@@ -22,10 +22,10 @@
package org.richfaces.renderkit;
import java.io.IOException;
+import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -34,6 +34,7 @@
import javax.faces.FacesException;
import javax.faces.component.NamingContainer;
import javax.faces.component.UIComponent;
+import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.el.MethodBinding;
@@ -50,7 +51,6 @@
import org.richfaces.component.state.TreeState;
import org.richfaces.component.state.TreeStateAdvisor;
import org.richfaces.model.LastElementAware;
-import org.richfaces.model.ListRowKey;
import org.richfaces.model.TreeRange;
import org.richfaces.model.TreeRowKey;
@@ -367,28 +367,6 @@
NSUtils.writeNameSpace(context, component);
}
-
- private TreeRowKey parentRowKey(TreeRowKey key) {
- //If depth is > 1, return parent row key
- int depth = key.depth();
- TreeRowKey rowKey = key;
-
- if (depth > 1) {
- List keyComps = new ArrayList(depth);
-
- for(Iterator iter = key.iterator(); iter.hasNext(); ) {
- Object next = iter.next();
- if (iter.hasNext()) {
- keyComps.add(next);
- }
- }
-
- rowKey = new ListRowKey(keyComps);
- }
-
- return rowKey;
- }
-
public void encodeAjaxChildren(FacesContext context, UIComponent component,
String path, Set ids, Set renderedAreas) throws IOException {
super.encodeAjaxChildren(context, component, path, ids, renderedAreas);
@@ -416,23 +394,7 @@
try {
Set ajaxKeys = tree.getAllAjaxKeys();
-
if (ajaxKeys != null) {
- Set aKeys = new HashSet();
-
- for(Iterator it = ajaxKeys.iterator(); it.hasNext(); ) {
- TreeRowKey treeRowKey = (TreeRowKey) it.next();
- treeRowKey = parentRowKey(treeRowKey);
-
- if (treeRowKey.depth() > 0) {
- aKeys.add(treeRowKey);
- }
- }
- ajaxKeys = aKeys;
- }
-
-
- if (ajaxKeys != null) {
List sortedKeys = new ArrayList(ajaxKeys.size());
sortedKeys.addAll(ajaxKeys);
Collections.sort(sortedKeys, treeRowKeyComparator);
@@ -440,8 +402,6 @@
TreeRowKey lastKey = null;
boolean nullRoot = false;
- System.err.println("TreeRendererBase.encodeAjaxChildren()" +
sortedKeys);
-
while (!nullRoot && ajaxKeysItr.hasNext()) {
TreeRowKey key = (TreeRowKey) ajaxKeysItr.next();
@@ -461,48 +421,35 @@
key = null;
}
-
-
-
tree.setRowKey(context, key);
-
- if (key != null) {
- int d = key.depth();
- List components = new ArrayList(d);
-
- for(Iterator iter = key.iterator(); iter.hasNext();
components.add(iter.next()));
-
- while(!tree.isRowAvailable()) {
-
- key = new ListRowKey(components.subList(0, d--));
-
- tree.setRowKey(context, key);
+
+ if (tree.isRowAvailable()) {
+ String treeClientId;
+ if (key == null) {
+ treeClientId = tree.getClientId(context);
+ } else {
+ treeClientId = tree.getNodeFacet().getClientId(context);
}
- }
-
-
- //key.getPath().
-
- //TODO: In case of deleted entry, try to update its parent
- //ey.getSubPathIterator(fromIndex)
-
-
- String treeClientId;
- if (key == null) {
- treeClientId = tree.getClientId(context);
- } else {
- treeClientId = tree.getNodeFacet().getClientId(context);
- }
- String treeChildrenId = treeClientId + NamingContainer.SEPARATOR_CHAR +
"childs";
-
- writeContent(context, tree, key);
- encodeScripts = true;
- renderedAreas.add(treeClientId);
- encodedAreaIds.add(treeClientId);
+ String treeChildrenId = treeClientId + NamingContainer.SEPARATOR_CHAR +
"childs";
+
+ writeContent(context, tree, key);
+ encodeScripts = true;
+ renderedAreas.add(treeClientId);
+ encodedAreaIds.add(treeClientId);
- renderedAreas.add(treeChildrenId);
- //encodedAreaIds.add(id+":childs");
+ renderedAreas.add(treeChildrenId);
+ //encodedAreaIds.add(id+":childs");
+ } else {
+ String cid = tree.getClientId(context);
+ String message = MessageFormat.format(
+ "Failed to re-render tree node: {0} due to model data unavailability!
" +
+ "Maybe parent node should be re-rendered instead?",
+ new Object[] { cid });
+
+ ExternalContext externalContext = context.getExternalContext();
+ externalContext.log(message);
+ }
}
//ajaxKeys.clear();
}