Highlighted

Follow-up to previous question regarding CFC functions

LEGEND ,
May 22, 2015

Copy link to clipboard

Copied

Hello, all,

Earlier, I had asked a question about methods not being found in components.  haxtbh‌ pointed out something that I had skipped over (I was in a hurry) in the documentation - that 'private' methods (even within the same CFC) cannot be referred via the "this" scope.  I changed all of my methods to be called via mapping (ie, "components.componentName().methodName(args)") and most of them work!  However, I've got a few that aren't being found, even with using the mapping.  I really do not want these methods to be pushed into "public" access; I would much prefer that functions called from within the same CFC be private.  Any suggestions on what could be causing these to not be found?

V/r,

^_^

Views

189

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Follow-up to previous question regarding CFC functions

LEGEND ,
May 22, 2015

Copy link to clipboard

Copied

Hello, all,

Earlier, I had asked a question about methods not being found in components.  haxtbh‌ pointed out something that I had skipped over (I was in a hurry) in the documentation - that 'private' methods (even within the same CFC) cannot be referred via the "this" scope.  I changed all of my methods to be called via mapping (ie, "components.componentName().methodName(args)") and most of them work!  However, I've got a few that aren't being found, even with using the mapping.  I really do not want these methods to be pushed into "public" access; I would much prefer that functions called from within the same CFC be private.  Any suggestions on what could be causing these to not be found?

V/r,

^_^

Views

190

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
May 22, 2015 0
Adobe Community Professional ,
May 24, 2015

Copy link to clipboard

Copied

WolfShade wrote:

... I changed all of my methods to be called via mapping (ie, "components.componentName().methodName(args)") and most of them work!  However, I've got a few that aren't being found, even with using the mapping...

Just use the obvious, standard way,

<cfset obj = createobject("component", "dotted.path.to.componentName")>

<cfset result = obj.methodName(args)>

It leaves no room for ambiguity or error, and makes your code easier to understand and to maintain.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 24, 2015 0
LEGEND ,
May 28, 2015

Copy link to clipboard

Copied

Hi, BKBK‌!

Thanks for replying.  I'm not sure if we're allowed to use CreateObject on the production servers.  And I'm trying to do this via CFSCRIPT as it appears a little cleaner than having all those CFSET tags.  Normally, I don't mind the HTML-style tags, but sometimes I just want less clutter. 

V/r,

^_^

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 28, 2015 0
New Here ,
May 25, 2015

Copy link to clipboard

Copied

I understand that you want to call your private method inside of the CFC.

I do this direktly by using the method name without any prefix:

          methodName()

This works well for me.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 25, 2015 0
LEGEND ,
May 28, 2015

Copy link to clipboard

Copied

Hi, j.herden‌.

You don't use "new" or anything to make sure that the current CFC is referenced?

V/r,

^_^

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 28, 2015 0