I was talking about this javascript code:
dojo.io.bind({
url: "<@s.url
action="updateCharacterAvailable" namespace="/hangman/ajax" />",
load: function(type, data, event) {
var div =
dojo.byId("updateCharacterAvailableDiv");
destroyWidgets();
div.innerHTML = data;
try{
var xmlParser = new dojo.xml.Parse();
var frag =
xmlParser.parseElement(div, null, true); // 1
dojo.widget.getParser().createComponents(frag); // 2
// eval any scripts being returned
var scripts =
div.getElementsByTagName('script');
for (var i=0; i<scripts.length; i++) {
eval(scripts[i].innerHTML); // 3
}
}
catch(e){
alert('dojo error '+e);
dojo.debug("auto-build-widgets error:
"+e);
}
},
mimetype: "text/html"
});
That its going to make an asynchronous request to the action
"updateCharacterAvailable", in the namespace "/hangman/ajax", the
returned html, will use Dojo widgets, for example:
<a dojoType="struts:BindAnchor">somelink</a>
in //1 the text is parsed into an xml fragment, and in //2 Dojo is
instructed to create widgets from that fragment. In //3 javascript
sections are evaluated, if you have any.
regards
musachy
walidito wrote:
Thank you for your response,
As I'm a newbie, I haven't undersood well this part of your answer for the
"easy way":
then use the code above to make the request and process the html
returned from your action and create the widgets.
-What "code above" are you talking about ?
-Could you please be ;ore explicit about this method?
thanks
Walid
in the header of my main page. Where shall I put
Musachy Barroso-2 wrote:
walidito wrote:
Hi everybody,
I'm trying to use both the struts-2 embedded ajax tags, I mean
<s:div id="once" theme="ajax" href="/TestAction.do" ...
And the real Dojo that I have downloaded from dojo's website.
Both work in a separate way, but If I try to use them both at the same
time
it does'nt work anymore... Let me explain :
In my div tag, I redirect to an action (TestAction) that is redericted
itself to a jsp containing "real" dojo widgets, and then the events
doesn't
work.
If your html references Dojo widgets, then it is a little more
complicated, the ajax hangman example in showcase does that, here is the
javascript from hangmanAjax.ftl:
dojo.io.bind({
url: "<@s.url
action="updateCharacterAvailable" namespace="/hangman/ajax" />",
load: function(type, data, event) {
var div =
dojo.byId("updateCharacterAvailableDiv");
destroyWidgets();
div.innerHTML = data;
try{
var xmlParser = new dojo.xml.Parse();
var frag =
xmlParser.parseElement(div, null, true);
//here Dojo creates the widget from
an xml...frag
dojo.widget.getParser().createComponents(frag);
// eval any scripts being returned
var scripts =
div.getElementsByTagName('script');
for (var i=0; i<scripts.length; i++) {
eval(scripts[i].innerHTML);
}
}
catch(e){
alert('dojo error '+e);
dojo.debug("auto-build-widgets
error: "+e);
}
},
mimetype: "text/html"
});
To fix it I have tried :
- to copy a working jsp with a dojo code inside . I mean a full jsp with
a
head and body html tags, etc.
- to copy just a part of the working jsp, without head and body html
tags,
etc. this looks like this :
<script type="text/javascript" src="../dojo/dojo.js"></script>
<script type="text/javascript">
dojo.require("dojo.io.*");
dojo.require("dojo.event.*");
...
I'm just wandering if it is really possible to add "real dojo" widgets to
struts 2. And if, Yes, if somenone could help, it would be great. thanks.
The easiest way is to add all the "dojo.require" to your main page, and
then use the code above to make the request and process the html
returned from your action and create the widgets.
musachy
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]