where to set ColdSpring defaultProperties?

14 views
Skip to first unread message

henry

unread,
Aug 2, 2007, 6:48:18 PM8/2/07
to model-glue
I want to use ${dsn} in Coldspring.xml, but I can't with MG because no
DefaultProperties (struct) is passed to the init() method of
coldspring.beans.DefaultXmlBeanFactory in ModelGlue.cfm around line
74.

In theory I can set it later later through...

coldspring.beans.DefaultXmlBeanFactory.setDefaultProperties()

So the following code should work:

<cfset defaultP = myColdSpring.getDefaultProperties()>
<cfset defaultP.dsn = "my_dsn_name">


but the only place I can access Coldspring, without hacking MG core
code, is Controller API's GetModelGlue().
However, by then it will be too late, and beans that require ${dsn}
will still be ${dsn}.

Can an MG App set coldspring's DefaultProperties without modifying
core file i.e. ModelGlue.cfm?


Thank you!
Henry

Jon_Messer

unread,
Aug 3, 2007, 1:24:24 AM8/3/07
to model-glue
You could set up your coldspring factory in Application.cfc
onApplicationStart with your config settings, then have Model-Glue use
it as the parent bean factory...

<cfset ModelGlue_PARENT_BEAN_FACTORY = application.MyCSFactory />

Wally Kolcz

unread,
Aug 3, 2007, 9:05:39 AM8/3/07
to model...@googlegroups.com
I am confused. I am attempting to pass a numeric variable through the URL to
the controller and have it used in a function. I keep getting that it is not
type numeric as needed for the model function.

I pass:

http://web3.avemarialaw.edu/prospective/index.cfm?event=getProfile&id=2

to the controller:

<cffunction name="getAlumniProfile" access="public" returntype="void"
output="no" hint="I get one Alumni profile to display based on a passed in
ID">
<cfargument name="event" type="ModelGlue.Core.Event" required="yes">
<cfset var AProfile = createObject("component",
"prospective.model.alumniProfiles")/>
<cfset profileID = arguments.event.getValue(id)/>
<cfset alumniProfile = Aprofile.getProfile(profileID) />
<cfset arguments.event.setValue("getAlumiProfile", alumniProfile)/>
</cffunction>

Which invoke the function:

<cffunction name="allProfiles" access="public" returntype="query"
output="no" hint="I display all alumni profiles for the home page">
<cfscript>
allProfiles="";

profilesGateway=application.Reactor.createGateway("adm_AlumniProfiles");
allProfiles=profilesGateway.getAll();
</cfscript>
<cfreturn allProfiles>
</cffunction>

But I get this error:

Oops!
Message The PROFILEID argument passed to the getProfile function is
not of type numeric.
Detail If the component name is specified as a type of this argument, its
possible that a definition file for the component cannot be found or is not
accessible.
Extended Info
Tag Context C (-1)
C:\Inetpub\wwwroot\prospective\controller\Controller.cfc (63)
C:\Inetpub\wwwroot\ModelGlue\unity\listener\Listener.cfc (51)
C:\Inetpub\wwwroot\ModelGlue\unity\eventrequest\MessageBroadcaster.cfc (57)
C:\Inetpub\wwwroot\ModelGlue\unity\framework\ModelGlue.cfc (387)
C:\Inetpub\wwwroot\ModelGlue\unity\framework\ModelGlue.cfc (360)
C:\Inetpub\wwwroot\ModelGlue\unity\framework\ModelGlue.cfc (331)
C:\Inetpub\wwwroot\ModelGlue\unity\framework\ModelGlue.cfc (289)
C:\Inetpub\wwwroot\ModelGlue\unity\ModelGlue.cfm (126)
C:\Inetpub\wwwroot\prospective\index.cfm (72)


Wally Kolcz

unread,
Aug 3, 2007, 9:16:30 AM8/3/07
to model...@googlegroups.com
Opps, I put the wrong model function. It is passing to this one:

<cffunction name="getProfile" access="public" returntype="struct"
output="no" hint="I display a specific profile by an ide number passed in">
<cfargument name="profileID" type="numeric" required="yes"/>
<cfscript>
alumniProfile="";

alumniProfile=application.Reactor.createRecord("adm_AlumniProfiles").load(al
umnid=arguments.profileID);
</cfscript>
<cfreturn alumniProfile>
</cffunction>

Tom McNeer

unread,
Aug 3, 2007, 10:07:08 AM8/3/07
to model...@googlegroups.com
I think the statement in your controller function:

 <cfset profileID = arguments.event.getValue(id)/>

... should be:

 <cfset profileID = arguments.event.getValue("id")/>


Note the quotes around "id."

--
Thanks,

Tom

Tom McNeer
MediumCool
http://www.mediumcool.com
1735 Johnson Road NE
Atlanta, GA 30306
404.589.0560

Wally Kolcz

unread,
Aug 3, 2007, 10:36:08 AM8/3/07
to model...@googlegroups.com

I’ll be darned. Interesting. It worked. I am so used to passing numbers without “. Thanks.

Tom McNeer

unread,
Aug 3, 2007, 12:53:25 PM8/3/07
to model...@googlegroups.com
On 8/3/07, Wally Kolcz <wko...@isavepets.com> wrote:

I'll be darned. Interesting. It worked. I am so used to passing numbers without ".

And you're also used to referring to variable names without using quotes in most cases. But in M-G controllers and views, when referring to objects within the event context, you need to add the quotes.

So --

arguments.event.getValue("someValue")
arguments.event.setValue("someValue")
viewstate.getValue("someValue")

... and so on.

