Error executing method

55 views
Skip to first unread message

Karen Payne

unread,
Mar 1, 2018, 2:37:32 PM3/1/18
to framework-one
Hello,

Just starting out with FW/1, a developer (since retired so I don't have him as a resource) in my company created a application using FW1 which works fine. 

So to learn FW/1 I downloaded a skeleton application from GitHub.

I created a component named common.cfc (under model\services) which has an init and a function which passes a string back to the caller e.g.

<cfcomponent output="false">

   
<cffunction name="init" output="false">
   
<cfargument name="dsn">
   
<cfargument name="globals">
   
<cfargument name="globals2">
   
<cfargument name="mailto">
   
<cfargument name="fw" type="struct" required="true">

   
<cfset variables.fw = arguments.fw>

   
<cfset variables.dsn = arguments.dsn>
   
<cfset variables.globals = arguments.globals>
   
<cfset variables.globals2 = arguments.globals2>
   
<cfset variables.mailTo = arguments.mailto>

   
<cfreturn this>

 
</cffunction>

 
<cffunction name="calledFromCommon"  access="public" output="false">
   
<cfreturn "Here">
 
</cffunction>


</cfcomponent>

Under views/main bank.cfm. IsDefined returns true but attempting to invoke the method I get "an error occured" (this is from adding error.cfm under views\main.
<cfoutput>
   
<p>Banking page</p>
   
<cfset application.painter = "Cats">

   
<cfif IsDefined("commonService.calledFromCommon")>
     
<cfset mme = commonServices.calledFromCommon()>
      YES!!!
   
<cfelse>
      NO
   
</cfif>
</cfoutput>

My question (and realize that there possibly not be other code people may need to see), if from what I posted is there anything that appears incorrect? If there a method to learn more about the runtime exception by altering the stock error page (a vanilla error page I got from the web)?

I appropriate any feedback and if more details are required I will provide them.

Karen  





Sean Corfield

unread,
Mar 1, 2018, 5:11:06 PM3/1/18
to framew...@googlegroups.com

Hi Karen! Welcome to FW/1!

 

Lots of questions in there so let’s see what I can do about answering them. I’ll start with the easiest one:

 

If there a method to learn more about the runtime exception by altering the stock error page (a vanilla error page I got from the web)?

 

For development purposes you could add <cfdump var=”#request.exception#”> to error.cfm to see a full dump of the exception which will probably help.

 

if from what I posted is there anything that appears incorrect?

 

One thing that stands out is that you have commonService in one line and commonServices in the next:

 

   <cfif IsDefined("commonService.calledFromCommon")>
     
<cfset mme = commonServices.calledFromCommon()>

 

Off-the-top-of-my-head, I’m a bit surprised the service and method are defined in the view – views are executed in the context of FW/1 so they wouldn’t normally see services (and in normal Model-View-Controller code you would not call services from a View, only from a Controller).

 

Do you have a controllers/main.cfc file? The normal flow would be for that to have a bank function – to match action=main.bank which leads to views/main/bank.cfm – and FW/1 would call the main controller’s bank function, passing in the request context (rc), and that function would call services to populate data into the rc:

 

                rc.mme = variables.commonService.calledFromCommon();

 

And then the views/main/bank.cfm file would reference that as #rc.mme#

 

To make the magic service injection work, main.cfc would need either a setter for the service:

 

                function setCommonService( commonService ) {

                                variables.commonService = commonService;

                }

 

Or you could use property injection instead, by adding accessors=true to your component tag and including a property declaration for the service:

 

                property commonService;

 

(Your code is all tag-based and I haven’t written CFCs like that for so long I’m not sure I’d get the tag syntax right, so you’ll have to take my script code above and rewrite it as the appropriate tags, if you’re going to keep your CFCs in tag syntax)

 

Hope that helps you move forward!

 

Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

 


From: framew...@googlegroups.com <framew...@googlegroups.com> on behalf of Karen Payne <karenpay...@gmail.com>
Sent: Thursday, March 1, 2018 11:36:40 AM
To: framework-one
Subject: [framework-one] Error executing method
 
--
FW/1 documentation: http://framework-one.github.io
FW/1 source code: http://github.com/framework-one/fw1
FW/1 chat / support: https://gitter.im/framework-one/fw1
FW/1 mailing list: http://groups.google.com/group/framework-one
---
You received this message because you are subscribed to the Google Groups "framework-one" group.
To unsubscribe from this group and stop receiving emails from it, send an email to framework-on...@googlegroups.com.
Visit this group at https://groups.google.com/group/framework-one.
For more options, visit https://groups.google.com/d/optout.

Karen Payne

unread,
Mar 1, 2018, 6:01:28 PM3/1/18
to framework-one

Hi Sean,

Thanks for the quick response, I've looked through your reply, good points you've made and appreciate this. Rather than me rushing thru and do quick checks and fixes tomorrow is another day and will respond back then,

Karen 

Karen Payne

unread,
Mar 2, 2018, 10:01:54 AM3/2/18
to framework-one
Hi Sean,

First off, I’m using tag based simply because the developers in this company have been using tags forever while I prefer your method coming from a C#/JavaScript background I don’t want to rock the boat in my first few months here but instead when a new app is needed introduce non tag based coding.

Next up, yes I added a (s) to commonService and since removal of the (s) it’s working now.

“do you have a controllers/main.cfc file?” yes and will readjust to match this pattern.

In regards to “To make the magic service injection work”, I will work through this.

I can’t thank you enough for your guidance with this. 

Karen

Sean Corfield

unread,
Mar 2, 2018, 8:14:03 PM3/2/18
to framew...@googlegroups.com

Next up, yes I added a (s) to commonService and since removal of the (s) it’s working now.

 

Excellent!

 

First off, I’m using tag based simply because the developers in this company have been using tags forever while I prefer your method coming from a C#/JavaScript background I don’t want to rock the boat in my first few months here but instead when a new app is needed introduce non tag based coding.

 

Good approach 😊

 

Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

 

Sent: Friday, March 2, 2018 7:01:54 AM
To: framework-one
Subject: [framework-one] Re: Error executing method
 
--
Reply all
Reply to author
Forward
0 new messages