And I will explain why.
If I make any mistakes, please, tell me.
This is my struts2 tag:
<s:a id="AncorId" 
       showLoadingText="false" 
       targets="%{'linkattachedMainDocRow' + #document.count}"
       theme="ajax" 
       href="%{#deleteDocumentAction}"
       notifyTopics="/afterDeleteLaw">
       Click me!
</s:a>
this is my JS code:
dojo.event.topic.subscribe("/afterDeleteLaw", _listeners, "test1");
var _listeners = {
        test1: function(sourceId){
                 alert("sourceId");
        }
};

Do you know what will happen? I'll tell you. test(sourceId) will be invoked
twice.
The first time sourceId = id of dojo anchor widget (AncorId)
The second time sourceId = response text (text which my action returned).

This is amazing logic:
The first time you get widget, that sends request, the second time you get
response and you don't have any opportunity to determine, which anchor
recieved this response!
 
Imagine such situation:
Inside <s:iterator> you make several <s:a> widgets, you generate unique
<s:url> for them and id attribute. 
User starts to click on widgets, they all start to send requests and receive
responses. As you know, JS in not thread safe, it means in a few seconds you
get terrible mix of widgets and responses inside subscribed topic. 

I've spent three days trying to solve it, the right solution is: do not use
dojo anchor tag, use jQuery or your own custom ajax functions.

Please, take into consideration, it's extremely hard to get on with
listeners, I was lucky and got an idea of using listeners inside
google.code. I still don't understand how it works.

As I understand, the idea of ajax tags is to simplyfy the work, not to make
it as complicated, as possible.

RFC.

-- 
View this message in context: 
http://www.nabble.com/%3Cs%3Aa-dojo-anchor%2C-seems-like-better-not-to-use-it-and-realize-it-yourself-tp18749842p18749842.html
Sent from the Struts - User mailing list archive at Nabble.com.


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

Reply via email to