You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Session A Mwamufiya <sm...@andrew.cmu.edu> on 2007/08/06 19:29:29 UTC

specifying a struts 2 action in the url field of a dojo function

Hello,

I've been trying to get the tree view code from the showcase to work for many days now, and I'm literally stuck.  I use logging to determine whether action methods are called or not, and the following script never gets to the dynamicTreeSelectAction action:

<script>
    function treeNodeSelected(nodeId) {
        dojo.io.bind({
            url: "<s:url value='dynamicTreeSelectAction.action' />?nodeId="+nodeId,
            load: function(type, data, evt) {
                var displayDiv = dojo.byId("displayId");
                displayDiv.innerHTML = data;
            },
            mimeType: "text/html"
        });
    };

    dojo.event.topic.subscribe("treeSelected", this, "treeNodeSelected");
</script>

Is it written properly in the showcase example (which doesn't work btw)? or is there another way of calling an action as part of the url?

Thanks for any help,
Session


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: specifying a struts 2 action in the url field of a dojo function

Posted by Session A Mwamufiya <sm...@andrew.cmu.edu>.
Great, it works!!  You were an immense help, I thank you.

Best,
Session

> Yes, it seems like the Dojo api changed at some point (the example was 
> fixed for 2.1) and now dojo passes the widget object for the node that was
> selected, instead of the id string. Just use the "id" property in the
> object that is passed to the function.
> 
> musachy
> 
> 
> On 8/6/07, Session A Mwamufiya <sm...@andrew.cmu.edu> wrote:
>> Hi,
>> 
>> Thanks so much for the breakthrough.  I implemented the change, and now
>> the action gets called.  The only thing now is that I don't seem to be
>> getting an actual nodeId in the display <div> element.  I just get an
>> object; here's what comes out in the display: Id:[object Object] Name:
>> 
>> It seems that the nodeId parameter isn't properly passed from the event
>> to the handler.  Does that object need to be set somewhere, or in my
>> tree somehow?
>> 
>> Here's the tree code <dojo:TreeSelector widgetId="treeSelector"
>> eventNames="select:nodeSelected"></dojo:TreeSelector> <s:tree 
>> theme="ajax" rootNode="%{treeRootNode}" 
>> childCollectionProperty="childrenNodes" nodeIdProperty="id" 
>> nodeTitleProperty="name" treeSelector="treeSelector"> </s:tree>
>> 
>> I'm almost there, if only I can figure this one out, I'm golden.  Once
>> again, thanks so much for the help.
>> 
>> Thanks, Session
>> 
>> 
>>> That didn't come out right, "this" in the global scope points to the 
>>> Window object.
>>> 
>>> musachy
>>> 
>>> On 8/6/07, Musachy Barroso <mu...@gmail.com> wrote:
>>>> That code is wrong as this line:
>>>> 
>>>> dojo.event.topic.subscribe("treeSelected", this,
>>>> "treeNodeSelected");
>>>> 
>>>> is using "this" which is not gonna be defined there. Try:
>>>> 
>>>> 
>>>> dojo.event.topic.subscribe("treeSelected", function 
>>>> treeNodeSelected(nodeId) { dojo.io.bind({ url: "<s:url 
>>>> value='dynamicTreeSelectAction.action' />?nodeId="+nodeId, load: 
>>>> function(type, data, evt) { var displayDiv =
>>>> dojo.byId("displayId"); displayDiv.innerHTML = data; }, mimeType:
>>>> "text/html" }); } );
>>>> 
>>>> musachy
>>>> 
>>>> On 8/6/07, Session A Mwamufiya <sm...@andrew.cmu.edu> wrote:
>>>>> Hello,
>>>>> 
>>>>> I've been trying to get the tree view code from the showcase to
>>>>> work for many days now, and I'm literally stuck.  I use logging to
>>>>>  determine whether action methods are called or not, and the
>>>>> following script never gets to the dynamicTreeSelectAction action:
>>>>> 
>>>>> 
>>>>> <script> function treeNodeSelected(nodeId) { dojo.io.bind({ url:
>>>>> "<s:url value='dynamicTreeSelectAction.action' />?nodeId="+nodeId,
>>>>> load: function(type, data, evt) { var displayDiv =
>>>>> dojo.byId("displayId"); displayDiv.innerHTML = data; }, mimeType:
>>>>> "text/html" }); };
>>>>> 
>>>>> dojo.event.topic.subscribe("treeSelected", this,
>>>>> "treeNodeSelected"); </script>
>>>>> 
>>>>> Is it written properly in the showcase example (which doesn't
>>>>> work btw)? or is there another way of calling an action as part of
>>>>> the url?
>>>>> 
>>>>> Thanks for any help, Session
>>>>> 
>>>>> 
>>>>> -----------------------------------------------------------------
>>>>> ---- To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>> 
>>>>> 
>>>> 
>>>> 
>>>> -- "Hey you! Would you help me to carry the stone?" Pink Floyd
>>>> 
>>> 
>>> 
>>> -- "Hey you! Would you help me to carry the stone?" Pink Floyd
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org For
>>> additional commands, e-mail: user-help@struts.apache.org
>>> 
>>> 
>>> 
>> 
>> 
>> --------------------------------------------------------------------- To
>> unsubscribe, e-mail: user-unsubscribe@struts.apache.org For additional
>> commands, e-mail: user-help@struts.apache.org
>> 
>> 
> 
> 
> -- "Hey you! Would you help me to carry the stone?" Pink Floyd
> 
> --------------------------------------------------------------------- To
> unsubscribe, e-mail: user-unsubscribe@struts.apache.org For additional
> commands, e-mail: user-help@struts.apache.org
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: specifying a struts 2 action in the url field of a dojo function

Posted by Musachy Barroso <mu...@gmail.com>.
Yes, it seems like the Dojo api changed at some point (the example was
fixed for 2.1) and now dojo passes the widget object for the node that
was selected, instead of the id string. Just use the "id" property in
the object that is passed to the function.

musachy


On 8/6/07, Session A Mwamufiya <sm...@andrew.cmu.edu> wrote:
> Hi,
>
> Thanks so much for the breakthrough.  I implemented the change, and now the action gets called.  The only thing now is that I don't seem to be getting an actual nodeId in the display <div> element.  I just get an object; here's what comes out in the display:
> Id:[object Object]
> Name:
>
> It seems that the nodeId parameter isn't properly passed from the event to the handler.  Does that object need to be set somewhere, or in my tree somehow?
>
> Here's the tree code
> <dojo:TreeSelector widgetId="treeSelector" eventNames="select:nodeSelected"></dojo:TreeSelector>
> <s:tree
>         theme="ajax"
>         rootNode="%{treeRootNode}"
>         childCollectionProperty="childrenNodes"
>         nodeIdProperty="id"
>         nodeTitleProperty="name"
>         treeSelector="treeSelector">
> </s:tree>
>
> I'm almost there, if only I can figure this one out, I'm golden.  Once again, thanks so much for the help.
>
> Thanks,
> Session
>
>
> > That didn't come out right, "this" in the global scope points to the
> > Window object.
> >
> > musachy
> >
> > On 8/6/07, Musachy Barroso <mu...@gmail.com> wrote:
> >> That code is wrong as this line:
> >>
> >> dojo.event.topic.subscribe("treeSelected", this, "treeNodeSelected");
> >>
> >> is using "this" which is not gonna be defined there. Try:
> >>
> >>
> >> dojo.event.topic.subscribe("treeSelected", function
> >> treeNodeSelected(nodeId) { dojo.io.bind({ url: "<s:url
> >> value='dynamicTreeSelectAction.action' />?nodeId="+nodeId, load:
> >> function(type, data, evt) { var displayDiv = dojo.byId("displayId");
> >> displayDiv.innerHTML = data; }, mimeType: "text/html" }); } );
> >>
> >> musachy
> >>
> >> On 8/6/07, Session A Mwamufiya <sm...@andrew.cmu.edu> wrote:
> >>> Hello,
> >>>
> >>> I've been trying to get the tree view code from the showcase to work
> >>> for many days now, and I'm literally stuck.  I use logging to
> >>> determine whether action methods are called or not, and the following
> >>> script never gets to the dynamicTreeSelectAction action:
> >>>
> >>> <script> function treeNodeSelected(nodeId) { dojo.io.bind({ url: "<s:url
> >>> value='dynamicTreeSelectAction.action' />?nodeId="+nodeId, load:
> >>> function(type, data, evt) { var displayDiv = dojo.byId("displayId");
> >>> displayDiv.innerHTML = data; }, mimeType: "text/html" }); };
> >>>
> >>> dojo.event.topic.subscribe("treeSelected", this, "treeNodeSelected");
> >>>  </script>
> >>>
> >>> Is it written properly in the showcase example (which doesn't work
> >>> btw)? or is there another way of calling an action as part of the
> >>> url?
> >>>
> >>> Thanks for any help, Session
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>>  To unsubscribe, e-mail: user-unsubscribe@struts.apache.org For
> >>> additional commands, e-mail: user-help@struts.apache.org
> >>>
> >>>
> >>
> >>
> >> -- "Hey you! Would you help me to carry the stone?" Pink Floyd
> >>
> >
> >
> > -- "Hey you! Would you help me to carry the stone?" Pink Floyd
> >
> > --------------------------------------------------------------------- To
> > unsubscribe, e-mail: user-unsubscribe@struts.apache.org For additional
> > commands, e-mail: user-help@struts.apache.org
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: specifying a struts 2 action in the url field of a dojo function

Posted by Session A Mwamufiya <sm...@andrew.cmu.edu>.
Hi,

Thanks so much for the breakthrough.  I implemented the change, and now the action gets called.  The only thing now is that I don't seem to be getting an actual nodeId in the display <div> element.  I just get an object; here's what comes out in the display:
Id:[object Object]
Name:

It seems that the nodeId parameter isn't properly passed from the event to the handler.  Does that object need to be set somewhere, or in my tree somehow?

Here's the tree code
<dojo:TreeSelector widgetId="treeSelector" eventNames="select:nodeSelected"></dojo:TreeSelector>
<s:tree
	theme="ajax"
	rootNode="%{treeRootNode}"
	childCollectionProperty="childrenNodes"
	nodeIdProperty="id"
	nodeTitleProperty="name"
	treeSelector="treeSelector">
</s:tree>

I'm almost there, if only I can figure this one out, I'm golden.  Once again, thanks so much for the help.

Thanks,
Session


> That didn't come out right, "this" in the global scope points to the 
> Window object.
> 
> musachy
> 
> On 8/6/07, Musachy Barroso <mu...@gmail.com> wrote:
>> That code is wrong as this line:
>> 
>> dojo.event.topic.subscribe("treeSelected", this, "treeNodeSelected");
>> 
>> is using "this" which is not gonna be defined there. Try:
>> 
>> 
>> dojo.event.topic.subscribe("treeSelected", function
>> treeNodeSelected(nodeId) { dojo.io.bind({ url: "<s:url
>> value='dynamicTreeSelectAction.action' />?nodeId="+nodeId, load:
>> function(type, data, evt) { var displayDiv = dojo.byId("displayId"); 
>> displayDiv.innerHTML = data; }, mimeType: "text/html" }); } );
>> 
>> musachy
>> 
>> On 8/6/07, Session A Mwamufiya <sm...@andrew.cmu.edu> wrote:
>>> Hello,
>>> 
>>> I've been trying to get the tree view code from the showcase to work
>>> for many days now, and I'm literally stuck.  I use logging to
>>> determine whether action methods are called or not, and the following
>>> script never gets to the dynamicTreeSelectAction action:
>>> 
>>> <script> function treeNodeSelected(nodeId) { dojo.io.bind({ url: "<s:url
>>> value='dynamicTreeSelectAction.action' />?nodeId="+nodeId, load:
>>> function(type, data, evt) { var displayDiv = dojo.byId("displayId"); 
>>> displayDiv.innerHTML = data; }, mimeType: "text/html" }); };
>>> 
>>> dojo.event.topic.subscribe("treeSelected", this, "treeNodeSelected");
>>>  </script>
>>> 
>>> Is it written properly in the showcase example (which doesn't work
>>> btw)? or is there another way of calling an action as part of the
>>> url?
>>> 
>>> Thanks for any help, Session
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>>  To unsubscribe, e-mail: user-unsubscribe@struts.apache.org For
>>> additional commands, e-mail: user-help@struts.apache.org
>>> 
>>> 
>> 
>> 
>> -- "Hey you! Would you help me to carry the stone?" Pink Floyd
>> 
> 
> 
> -- "Hey you! Would you help me to carry the stone?" Pink Floyd
> 
> --------------------------------------------------------------------- To
> unsubscribe, e-mail: user-unsubscribe@struts.apache.org For additional
> commands, e-mail: user-help@struts.apache.org
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: specifying a struts 2 action in the url field of a dojo function

Posted by Musachy Barroso <mu...@gmail.com>.
That didn't come out right, "this" in the global scope points to the
Window object.

musachy

On 8/6/07, Musachy Barroso <mu...@gmail.com> wrote:
> That code is wrong as this line:
>
>  dojo.event.topic.subscribe("treeSelected", this, "treeNodeSelected");
>
> is using "this" which is not gonna be defined there. Try:
>
>
>  dojo.event.topic.subscribe("treeSelected",
>   function treeNodeSelected(nodeId) {
>        dojo.io.bind({
>            url: "<s:url value='dynamicTreeSelectAction.action'
> />?nodeId="+nodeId,
>            load: function(type, data, evt) {
>                var displayDiv = dojo.byId("displayId");
>                displayDiv.innerHTML = data;
>            },
>            mimeType: "text/html"
>        });
>    }
> );
>
> musachy
>
> On 8/6/07, Session A Mwamufiya <sm...@andrew.cmu.edu> wrote:
> > Hello,
> >
> > I've been trying to get the tree view code from the showcase to work for many days now, and I'm literally stuck.  I use logging to determine whether action methods are called or not, and the following script never gets to the dynamicTreeSelectAction action:
> >
> > <script>
> >     function treeNodeSelected(nodeId) {
> >         dojo.io.bind({
> >             url: "<s:url value='dynamicTreeSelectAction.action' />?nodeId="+nodeId,
> >             load: function(type, data, evt) {
> >                 var displayDiv = dojo.byId("displayId");
> >                 displayDiv.innerHTML = data;
> >             },
> >             mimeType: "text/html"
> >         });
> >     };
> >
> >     dojo.event.topic.subscribe("treeSelected", this, "treeNodeSelected");
> > </script>
> >
> > Is it written properly in the showcase example (which doesn't work btw)? or is there another way of calling an action as part of the url?
> >
> > Thanks for any help,
> > Session
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
>
> --
> "Hey you! Would you help me to carry the stone?" Pink Floyd
>


-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: specifying a struts 2 action in the url field of a dojo function

Posted by Musachy Barroso <mu...@gmail.com>.
That code is wrong as this line:

 dojo.event.topic.subscribe("treeSelected", this, "treeNodeSelected");

is using "this" which is not gonna be defined there. Try:


 dojo.event.topic.subscribe("treeSelected",
  function treeNodeSelected(nodeId) {
       dojo.io.bind({
           url: "<s:url value='dynamicTreeSelectAction.action'
/>?nodeId="+nodeId,
           load: function(type, data, evt) {
               var displayDiv = dojo.byId("displayId");
               displayDiv.innerHTML = data;
           },
           mimeType: "text/html"
       });
   }
);

musachy

On 8/6/07, Session A Mwamufiya <sm...@andrew.cmu.edu> wrote:
> Hello,
>
> I've been trying to get the tree view code from the showcase to work for many days now, and I'm literally stuck.  I use logging to determine whether action methods are called or not, and the following script never gets to the dynamicTreeSelectAction action:
>
> <script>
>     function treeNodeSelected(nodeId) {
>         dojo.io.bind({
>             url: "<s:url value='dynamicTreeSelectAction.action' />?nodeId="+nodeId,
>             load: function(type, data, evt) {
>                 var displayDiv = dojo.byId("displayId");
>                 displayDiv.innerHTML = data;
>             },
>             mimeType: "text/html"
>         });
>     };
>
>     dojo.event.topic.subscribe("treeSelected", this, "treeNodeSelected");
> </script>
>
> Is it written properly in the showcase example (which doesn't work btw)? or is there another way of calling an action as part of the url?
>
> Thanks for any help,
> Session
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org