Accessing Plugins like "Validator" from a CFC

Hi,

I'm getting this error in a Bean I'm trying to use:

Message Variable GETPLUGIN is undefined.

It works fine in my handlers, and I think I know why its not working
but my the fix I've tried hasn't worked out. Here is my CFC. This is
my first try with script CFCs, so if you see anything wrong, kindly
let me know.

<cfscript>
  Component displayname="myBean" accessors="true" ouput="false"
autowire=true {

    property name="validator" type="coldbox:plugin:Validator"
scope="instance";
    property name="firstname" getter="true" setter="true" type="string";
    property name="lastname" getter="true" setter="true" type="string";

    public array function validate() {
      var validator = getPlugin('Validator');
              }
</cfscript>

How can I use the plugin here in my bean or should I do this a
different way?

Thanks,

West

I think you will need to pass in the constructor the controller, then you
will need to use that to get the plugin.

I might be wrong, but I don't think it is injected by default without being
wired up with lightwire or ColdSpring.

West,

property name="validator"
type="coldbox:plugin:Validator"
scope="instance";

public array function validate() {
      var validator = instance.validator;
              }

By autowiring with coldbox:plugin:Validator you are placing the
validator plugin into the instance scope, do no need for getPlugin and
yes, it doesn't' exist.

Hope that helps you out. You don't need lightwire or Coldspring for
this type of injection.

Note if you're are running Coldbox 3.0 autowireing via inject instead of
type is preferred.

property name="validator"
inject="coldbox:plugin:Validator"
scope="instance";

http://wiki.coldbox.org/wiki/WhatsNew:3.0.0.cfm#Updated_Dependency_Injec
tion_DSL

Curt Gratz
Computer Know How