BeanFactoryAware in cfscript

3 views
Skip to first unread message

Tony Nelson

unread,
Nov 9, 2009, 2:58:28 PM11/9/09
to ColdSpring-Users
Random question, but is it possible to make a component written in
script aware of the bean factory? My first thought would be something
like:

component {

public void function setBeanFactory(required
coldspring.beans.BeanFactory beanFactory) {
variables.beanFactory = arguments.beanFactory;
}

}

Doing that will cause a syntax error saying "You cannot use a variable
reference with "." operators in this context". Is it possible to use
periods in argument types? If so, what's the syntax?

Mark Mandel

unread,
Nov 9, 2009, 3:32:48 PM11/9/09
to coldspri...@googlegroups.com
If I remember correctly, you will need to go:

import coldspring.beans.*;

component {

       public void function setBeanFactory(required BeanFactory beanFactory) {
               variables.beanFactory = arguments.beanFactory;
       }

}

Although I can't remember if the import statement goes inside or outside the component definition.

I believe the fact you need an import is a bug on the tracker...

Mark
--
E: mark....@gmail.com
T: http://www.twitter.com/neurotic
W: www.compoundtheory.com

Tony Nelson

unread,
Nov 9, 2009, 3:36:57 PM11/9/09
to coldspri...@googlegroups.com
Will that work with ColdSpring though? If I remember correctly, ColdSpring will check the component's meta data look for a "setBeanFactory" function that has 1 argument with a type of "coldspring.beans.BeanFactory". Will importing coldspring.beans.* have an effect on the meta data of the function's argument? At first glance, I would assume it wouldn't.

-Tony

Mark Mandel

unread,
Nov 9, 2009, 3:39:04 PM11/9/09
to coldspri...@googlegroups.com
You could always try it ;o)

But yes, it will return the same meta data. The import statement allows 'BeanFactory' to be resolved to 'coldspring.beans.BeanFactory'. The metadata should be identical.

Mark
Reply all
Reply to author
Forward
0 new messages