>> -----Original Message-----
>> From: Mike Soultanian [mailto:[EMAIL PROTECTED]
>> Sent: Wednesday, September 14, 2005 12:19 PM
>> To: CF-Talk
>> Subject: form validation utilizing database field
>> types/sizes/etc
>>
>> I was wondering if there is a way to pull column
>> information from oracle to help with form validation.
>> It would be really nice if I could set up my database
>> and then have coldfusion read the setup of my tables
>> and perform its form validation based on that.

> I'm almost positive that Isaac's done something like
> this with onTap.  You might want to bug him about it
> (because it's REALLY hard to get him to talk
> about onTap).   ;^)

Heh... I never claimed to be modest. :)

But yeah... once you've configured your db, this code will handle all
your numeric, date, string-length and required field validation for a
given table, in addition to populating the form with data either from
form submission or from the database and automating select, radio and
checkbox option lists based on foreign key relationships:

<cfmodule template="#request.tapi.xhtml()#">
  <tap:form tap:dbtable="tblProduct">
    <input type="hidden" name="productid" />

    <input type="text" name="productname" label="Name" />
    <select name="categoryid" label="Category"><option /></select>
    <input type="text" name="listprice" label="Price" />
    <textarea name="productdescription" label="Description" />

    <button type="submit">Save</button>
  </tap:form>
</cfmodule>

So the above is actually a complete form and functional as-is for both
inserts and updates against a theoretical product table. The custom
tag shown above is a wrapper for the framework's (x)html libraries.
You could get better performance by losing the flexibility of these
libraries  and rolling your own form tools. The extra overhead is the
price of loads of flexibility... they're hella flexible - much moreso
than <cfform format="xml">.

The underlying engine for getting the db meta-data is a J2EE solution
and I wrote it up in the CFDJ article Leveraging JDBC or Just Fetching
Coffee (see the sys-con url in my sig) and works with any J2EE
datasource (not just Oracle) -- though even with J2EE I've still had
to write in a couple db-specific hacks to mitigate variations in the
returned meta-data.

s. isaac dealey     954.522.6080
new epoch : isn't it time for a change?

add features without fixtures with
the onTap open source framework

http://www.fusiontap.com
http://coldfusion.sys-con.com/author/4806Dealey.htm


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:218256
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=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to