Hi Session

I don't know if it can be done only via the struts tags but I was able to
achieve this by using some dojo javascript code in my jsp. 

Here are some code snippets that might solve your problem

<html>
<head>
.
.
.
  <s:head theme="ajax" debug="true"/>
  
  //The following extensions are required to save or restore state of a tree
  dojo.require("dojo.widget.TreeLoadingController");
  dojo.require("dojo.widget.TreeControllerExtension");
  
  dojo.addOnLoad(function() {
    dojo.lang.mixin(dojo.widget.byId('treeController'),
dojo.widget.TreeControllerExtension.prototype);
    //The following code will make sure that the saveExpandedIndices
function is called everytime a node 
    //is collapsed or expanded
    dojo.event.topic.subscribe("contentTree/expand",saveExpandedIndices);
    dojo.event.topic.subscribe("contentTree/collapse",saveExpandedIndices);

    
  });
  
  //The following function saves the state of the tree
  function saveExpandedIndices() {
    // You can save this object as tree persistent state
    indices = dojo.widget.byId('treeController').saveExpandedIndices(
      dojo.widget.byId('contentTree')
    );
    /*
    * "indices" is a javascript object which is nothing but a
multi-dimension arrays containing indices of all expanded nodes
    * I am saving this object inside a cookie. You can have a different
implementation...
    * I am using json.js to convert the object into a string
    * and then a custom function called storeCookie which stores the string
in a cookie
    */
    storeCookie("categoryTreeState",indices.toJSONString(),1);
  }
.
.
.
  //The following function restores the state of the tree. This can probably
be called body-onload
  //You will have to pass it the stored indices object though
  function restoreExpandedIndices(indices) {
      dojo.widget.byId('treeController').restoreExpandedIndices(
      dojo.widget.byId('contentTree'), indices
    );
  }
.
.
.
</head>
<body>
.
.
.
<div dojoType="TreeLoadingController" widgetId="treeController"
RPCUrl="local"></div>
<s:tree id="contentTree" 
    name="contentTree"
    theme = "ajax"
        rootNode="%{category}"
        childCollectionProperty="categoryList"
        nodeIdProperty="identifierString"
        nodeTitleProperty="name">
</s:tree>
.
.
.
</body>

Hope this helps.

Manu

-----Original Message-----
From: Session A Mwamufiya [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, September 05, 2007 10:34 PM
To: Struts Users Mailing List
Cc: Struts Users Mailing List
Subject: Re: reloading a tree at a certain level of expension

Anyone knows whether this feature has been added in yet?

> Session A Mwamufiya wrote:
>> I'm relaunching this thread in case an s:tree expert may have missed it
>> the first time around :).
>> 
>>> Is there a way that when a s:tree is reloaded, it expends to a
>>> particular level of expansion?  I presume that I will save that
>>> expansion level in my session object, but I'm not sure how to get it
>>> or set the tree to it, or if it's even possible.
> 
> 
> Looking into TreeSelector API I found a selectedNode parameter - will it
> do the job? Feel free to ask Struts2 developers to include selectedNode
> parameter into s:tree tag if is does what you expect (and if it's not
> included there yet - sometimes S2 code changes faster than its
> documentation).
> 
> Oleg
> 
> --------------------------------------------------------------------- To
> unsubscribe, e-mail: [EMAIL PROTECTED] For additional
> commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to