Sorry, I got a note saying my post was "too long". I apologize, but I was
pasting code...I broke it into two pieces and thought I'd post both parts,
so you (you all) could see it.

>From previous...

It works...I want it to be good and robust though...so, looking it over, is
there anything I can do to make it better? What follows is good ol' generic
code to insert from a form, but using a CFC to do so. So, look over the
Processing and the CFC and let me know what you think. Of particular
importance to me, is how I pull out the datasource name or pass the
datasource name in to make it the same for the whole instance of the CFC
(local to all the functions in the CFC once its instantiated).

So please to be telling me what I did wrong, and what you'd change?
Appreciate it, this is my first stab at it, using CFCs and I want to make
sure it's a good "best practices" example. Like, did I hit all the tag
attributes correctly? Etc...

Jeff

*****
FROM THE SUBMITTING FORM PAGE
*****

<cfif IsDefined("FORM.InsertHostingProvider") AND FORM.InsertHostingProvider
EQ "True">
  <cfset variables.InsertInstance = structNew()>
  <cfif IsDefined("FORM.Name") AND #FORM.Name# NEQ "">
   <cfset variables.InsertInstance.Name = FORM.Name>
  </cfif>
  <cfif IsDefined("FORM.Address") AND #FORM.Address# NEQ "">
   <cfset variables.InsertInstance.Address = FORM.Address>
  </cfif>
  <cfif IsDefined("FORM.City") AND #FORM.City# NEQ "">
   <cfset variables.InsertInstance.City = FORM.City>
  </cfif>
  <cfif IsDefined("FORM.State") AND #FORM.State# NEQ "">
   <cfset variables.InsertInstance.State = FORM.State>
  </cfif>
  <cfif IsDefined("FORM.Zip") AND #FORM.Zip# NEQ "">
   <cfset variables.InsertInstance.Zip = FORM.Zip>
  </cfif>
  <cfif IsDefined("FORM.Phone") AND #FORM.Phone# NEQ "">
   <cfset variables.InsertInstance.Phone = FORM.Phone>
  </cfif>
  <cfif IsDefined("FORM.Fax") AND #FORM.Fax# NEQ "">
   <cfset variables.InsertInstance.Fax = FORM.Fax>
  </cfif>
  <cfif IsDefined("FORM.Website") AND #FORM.Website# NEQ "">
   <cfset variables.InsertInstance.Website = FORM.Website>
  </cfif>
  <cfif IsDefined("FORM.ContactFirstName") AND #FORM.ContactFirstName# NEQ
"">
   <cfset variables.InsertInstance.ContactFirstName = FORM.ContactFirstName>
  </cfif>
  <cfif IsDefined("FORM.ContactLastName") AND #FORM.ContactLastName# NEQ "">
   <cfset variables.InsertInstance.ContactLastName = FORM.ContactLastName>
  </cfif>

  <cfset variables.insertObject = createObject("component",
"MySite.maint").insertHostingProvider(variables.InsertInstance)>

<!---  <cflocation url="" --->
<cfdump var="#variables#">
</cfif>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to