<s:url var="ajaxTest" action="AjaxInfo">
        <s:param name="uid" value="userid />
</s:url>
<a onmouseover="dojo.event.topic.publish('/request')">Show Info</a>
<sx:bind listenTopics="/request" href="%{#ajaxTest}" targets="userInfoBar"/>

Should work just fine.

The url already has userid added to it.

You can also wire the dojo request directly to the onmouseover event with some 
javascript

<s:url var="ajaxTest" action="AjaxInfo">
        <s:param name="uid" value="userid />
</s:url>
<a id="infoLink">Show Info</a>
<script>
        dojo.event.connect(dojo.byId("infoLink"),"onmouseover", function(){
                dojo.io.bind({
                        url: "<s:property value="%{#ajaxTest}" />",
                        load: function(type, data, evt){
                                        var target = dojo.byId("userInfoBar");
                                        target.innerHTML = data;
                                },
                        mimetype: "text/html"
                });
        });
</script>


In general, to get parameters through a topic, you can just add parameters to 
your handler function.

<script>
        dojo.event.topic.subscribe("/request", function(arg1,arg2,arg3){
                dojo.io.bind({
                        url: "<s:property value="%{#ajaxTest}" />?uid="+arg1,
                        load: function(type, data, evt){
                                        var target = dojo.byId("userInfoBar");
                                        target.innerHTML = data;
                                },
                        mimetype: "text/html"
                });
        });
</script>

-nick


-----Original Message-----
From: Matthew (IRQ) [mailto:[EMAIL PROTECTED]
Sent: November 22, 2007 5:12 PM
To: user@struts.apache.org
Subject: [Dojo] Pass topic parameters to action


Hi there,

I'm using Struts 2.1.1 with the new dojo plugin library and I stumpled over
the following problem for which I couldn't find any solution yet even after
hours of searching the net.

The application I'm building is a small calendar application that shows your
absences in a monthly view. What I'd like to add is some kind of info bar
that dynamically loads additional information as soon as the user hovers
over an absence.

At the moment, I'm using a parameterized url for each single absence (within
an iterator):
<div id="userInfoBar"></div>

<s:url id="ajaxTest" value="/AjaxInfo.action" >
    <s:param name="uid" value ="userid"></s:param>
</s:url>
<sx:a href="%{ajaxTest}" targets="userInfoBar">Show Info</sx:a>

This now generates lots of ajax source code and it only works when I click
on the link (but I want that it also works when I just move over the link
with the mouse). From what I've seen this is possible with the bind tag and
so I'd like to have is the following:
<s:a onmouseover="dojo.event.topic.publish('/request', userid)">Show
Info</sx:a>
<sx:bind listenTopics="/request" href="%{ajaxTest}" targets="userInfoBar"/>

But how do I pass the userid object to my action? Every help is welcomed.

Greetings,

Matthias


--
View this message in context: 
http://www.nabble.com/-Dojo--Pass-topic-parameters-to-action-tf4858767.html#a13904168
Sent from the Struts - User mailing list archive at Nabble.com.


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


********************
NOTICE OF CONFIDENTIALITY
This communication including any information transmitted with it is 
intended only for the use of the addressees and is confidential. 
If you are not an intended recipient or responsible for delivering 
the message to an intended recipient, any review, disclosure, 
conversion to hard copy, dissemination, reproduction or other use 
of any part of this communication is strictly prohibited, as is the 
taking or omitting of any action in reliance upon this communication. 
If you receive this communication in error or without authorization 
please notify us immediately by return e-mail or otherwise and 
permanently delete the entire communication from any computer, 
disk drive, or other storage medium.

If the above disclaimer is not properly readable, it can be found at 
www.td.com/legal
                                                           
AVERTISSEMENT DE CONFIDENTIALITE                   
Ce courriel, ainsi que tout renseignement ci-inclus, destiné uniquement 
aux destinataires susmentionnés,  est confidentiel.  Si vous 
n’êtes pas le destinataire prévu ou un agent responsable de la 
livraison de ce courriel, tout examen, divulgation, copie, impression, 
reproduction, distribution, ou autre utilisation d’une partie de ce 
courriel est strictement interdit de même que toute intervention ou 
abstraction à cet égard.  Si vous avez reçu ce message par erreur ou 
sans autorisation, veuillez en aviser immédiatement l’expéditeur par 
retour de courriel ou par un autre moyen et supprimer immédiatement 
cette communication entière de tout système électronique.

Si l'avis de non-responsabilité ci-dessus n'est pas lisible, vous 
pouvez le consulter à www.td.com/francais/legale

Reply via email to