Author: michiel
Date: 2009-06-08 13:08:19 +0200 (Mon, 08 Jun 2009)
New Revision: 35820

Added:
   
mmbase/trunk/applications/taglib/src/main/java/org/mmbase/bridge/jsp/taglib/containers/QueryWrapper.java
Modified:
   
mmbase/trunk/applications/taglib/src/main/java/org/mmbase/bridge/jsp/taglib/ContextReferrerTag.java
   
mmbase/trunk/applications/taglib/src/main/java/org/mmbase/bridge/jsp/taglib/containers/ListContainerTag.java
   
mmbase/trunk/applications/taglib/src/main/java/org/mmbase/bridge/jsp/taglib/containers/ListNodesContainerTag.java
   
mmbase/trunk/applications/taglib/src/main/java/org/mmbase/bridge/jsp/taglib/containers/ListRelationsContainerTag.java
   
mmbase/trunk/applications/taglib/src/main/java/org/mmbase/bridge/jsp/taglib/containers/QueryContainer.java
   
mmbase/trunk/applications/taglib/src/main/java/org/mmbase/bridge/jsp/taglib/containers/RelatedNodesContainerTag.java
   
mmbase/trunk/applications/taglib/src/main/java/org/mmbase/bridge/jsp/taglib/tree/TreeContainerTag.java
Log:
MMB-1830

Modified: 
mmbase/trunk/applications/taglib/src/main/java/org/mmbase/bridge/jsp/taglib/ContextReferrerTag.java
===================================================================
--- 
mmbase/trunk/applications/taglib/src/main/java/org/mmbase/bridge/jsp/taglib/ContextReferrerTag.java
 2009-06-08 10:39:04 UTC (rev 35819)
+++ 
mmbase/trunk/applications/taglib/src/main/java/org/mmbase/bridge/jsp/taglib/ContextReferrerTag.java
 2009-06-08 11:08:19 UTC (rev 35820)
@@ -20,6 +20,7 @@
 import org.mmbase.bridge.jsp.taglib.edit.FormTag;
 import org.mmbase.bridge.jsp.taglib.util.Attribute;
 import org.mmbase.bridge.jsp.taglib.containers.QueryContainer;
+import org.mmbase.bridge.jsp.taglib.containers.QueryWrapper;
 import org.mmbase.util.Casting;
 import org.mmbase.util.logging.*;
 import org.mmbase.framework.*;
@@ -819,15 +820,20 @@
      * Implements a getQuery for QueryContainerReferrers
      * @since MMBase-1.9.0
      */
