Matt Williams said the following on 4/5/2006 9:42 AM:
I am able to duplicate Brian's issue using stable release 0.5. If I use constructor-arg to pass a bean, and have a private setter for that bean, it throws the error saying "The method 'setPersonGateway' could not be found in component".
 
If I change the setter to public access, no error. If I comment out the setter all together, no error.
 
As far as whether constructor-args or setter methods is better... It seems like I read in the CS documentation or something that the setter method is preferred. But I don't why that would be. Brian's point of if the component needs it, the let the init get it makes sense. And then the init calls the private setter. So having a private setter and a public getter for that bean would be logical.
 
My $.02
I've been unable to reproduce this.  I have situations in my application where I use constructor-arg and have a private setter for it.  I have double checked that the setter is private (the getter is public).  I am using the latest BER.

Matt, IIRC the reason why you should prefer setter injection over constructor injection is to reduced circular dependency issues.  My rule of thumb is that unless the object needs certain things during init() then use setter injection.  You can also have CS call a init-method meaning CS automatically will call your init() method, wire things, inject dependencies and then call your init-method (I usually name it setup()).

Am I correct Dave or Chris?

.Peter
-- 
Peter J. Farrell :: Maestro Publishing
Member Team Mach-II :: Member Team Fusion
http://blog.maestropublishing.com

Create boilerplate beans and transfer objects for ColdFusion!
Fire up a cup of Rooibos!
http://rooibos.maestropublishing.com/

Reply via email to