> -----Original Message-----
> From: Dave Watts [mailto:[EMAIL PROTECTED]
> Sent: Saturday, March 04, 2006 3:36 AM
> To: CF-Talk
> Subject: RE: passing cf structure to AjaxCFC?
> 
> > Hmm, that is not very convenient.  If I want the AjaxCFC to
> > access data from application and session scope, I have to
> > convert both of them to JS structures.  There must be a
> > better way for the AjaxCFC to access persistent scopes.
> 
> I'm not sure what you expect. The only way for JavaScript to be able to
> read
> values from CF variables, is if you use CF to write JavaScript statements
> that create JavaScript variables. There's no magic mechanism by which
> JavaScript can read CF values directly.

It's a subtle distinction but I really dislike the idea of CF writing
JavaScript to pass data.  Instead I feel strongly that the server and the
client should agree on a data format and pass that formatted data only.

(I'm not picking on your Dave - I think you were being more general and
focusing on the server-side of things.  It's just that your post reminded me
of why I dislike server-side client-side code generators.)

+) Passing rendered script is tightly coupled - you're using CFML to write
JavaScript.  If you want to move to, say, PHP or VB Script or Flash you'll
have rewrite both sides of the equation.  Passing just data in an agreed
upon format means that only one side needs to be rewritten/reworked.

+) Passing script means that container capable of running the script is
required on the client - in other words you can't use that data until the
script is executed someplace.  This is fine if you're going "page to page"
but breaks down when you're making intra-page calls.  You have to either
create new functions with dynamically added script blocks, dedicate a frame
to script handling or something similar.

Passing data simply means that you, well, pass data - it's passed to the
client and run through your (preexisting) handler and you have data. 

+) Using an agreed upon format for the data instead of script allows for
much simpler data validation.  Use a decent XML format and you've got access
to XSD or DTD validation immediately.  You can also, depending the format,
often validate datatypes, structural rules and other aspects of the passed
data.

+) Passing JavaScript code has the potential to create a security issue
since you're essentially getting (and running blind) dynamically generated
client-side code.  This is why the JSON camp moved to parsing the
information received instead of just executing it as a script.

Jim Davis



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:234184
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to