Application.cfc, THIS.mappings & cfinclude
Copy link to clipboard
Copied
hi there
In my Application.cfc
<cfcomponent>
<cfscript>
THIS.name = "myName";
{etc.}
THIS.mappings = StructNew();
mappingname = "/include";
mappingpath = "Z:\webincludes\didi\test\aaisession\appcfc";
THIS.mappings[mappingname] = mappingpath;
</cfscript>
<cfinclude template="/include/appcfc-onApplicationStart.inc" >
{etc.}
does not work!
When I do the mapping in CFadmin, it works. But I need to do it on an application base.
Is this due to the fact, that at the time CF tries to resolve the path of the template, the mapping has not yet been assigned?
How can I overcome this?
-Didi
Copy link to clipboard
Copied
b) having more motivation to refactor someone else's code than I currently do.
Correct answer.
Copy link to clipboard
Copied
Hey, that's why I am here -- to learn
Owain North wrote:
I'd guess your methods are loosely grouped based on function - move each of these out into a separate class, then create an instance in the Application scope. For example:
[SecurityFunctions.cfc]
<cfcomponent name="SecurityFunctions">
[security-based methods]
</cfcomponent>
[Application.cfc]
<cfcomponent>
[onApplicationStart]
<cfset Application.SecurityFunctions = new SecurityFunctions() />
</cfcomponent>
You can then call Application.SecurityFunctions.MyMethod() publicly, or stick it in the variables scope if you'd rather it be private.
I think, this is the way I will follow in the future ..
Thanx to all of you that give us such valuable support here
-Didi
Copy link to clipboard
Copied
I just wanted to get a lean Application.cfc, since I do not like to scroll around in codefiles having hundreds of lines.
I prefer smaller code chunks - that's actually all behind it
You should not structure / design your code (or try things that don't work!) just to appease your laziness.
If you don't want to scroll about in a CFC, use the Outline view. Or bookmarks. Or the Find functionality. Or leverage the inbuilt code folding that CFB provides. Or just stop being lazy!
--
Adam
Copy link to clipboard
Copied
Regarding "BTW: Do you work with CFB2? What version control system are you using?"
I work with Dreamweaver. We use Team Foundation Server for source control. We also develop on a development server as opposed to our local machines.


-
- 1
- 2