> When I first started > doing CFCs the method I used was to validate in a CFM file and if things > passed I would then pass things into my CFC for the DB insert/update.
That sounds like what I'm considering doing now. I normally (without using a CFC at all), submit a form back to the page it's on, run CF validation, then process the query on that page, then redirect to a success page. Now, I've moved the insert query to a CFC, but was wondering how to handle the validation. I guess I could use a separate CFC for validation, and then the form variables would still be good for the insert CFC method. >From your description of your method above, it sounds like it's not necessary to have the "action" attribute of the form tag set to go to the CFC with the method attached to the URL, as described in the CF docs. I guess it would be good to use this approach, perhaps: formpage.cfm > submits back to itself > which then references a CFC for validation (which returns error messages to the form page if there are errors?)> and if all is valid, the form data is passed to the data-handling CFC for insertion. Sounds like I just need to move the validation form the form page (cfm) to a CFC. formpage.cfm validation.cfc datahandling.cfc Sound reasonable? Rick Aaron Rouse wrote: > That is entirely up to you, I thought from reading your post that you > already had validation methods written into a CFC but were thinking you had > to post the form to that CFC which was throwing a monkey wrench into your > plans. There is no right or wrong way to tackle this. When I first started > doing CFCs the method I used was to validate in a CFM file and if things > passed I would then pass things into my CFC for the DB insert/update. That > has morphed through many different methods for me over the years though. > > On Sun, Oct 19, 2008 at 9:36 PM, Rick Faircloth <[EMAIL PROTECTED]>wrote: > > >> So, use the CFC for the validation, as well? >> >> Rick >> >> Aaron Rouse wrote: >> >>> Sticking with your current method why don't you just continue to post >>> >> back >> >>> to the same page. Then in your check if it is a post back you >>> >> instantiate >> >>> your CFC and pass in the FORM structure to do data validation. That >>> >> seems >> >>> like it would be the quickest way to mesh things into your current >>> >> methods. >> >>> Now people could argue you should change the methods around completely. >>> >>> On Sun, Oct 19, 2008 at 9:09 PM, Rick Faircloth < >>> >> [EMAIL PROTECTED]>wrote: >> >>> >>>> Hi, all... >>>> >>>> I'm slowly but surely integrating CFC's into my coding. >>>> >>>> But now I'm wondering how best to modify my usual CF validation >>>> of form values with a CFC in the mix. >>>> >>>> I typically design a page with a form, have it submit back to itself, >>>> run validation on the form variables, output appropriate error messages >>>> if needed, >>>> and if everything validates, I run the query, let's say an insert query, >>>> on the >>>> same page as the form, then using cflocation to direct to a success >>>> >> page. >> >>>> But, using the CFC requires that the form's action page be the cfc >>>> >> itself, >> >>>> with the method in the URL, e.g., "properties.cfc?method=insert" >>>> >>>> Will I end up having to use session variables to make this work so I can >>>> submit the form back to the page it's on, validate and if all validates, >>>> then >>>> change the form variables to session variables and using cflocation to >>>> then go to the cfc? Can that even be done?... cflocation >>>> url="properties.cfc?method=insert" ??? >>>> >>>> Thanks for any feedback. >>>> >>>> Rick >>>> >>>> >>>> >>>> >>> >> > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314123 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

