Thanks Teddy.
Yeah, I purchased *Object Oriented ColdFusion* and a raft of other books &
videos for myself for Christmas.
It's on short list now.



On Fri, Dec 31, 2010 at 12:45 PM, Teddy R. Payne <teddyrpa...@gmail.com>wrote:

> Phillip,
> In your example, I see that you initialize your Answer object with a
> local structure from onApplicationStart.  If this is the only place
> where your DSN is referenced or passed around, it seems it would work
> pretty straight forward as intended.
>
> If you wanted to use your DSN information elsewhere, you may want to
> create an object in your application scope that would hold your DSN
> information and then pass that around.  This can definitely be
> considered a starting point of creating configuration objects and
> could lead you into dependency injection ideas (e.g. ColdSpring).
>
> A good website I found on this idea is here:
>
> http://www.objectorientedcoldfusion.org/wiki/Gateway
>
> In the above website, they start a nice way to reference a gateway
> (data access queries mostly) and pass a data source object into the
> component.  Now, you can adapt the form save to have a similar
> approach without much effort.
>
> Just an idea and not a criticism or saying your approach is incorrect.
>  Just something I have been looking into for some ideas as I move away
> from DAO(s) in favor of Gateways for smaller solution sets that do not
> have external interfaces.
>
>
> Teddy R. Payne, ACCFD
> Google Talk - teddyrpa...@gmail.com
>
>
>
>
> On Fri, Dec 31, 2010 at 12:10 PM, Phillip Senn <phillips...@gmail.com>
> wrote:
> > In recent days, I've actually experimented and had success just passing
> in a
> > structure and using it in the component.
> > I actually call the argument that was passed into function "form".
> > Not to be confused with the form structure, but it's name was inspired by
> me
> > passing in the form structure from the calling page.
> > I said to myself, "self, why don't you just keep it the same name?"
> >
> > Answer.cfc:
> > <cfcomponent>
> > <cffunction name="Init">
> > <cfargument name="form">
> > <cfset Variables.Datasource = form.Datasource>
> > <cfset Variables.Username = form.Username>
> > <cfset Variables.Password = form.Password>
> > <cfreturn this>
> > </cffunction>
> > <cffunction name="Save">
> > <cfargument name="form">
> > <cfquery datasource="#Variables.Datasource#"
> username="#Variables.Username#"
> > password="#Variables.Password#">
> > Update myTable SET
> > myAnswer = <cfqueryparam cfsqltype="cf_sql_integer"
> value="#form.myAnswer#">
> > WHERE AnswerID = <cfqueryparam cfsqltype="cf_sql_integer"
> > value="#form.AnswerID#">
> > </cfquery>
> > </cffunction>
> > Application.cfc:
> > <cffunction name="onApplicationStart" output="False" returntype="void">
> > <cfset var local = {}>
> > <cfset local.Datasource = "myServer">
> > <cfset local.UserName = "xxx">
> > <cfset local.Password = "xxx">
> > <cfset Application.Answer =
> > CreateObject("component","com.Answer").Init(local)>
> > </cffunction>
> > Finally, on the page itself:
> > Answer.cfm
> > <cfif StructKeyExists(form,"UpdateAnswer")>
> > <cfset Application.Answer.Save(form)>
> > </cfif>
> > <cfform>
> > <input name="myAnswer">
> > <input name="AnswerID" type="hidden">
> > <input name="UpdateAnswer" type="submit" value="Update">
> > </cfform>
> >
> > On Thu, Dec 30, 2010 at 5:05 PM, Charlie Stell <charlie.st...@gmail.com>
> > wrote:
> >>
> >> Say you have the following abc.cfc :
> >> <cfcomponent>
> >> ...
> >>  <cffunction name="x">
> >>   <cfargument name="a">
> >>   <cfargument name="b">
> >>   <cfargument name="c">
> >>   <cfargument name="d">
> >> ...
> >> </cffunction>
> >> ...
> >> </component>
> >>
> >> Ang you going to invoke in from somewhere else. Depending on the
> >> situation, sometimes you'll have different combinations of the arguments
> >> (for example maybe your using the same function to run some user search
> for
> >> both a simple and advanced mode) . Using argumentCollection, you can
> avoid
> >> the hassle of having to pass in blank values so that the positioning is
> >> right - you would doing something like:
> >> <cfset i = structnew()>
> >> <cfif simple_case>
> >>  <cfset i["a"] = form_imput_A>
> >> <cfelse>
> >>  <cfset i["b"] = form_imput_B>
> >>  <cfset i["c"] = form_imput_C>
> >>  <cfset i["d"] = form_imput_D>
> >> </cfif>
> >> <cfset results =
> >> createobject("component","path_to_cfc.abc").x(argumentCollection=i)>
> >> That certainly isn't an in depth example... but hope it helps some!
> >>
> >> On Thu, Dec 30, 2010 at 4:52 PM, Matthew Nicholson
> >> <matthew.nichol...@soltech.net> wrote:
> >>>
> >>> Afternoon All!
> >>>
> >>>
> >>>
> >>> Here’s my basic dilemma. I’m enhancing a CF application that needs a
> >>> whole lot of TLC. With that, I’m attempting to redesign a few aspects
> of the
> >>> application to use components to keep with good design principles.
> >>>
> >>>
> >>>
> >>> Now, I think I’m being exceptionally thick headed but I can’t for the
> >>> life of me figure a way to pass as argumentCollection into my component
> and
> >>> then utilize its information.
> >>>
> >>>
> >>>
> >>> Does anyone have a good resource or tutorial on how to do this? I’ve
> >>> found plenty that talk of using the argumentCollection but none of them
> >>> illustrate it’s use within the component.
> >>>
> >>>
> >>>
> >>> Thank you very much for your time and expertise!
> >>>
> >>>
> >>>
> >>> Matthew R. Nicholson
> >>>
> >>> SolTech, Inc.
> >>>
> >>> Cell: 770-833-5326
> >>>
> >>> www.soltech.net
> >>>
> >>> To find what you seek in the road of life, the best proverb of all is
> >>> that which says: "Leave no stone unturned."
> >>>       ~Edward Bulwer Lytton
> >>>
> >>>
> >>>
> >>> -------------------------------------------------------------
> >>> To unsubscribe from this list, manage your profile @
> >>> http://www.acfug.org?fa=login.edituserform
> >>>
> >>> For more info, see http://www.acfug.org/mailinglists
> >>> Archive @ http://www.mail-archive.com/discussion%40acfug.org/
> >>> List hosted by FusionLink
> >>> -------------------------------------------------------------
> >
> >
>
>
> -------------------------------------------------------------
> To unsubscribe from this list, manage your profile @
> http://www.acfug.org?falogin.edituserform
>
> For more info, see http://www.acfug.org/mailinglists
> Archive @ http://www.mail-archive.com/discussion%40acfug.org/
> List hosted by http://www.fusionlink.com
> -------------------------------------------------------------
>
>
>
>

Reply via email to