[ 
https://issues.apache.org/struts/browse/WW-1813?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_40737
 ] 

Manu Mahajan commented on WW-1813:
----------------------------------

I did a little investigation on this because I needed this to work for a 
project that I'm doing. Here's the result of my effort.

I think this has broken due to a change in Dojo upstream.

I downloaded the latest version of Dojo (0.4.2) and I went through some sample 
pages which used the tree widget. Here's what I found

Code generated by Struts 2 taglib:

<div dojoType="Tree"  publishSelectionTopic="treeNodeSelected">

This does not work.

Code in a dojo sample:

<dojo:TreeSelector widgetId="treeSelector" 
eventNames="select:nodeSelected"></dojo:TreeSelector>
<div dojoType="Tree" selector="treeSelector">

This seems to work fine.

So it seems that dojo requires a <dojo:TreeSelector> widget to capture events 
from a Tree and selector parameter in the tree tag to connect the tree and the 
selector.

To accomodate this I modified the struts code to add a new parameter to the 
<s:tree> tag called "treeSelector".

I had to modify the following files
1. template/ajax/tree.ftl (for painting selector=" " in the resulting xhtml)
2. org/apache/struts2/components/Tree.class (added property treeSelector along 
with getter and setter)
3. org/apache/struts2/views/jsp/ui/TreeTag.class (added property treeSelector 
along with getter and setter)
4. META-INF/struts-tags.tld (modified tld to accept treeSelector as a parameter 
for the tree tag)

I am posting the changed files for review.

Now my jsp looks something like this
<s:head debug="true" theme="ajax"/>
<script language="JavaScript" type="text/javascript">
dojo.addOnLoad(function() {
        dojo.event.topic.subscribe("nodeSelected",
             function(message) { dojo.debug(message.node.title+" selected"); }
        );
    });
</script>
<dojo:TreeSelector widgetId="treeSelector" 
eventNames="select:nodeSelected"></dojo:TreeSelector>
<s:tree theme = "ajax"
        rootNode="%{category}"
        childCollectionProperty="categoryList"
        nodeIdProperty="id"
        nodeTitleProperty="name"
        treeSelector="treeSelector">
</s:tree>

This is working perfectly for me but I think the solution will be complete if 
we add a new <s:treeSelector> tag to the taglib.

Hope this was useful. I'm posting something for the first time here so I do not 
know the best practices. Hope you don't mind.

> Tree Tag's treeSelectedTopic attribute doesn't works
> ----------------------------------------------------
>
>                 Key: WW-1813
>                 URL: https://issues.apache.org/struts/browse/WW-1813
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Views
>    Affects Versions: 2.0.6
>         Environment: 
> jdk1.5.0_08,apache-tomcat-5.5.20,struts2-showcase-2.0.6.war
>            Reporter: zhouyanming
>         Assigned To: Musachy Barroso
>             Fix For: 2.1.0
>
>
> in /tags/ui/treeExampleDynamic.jsp

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to