struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Manu Mahajan <m...@comprointertech.com>
Subject Re: unable to capture events with <s:tree>
Date Tue, 03 Apr 2007 10:00:16 GMT
Hi Dave,

If your code is working then can you please check what version of struts 
you are using because it's not working for me. I am using 
struts2-core-2.0.6.jar

I tried to investigate the problem a bit and here's the result of my effort.

I downloaded the dojo toolkit from the official website and went through 
some samples. Here is what I found

Code generated by struts2
<div dojoType="Tree"  id="contentTree" 
publishSelectionTopic="treeNodeSelected">

This is not working for me.

Code from Dojo sample
<dojo:TreeSelector widgetId="treeSelector" 
eventNames="select:nodeSelected"></dojo:TreeSelector>
<div dojoType="Tree" id="contentTree" selector="treeSelector">

This is working.

I think the <dojo:TreeSelector> is required for the tree to notify 
select events. and the selector parameter in the tree connects the tree 
and the selector.

Since the <s:tree> tag does not support the selector parameter I 
modified struts code to allow a parameter named "treeSelector" in this tag
I made changes to the following files in the struts-core jar
template/ajax/tree.ftl
org/apache/struts2/components/Tree.class
org/apache/struts2/views/jsp/ui/TreeTag.class
/META-INF/struts-tags.tld

The modified files are attached with the mail as a .zip file in case 
somebody else wants to use/review them.(I had to zip them because I 
thought it might be rude to send 400KB of attachments)

So my jsp now looks like

<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 id="contentTree"
        name="contentTree"
        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 would not be 
complete till we have a <s:treeSelector> tag in the tag lib.

Please suggest if I'm on the right track and if this could be 
incorporated in the struts code and what is the formal way to suggest 
this to the developers.

Regards
Manu  Mahajan




Dave Newton wrote:
> --- Manu Mahajan <manu@comprointertech.com> wrote:
>   
>> I'm using Tomcat 5.5
>>     
>
> The code I posted is working for me; can you post your
> current code? (Personally I won't have access to my
> code until this evening, but maybe somebody else can
> help.)
>
> d.
>
>
>
>  
> ____________________________________________________________________________________
> It's here! Your new message!  
> Get new email alerts with the free Yahoo! Toolbar.
> http://tools.search.yahoo.com/toolbar/features/mail/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>   


Mime
View raw message