Hi all,

I'm trying to instantiate an object either in the psuedo-contructor or
init of my cfc as a variable so I can use it within all my method inside
that cfc.  For some reason when I call a method from that object I get a
Method not found error.  I'm not sure if this is the best way of going
about it so if anyone has a better idea, I'd like to hear about it. :)
If I istantiate it WITHIN the cffunction, it works fine. Any ideas?

Here's a sample of how I'm doing it.  When I try to call addErrorMsg();
or isSuccess() or any methods in errorMsg or Imanage or instGateway it
throws a Method not found error.

<cfcomponent displayname="feeds" output="false" ...>
  <cfscript>
    var errorMsg = createObject("component",
"com.util.errorMessages").init();
    var iManager = createObject("component",
"com.util.imageManager").init();
    var instGateway = createObject("component",
"FeedsGateway").init(application.global);
  </cfscript>

  <cffunction name="init" access="public" returntype="feeds"
hint="Constructor">
    <cfreturn this>
  </cffunction>

  <cffunction name="insertFeedRecord" access="public" ...>
    <cfargument name="dataset" required="true" type="struct"
hint="Passed Dataset" />

    <cfscript>
     var feedsBean = "";
     var newFileName = "";
     var instGatway = "";
     var results = structNew();

     feedsBean = createObject("component",
"feedsBean").init(argumentCollection=dataset);

     // Validate the required fields and do an image upload
     if (not len(trim( feedsBean.getFeedName() )))
errorMsg.addErrorMsg("...Blah");
     if (not len(trim( feedsBean.getFeedDescription() )))
errorMsg.addErrorMsg("...Blah");
     if (not len(trim( feedsBean.getAuthorName() )))
errorMsg.addErrorMsg("...Blah");

     if (errorMsg.isSuccess()) {
       results.success = instGateway.create(feedsBean, errorMsg);
       results.errors = errorMsg.getErrors();
     }
     else {
       results.success = 0;
       results.errors = errorMsg.getErrors();
     }
    </cfscript>

    <cfreturn results />
  </cffunction>
</cfcomponent>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:328697
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to