But if you do that you are reassigning the value of variables.utility each
time you call the function. Is there a way to just set variables.utility
once and then reference it inside the function I am calling? Normally you'd
do that in the init but that doesn't seem to be an option in the extended
gateway for some reason.
 
Bryan


  _____  

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Brian Kotek
Sent: Sunday, December 31, 2006 1:04 AM
To: [email protected]
Subject: Re: [Reactor for CF] Accessing another cfc inside an extended
gateway


Nice, Qasim. I didn't even know Reactor had such a method. I tested it and
it works just fine. In the Gateway you can do something like:

    
    <cffunction name="getUtility" returntype="any" access="private"
output="false"> 
        <cfif not StructKeyExists(variables, 'utility')>
            <cfset variables.utility = _getBean('utility') />
        </cfif>
        <cfreturn variables.utility /> 
    </cffunction>




On 12/29/06, Qasim Rasheed <[EMAIL PROTECTED]> wrote: 

Bryan,

AFAIK, every Reactor object has a method called _getBean() which gives you
an access to the ColdSpring bean objects. That might solve your issue. 

Thanks

Qasim


On 12/29/06, Brian Kotek <[EMAIL PROTECTED]> wrote: 

I don't believe that the generated Reactor components have an init() method.
So writing your own won't matter because nothing will automatically call it.

I'm not sure why ColdSpring doesn't attempt to use setter injection to
autowire the gateway if you have a setter method that matches up with
another bean. I speculate it has something to do with the fact that this is
done with a factory method call and not a direct instantiation by
ColdSpring. 

I think what you'll need to do is write a custom setter for your
ModelUtilities in your custom gateway, then use ColdSpring in the typical
way to get the Gateway from the Reactor factory and inject it into your
Manager component (or Service, ORMAdapter, etc.). You'd also use ColdSpring
to create an instance of your ModelUtilities and inject that into the same
component. Finally, you'd have to manually have some code in your Manager
(or whichever) component to call the setter on your custom gateway and pass
the ModelUtilities into it. Something like this maybe in your Manager: 

    <cffunction name="setModelUtilities" returntype="void" access="public"
output="false">
        <cfargument name="modelUtilities" type="any" required="true" /> 
        <cfset getMyTableGateway().setUtility(arguments.modelUtilities) />
    </cffunction>

The only thing that worries me there is that this seems to depend on
ColdSpring injecting the gateway before it injects the utility. It worked
when I tested it locally but I'd double check to make sure. Anyway, hope
that helps. 





On 12/29/06, Bryan S <  <mailto:[EMAIL PROTECTED]>
[EMAIL PROTECTED]> wrote: 

O.K. I have more information on this now that I'm hoping this will turn a
light bulb on for someone. 

I'm trying to call variables.instance.ModelUtilities.myFunctionName() from
within my extended gateway
extends="reactor.project.AppManager.Gateway.MyTableGateway"


If I put the code below at the top of my extended Gateway I am able to
access the function in my object, however, it won't work automatically out
of ColdSpring the way the rest of my objects do. I tried putting this same
code in an init in my extended gateway but the init never gets called. I am
wondering why the init doesn't get called and if it's supposed to be that
way how do I accomplish this correctly. 

<cfset variables.instance.ColdSpringBeanFactory =
createObject("component","coldspring.beans.DefaultXmlBeanFactory").init() />

<cfset variables.instance.ColdSpringBeanFactory.loadBeansFromXmlFile
("D:\Inetpub\wwwroot\AppManager\config\ColdSpring.xml",true) />

<cfset variables.instance.ModelUtilities =
variables.instance.ColdSpringBeanFactory.getBean("ModelUtilities") /> 




On 12/28/06, Bryan S <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> > wrote: 

If I call my function getModelUtilities().setQuerySortCriteria() from my
model glue controller there is no problem.

However, if I call it from my extended Gateway I get the error message
below. I went into my autowire.cfm and if I call a different getter in there
variables.instance has a modelutilities in it. However, when I dump
variables.instance inside of getModelUtilities it doesn't exist. What am I
missing?


Message  Element INSTANCE.MODELUTILITIES is undefined in VARIABLES.     
Detail   
        
Extended Info    
        
Tag Context      D:\Inetpub\wwwroot\AppManager\includes\autowire.cfm (47)
D:\Inetpub\wwwroot\AppManager\model\data\Gateway\GROUP_USERGateway.cfc (57)



-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
Reactor for ColdFusion Mailing List
[email protected]
Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
<http://www.mail-archive.com/reactor%40doughughes.net/> 
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- 



-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
Reactor for ColdFusion Mailing List
[email protected]
Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
<http://www.mail-archive.com/reactor%40doughughes.net/> 
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- 



-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
Reactor for ColdFusion Mailing List
[email protected]
Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
<http://www.mail-archive.com/reactor%40doughughes.net/> 
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- 




-- 
Qasim Rasheed
Certified Advance ColdFusion MX Developer
(IM qasimrasheed AT yahoo, msn or GTalk) 

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
Reactor for ColdFusion Mailing List
[email protected]
Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
<http://www.mail-archive.com/reactor%40doughughes.net/> 
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- 



-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
Reactor for ColdFusion Mailing List
[email protected]
Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --



-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Reactor for ColdFusion Mailing List
[email protected]
Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

Reply via email to