Re: Passing arguments into base class

2015-02-06 Thread Dean Lawrence

Thanks Nathan, that's good to know. I will definitely have to look deeper
into that. I have been using ColdSpring in a common way for so long that I
have not looked over the documentation in a couple years. I may have had
the ability all along and not known it. Thanks again!

On Fri, Feb 6, 2015 at 3:40 PM, Nathan Strutz str...@gmail.com wrote:


 You're using ColdSpring and you say CS is not autowiring the field on a
 base class? It's supposed to, FYI, it just is. If it does not, you can do
 it explicitly in your xml file (if you use the DefaultXMLBeanFactory.cfc).
 Also, make sure the autowire option is on, at least for this object if not
 for all of your beans. It's strange that it is not working, maybe this
 would be a question for the ColdSpring list.

 Nathan Strutz



-- 

  [image: profile picture]  *Dean Lawrence*
*President*
Internet Data Technology
*Phone:* 888-438-4381 x701
*Web:* www.idatatech.com
*Email:* d...@idatatech.com
  Programming | Database | Consulting | Training


~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360075
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Passing arguments into base class

2015-02-06 Thread Jason Durham

I tried to answer this twice but neither of my previous emails went
through.  I'm trying from another account.

Byron's last example passing the value from the child object to the parent
definitely works.  I'm not sure what's in your Util class, but the name of
it seems to imply using it as a mixin is the avenue I'd take.


Jason Durham

On Fri, Feb 6, 2015 at 1:23 PM, Byron Mann byronos...@gmail.com wrote:


 This might work, if I'm understanding.

 component name='baseClass' {

   variables.utilClass = '';

public any function init(utilClass utilClass){
  variables.utilClass = arguments.utilClass;
   }

 }

 In your derived class you can do this.

 component extends='baseClass'{
   public any function init(utilClass utilClass){
 super.init(argumentCollection=arguments);
   }
 }


 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360068
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Passing arguments into base class

2015-02-06 Thread Dean Lawrence

Byron,

This is pretty much what I was thinking that I had to do, but was hoping to
not have to explicitly call the super.init() method for every class that
extends the base class. I'm just not sure if what I am trying to do is even
possible.

On Fri, Feb 6, 2015 at 2:23 PM, Byron Mann byronos...@gmail.com wrote:


 This might work, if I'm understanding.

 component name='baseClass' {

   variables.utilClass = '';

public any function init(utilClass utilClass){
  variables.utilClass = arguments.utilClass;
   }

 }

 In your derived class you can do this.

 component extends='baseClass'{
   public any function init(utilClass utilClass){
 super.init(argumentCollection=arguments);
   }
 }


 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360071
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Passing arguments into base class

2015-02-06 Thread Nathan Strutz

You're using ColdSpring and you say CS is not autowiring the field on a
base class? It's supposed to, FYI, it just is. If it does not, you can do
it explicitly in your xml file (if you use the DefaultXMLBeanFactory.cfc).
Also, make sure the autowire option is on, at least for this object if not
for all of your beans. It's strange that it is not working, maybe this
would be a question for the ColdSpring list.

Nathan Strutz

On Fri Feb 06 2015 at 3:30:14 PM Dean Lawrence dean...@gmail.com wrote:


 Thanks Nathan,

 I am familiar with IoC and am using ColdSpring for this very purpose.
 However, it doesn't really work in this situation because the base class is
 never called directly though the beanfactory. The bean that is extending
 the base class may, but not the baseclass itself. This is my issue.

 I am actually already doing something identical to what Byron suggested,
 but by calling the utility class through the beanfactory (which is stored
 in the application scope) instead of creating a new instance of the utility
 class using New. In either case, the utility class variable is being
 explicitly called/created within the base class, not passed in as an
 argument.

 On Fri, Feb 6, 2015 at 2:14 PM, Nathan Strutz str...@gmail.com wrote:




~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360073
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Passing arguments into base class

2015-02-06 Thread Dean Lawrence

Hi Jon,

No, the utility class is not dependent on the base class. The base class
has some universal methods that handle things like performing common
preInsert and preUpdate ORM methods across all my persistent objects. My
utility class has some common methods that I use for such things as
encryption/decrypt. I am need of some of the methods that are in the
utility class from within my base class. Since the base class is never call
directly or from my beanfactory (I use ColdSpring), I don't know how to
inject the utility class into the base class.