Because ... you're passing an argument, which is a string that is the name of the variable. You're not actually passing the variable itself. This tripped me up a number of times before I caught on.

henry

unread,
Aug 9, 2007, 7:22:23 PM8/9/07
to model-glue
I tried, but using Coldfusion's setParent does NOT solve the "not
replacing ${xxx}" problem.

In ModelGlue.cfm, around line 77 :

<!--- Very Simple HBF support --->
<cfif isObject(ModelGlue_PARENT_BEAN_FACTORY)>
<cfset
_modelglue.beanFactory.setParent(ModelGlue_PARENT_BEAN_FACTORY) />
</cfif>


So it uses Coldspring's beanFactory.setParent(), so I tried to unit
test this myself...

<cfscript>
props = StructNew();
props .dsn = "myDsn";
BFpath = "coldspring.beans.DefaultXmlBeanFactory";

// cs1 is like ModelGlue_PARENT_BEAN_FACTORY in Application.cfc
cs1 = createObject("component", BFpath).init(defaultProperties =
props);

// cs2 is like _modelglue.beanFactory in MG
cs2 = createObject("component", BFpath).init();
cs2.setParent(cs1);

cs2.getBean("myDAO");

// and cs2 still does NOT resolve ${dsn} correctly...

</cfscript>

Help...


Henry

Sean Corfield

unread,
Aug 10, 2007, 3:20:13 AM8/10/07
to model...@googlegroups.com
On 8/9/07, henry <henry...@gmail.com> wrote:
> I tried, but using Coldfusion's setParent does NOT solve the "not
> replacing ${xxx}" problem.

You are misunderstanding Jon's suggestion.

> <cfscript>
> props = StructNew();
> props .dsn = "myDsn";
> BFpath = "coldspring.beans.DefaultXmlBeanFactory";
>
> // cs1 is like ModelGlue_PARENT_BEAN_FACTORY in Application.cfc
> cs1 = createObject("component", BFpath).init(defaultProperties =
> props);

This will cause ${dsn} to be replaced only for the XML loaded into cs1.

Jon was suggesting you put your beans in two separate XML files with
any definitions that need property replacement in the XML file that
you load into the parent factory and the other beans in the
(Model-Glue) ColdSpring XML file.
--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

henry

unread,
Aug 10, 2007, 12:40:48 PM8/10/07
to model-glue
I see! thank you very much Mr. Corfield. You've been very helpful,
much appreciated.

But don't u think the next MG version might want to add an optional
field that can let us add the "defaultProperties" to its default bean
factory?


Henry

On Aug 10, 12:20 am, "Sean Corfield" <seancorfi...@gmail.com> wrote:


> On 8/9/07, henry <henryho...@gmail.com> wrote:
>
> > I tried, but using Coldfusion's setParent does NOT solve the "not
> > replacing ${xxx}" problem.
>
> You are misunderstanding Jon's suggestion.
>
> > <cfscript>
> > props = StructNew();
> > props .dsn = "myDsn";
> > BFpath = "coldspring.beans.DefaultXmlBeanFactory";
>
> > // cs1 is like ModelGlue_PARENT_BEAN_FACTORY in Application.cfc
> > cs1 = createObject("component", BFpath).init(defaultProperties =
> > props);
>
> This will cause ${dsn} to be replaced only for the XML loaded into cs1.
>
> Jon was suggesting you put your beans in two separate XML files with
> any definitions that need property replacement in the XML file that
> you load into the parent factory and the other beans in the
> (Model-Glue) ColdSpring XML file.
> --
> Sean A Corfield -- (904) 302-SEAN

> An Architect's View --http://corfield.org/

Sean Corfield

unread,
Aug 10, 2007, 2:21:57 PM8/10/07
to model...@googlegroups.com
On 8/10/07, henry <henry...@gmail.com> wrote:
> But don't u think the next MG version might want to add an optional
> field that can let us add the "defaultProperties" to its default bean
> factory?

Why don't you check the bug tracker and see if anyone has already
requested that? And, if no one has requested it, open a new ticket for
it.


--
Sean A Corfield -- (904) 302-SEAN

An Architect's View -- http://corfield.org/

henry

unread,
Aug 10, 2007, 5:36:13 PM8/10/07
to model-glue
Good idea, here it is:
http://trac.model-glue.com/model-glue/ticket/302


On Aug 10, 11:21 am, "Sean Corfield" <seancorfi...@gmail.com> wrote:


> On 8/10/07, henry <henryho...@gmail.com> wrote:
>
> > But don't u think the next MG version might want to add an optional
> > field that can let us add the "defaultProperties" to its default bean
> > factory?
>
> Why don't you check the bug tracker and see if anyone has already
> requested that? And, if no one has requested it, open a new ticket for
> it.
> --
> Sean A Corfield -- (904) 302-SEAN

> An Architect's View --http://corfield.org/

mark miller

unread,
Aug 16, 2007, 5:42:10 AM8/16/07
to model-glue
I have posted a new topic about coldspring default properties .... i
think it is exactly what you are looking for

henry

unread,
Aug 16, 2007, 8:48:29 PM8/16/07
to model-glue
Qs
1.) why do u need to change ModelGlue/Core/ColdSpringLoader.cfc? I
only changed ModelGlue/Unity/ModelGlue.cfm and it seems to be working
fine.
2.) why a new thread?

Thanks,
Henry

mark miller

unread,
Aug 20, 2007, 3:47:58 AM8/20/07
to model-glue
1. you only needed to change the unity file as you are using unity ...
if you are not using unity then need to change core ... so iadded it
for completeness.

2. A new thread as i posted this before i saw that someone had asked
about it. Sorry.

Reply all
Reply to author
Forward
0 new messages