• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Chapter 4. Handling a Fuseaction > Section 8: Preparing the Fuseaction

Section 8: Preparing the Fuseaction

Section 8 of the core file prepares the compound fuseaction to be handled separately as a circuit and a fuseaction. We have stripped the error-handling code from this section for compactness in this text. We will go back and cover it fully later. Here is section 8 from the core file:

FB_.rawFA = attributes.fuseaction; 
if (ListLen(FB_.rawFA, '.') is 1 and Right(FB_.rawFA,1) is '.') 
  fusebox.fuseaction = "fusebox.defaultfuseaction"; 
  fusebox.fuseaction = ListGetAt( FB_.rawFA, 2,  '.' ); 
fusebox.circuit = ListGetAt( FB_.rawFA, 1, '.'); 

This is the first section of the core that is mostly CFScript. Why isn’t more of the core in CFScript?

More of the code is not in CFScript because script equivalents aren’t available for many important CFML tags, including <cfinclude> and <cftry> / <cfcatch>. When it is feasible, the core uses CFScript.

This section’s primary purpose is to set three keys in the fusebox structure based on attributes.fuseaction and to utilize one more previously set API variable. The first variable it creates is fusebox.fuseaction, done so by the first if / else block. (The variable FB_.rawFA is in the private structure FB_. The first line in section 8 sets FB_.rawFB to the value of attributes.fuseaction, essentially copying it.)

This variable is created in one of two ways. It is either copied from the second part of the fuseaction, or it is created as the string fusebox.defaultFuseaction if the second part of the passed-in fuseaction is empty.

The string "fusebox.defaultFuseaction" was arbitrarily chosen to be the default fuseaction name. It can then be used in your fbx_switch.cfm like this:

<cfcase value="main,fusebox.defaultFuseaction"> 

When creating page links, you can take advantage of this default fuseaction functionality:

<a href="index.cfm?fuseaction=home."> 

Notice how the fuseaction is a circuit name followed by a period, and how nothing follows it. Usually, the fuseaction appears after the period, but by leaving it off, we are asking the core to change the fusebox.fuseaction to fusebox.defaultFuseaction.

Therefore, fusebox.fuseaction gets set to the second part of the fuseaction or, if blank, gets set to fusebox.defaultFuseaction. What are fusebox.circuit and fusebox.targetCircuit ?

Section 8 creates the second variable with this line:


This line is simple. It copies the first part of the fuseaction into the API variable fusebox.circuit. This variable is referenced further during the processing of the core. It is also helpful during coding to perform certain actions depending on the current circuit. We will discuss this API more during the discussion of layouts and during the application tutorial in Part III of this book, “Fusebox Lifecycle Process (FLiP).

The last API variable set in this section is fusebox.targetCircuit. The difference between this variable and fusebox.circuit is that this variable is the circuit alias that was found in the circuits structure as opposed to the circuit that was requested. In all non-error situations, fusebox.targetCircuit and fusebox.circuit will be the same. The distinction will become clearer as we discuss how the core file uses each one differently.

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint