Thanks guys.  Very helpful and informative.

Byron

On Jan 6, 4:36 pm, "Dan Wilson" <[email protected]> wrote:
> I agree with Ezra.
>
> Consistent use of the beans scope is better documentation. It's easy to see 
> what a certain controller needs.
>
> DW
> Sent from a mobile. Please excuse brevity and typos.
>
> -----Original Message-----
> From: Ezra Parker <[email protected]>
>
> Sender: [email protected]
> Date: Thu, 6 Jan 2011 13:27:45
> To: <[email protected]>
> Reply-To: [email protected]
> Subject: Re: [Model-Glue] Re: Referencing beans scope in an init function of 
> a controller
>
> No problem.
>
> I'd say it's a matter of preference -- personally, I tend to avoid
> defining init() methods in my controllers, and I prefer using the
> beans scope to getModelGlue().getBean(), so I'd go with the
> onApplicationStart approach instead.
>
> --
> Ezra
>
> On Thu, Jan 6, 2011 at 1:14 PM, byron <[email protected]> wrote:
> > Thanks Ezra.  Will try this out.  Any advantage/disadvantage doing one
> > vs the other?  Or is it a stylistic preference?
>
> > Byron
>
> > On Jan 6, 4:06 pm, Ezra Parker <[email protected]> wrote:
> >> On Thu, Jan 6, 2011 at 12:33 PM, byron <[email protected]> wrote:
> >> > Thanks, Ezra.  Yes, I would like to see an example.
>
> >> Sure. First you'd add the message listener to your controller's XML config:
>
> >> <controller id="eHopeController" type="controller.eHopeController">
> >>     <message-listener message="onApplicationStart" />
> >> </controller>
>
> >> Then add the corresponding controller function -- here's a minimalist 
> >> example:
>
> >> <cffunction name="onApplicationStart" output="false">
> >>     <cfargument name="event" />
>
> >>     <cfset variables.settings = beans.applicationSettings.getConfig() />
> >> </cffunction>
>
> >> > Would doing something like
> >> > getModelGlue().getBean("applicationSettings", true) work also?
>
> >> Yes, but with a caveat:
>
> >> I actually should have mentioned this in my first response, but if
> >> you're going to define an init() method in your controllers, you need
> >> to make sure to call super.init() in order to execute the base
> >> controller's constructor, as otherwise getModelGlue() is not going to
> >> work either. Here's the modification you would need to make to the
> >> init() method you posted:
>
> >> <cffunction name="init" access="public" returnType="eHopeController"
> >> output="false">
> >>     <cfargument name="framework" />
>
> >>     <cfset super.init(framework) />
>
> >>     <cfset variables.settings =
> >> getModelGlue().getBean("applicationSettings").getConfig() />
>
> >>     <cfreturn this />
> >> </cffunction>
>
> >> --
> >> Ezra
>
> > --
> > Model-Glue Sites:
> > Home Page:http://www.model-glue.com
> > Documentation:http://docs.model-glue.com
> > Bug Tracker:http://bugs.model-glue.com
> > Blog:http://www.model-glue.com/blog
>
> > You received this message because you are subscribed to the Google
> > Groups "model-glue" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]
> > For more options, visit this group at
> >http://groups.google.com/group/model-glue?hl=en
>
> --
> Model-Glue Sites:
> Home Page:http://www.model-glue.com
> Documentation:http://docs.model-glue.com
> Bug Tracker:http://bugs.model-glue.com
> Blog:http://www.model-glue.com/blog
>
> You received this message because you are subscribed to the Google
> Groups "model-glue" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group 
> athttp://groups.google.com/group/model-glue?hl=en

-- 
Model-Glue Sites:
Home Page: http://www.model-glue.com
Documentation: http://docs.model-glue.com
Bug Tracker: http://bugs.model-glue.com
Blog: http://www.model-glue.com/blog

You received this message because you are subscribed to the Google
Groups "model-glue" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/model-glue?hl=en

Reply via email to