On Fri, Feb 6, 2015 at 2:23 PM, Jon Clausen jon_clau...@silowebworks.com
wrote:


 Dean,

 Is your utility class dependent on the the base class (e.g. - does it use
 “this” or the variables scope)?  If so, then you have a couple of 
 different
 ways you can go:

 1) use it as a mixin inside your component{} , and forego the class
 wrapper for the Utility methods entirely:

 include template=“Utilities.cfm”;

 2) use inheritance of the Utilities class on the base class (or the base
 class’ super class):

 component name=“BaseClass” extends=“UtilityClass”{}

 If it’s not dependent on the base class, you can either:

 1) Inject it using a dependency framework like Wirebox (
 http://wiki.coldbox.org/wiki/WireBox.cfm - which can run outside of a
 Coldbox app), Coldspring, etc. ( I see Nathan just replied to this effect)
 and just call the injection mapping in your constructor.  If there are
 constructor arguments the Util class needs, you can set those with your
 injection framework and be done with them.

 2) If the methods are all static helpers, incorporate it as a mixin to
 your Application.cfc, so that the methods become available globally,
 without scope, on every request.


 Jon




-- 

  [image: profile picture]  *Dean Lawrence*
*President*
Internet Data Technology
*Phone:* 888-438-4381 x701
*Web:* www.idatatech.com
*Email:* d...@idatatech.com
  Programming | Database | Consulting | Training


~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360072
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Passing arguments into base class

2015-02-06 Thread Nathan Strutz

Dean,

Byron's suggestion is a good one, and the right way to go unless you use an
IoC container. It's an object-oriented programming idea where, when you
come to the point of not wanting to instantiate all your objects. You
invert the control of creating away from what normally creates them into
some kind of bean factory. There are a number of them out there for
ColdFusion. ColdSpring, WireBox, and DI/1 to name the big ones off the top
of my head. An ioc container/factory will keep it all internally for you,
wire your bean up, then hand you what you asked for, all ready to go.

The only other solution is to send in your utility object each time you
create something that needs it.

On Fri Feb 06 2015 at 1:24:38 PM Dean Lawrence dean...@gmail.com wrote:


 Thanks Byron,

 I wasn't wanting my utility class to inherit my base class, I am wanting to
 inject the utility class into the base class. I'm trying to get away from
 explicitly defining the utility class from within the base class. Since the
 base class is not called directly, I don't know how to pass the utility
 class in as a required argument during initialization.

 On Fri, Feb 6, 2015 at 12:11 PM, Byron Mann byronos...@gmail.com wrote:

 
  Think you might want something like this in your base cfc? I think you'd
  not want the UtilClass to inherit the base class however, or this would
  lead to a circular reference and probably kill the app.
 
  component name='baseClass' {
 
   variables.utilClass = new UtilClass();
 
  }
 
 
 

 --

   [image: profile picture]  *Dean Lawrence*
 *President*
 Internet Data Technology
 *Phone:* 888-438-4381 x701
 *Web:* www.idatatech.com
 *Email:* d...@idatatech.com
   Programming | Database | Consulting | Training


 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360065
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Passing arguments into base class

2015-02-06 Thread Byron Mann

This might work, if I'm understanding.

component name='baseClass' {

  variables.utilClass = '';

   public any function init(utilClass utilClass){
 variables.utilClass = arguments.utilClass;
  }

}

In your derived class you can do this.

component extends='baseClass'{
  public any function init(utilClass utilClass){
super.init(argumentCollection=arguments);
  }
}


~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360067
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Passing arguments into base class

2015-02-06 Thread Jon Clausen

Dean,

Is your utility class dependent on the the base class (e.g. - does it use 
“this” or the variables scope)?  If so, then you have a couple of 
different ways you can go:

1) use it as a mixin inside your component{} , and forego the class wrapper for 
the Utility methods entirely:

include template=“Utilities.cfm”;

2) use inheritance of the Utilities class on the base class (or the base 
class’ super class):  

component name=“BaseClass” extends=“UtilityClass”{}

If it’s not dependent on the base class, you can either:

1) Inject it using a dependency framework like Wirebox 
(http://wiki.coldbox.org/wiki/WireBox.cfm - which can run outside of a Coldbox 
app), Coldspring, etc. ( I see Nathan just replied to this effect) and just 
call the injection mapping in your constructor.  If there are constructor 
arguments the Util class needs, you can set those with your injection framework 
and be done with them.

2) If the methods are all static helpers, incorporate it as a mixin to your 
Application.cfc, so that the methods become available globally, without scope, 
on every request. 


Jon
 

On February 6, 2015 at 1:24:03 PM, Dean Lawrence (dean...@gmail.com) wrote:


Thanks Byron,  

