Accessing Simple Config Bean from Controller

15 views
Skip to first unread message

Clifford Moon

unread,
Mar 22, 2012, 9:34:04 AM3/22/12
to model-glue
Greetings,

I have the following bean defined within my coldspring.xml file.

<bean id="AppConfig" class="ModelGlue.Bean.CommonBeans.SimpleConfig">
<property name="Config">
<map>
<entry key="AppTitle"><value>Event Management</value></
entry>
<entry key="dsn"><value>webapps</value></entry>
<entry key="mssql_dsn"><value>internetservices</value></entry>

</map>
</property>
</bean>


Is there any way to access the entries of this bean from within the
controller?

Thanks,

Cliff

Matt Quackenbush

unread,
Mar 22, 2012, 9:44:26 AM3/22/12
to model...@googlegroups.com
Something like getModelGlue().getBean("AppConfig") should give it to you. Or, if you're on MG3, add a `beans="AppConfig"` attribute to your controller definition, and just reference it as `beans.AppConfig`.

HTH

--
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 model...@googlegroups.com
To unsubscribe from this group, send email to
model-glue+...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/model-glue?hl=en

Chris Blackwell

unread,
Mar 22, 2012, 9:45:50 AM3/22/12
to model...@googlegroups.com
Hi Cliff,

In your controller add the beans annotation to the component

component extends="ModelGlue.." beans="AppConfig" 

ModelGlue will then inject your AppConfig into the controllers beans scope

function doSomething(event) {
   var someSetting = beans.AppConfig.someSetting;
}

Chris


Clifford Moon

unread,
Mar 22, 2012, 10:02:53 AM3/22/12
to model-glue
Greetings,

Thanks for the quick replies Mark and Chris,

I'm on MG3, and added the following to the controller component:

<cfcomponent displayname="registrantController" output="false" hint="I
am the controller for Registrant."
extends="ModelGlue.gesture.controller.Controller" beans="AppConfig">

I then tried the following,

<cfset theSystem = beans.AppConfig.theSystem />
<cfset theProtocol = beans.AppConfig.theProtocol />

and got this error:

Element APPCONFIG.THESYSTEM is undefined in BEANS.

What did I miss here.

Thanks for any help,

Cliff


On Mar 22, 8:45 am, Chris Blackwell <ch...@team193.com> wrote:
> Hi Cliff,
>
> In your controller add the beans annotation to the component
>
> component extends="ModelGlue.." beans="AppConfig"
>
> ModelGlue will then inject your AppConfig into the controllers beans scope
>
> function doSomething(event) {
>    var someSetting = beans.AppConfig.someSetting;
>
> }
>
> Chris
>

Clifford Moon

unread,
Mar 22, 2012, 10:21:02 AM3/22/12
to model-glue
Hi,

Answered my own question. Was referencing something that wasnt
defined in the bean .. DOH!..

Thanks for all the help,

Cliff

Jared Rypka-Hauer

unread,
Mar 23, 2012, 3:49:08 PM3/23/12
to model...@googlegroups.com
Indeed... just to clarify for anyone reading this in the archives later on, by default it's at

beans.AppConfig.getConfigSetting("theSetting")

where beans.AppConfig is a reference to the bean and getConfigSetting() is (obviously) a method on the bean. If you were to dump the bean you'd see 3 methods and no properties whereas what you were trying to access were actually properties and not method calls.

Sorry to state the obvious. :) These archives show up in Google searches and I figured we should close the loop on this question in case anyone else ran into it later on.

Still alive and kicking... :)

J

Reply all
Reply to author
Forward
0 new messages