Comparing circuit.xml.cfm to circuitName.cfc in Fusebox 5.5

circuit.xml.cfm (Fusebox 4 – 5.5)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE circuit>
<circuit access="public">
	<fuseaction name="List" access="public">
		<if condition="#StructKeyExists(attributes, 'user_id')#">
			<true>
				<set name="attributes.reminder_user_id" value="#attributes.user_id#" />
			</true>
		</if>
		<include circuit="mReminders" template="actGetReminders" />
		<include circuit="vReminders" template="dspListReminders" contentvariable="content.main" />
	</fuseaction>
	<prefuseaction>
		<xfa name="Calendar" value="Calendar.Month" />
	</prefuseaction>
</circuit>

CFC as a circuit with Fusebox 5.5

<cfcomponent output="false">
	<cffunction name="List">
		<cfargument name="myFusebox" />
		<cfargument name="event" />
		<cfif event.ValueExists('user_id')>
			<cfset event.setValue("reminder_user_id", event.GetValue('user_id')) />
		</cfif>
		<cfset myFusebox.do( action="mReminders.actGetReminders" ) />
		<cfset myFusebox.do( action="vReminders.dspListReminders", contentvariable="content.main" ) />
	</cffunction>
	<cffunction name="prefuseaction">
		<cfargument name="myFusebox" />
		<cfargument name="event" />
		<cfset event.xfa("Calendar", "Calendar.Month") />
	</cffunction>
</cfcomponent>

3 thoughts on “Comparing circuit.xml.cfm to circuitName.cfc in Fusebox 5.5

  1. You can see why I write controller CFCs in cfscript. The above becomes:

    <cfscript>
    function list(myFusebox,event) {
    if (event.valueExists(‘user_id’) {
    event.setValue(“reminder_user_id”,event.getValue(‘user_id’));
    }
    myFusebox.do(action=”mReminders.actGetReminders”);
    myFusebox.do(action=”vReminders.dspListReminders”, contentvariable=”content.main”);
    }
    function prefuseaction(myFusebox,event) {
    event.xfa(“Calender”,”Calendar.Month”);
    }
    </cfscript>

    Hope that doesn’t get too horribly mangled by wordpress!

  2. Hi Sean, it’s an honour to have a post from you 🙂

    The cfscript version is definitely cleaner. I went for the above partly because I’ve been using the syntax from the “Fusebox 5.5 Release Notes” pdf (http://preview.tinyurl.com/yvkxjk) to get started. I was also thinking about adding the hint to cffunction attribute to make the whole app self documenting.

  3. Yeah, when I wrote the Release Notes I wasn’t sure how folks would react to all-script components 🙂 I write a lot of my CFCs as cfscript now – the enhancements to the operators in CF8 made more difference to my style than I would have imagined.

Leave a comment