Switch file

From Wikipedia, the free encyclopedia

The Fusebox switch file fbx_switch.cfm decides which fuses to call to accomplish the requested fuseaction. It is basically a CFSWITCH statement on the fuseaction variable with one or more CFLINCLUDEs to fuse files that do the actual work; the display (dsp_*.cfm), CFML actions (act_*.cfm) or SQL queries (qry_*.cfm). The resulting HTML is captured using CFSAVECONTENT by the Fusebox core file. It is then displayed by the layout file specified in this circuits fbx_layouts.cfm file. This helps separate graphical layout from code. The resulting HTML is passed back up through the parent circuits providing for nest layout of menu options. Similarly as errors are caught by the fbx_errorCatch.cfm file and may be optionally bubbled up through the parent circuits to the root circuit.

Finally the core file outputs the completed nested layout. Layouts may also be selected based on user interaction or personalization settings. A simple fbx_switch.cfm is shown below.

<cfswitch expression = "#fusebox.fuseaction#">

<cfcase value="showInputForm">
<cfset XFA.add = "admin.add">
        <cfset XFA.edit = "admin.edit">
        <cfset XFA.delete = "admin.delete">
        <cfinclude template="dsp_InputForm.cfm">
</cfcase>

<cfcase value="showEmployeeList">
<cfinclude template="qry_EmployeeList.cfm>
<cfinclude template="dsp_EmployeeList.cfm>
</cfcase>

<cfdefaultcase>
        <cfoutput>I received a fuseaction called #fusebox.fuseaction#" that circuit "#fusebox.circuit#" doesn't have a handler for.</cfoutput>
</cfdefaultcase>

</cfswitch>

[edit] See also

Fusebox (programming)