> >On Apr 6, 2004, at 10:09 AM, Thomas Chiverton wrote:
> > In the chatdemo, what tells it to link the messages ThinArray
> > _javascript_
> >  object, to the query returned byrobject.getMessages (that I can see
> > calls a
> >  web service) ?

> On Tue, 2004-04-06 at 10:40, Dick Applebaum wrote:
>      // sets up a thin array  object named message
>      var messages = new ThinArray();
>
>     // creates a DefaultHandler that specifies the messages object as
>        //the target of the (to be issued) ws request
>     dh = new DefaultHandler("messages");
>
>     // invokes the ws passing lastid and chatroom, naming the dh handler
>        // as the recipient
>     robject.getMessages(
>         lastid,
>         xmlformat(document.chatform.room.value),
>        dh.handle
>        );
>

Those are the steps, but to add a bit so you know the skinny:

var messages = new ThinArray();

Obviously makes a thin array, you could also do ... = new Map() if you
were passing a native cf structure or ... = new List() if you were
passing a native cf array.

dh = new DefaultHandler("messages");

This is the begining to the answer. The default handlers job is to parse
the SOAP response from the web service and translate the cf data type to
the _javascript_ data type. (Note the variable name is passed in in
quotes.)

robject.getMessages(lastid, dh.handle);

This is, as you said, a web service call. The last parameter is the
handler (it is not defined in the cfc). It's a bit like passing a
pointer in C - the last variable should be the handler if you want to do
anything with the web service result.

After the call is made

alert(message);

will show you the new value.

BTW here is a quick cf-js data type mapping

CF                             JS
---------------------------
String                   String
Numeric                 parseInt(String), parseFloat(String) etc
Struct                   Map()
Array                     List()
Query                     ThinArray() and using the cfBAM.cfc on the
server

Cheers,
--
Rob <[EMAIL PROTECTED]>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to