Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Application.cfc, THIS.mappings & cfinclude

Explorer ,
Apr 05, 2012 Apr 05, 2012

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

TOPICS
Server administration
9.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 09, 2012 Apr 09, 2012

b) having more motivation to refactor someone else's code than I currently do.

Correct answer.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 09, 2012 Apr 09, 2012

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 09, 2012 Apr 09, 2012

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 09, 2012 Apr 09, 2012
LATEST

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.

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