I wasn't wanting my utility class to inherit my base class, I am wanting to  
inject the utility class into the base class. I'm trying to get away from  
explicitly defining the utility class from within the base class. Since the  
base class is not called directly, I don't know how to pass the utility  
class in as a required argument during initialization.  

On Fri, Feb 6, 2015 at 12:11 PM, Byron Mann byronos...@gmail.com wrote:  

  
 Think you might want something like this in your base cfc? I think you'd  
 not want the UtilClass to inherit the base class however, or this would  
 lead to a circular reference and probably kill the app.  
  
 component name='baseClass' {  
  
 variables.utilClass = new UtilClass();  
  
 }  
  
  
  

--  

[image: profile picture] *Dean Lawrence*  
*President*  
Internet Data Technology  
*Phone:* 888-438-4381 x701  
*Web:* www.idatatech.com  
*Email:* d...@idatatech.com  
Programming | Database | Consulting | Training  




~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360066
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Passing arguments into base class

2015-02-06 Thread Dean Lawrence

Thanks Nathan,

I am familiar with IoC and am using ColdSpring for this very purpose.
However, it doesn't really work in this situation because the base class is
never called directly though the beanfactory. The bean that is extending
the base class may, but not the baseclass itself. This is my issue.

I am actually already doing something identical to what Byron suggested,
but by calling the utility class through the beanfactory (which is stored
in the application scope) instead of creating a new instance of the utility
class using New. In either case, the utility class variable is being
explicitly called/created within the base class, not passed in as an
argument.

On Fri, Feb 6, 2015 at 2:14 PM, Nathan Strutz str...@gmail.com wrote:


 Dean,

 Byron's suggestion is a good one, and the right way to go unless you use an
 IoC container. It's an object-oriented programming idea where, when you
 come to the point of not wanting to instantiate all your objects. You
 invert the control of creating away from what normally creates them into
 some kind of bean factory. There are a number of them out there for
 ColdFusion. ColdSpring, WireBox, and DI/1 to name the big ones off the top
 of my head. An ioc container/factory will keep it all internally for you,
 wire your bean up, then hand you what you asked for, all ready to go.

 The only other solution is to send in your utility object each time you
 create something that needs it.



-- 

  [image: profile picture]  *Dean Lawrence*
*President*
Internet Data Technology
*Phone:* 888-438-4381 x701
*Web:* www.idatatech.com
*Email:* d...@idatatech.com
  Programming | Database | Consulting | Training


~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360070
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Passing arguments into base class

2015-02-06 Thread Byron Mann

Think you might want something like this in your base cfc? I think you'd
not want the UtilClass to inherit the base class however, or this would
lead to a circular reference and probably kill the app.

component name='baseClass' {

 variables.utilClass = new UtilClass();

}


On Fri, Feb 6, 2015 at 11:14 AM, Dean Lawrence dean...@gmail.com wrote:


 All of my classes in my app are derived from a base class. I've been using
 this successfully for the last couple of years. However, within the base
 class, I need the use of a utility class as well. I am currently calling it
 from the application scope, but I want to better encapsulate the base class
 and inject the utility class into the base class instead of relying on an
 external reference. My question is, how do I do this? I know how to do it
 with a regular class file, but not with a class that is being inherited.
 Can anyone give me some direction?

 Thanks,

 --

   [image: profile picture]  *Dean Lawrence*
 *President*
 Internet Data Technology
 *Phone:* 888-438-4381 x701
 *Web:* www.idatatech.com
 *Email:* d...@idatatech.com
   Programming | Database | Consulting | Training


 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360062
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Passing arguments into base class

2015-02-06 Thread Dean Lawrence

Thanks Byron,

I wasn't wanting my utility class to inherit my base class, I am wanting to
inject the utility class into the base class. I'm trying to get away from
explicitly defining the utility class from within the base class. Since the
base class is not called directly, I don't know how to pass the utility
class in as a required argument during initialization.

On Fri, Feb 6, 2015 at 12:11 PM, Byron Mann byronos...@gmail.com wrote:


 Think you might want something like this in your base cfc? I think you'd
 not want the UtilClass to inherit the base class however, or this would
 lead to a circular reference and probably kill the app.

 component name='baseClass' {

  variables.utilClass = new UtilClass();

 }




-- 

  [image: profile picture]  *Dean Lawrence*
*President*
Internet Data Technology
*Phone:* 888-438-4381 x701
*Web:* www.idatatech.com
*Email:* d...@idatatech.com
  Programming | Database | Consulting | Training


~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360063
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm