November 21, 2008

Pages


Search Site


Topics



Archives

Tweets

Entries for month: April 2008

Modifying Illudium to return the ID of an inserted row in CF8

April 28 2008 by Adam
I've been working on a project where we're using Illudium to generate some objects (beans, dao's, and gateways) to speed up our development process. We also happen to be using ColdFusion 8, which means we have access to great new features, like the primary key return value from an insert query. During a presentation on how to use Illudium and how it saves us time and effort, my team saw that I was: (1) Inserting a record, then (2) Creating a bean with all of the properties of that record except its missing id value, and then (3) searching for the matching record — so that I could use its ID in related code; and asked if there was any way to improve that. That's when it dawned on me that CF8 returns the primary key value (in most cases — Oracle just returns the "RowID" which can be used to look up the primary key), for just this reason. By the end of the day I had modified the XSLT template for the Create function in the DAO object that's packaged with Illudium to return this value instead of true or false indication of success — and with no prior knowledge or experience with XSLT. It was simple to extend my code so that it wouldn't error on earlier versions of ColdFusion (instead of the primary key value, it will return 1/-1 for success/failure), and also to account for other database types. All types documented by Adobe are supported here. Here's the updated code for create.xsl. Note that the majority of what I changed is at the end: [viewcode] src="create.xsl.txt" showsyntax=no geshi=xml scroll="yes" scrollheight="300px" link="yes" [/viewcode] And here's an example create function I made from the ART table of the CFArtGallery example datasource: [viewcode] src="fn_create.txt" showsyntax=no geshi=cfm scroll="yes" scrollheight="300px" [/viewcode] Brian Rinaldi, the creator of Illudium, offered to help me out if I got stuck, but honestly he's done such a good job architecting Illudium to be easily extended that it was a piece of cake. Thanks again for the awesome code generator, Brian!

Posted in ColdFusion | ColdFusion 8 | Databases |

Easily create/list/update/delete IIS mappings from ColdFusion

April 08 2008 by Adam
When I needed to create mappings on the fly for a client, I did some reading and wrote a quick component to make it easier. (Hat tip: Eric Jones) Once I had that done, it was obvious to me that I should extrapolate this into a full CRUD object. Enter IISVDM (IIS Virtual Directory Manager). It uses CFExecute to wrap the VBScript "iisvdir.vbs" included with IIS6.0. Obviously, then, there are some fairly steep technical requirements: CFMX6+, to use components, IIS6.0 (5.0 and earlier don't have the VBScript tool available), and appropriate permissions to run CFExecute. I should note that I've only tested with CF8, so there may be a syntax difference or two. (Please point those out if you find them!) Of course, using CFExecute and VBScript imposes a certain security risk. Please do make sure you secure access to any pages that use the component. I'm working on documentation and I've included some example scripts in the download. I'm also working on improving the return values from the create/edit/delete functions so that not only do you get a success flag (bool), but also error messages (if any), and the output of the cfexecute(s).

Posted in ColdFusion | iisvdm | My projects |