1

Model Glue 3 introduced bean injection, which allows you to do this in a controller to access it:

beans.component.function();

However, the beans scope is only available for a controller. How would I access a bean outside of a controller, for example in Application.cfc or a helper UDF? I have a SimpleConfig bean that I'd like to access some config info for.

Daniel T.
  • 37,212
  • 36
  • 139
  • 206

1 Answers1

1

It's going to depend on your bean factory -- most likely ColdSpring. If your ColdSpring instance is saved in Application.beanFactory (I think this is the default, it's been some time since I last used ModelGlue), then you would do the following:

variables.config = application.beanFactory.getBean("SimpleConfig");
Adam Tuttle
  • 19,505
  • 17
  • 80
  • 113
  • Unfortunately, the bean factory does not exist on `application`. – Daniel T. Sep 20 '11 at 20:26
  • Somewhere in Application scope, you'll find the Model Glue instance saved -- it might be Application._modelglue or something like that. If you can find that, then according to the docs (http://docs.model-glue.com/wiki/ReferenceMaterials/ModelGlueApi#Model-GlueAPI) you can call `{modelGlueObject}.GetBean("config");` (where "config" is the bean id of your config bean) – Adam Tuttle Sep 21 '11 at 00:28