I don't think there IS any really good documentation anywhere on this.  The
best docs I've found have been on the WDDX.org online SDK.  Your best help,
I think, is to just get in there and do it; it's not that complex.  
Here's some of the essential info that you need.  CFML2JS creates a
WddxRecordset JS object.  This object consists of some methods, which I'll
get to in a minute, and some properties.  These properties are your columns
in your query, or your keys in your struct.  When making the conversion from
CFML to JS, all columnnames/keys are lowercased(don't ask me why, I don't
know).  The toplevelvariable in your tag will be the name of your JS object.
Now, in the case of a query, each column is an array of values, just they
way it is in a CF query.  So you can access values like so:
jsobjectname.columnname[row].  

If you want to be able to access your wddxrecordset by a particular
value(say, a primary key), you'll want to create a lookup array(by looping
over your recordset, and assigning pkarray[pkey]=id), then you can access
your query by pk by referencing jsobjectname.columnname[pkarray[pkey]],
which will give you the correct row, looking up by pkey.  This is excellent
for related recordsets.  

WDDX gives you a few methods, such as getRowCount(), which returns the
number of rows in the query, as well as(self-explanatory):

addColumn("columnname")
addRows(numberofrows)
setField(row,"columnname","value")
getField(row,"columnname")
dump() which dumps the data into a table.  

so, if you want to access these methods, you can access them by:

jsobjectname.methodname(parameters); like this
jsPersonObject.addColumn("Address1");
jsPersonObject.setField(1,"Address1","1400 16th St NW");
jsPersonObject.dump()

but when setting and retrieving data in/from the JS object, it's generally
easier to use 

jsPersonObject.Address1[1]="1400 16th St NW" syntax instead of
jsPersonObject.setField(1,"Address1","1400 16th St NW");

But that's my opinion.

When you want to push that back to the server, you can code something like
this:
function save(){
        myWddxSerializer=new WddxSerializer();
        
document.forms[0].wddxPacket.value=myWddxSerializer.serialize(jsPersonObject
);
        document.forms[0].submit();
}


I hope my examples do less harm than good. 


                Jason Powers
                Fig Leaf Software
                202-797-5440


-----Original Message-----
From: Mak Wing Lok [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 15, 2001 8:58 PM
To: CF-Talk
Subject: Re: CF to WDDX to JS


hi,

I'm having some question too on CFML2JS as i don't find a good documentation
that explain much on this, anyone care to tell me where can i find a good
documentation or example on this?



----- Original Message -----
From: Jason Powers <[EMAIL PROTECTED]>
To: CF-Talk <[EMAIL PROTECTED]>
Sent: Tuesday, January 16, 2001 7:34 AM
Subject: RE: CF to WDDX to JS


> You should be able to do this very simply using the CFWDDX action
"CFML2JS".
> It'll automatically create the JS object for you.  You don't need to pass
> the wddx text to the browser, you can actually pass the JS object.  If
> that's not what you need, can you give a little more detail about your
> needs?
>
> Jason Powers
> Fig Leaf Software
> 202-797-5440
>
>
> -----Original Message-----
> From: Robert Weimer [mailto:[EMAIL PROTECTED]]
> Sent: Monday, January 15, 2001 1:37 PM
> To: CF-Talk
> Subject: CF to WDDX to JS
>
>
> I have an application that serializes a CFQuery to WDDX and is then
> supposed to pass the WDDX packet to the web browser to be deserialized and
> output as JavaScript.  I am NOT a JS developer, but I play one on the
> Internet ;)
>
> I've looked throughout the WDDX site and SDK, but find little support or
> explanation on the WddxDeserializer JS Object.  Can anyone help?  How does
> this object work?  I thought I should deserialize the query and load it
> into a JS array, but I simply can't figure out how to accomplish it.
>
> Any help would be greatly appreciated.
>
> Thanks,
>
> Robert
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to