I am getting an error that I cannot decipher. It says the parameter
value TRANSFER to function INIT is required and has not been passed
in. However, (a) It does not say which function is requiring Transfer
to be passed in and (2) it should be passed in by lightwire
automagically.
See this link for the error:
http://www.pasteserver.net/322
And see the code below for the LightWire config settings:
variables.Bean.transferFactory.Singleton = 1;
variables.Bean.transferFactory.Path = "transfer.transferFactory";
variables.Bean.transferFactory.ConstructorProperties.datasourcePath =
"/#application.name#/config/datasource.xml";
variables.Bean.transferFactory.ConstructorProperties.configPath =
"/#application.name#/config/transfer.xml";
variables.Bean.transferFactory.ConstructorProperties.definitionPath =
"/#application.name#/com/transfer/definitions";
// User service
variables.Bean.userService.Singleton = 1;
variables.Bean.userService.Path = "#application.name#.com.user.userService";
variables.Bean.userService.ConstructorDependencies = "transferFactory";
variables.Bean.userService.SetterDependencies = "userGateway";
Thanks for your help, I really appreciate it!
I get this error when I don't pass in a constructor argument or constructor
dependency. If you look in one of the objects you are calling, it will have
a cfargument in the init() method with a name of transfer (that is what is
causing the error). It is not necessarily Transfer. If you have put transfer
in your UserService as a constructor dependency, then it would be your
UserSevice throwing this error.
The fix would be to add variables.Bean.UserService.ConstructorDependencies =
"Transfer"; (assuming Transfer is an object not a property - which I'm
guessing is a correct assumption).
You need to put the constructordependencies for any bean that requires
objects to be passed into its init() method, so if ProductService and
MyOtherBean also require transfer, you'd also have to add the following to
your lightwire config:
variables.Bean.ProductService.ConstructorDependencies = "Transfer";
variables.Bean.MyOtherBean.ConstructorDependencies = "Transfer";
Any help?
Best Wishes,
Peter
So I changed this:
> variables.Bean.transferFactory.Singleton = 1;
> variables.Bean.transferFactory.Path = "transfer.transferFactory";
> variables.Bean.transferFactory.ConstructorProperties.datasourcePath =
> "/#application.name#/config/datasource.xml";
> variables.Bean.transferFactory.ConstructorProperties.configPath =
> "/#application.name#/config/transfer.xml";
> variables.Bean.transferFactory.ConstructorProperties.definitionPath =
> "/#application.name#/com/transfer/definitions";
>
> // User service
> variables.Bean.userService.Singleton = 1;
> variables.Bean.userService.Path = "#application.name#.com.user.userService";
> variables.Bean.userService.ConstructorDependencies = "transferFactory";
> variables.Bean.userService.SetterDependencies = "userGateway";
To this:
// Transfer ORM
variables.Bean.transfer.Singleton = 1;
variables.Bean.transfer.Path = "transfer.transferFactory";
variables.Bean.transfer.ConstructorProperties.datasourcePath =
"/#application.name#/config/datasource.xml";
variables.Bean.transfer.ConstructorProperties.configPath =
"/#application.name#/config/transfer.xml";
variables.Bean.transfer.ConstructorProperties.definitionPath =
"/#application.name#/com/transfer/definitions";
// User service
variables.Bean.userService.Singleton = 1;
variables.Bean.userService.Path = "#application.name#.com.user.userService";
variables.Bean.userService.ConstructorDependencies = "transfer";
variables.Bean.userService.SetterDependencies = "userGateway";
Just a thought:
Error message:
It says the parameter
value TRANSFER to function INIT is required and has not been passed
in.
Config code:
>>> variables.Bean.userService.ConstructorDependencies = "transferFactory";
Sounds like you either need to change cfargument name to transferfactory or
change the name of the bean in LightWire config to Transfer.
Best Wishes,
Peter
Wow, in addition to writing LightWire FAQs for transfer it looks like you're
going to at least know answers to all the possible FAQs on LightWire as well
by the time you're done!!!
Best Wishes,
Peter
-Aaron
I'm glad that you are "impressed," Mark seems to think that I need to
show more initiative and is pretty much sick of hearing from me at
this point (though he is very cordial and does try to help).
-Aaron
Oh, I should add that if I was Mark I would probably think the same
thing. I have asked him some pretty stupid questions. No bad feelings
toward Mark.
-Aaron
It is a fair question, but in LightWire, if you think about it, it need to
know what bean to pass in.
Right now it does:
ConstructorDependencies = "BeanName"
And then looks for the bean in variables.beans called
variables.beans.BeanName
I am very open to being able to pass in transferFactory as transfer, but
then you need to tell it that, so we get:
ConstructorDependencies.transfer = "transferFactory"
A little more typing, but not bad.
But what if you want to pass in BeanA, BeanB, BeanC and BeanD?
Right now you'd set
ConstructorDependencies = "BeanA,BeanB,BeanC,BeanD"
With the property value approach, you'd have to type:
ConstructorDependencies.NameA = "BeanA"
ConstructorDependencies.NameB = "BeanB"
ConstructorDependencies.NameC = "BeanC"
ConstructorDependencies.NameD = "BeanD"
So, question is how often is it true that NameX <> BeanX? If it is half the
time, this is worth changing. If it is 1 time in 10, maybe not so much.
Other option is to extend the list to allow an optional alias:
ConstructorDependencies = "BeanA,BeanB as NameB,BeanC,BeanD"
Or something similar - perhaps just a pipe to delimit the optional alias.
That would be fairly easy to implement. It'd be a little "magic charactery"
but *may* be worth it.
What would be the use cases for where argument name <> bean name, how often
do they come up and how should LightWire support them? Any preferences?
Best Wishes,
Peter
addConstructorBean(BeanName string required, BeanAlias string
optional)
same for addSetterBean and addMixinBean. That way nice and clean and
easy optional alias support. Would that work?
> On 3/1/07 4:46 PM, "Aaron Roberson" <iisitedes...@gmail.com> wrote:
>
>
>
> > I already posted that same thing... ha,ha. But I would like to ask, do
> > you think you should have to do that? When passing arguments into an
> > object with many parameters, you can pass them in using
> > name-value-pairs or order-value-pairs. Either way, argument name and
> > the parameter name do not have to match.
>
> > -Aaron
>
if (argument position = 1){send to first parameter}
if (argument position = 2){send to second parameter}
or
right(arg, "=") send to left(arg, "=")
-Aaron
Lets say you have three beans - BeanA, BeanB and BeanC
They should be passed to UserService as BeanA, NewNameForB and BeanC
What exactly would you want to type in the config bean to tell it that
UserService needed those three?
I'm proposing:
addConstructorBean("BeanA");
addConstructorBean("BeanB", "NewNameForB");
addConstructorBean("BeanC");
OR something like
setConstructorBeanList("BeanA,BeanB:NewNameForB,BeanC");
Thoughts? Preferences? I'm tempted to support both . . . ?
And the receiving object could have:
<cfargument name="Bean1" type="path.to.Bean1">
<cfargument name="Bean2" type="path.to.Bean2">
<cfargument name="Bean3" type="path.to.Bean3">
You shouldn't have to know what the name of parameter is that you are
passing the argument to. It should be encapsulated. "BeanA" should
just map to "Bean1" because it is being passed in by name-value-pair
or position-value-pair. That would be consistent with every other
language including ColdFusion.