ToXML CFC - Converting data types to XML
At the Spry session at CFUNITED I talked about some code I used for my various Spry demos. This code converted queries to XML objects to use for Spry. (By the way, I'm working on some code that may make it even easier to use CFCs - no more converting to XML!) I just cleaned up my demo code a bit and cleaned it up in a nice CFC. The CFC has a listToXML, arrayToXML, queryToXML, and structToXML.
Any comments are welcome.
Comments
# Posted By Emmet
| 7/2/06 3:42 PM
# Posted By Raymond Camden
| 7/2/06 4:26 PM
# Posted By Kyle Hayes
| 7/2/06 4:29 PM
# Posted By Lola Lee Beno
| 7/2/06 4:51 PM
# Posted By emmet
| 7/2/06 5:04 PM
# Posted By Simon Horwith
| 7/2/06 5:23 PM
# Posted By Raymond Camden
| 7/2/06 6:14 PM
Thanks for the CFC example, makes working with SPRY a little more interesting. :-)
# Posted By Dan Sorensen
| 7/2/06 7:07 PM
# Posted By Simon Horwith
| 7/2/06 7:35 PM
# Posted By Raymond Camden
| 7/2/06 8:05 PM
# Posted By Simon Horwith
| 7/2/06 8:17 PM
Although - I compared the XML generated by my code using my simple query and converting the same thing to wddx. My XML was 415 characters. The WDDX was 611.
# Posted By Raymond Camden
| 7/2/06 8:23 PM
# Posted By Michael White
| 7/2/06 8:31 PM
# Posted By Simon Horwith
| 7/2/06 8:34 PM
# Posted By Raymond Camden
| 7/2/06 8:43 PM
# Posted By David A.
| 7/3/06 12:06 AM
As for the XML functions and component ideas, I can see an immediate use for the functions in the realm of configuration files. If you wanted to create dynamic xml config files, then easy to use functions would be a good way to speed that up in conjunction with the other XML functions provided with CF.
Serialized data will always be a problem for transferring data. Flex really makes this beautiful. The flash remoting will slowly become my tranfer layer du jour. You have to love raw data.
Data sushi style!!
# Posted By Teddy R Payne
| 7/3/06 9:30 AM
Loved your CFC talk (even though it turned out you are right about passing in a structure instead of individual arguments :) at CFUnited. Also, thought that your Application.CFC article in the new CF mag (can't remember the name off the top of my head) was excellent as well.
That being said......
In MY humble opinion, SPRY isn't ready for prime time. Its a nice little toy, but not overly sophisticated in what it can/will do, and its ability to allow the developer to modify the user experience is sorely lacking (other than its HTML table capabilities). I think you are pretty much dead-on-balls-accurate with pretty much every single thing out of your mouth, and I can't understand how you can be missing the mark THIS much with SPRY - I feel your so far out there on this one that is makes me feel that maybe I am wrong, simply because I agree with you so often (does that make sense??)
I understand you're not an Adobe employee - or even associate, if I understand correctly - and its not your job to sell their products. But, if you could, explain why I should use SPRY instead of AJAXcfc, for example.
Please don't misunderstand me - I am truly not attempting to rain on your SPRY parade here; I am just a touch nervous with my OWN outlook because in this instance it is completely different from your own. If you have a second, explain how SPRY competes with the 800lb gorilla in the room - in this case (again, IMHO) AJAXcfc.
I appreciate it. Your blog is an excellent resource, even if it is offbase on this one :)
nb
# Posted By Neil Bailey
| 7/3/06 8:44 PM
First off - in the future - please know it is ok to disagree with me. No need to worry about offending me. ;)
Spry is NOT released code yet. I would only use it on a production site if you were sure it would work well for you. But there is a reason Adobe calls it a Pre-release, because that is exactly what it is.
Spry right now is super good at reading AJAX data. By that I mean, it is trivial to use Spry to bind data to a remote data source. I have yet to see a system do that as easily.
It isn't just tables, but tables are used in most of the examples. I know I showed sme drop downs as well.
There -are- widgets in Spry, but they haven't been heavily documented yet. Future releses will show more information about them.
Does this make sense?
# Posted By Raymond Camden
| 7/3/06 8:55 PM
# Posted By Raymond Camden
| 7/3/06 8:55 PM
I am very new to the entire AJAX scene (we've been using it for the the last couple of weeks), but it just seems to me that with such an established, easy to use, flexible AJAX framework as AJAXcfc is already in the marketplace, it would behoove Adobe to work w/ Rob to make AJAXcfc perfect (hell, call it SPRY, call it whatever you want) - just that starting OVER seems.....silly.
But, who am I to second guess the ways and days of Adobe? I personally think that they are also WAY off the mark with Flex2, but again, what do I know.....
# Posted By Neil Bailey
| 7/3/06 8:59 PM
Flex 2: Why do you not feel it rocks? I mean, I can't think of another way of making RIAs.
# Posted By Raymond Camden
| 7/3/06 9:26 PM
Yes you can build a really cool storefront in Flex - but you wouldn't....again, the load time would come into play and your customers would be gone. You could build all kinds of really cool things in Flex - but, the bottom line is, other than geeks like myself seeing what I can do simply to see if I can do it, I truly don't see Flex (or the other products like it - read Lazslo) making much of an impact - the overhead is truly just too great. Its like this really cool concept car that everyone flocks to a car show to see, but would NEVER buy for their daily commute to work.
What else would you use to build an RIA? Well, its funny you ask that, because after we rewrote almost all of our apps in Flash Forms (curteousy of the lobbying of yours truly - MAJOR mistake), we asked ourself the exact same question. What we came up w/ is straight DHTML using an AJAX connector (AJAXcfc in our case) to connect to the backend.
If I seem to be pushing AJAXcfc hard, I don't mean to - I swear I have no connection w/ Rob Ghonda at ALL (never met him before last Wednesday). AJAXcfc just really, REALLY saved my bacon by providing a reasonable alternative to the Flash Forms. Does AJAX provide the same built in validation that the Flash Forms do? No, of course not. But the apps now load in 3-5 seconds, instead of the 45-50 seconds they were taking to load before, and to my boss, that is more important than built-in validation - which we can write routines to replicate anyway.
Sorry for the extra-long response.
nb
# Posted By Neil Bailey
| 7/3/06 10:17 PM
# Posted By Simon Horwith
| 7/3/06 10:26 PM
I have, however, built a large number of flash forms, which use remoting to connect to a CFC on the back end (ala ASFusion). And as I said in my last post, this is my only frame of reference for a real-world app (I understand that they are two different things, but I believe that Flash Forms are a sub-set of Flex, no??) And I can't see a single thing we would EVER use Flash Forms for again. They look slick, and the validation is fantastic, etc etc etc.
But I can get the same (well, a comparable, anyway) slick set of UI widgets from DOJO, and can duplicate the remoting functionality w/ AJAX. And the form loads in single digit seconds - usually under 5. When Flex can deliver an app in under 5 seconds, then maybe it has real world usage.
All of that being said, not a single person has been able to tell me what they would build in Flex for a real-world, paying project (hell, I asked Ben himself personally that exact same question at CFUnited, and he - perhaps unintentionally - completely sidestepped the question). A dashboard. Ok, I will give you that.
A storefront? Maybe, I guess..... what else? Tell me this: would you build an online employment application in Flex? How about a credit card application, or a patients' notes app for a physician or a part ordering system or a........THESE are the applications that are built in ColdFusion (at least in my experience, and I have been doing this for a fairly long time). Flex isn't ideal for ANY of them - you could force it I suppose (we DID, with the Flash Forms), but why force a square peg into a round hole WHEN YOU HAVE A ROUND PEG!!!!????
I don't mean to rain on the Flex2 parade - rather, I am looking to be convined!
# Posted By Neil Bailey
| 7/3/06 10:36 PM
Use of Flex: Ignore Flex for a minute and focus on RIA. If you need convincing that RIA's themselves make sense, I'm not sure what to say. Maybe I'm brainwashed but I thought it was obvious. Of course you wouldn't replace every web page with a RIA, but somethings really do make more sense as a RIA. Control panels, for example, make more sense as a RIA.
I think we will definitely see folks misuse Flex, just as we saw folks make bad use of Flash, and CF, and .Net, etc. Any new tool will have sites that misuse the technology.
As for speed in general, again, I know I've seen Flex2 apps load very quickly. They will never be as fast as plain jane HTML, but I think the trade offs are more than worthwhile, and save you time in the long run.
# Posted By Raymond Camden
| 7/4/06 7:22 AM
Of COURSE I see the value in RIAs - the value is immeasurable in terms of web applications.
My question is this: why not write RIA applications with a DHTML front end, a CFC handling the database (and whatever else needs handling) and an AJAX connector between the two?
This will give you - in my mind, at least - almost the exact same capabilities (minus that slick Flash look of course), but with a load time that is about 40 seconds faster.
My main question is not what you wouldn't use Flex for, but specifically what you WOULD use it for? I can think of a dozen RIAs off the top of my head without even really trying, but not a single one of them is a good fit for a Flex application - again, this is all my opinion. I am actually sincerely seeking to be convinced otherwise!
# Posted By Neil Bailey
| 7/4/06 11:44 AM
# Posted By Raymond Camden
| 7/5/06 8:34 AM
I still haven't been able to get a single real-world example - other than a dashboard - that is a perfect fit for Flex.
# Posted By Neil Bailey
| 7/5/06 9:52 AM
# Posted By Raymond Camden
| 7/5/06 10:01 AM
Unfortunately, my only frame of reference for real-world applications is Flash Forms. And Ray, they truly killed us - to the point that people almost lost their jobs@
If real-world, functionality-heavy Flex2 apps are truly loading in 10 seconds, then I would agree that Flex2 is the RIA platform of TODAY, let alone tomorrow. I just haven't seen it.
As for HTML load time: we have converted most (not all, yet) of our Flash Forms to HTML/AJAX, and the avg load time is about 5 seconds. If equivalent Flex apps were to load in...hell, 15 seconds, I would be happy (we're talking 6 grids, 5 tabs - each with..maybe 20 fields each; the grids need to be displayed dynamically, depending on the selected criteria, as do certain of the tabs).
Also, I haven't YET heard of a single real-world application - again, I agree with the dashboard concept, regardless of the loadtime; so other than a dashbaord - that YOU feel Flex2 is IDEAL for.
Thanks for listening to (reading??) my rambling.
# Posted By Neil Bailey
| 7/5/06 10:13 AM
# Posted By Kyle Hayes
| 7/5/06 1:32 PM
Sure, I could write a Word Processor, but I have MS Office. Sure I could write a... hell, I dunno, anything, but the point is: WHY!
My main point is this: I think flex2 will be a cool little toy. Again, it will be like the concept cars that the car companies put out: they generate a lot of discussion, and the whole world thinks that they're cool, but NOBODY DRIVES THEM TO WORK!!!
I want my apps to look as slick and as cool as the next guy, but.... I, personally, just don't see much of a marketplace for this. After the initial "cool" factor dies down, I think this will be the next Spectra.
And still, nobody has been able to tell me what they would use flex2 to build. Its like the emperor's new clothes - everyone says Flex2 is the future of the internet because everyone ELSE is saying that flex2 is the future of the internet.
Or, maybe I am just missing the point...if so, tell me what you would build in flex2. Not a general category of applications like "desktop apps for the browser", but specifically, what? A dashboard. Ok. What else?
# Posted By Neil Bailey
| 7/5/06 1:41 PM
tony was a dumb ass for not seeing it... right :)
ok, you can apologize at ANY time ray!
later holmes.
# Posted By Gary
| 7/14/06 4:33 PM
# Posted By Raymond Camden
| 7/15/06 4:21 PM
# Posted By Paul Baylis
| 4/26/08 7:43 AM
# Posted By Paul Baylis
| 4/26/08 7:45 AM
# Posted By Raymond Camden
| 4/26/08 9:48 AM
<cfinvoke component="data" method="getData" returnVariable="data">
and using it in Spry, e.g. as follows:
<script type="text/javascript">
var mydata = new Spry.Data.XMLDataSet("data.cfc?method=getdataXML","/people/person");
mydata.setColumnType("age","numeric");
</script>
Just thought it might have been included with the download files. As a newby, I was just wanting to see how it all fits together.
# Posted By Paul Baylis
| 4/27/08 3:16 AM
# Posted By Raymond Camden
| 4/27/08 7:50 AM
# Posted By Mamtha
| 10/16/08 12:48 PM
# Posted By Raymond Camden
| 10/16/08 3:24 PM
You can read about it and download it here: http://www.leeftpaulnog.nl/2009/02/toxml-function-...
Hope it's of use to someone; it helped me anywayz ;-)
# Posted By Paul Klinkenberg
| 2/25/09 11:38 AM
