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
<cfset ModelGlue_PARENT_BEAN_FACTORY = application.MyCSFactory />
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)
<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>
I’ll be darned. Interesting. It worked. I am so used to passing numbers without “. Thanks.
I'll be darned. Interesting. It worked. I am so used to passing numbers without ".
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
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
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/
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/
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/
Thanks,
Henry
2. A new thread as i posted this before i saw that someone had asked
about it. Sorry.