OO and CFForm

Maybe I'm taking this too literally... as often happens with people who have Asperger Syndrome. Anyway, the other day someone posted a comment on Dan Vega's blog about CF and OO. Here's the comment:

I will feel more comfortable calling CF OOP once it's not as tag based. Once i can create and extend some of the built in tags. When i don't have to put on my page i could simply write a component that can create an instance of the cfform and append other objects and then call a construtor method on the CFform Object to display it on the page. Cough cough ".NET"

I hope i don't get called a MS fanboy!

-- Aaron

I have mixed emotions about this comment. On the one hand, sure it might be nice to be able to extend some of CF's built in tags to improve the existing functionality? On the other hand, it's almost never really necessary... Aside from the ability to create all manner of "wrappers" for CF's native features (which I've done a lot of over the years), you can certainly use Java reflection for anything that can't be done with the native CF tags. And for that matter, the Java Loader makes doing that even easier.

But then why even bother with CFForm as an example? In my mind CFForm is kind of a quick way to get things done if a) you're new to CF and don't have a better form framework handy or b) if you're trying to do something for yourself quickly and quality isn't a concern. For that matter there are a bunch of open source or alternative form frameworks around. Aside from the form tools in the onTap framework, cfUniForm and coreForms both on RIAForge, New Zealand native and a good friend of mine, Matt Walker produces one called TerraForm.

Around the time that Flash forms and XForms were introduced in ColdFusion, Matt and I were talking about his project, wondering if the new features in ColdFusion would make TerraForm obsolete. It did not. And these days the general recommendation for Flash forms even is "use Flash" or build them in Flex. For that matter, the form tools in the onTap framework as well are still far more powerful than CFForm (and no harder to use). To be honest, the XForms implementation did inspire some new features, but it's still no replacement for the onTap framework's templating engine, (which imo frequently resembles that "code behind" concept you see in some of the newer MS technologies that Aaron mentioned).

But what tends to stick in my craw about these kinds of comments is the insinuation that the SYNTAX of the language has anything at all to do with its being or not being OO. So cfform is tag based? So what?! There are better form tools available anyway. But for that matter, even with the currently available features in ColdFusion 8, you can still implement CFForm in CFScript. Yes! Yes you can!

How does this look as a simple starting point?

   myForm = CreateObject("component","form").init();
   myForm.add("productName",true,"Product Name").add("productPrice",true,"Price");

Now I'm not going to be using this code myself, largely because I already have a set of form tools that are far more flexible already. This does however show that you can indeed even work with cfform in script. For the full code, you should see a download in the links below.

BlogCFC was created by Raymond Camden. This blog is running version 5.5.006. | Protected by Akismet | Blog with WordPress