|
This is slightly off topic in terms of MVC
and the GetPageContext() methodology, but I thought it might be useful anyway,
given the “validation” slant we’ve started to take. All of our forms post to themselves, and
the start of every form page is the validation routine. Validation itself
is performed by a validation object. I find keeping the handling logic in
the form page itself to be beneficial in terms of encapsulating the function of
the page itself. A typical form in our application looks like this: Someform.cfm: <cfparam name=”form.bSubmitted”
type=”numeric” default=”0”/> <!--- This is the form handler //---> <cfif form.bSubmitted> <cfset
validator = CreateObject(“component”, “cfc.Validator”)> <cfset validator.CheckComplete(form.field1,
“Name”)> <cfset
validator.CheckDate(form.field2, “Birthday”)> <cfif
validator.ErrorCount is 0> <!---
Do something with the data here //---> <cfinvoke
component=”cfc.SomethingManager” method=”AddSomething”> <cfinvokeargument
name=”name” value=”#form.field1”/> <cfinvokeargument name=”birthday” value=”#form.field2”/> </cfinvoke> <!---
Redirect to a confirmation page or something …. //---> <cflocation
url="" addtoken=”no”> <cfelse> <cfset
errorList = validator.GetErrorList()> </cfif> </cfif> <!--- This is the form itself //---> <cfparam name=”form.field1”
type=”string” default=””/> <cfparam name=”form.field2”
type=”string” default=””/> <cfparam name=”errorList”
type=”string” default=””/> <!--- Insert HTML stuff here //---> <form name=”someForm”
action="" method=”post”> <cfoutput> <cfif
errorMessage is not “”> <cfinvoke
component=”cfc.ErrorManager” method=”formatErrorsHTML”> <cfinvokeargument name=”errorList” value=”#errorList#”/> </cfinvoke> <br><br> </cfif> Name:
<input type=”text” name=”field1” value=”#form.field1#”/><br> Birthday: <input type=”text” name=”field2”
value=”#form.field2#”/> </cfoutput> <input type=”submit”
name=”dataAction” value=”Submit”/> <input
type=”hidden” name=”bSubmitted” value=”1”/> </form> The “bSubmitted” field is a
little trick that lets you know the form as submitted either by a button or by
pressing enter on a text field. We’re also obviously very into
encapsulating validation and error handling logic in CFCs. HTH, Roland From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf
Of Peter H Hi
Anthony, When I
was looking into validation using coldfusion, I found many references to using
cfinlcudes but couldn't find an example of it anywhere. The
approach used here came about simply because I couldn't think of a better
way to cleanly seperate the form itself from the validation. Theres
bound to be advantages and disadvantages to both so If you have an example of
using cfincludes for validation could you post it for me. Any body
else have views on this? Cheers,
Pete (aka lad4bear)
You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com). CFCDev is supported by New Atlanta, makers of BlueDragon http://www.newatlanta.com/products/bluedragon/index.cfm An archive of the CFCDev list is available at www.mail-archive.com/[email protected] ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com). CFCDev is supported by New Atlanta, makers of BlueDragon http://www.newatlanta.com/products/bluedragon/index.cfm An archive of the CFCDev list is available at www.mail-archive.com/[email protected] |
- Re: [CFCDev] MVC and GetPageContext.Forward() Roland Collins
- Re: [CFCDev] MVC and GetPageContext.Forward() Peter J. Farrell
- Re: [CFCDev] MVC and GetPageContext.Forward() Sean Corfield
- Re: [CFCDev] MVC and GetPageContext.Forward(... Peter J. Farrell
- Re: [CFCDev] MVC and GetPageContext.Forward(... Peter J. Farrell
- Re: [CFCDev] MVC and GetPageContext.Forw... Sean Corfield
- RE: [CFCDev] MVC and GetPageContext.Forward(... Roland Collins
- RE: [CFCDev] MVC and GetPageContext.Forward() Dawson, Michael
- RE: [CFCDev] MVC and GetPageContext.Forward() Barry Beattie
- RE: [CFCDev] MVC and GetPageContext.Forward() Roland Collins
- RE: [CFCDev] MVC and GetPageContext.Forward() Barry Beattie