-    protected Query getQuery(Attribute container) throws JspTagException {
+    final protected Query getQuery(Attribute container) throws JspTagException 
{
         Query query;
         if (container == null || container == Attribute.NULL) {
-            query = (Query) pageContext.getAttribute(QueryContainer.KEY, 
QueryContainer.SCOPE);
-            if (query == null) throw new JspTagException("No query found (" + 
QueryContainer.KEY + ")");
-            if (query.isUsed()) {
-                query = query.clone();
-                assert ! query.isUsed();
+            QueryWrapper<? extends Query> qcont = (QueryWrapper<? extends 
Query>) pageContext.getAttribute(QueryContainer.KEY, QueryContainer.SCOPE);
+            if (qcont == null) {
+                throw new JspTagException("No query found (" + 
QueryContainer.KEY + ")");
             }
+            if (qcont.query.isUsed()) {
+                log.debug("Found used query, cloning now");
+                qcont.cloneQuery();
+                assert ! qcont.query.isUsed();
+            }
+            log.debug("Found query " + qcont.query);
+            query = qcont.query;
         } else {
             QueryContainer c = findParentTag(QueryContainer.class, (String) 
container.getValue(this));
             query = c.getQuery();

Modified: 
mmbase/trunk/applications/taglib/src/main/java/org/mmbase/bridge/jsp/taglib/containers/ListContainerTag.java
===================================================================
--- 
mmbase/trunk/applications/taglib/src/main/java/org/mmbase/bridge/jsp/taglib/containers/ListContainerTag.java
        2009-06-08 10:39:04 UTC (rev 35819)
+++ 
mmbase/trunk/applications/taglib/src/main/java/org/mmbase/bridge/jsp/taglib/containers/ListContainerTag.java
        2009-06-08 11:08:19 UTC (rev 35820)
@@ -28,7 +28,7 @@
 
     private static final long serialVersionUID = 0L;
 
-    private Query   query        = null;
+    private QueryWrapper<Query>  query        = null;
     protected Object prevQuery   = null;
     private Attribute cachePolicy  = Attribute.NULL;
     private Attribute path       = Attribute.NULL;
@@ -70,15 +70,19 @@
 
 
     public Query getQuery() {
-        if (query.isUsed()) query = query.clone();
-        return query;
+        if (query.query.isUsed()) {
+            query.query = query.query.clone();
+        }
+        return query.query;
     }
 
     // overridden from CloudReferrer
     @Override
     public Cloud getCloudVar() throws JspTagException {
-        if (query == null) return super.getCloudVar(); // I think that this 
does not happen.
-        return query.getCloud();
+        if (query == null) {
+            return super.getCloudVar(); // I think that this does not happen.
+        }
+        return query.query.getCloud();
     }
 
 
@@ -86,13 +90,13 @@
     public int doStartTag() throws JspTagException {
         prevQuery= pageContext.getAttribute(QueryContainer.KEY, 
QueryContainer.SCOPE);
         if (getReferid() != null) {
-            query = (Query) 
getContextProvider().getContextContainer().getObject(getReferid());
+            query = new QueryWrapper<Query>((Query) 
getContextProvider().getContextContainer().getObject(getReferid()));
         } else {
             if (path == Attribute.NULL) {
                 throw new JspTagException("Path attribute is mandatory");
             }
             Cloud cloud = getCloudVar();
-            query = cloud.createQuery();
+            query = new QueryWrapper<Query>(cloud.createQuery());
         }
 
         if (getId() != null) { // write to context.
@@ -103,14 +107,14 @@
         }
 
         if (cachePolicy != Attribute.NULL) {
-            
query.setCachePolicy(CachePolicy.getPolicy(cachePolicy.getValue(this)));
+            
query.query.setCachePolicy(CachePolicy.getPolicy(cachePolicy.getValue(this)));
         }
 
-        Queries.addPath(query, (String) path.getValue(this), (String) 
searchDirs.getValue(this));
+        Queries.addPath(query.query, (String) path.getValue(this), (String) 
searchDirs.getValue(this));
 
-        Queries.addFields(query, (String) fields.getValue(this));
+        Queries.addFields(query.query, (String) fields.getValue(this));
 
-        Queries.addStartNodes(query, nodes.getString(this));
+        Queries.addStartNodes(query.query, nodes.getString(this));
         pageContext.setAttribute(QueryContainer.KEY, query, 
QueryContainer.SCOPE);
         return EVAL_BODY;
     }

Modified: 
mmbase/trunk/applications/taglib/src/main/java/org/mmbase/bridge/jsp/taglib/containers/ListNodesContainerTag.java
===================================================================
--- 
mmbase/trunk/applications/taglib/src/main/java/org/mmbase/bridge/jsp/taglib/containers/ListNodesContainerTag.java
   2009-06-08 10:39:04 UTC (rev 35819)
+++ 
mmbase/trunk/applications/taglib/src/main/java/org/mmbase/bridge/jsp/taglib/containers/ListNodesContainerTag.java
   2009-06-08 11:08:19 UTC (rev 35820)
@@ -34,7 +34,7 @@
     private static final Logger log = 
Logging.getLoggerInstance(ListNodesContainerTag.class);
     // nodereferrer because RelatedNodesContainer extension
 
-    protected NodeQuery   query       = null;
+    protected QueryWrapper<NodeQuery>   query       = null;
     protected Object      prevQuery   = null;
     protected Attribute cachePolicy  = Attribute.NULL;
     protected Attribute   path        = Attribute.NULL;
@@ -102,14 +102,18 @@
     }
 
     public NodeQuery getNodeQuery() {
-        if (query.isUsed()) query = (NodeQuery) query.clone();
-        return query;
+        if (query.query.isUsed()) {
+            query.cloneQuery();
+        }
+        return query.query;
     }
 
     // overridden from CloudReferrer.
     public Cloud getCloudVar() throws JspTagException {
-        if (query == null) return super.getCloudVar(); // I think that this 
does not happen.
-        return query.getCloud();
+        if (query == null) {
+            return super.getCloudVar(); // I think that this does not happen.
+        }
+        return query.query.getCloud();
     }
 
     /**
@@ -123,13 +127,15 @@
             return (NodeQuery) o;
         } else if (o instanceof SearchQuery) {
             SearchQuery q = (SearchQuery) o;
-            if (q.getSteps().size() != 1) throw new IllegalStateException("The 
object " + q + " has not precisely one step and can therefore not be converted 
to a NodeQuery");
-            NodeQuery query = 
getCloudVar().getNodeManager(q.getSteps().get(0).getTableName()).createQuery();
-            query.setConstraint(Queries.copyConstraint(q.getConstraint(), 
q.getSteps().get(0), query, query.getNodeStep()));
-            query.setOffset(q.getOffset());
-            query.setMaxNumber(q.getMaxNumber());
-            query.setDistinct(q.isDistinct());
-            return query;
+            if (q.getSteps().size() != 1) {
+                throw new IllegalStateException("The object " + q + " has not 
precisely one step and can therefore not be converted to a NodeQuery");
+            }
+            NodeQuery nq = 
getCloudVar().getNodeManager(q.getSteps().get(0).getTableName()).createQuery();
+            nq.setConstraint(Queries.copyConstraint(nq.getConstraint(), 
nq.getSteps().get(0), nq, nq.getNodeStep()));
+            nq.setOffset(q.getOffset());
+            nq.setMaxNumber(q.getMaxNumber());
+            nq.setDistinct(q.isDistinct());
+            return nq;
         } else {
             // will give CCE.
             return (NodeQuery) o;
@@ -141,14 +147,14 @@
         prevQuery= pageContext.getAttribute(QueryContainer.KEY, 
QueryContainer.SCOPE);
         String cloneId = clone.getString(this);
         if (! "".equals(cloneId)) {
-            query = 
toNodeQuery(getContextProvider().getContextContainer().getObject(cloneId));
+            query = new 
QueryWrapper<NodeQuery>(toNodeQuery(getContextProvider().getContextContainer().getObject(cloneId)));
             if (query == null) {
                 throw new JspTagException("No query found with id '" + cloneId 
+ "' in " + getContextProvider().getContextContainer());
             }
-            query = (NodeQuery) query.clone();
+            query.query = (NodeQuery) query.query.clone();
         } else if (getReferid() != null) {
             Object o = 
getContextProvider().getContextContainer().getObject(getReferid());
-            query = toNodeQuery(o);
+            query = new QueryWrapper<NodeQuery>(toNodeQuery(o));
 
             if (query == null) {
                 throw new JspTagException("No query found in referred id " + 
getReferid());
@@ -158,34 +164,34 @@
             }
         } else {
             if (nodeManager != Attribute.NULL) {
-                query = 
super.getCloudVar().getNodeManager(nodeManager.getString(this)).createQuery();
+                query = new 
QueryWrapper<NodeQuery>(super.getCloudVar().getNodeManager(nodeManager.getString(this)).createQuery());
                 if (path != Attribute.NULL) throw new JspTagException("Should 
specify either 'type' or 'path' attributes on listnodescontainer");
                 if (element != Attribute.NULL) throw new 
JspTagException("'element' can only be used in combination with 'path' 
attribute");
             } else {
                 if (path == Attribute.NULL) throw new JspTagException("Should 
specify either 'type' or 'path' attributes on listnodescontainer");
 
-                query = super.getCloudVar().createNodeQuery();
-                Queries.addPath(query, (String) path.getValue(this), (String) 
searchDirs.getValue(this));
+                query = new 
QueryWrapper<NodeQuery>(super.getCloudVar().createNodeQuery());
+                Queries.addPath(query.query, (String) path.getValue(this), 
(String) searchDirs.getValue(this));
 
                 if (element != Attribute.NULL) {
                     String alias = element.getString(this);
-                    Step nodeStep = query.getStep(alias);
+                    Step nodeStep = query.query.getStep(alias);
                     if (nodeStep == null) {
                         throw new JspTagException("Could not set element to '" 
+ alias + "' (no such step)");
                     }
-                    query.setNodeStep(nodeStep);
+                    query.query.setNodeStep(nodeStep);
                 } else {
                     // default to first step
-                    query.setNodeStep(query.getSteps().get(0));
+                    query.query.setNodeStep(query.query.getSteps().get(0));
                 }
             }
         }
         if (cachePolicy != Attribute.NULL) {
-            
query.setCachePolicy(CachePolicy.getPolicy(cachePolicy.getValue(this)));
+            
query.query.setCachePolicy(CachePolicy.getPolicy(cachePolicy.getValue(this)));
         }
 
         if (nodes != Attribute.NULL) {
-            Queries.addStartNodes(query, nodes.getString(this));
+            Queries.addStartNodes(query.query, nodes.getString(this));
         }
 
         if (getId() != null) { // write to context.
@@ -215,7 +221,7 @@
         pageContext.setAttribute(KEY, prevQuery, SCOPE);
         prevQuery = null;
         if (markused.getBoolean(this, false)) {
-            query.markUsed();
+            query.query.markUsed();
         }
         query = null;
         return super.doEndTag();

Modified: 
mmbase/trunk/applications/taglib/src/main/java/org/mmbase/bridge/jsp/taglib/containers/ListRelationsContainerTag.java
===================================================================
--- 
mmbase/trunk/applications/taglib/src/main/java/org/mmbase/bridge/jsp/taglib/containers/ListRelationsContainerTag.java
       2009-06-08 10:39:04 UTC (rev 35819)
+++ 
mmbase/trunk/applications/taglib/src/main/java/org/mmbase/bridge/jsp/taglib/containers/ListRelationsContainerTag.java
       2009-06-08 11:08:19 UTC (rev 35820)
@@ -27,7 +27,7 @@
  */
 public class ListRelationsContainerTag extends NodeReferrerTag implements 
NodeQueryContainer {
 
-    private NodeQuery   query        = null;
+    private QueryWrapper<NodeQuery>   query        = null;
     private Object      prevQuery    = null;
     private Attribute cachePolicy  = Attribute.NULL;
     private Attribute type       = Attribute.NULL;
@@ -60,8 +60,10 @@
         return getNodeQuery();
     }
     public NodeQuery getNodeQuery() {
-        if (query.isUsed()) query = (NodeQuery) query.clone();
-        return query;
+        if (query.query.isUsed()){
+            query.cloneQuery();
+        }
+        return query.query;
     }
 
     public Node getRelatedFromNode() throws JspTagException {
@@ -73,7 +75,7 @@
         initTag();
         prevQuery= pageContext.getAttribute(QueryContainer.KEY, 
QueryContainer.SCOPE);
         if (getReferid() != null) {
-            query = (NodeQuery) 
getContextProvider().getContextContainer().getObject(getReferid());
+            query = new QueryWrapper<NodeQuery>((NodeQuery) 
getContextProvider().getContextContainer().getObject(getReferid()));
         } else {
             Node relatedFromNode = getNode();
             Cloud cloud = relatedFromNode.getCloud();
@@ -81,11 +83,11 @@
             if (type != Attribute.NULL) {
                 nm = cloud.getNodeManager(type.getString(this));
             }
-            query        = Queries.createRelationNodesQuery(relatedFromNode, 
nm, (String) role.getValue(this), (String) searchDir.getValue(this));
+            query        = new 
QueryWrapper<NodeQuery>(Queries.createRelationNodesQuery(relatedFromNode, nm, 
(String) role.getValue(this), (String) searchDir.getValue(this)));
         }
 
         if (cachePolicy != Attribute.NULL) {
-            
query.setCachePolicy(CachePolicy.getPolicy(cachePolicy.getValue(this)));
+            
query.query.setCachePolicy(CachePolicy.getPolicy(cachePolicy.getValue(this)));
         }
         if (getId() != null) { // write to context.
             getContextProvider().getContextContainer().register(getId(), 
query);

Modified: 
mmbase/trunk/applications/taglib/src/main/java/org/mmbase/bridge/jsp/taglib/containers/QueryContainer.java
===================================================================
--- 
mmbase/trunk/applications/taglib/src/main/java/org/mmbase/bridge/jsp/taglib/containers/QueryContainer.java
  2009-06-08 10:39:04 UTC (rev 35819)
+++ 
mmbase/trunk/applications/taglib/src/main/java/org/mmbase/bridge/jsp/taglib/containers/QueryContainer.java
  2009-06-08 11:08:19 UTC (rev 35820)
@@ -33,4 +33,5 @@
     void setJspvar(String jv);
 
 
+
 }

Added: 
mmbase/trunk/applications/taglib/src/main/java/org/mmbase/bridge/jsp/taglib/containers/QueryWrapper.java
===================================================================
--- 
mmbase/trunk/applications/taglib/src/main/java/org/mmbase/bridge/jsp/taglib/containers/QueryWrapper.java
                            (rev 0)
+++ 
mmbase/trunk/applications/taglib/src/main/java/org/mmbase/bridge/jsp/taglib/containers/QueryWrapper.java
    2009-06-08 11:08:19 UTC (rev 35820)
@@ -0,0 +1,42 @@
+/*
+
+This software is OSI Certified Open Source Software.
+OSI Certified is a certification mark of the Open Source Initiative.
+
+The license (Mozilla version 1.0) can be read at the MMBase site.
+See http://www.MMBase.org/license
+
+*/
+package org.mmbase.bridge.jsp.taglib.containers;
+
+import org.mmbase.bridge.*;
+import org.mmbase.bridge.jsp.taglib.CloudProvider;
+import javax.servlet.jsp.PageContext;
+
+
+/**
+ * A simple wrapper around a query object, which is used to be put on the 
request and such.
+ * The query object can simply be cloned, without having to reput it and such.
+ * @since MMBase-1.9.2
+ * @author Michiel Meeuwissen
+ */
+public class QueryWrapper<Q extends Query> {
+    public Q query;
+    public QueryWrapper(Q q) {
+        query = q;
+    }
+    public void cloneQuery() {
+        query = (Q) query.clone();
+    }
+
+    public String toString() {
+        return query.toSql();
+    }
+    public String getSql() {
+        return query.toSql();
+    }
+    public Q getQuery() {
+        return query;
+    }
+
+}

Modified: 
mmbase/trunk/applications/taglib/src/main/java/org/mmbase/bridge/jsp/taglib/containers/RelatedNodesContainerTag.java
===================================================================
--- 
mmbase/trunk/applications/taglib/src/main/java/org/mmbase/bridge/jsp/taglib/containers/RelatedNodesContainerTag.java
        2009-06-08 10:39:04 UTC (rev 35819)
+++ 
mmbase/trunk/applications/taglib/src/main/java/org/mmbase/bridge/jsp/taglib/containers/RelatedNodesContainerTag.java
        2009-06-08 11:08:19 UTC (rev 35820)
@@ -55,10 +55,10 @@
         prevQuery= pageContext.getAttribute(QueryContainer.KEY, 
QueryContainer.SCOPE);
         String cloneId = clone.getString(this);
         if (! "".equals(cloneId)) {
-            query = (NodeQuery) 
getContextProvider().getContextContainer().getObject(cloneId);
-            query = (NodeQuery) query.clone();
+            query = (QueryWrapper<NodeQuery>) 
getContextProvider().getContextContainer().getObject(cloneId);
+            query.cloneQuery();
         } else if (getReferid() != null) {
-            query = (NodeQuery) 
getContextProvider().getContextContainer().getObject(getReferid());
+            query = (QueryWrapper<NodeQuery>) 
getContextProvider().getContextContainer().getObject(getReferid());
             if (nodeManager != Attribute.NULL || role != Attribute.NULL || 
searchDirs != Attribute.NULL || path != Attribute.NULL || element != 
Attribute.NULL) {
                 throw new JspTagException("Cannot use 'nodemanager', 'role', 
'searchdirs', 'path' or 'element' attributes together with 'referid'");
             }
@@ -70,11 +70,11 @@
                 CloudProvider cloudProvider = findCloudProvider(false);
                 cloud = cloudProvider != null ? cloudProvider.getCloudVar() : 
node.getCloud();
             }
-            query = cloud.createNodeQuery();
+            query = new QueryWrapper<NodeQuery>( cloud.createNodeQuery());
 
-            Step step = query.addStep(node.getNodeManager());
-            query.setAlias(step, node.getNodeManager().getName() + "0");
-            query.addNode(step, node);
+            Step step = query.query.addStep(node.getNodeManager());
+            query.query.setAlias(step, node.getNodeManager().getName() + "0");
+            query.query.addNode(step, node);
 
             if (nodeManager != Attribute.NULL || role != Attribute.NULL) {
 
@@ -84,15 +84,15 @@
                 } else {
                     nodeManagerName = nodeManager.getString(this);
                 }
-                RelationStep relationStep = 
query.addRelationStep(cloud.getNodeManager(nodeManagerName),
+                RelationStep relationStep = 
query.query.addRelationStep(cloud.getNodeManager(nodeManagerName),
                                                                   (String) 
role.getValue(this), (String) searchDirs.getValue(this));
-                query.setNodeStep(relationStep.getNext());
+                query.query.setNodeStep(relationStep.getNext());
                 if (path != Attribute.NULL) throw new JspTagException("Should 
specify either 'type'/'role' or 'path' attributes on relatednodescontainer. 
Path=" + path + " Nodmanager=" + nodeManager + " role=" + role);
                 if (element != Attribute.NULL) throw new 
JspTagException("'element' can only be used in combination with 'path' 
attribute. Element=" + element);
             } else {
                 if (path == Attribute.NULL) throw new JspTagException("Should 
specify either 'type' or 'path' attributes on relatednodescontainer");
 
-                List<Step> newSteps = Queries.addPath(query, (String) 
path.getValue(this), (String) searchDirs.getValue(this));
+                List<Step> newSteps = Queries.addPath(query.query, (String) 
path.getValue(this), (String) searchDirs.getValue(this));
 
                 if (element != Attribute.NULL) {
                     String alias = element.getString(this);
@@ -100,15 +100,15 @@
                     if (nodeStep == null) {
                         throw new JspTagException("Could not set element to '" 
+ alias + "' (no such (new) step)");
                     }
-                    query.setNodeStep(nodeStep);
+                    query.query.setNodeStep(nodeStep);
                 } else {
                     // default to third step (first two are the node and the 
relation)
-                    query.setNodeStep(query.getSteps().get(2));
+                    query.query.setNodeStep(query.query.getSteps().get(2));
                 }
             }
         }
         if (cachePolicy != Attribute.NULL) {
-            
query.setCachePolicy(CachePolicy.getPolicy(cachePolicy.getValue(this)));
+            
query.query.setCachePolicy(CachePolicy.getPolicy(cachePolicy.getValue(this)));
         }
 
         if (getId() != null) { // write to context.

Modified: 
mmbase/trunk/applications/taglib/src/main/java/org/mmbase/bridge/jsp/taglib/tree/TreeContainerTag.java
===================================================================
--- 
mmbase/trunk/applications/taglib/src/main/java/org/mmbase/bridge/jsp/taglib/tree/TreeContainerTag.java
      2009-06-08 10:39:04 UTC (rev 35819)
+++ 
mmbase/trunk/applications/taglib/src/main/java/org/mmbase/bridge/jsp/taglib/tree/TreeContainerTag.java
      2009-06-08 11:08:19 UTC (rev 35820)
@@ -64,36 +64,39 @@
      * Static because also used by TreeTag itself.
      */
     static NodeQuery  getStartQuery(NodeReferrerTag thisTag, Attribute 
containerAttribute, Attribute nodeAttribute) throws JspTagException {
-        NodeQuery query = null;
+        NodeQuery nq = null;
         String container = containerAttribute.getString(thisTag);
         String node      = nodeAttribute.getString(thisTag);
         if ("".equals(container) && "".equals(node)) {
             log.debug("no node attribute, no container attribute, trying 
container first");
-            Query q = (Query) 
thisTag.getPageContext().getAttribute(QueryContainer.KEY, QueryContainer.SCOPE);
-            if (q != null && (q instanceof NodeQuery)) query = (NodeQuery) q;
-            if (query == null) {
+            QueryWrapper q = (QueryWrapper) 
thisTag.getPageContext().getAttribute(QueryContainer.KEY, QueryContainer.SCOPE);
+            if (q != null && (q.query instanceof NodeQuery)) {
+                nq = (NodeQuery) q.query;
+            }
+
+            if (nq == null) {
                 NodeQueryContainer c = 
thisTag.findParentTag(NodeQueryContainer.class, null, false);
                 if (c != null) {
-                    query = c.getNodeQuery();
+                    nq = c.getNodeQuery();
                 }
             }
         } else if (! "".equals(container)) {
             log.debug("container attribute, trying container");
             NodeQueryContainer c = 
thisTag.findParentTag(NodeQueryContainer.class, container, true);
             if (c != null) {
-                query = c.getNodeQuery();
+                nq = c.getNodeQuery();
             }
         }
-        if (query == null) { // try to work as node-referrer
+        if (nq == null) { // try to work as node-referrer
             log.debug("working as node-referrer");
             Node n = thisTag.findNode();
             if (n == null) {
                 throw new TaglibException("No NodeQueryContainer nor a 
NodeProvider found in tree-tag");
             } else {
-                query = Queries.createNodeQuery(n);
+                nq = Queries.createNodeQuery(n);
             }
         }
-        return query;
+        return nq;
 
     }
 
@@ -107,26 +110,26 @@
         prevQuery= pageContext.getAttribute(QueryContainer.KEY, 
QueryContainer.SCOPE);
         // first of all, we need a 'start' query, take it from a surrounding 
'nodequery container'
 
-        query = getStartQuery(this, container, parentNodeId);
+        query = new QueryWrapper<NodeQuery>(getStartQuery(this, container, 
parentNodeId));
 
 
         if (nodeManager != Attribute.NULL) {
-            tree = new GrowingTreeList(query,
+            tree = new GrowingTreeList(query.query,
                                        maxDepth.getInt(this, 5),
-                                       
query.getCloud().getNodeManager(nodeManager.getString(this)),
+                                       
query.query.getCloud().getNodeManager(nodeManager.getString(this)),
                                        role.getString(this),
                                        searchDirs.getString(this));
 
             if (path != Attribute.NULL) throw new JspTagException("Should 
specify either 'type' or 'path' attributes on treecontainer");
         } else {
-            tree = new GrowingTreeList(query, maxDepth.getInt(this, 5));
+            tree = new GrowingTreeList(query.query, maxDepth.getInt(this, 5));
             if (path != Attribute.NULL) {
                 Queries.addPath(tree.getTemplate(), (String) 
path.getValue(this), (String) searchDirs.getValue(this));
 
                 // I'm not entirely sure why the following is necessary at all:
                 Step step = tree.getTemplate().getSteps().get(2);
-                if (query.getSteps().contains(step)) {
-                    query.setNodeStep(step);
+                if (query.query.getSteps().contains(step)) {
+                    query.query.setNodeStep(step);
                 }
             }
         }

_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to