PDA

View Full Version : Js request


pep
06-02-2004, 05:34 PM
I want to make a soap request on user's click.

so I have a class that makes th request, wich works perfectly when I use it with tags, and I initialize it like this,



var customDataset=
new xsoapdataset(canvas,
{
name:classroot.getUID()+'data',
src:'http://tomcatserver:8080/axis/services/Myservice',
path:'/All/foo/bar',
type:"http",
autorequest:"false",
onerror:"canvas.alert('Error while retriving your contact list <br/> Do you want to retry?',' ')",
ontimeout:"canvas.alert('Timeout while retriving your contact list <br/> Do you want to retry?',' ')" ,
ondata:"canvas.swap"+classroot.getUID()+"Event.sendEvent()"
}
);

where I have already created a swap<thisclassrootUID>Event to do something int his contex ondata.

var swapme=new LzDelagate(this.inside,"answer");
swapme.register(canvas,'swap'+classroot.getUID()+' Event');


unfortunately, the delegate do not work and answer() is never called.

I also tried to have the ondata event work like this:

swapme.register(customDataset,"ondata")
canvas.updateLoginEvent.sendEvent();

and this

{name: ...
...
ondata:'answer'
}




none works.

rq:
I must have a name like classroot.getUID+'data' so that each occurence of the class can have its own dataset, since to dataset cannot have the same name. But then I couldn't find a way to call the dataset from else where to launch the request method again.

antun
06-03-2004, 09:12 AM
The way to get an event sent from an attribute that you have not declared is as follows:


<canvas debug="true">

<view id="foo" />

<button>Send the onmyspecialevent event.
<method event="onclick">
foo['onmyspecialevent']['sendEvent']();
</method>
</button>

<method event="onmyspecialevent" reference="foo">
Debug.write( "onmyspecialevent event got sent" );
</method>

</canvas>


The <method="onmyspecialevent"...> syntax is probably the most robust way of debugging events. I know you need to use delegates because you're using dynamically-named events, but you can always hard-code the method syntax while coding to be sure the event is getting sent.

Now I said this was for undeclared attributes. What I mean is that if you do:


<view name="foo">
<attribute name="bar" type="number" value="0" />
</view>


... foo will send the "onbar" attribute whenever bar is changed, using foo.setAttribute('bar', newvalue). A simple assignment (foo.bar = newvalue) won't send the onbar event.

-Antun