An Architect's View

CFML, Clojure, Software Design, Frameworks and more...

An Architect's View

Fusebox 5 - The Power of Custom Lexicons

April 16, 2006 ·

I leave this example to speak for itself... fusebox.xml:
<fusebox xmlns:mg="ModelGlue/" mg:root="fbmg">
   <classes>
      <class alias="controller" classpath="fbmg.controller.Controller"
         mg:needStuff="getStuff" />
   </classes>
   <circuits>
      <circuit alias="do" path="controller/" />
   </circuits>
   <parameters>
      <parameter name="mode" value="development-no-load" />
      <parameter name="defaultFuseaction" value="do.welcome" />
   </parameters>
</fusebox>
circuit.xml:
<circuit access="public" xmlns:mg="ModelGlue/" mg:viewMappings="views/">
   <fuseaction name="welcome">
      <mg:broadcasts>
         <mg:message name="needStuff" />
      </mg:broadcasts>
      <mg:views>
         <mg:include template="main.cfm" />
      </mg:views>
   </fuseaction>
</circuit>
Controller.cfc:
<cfcomponent name="Controller">
   <cffunction name="getStuff" returntype="void" access="public" output="true">
      <cfargument name="attrs" type="struct" required="true" />
      <cfset arguments.attrs.stuff = "1234" />
   </cffunction>   
</cfcomponent>
views/main.cfm:
<cfoutput>
   <p>This is the main Model-Glue view.</p>
   <p>This is the stuff: #viewState.getValue('stuff')#.</p>
</cfoutput>
This is using what will be the Alpha 2 codebase...

Tags: coldfusion · fusebox · modelglue

7 responses

  • 1 Nick Tong // Apr 16, 2006 at 1:17 AM

    Neat, can't wait to get my hands on it.
  • 2 Mike Kear // Apr 16, 2006 at 5:28 AM

    Well perhaps for those of us less attuned to the voices of framework code, can you please explain what the example is saying while it's speaking for itself??
  • 3 Sean Corfield // Apr 16, 2006 at 10:29 AM

    Mike,

    The example above uses a custom lexicon (&quot;ModelGlue&quot;) that contains a handle of custom verbs I wrote (&quot;broadcasts&quot;, &quot;message&quot;, &quot;views&quot;, &quot;include&quot;) to allow Fusebox applications to be written in the style of Model-Glue applications - there's no Model-Glue framework here, just a similar grammar style. It's intended to show how custom lexicons let you extend the Fusebox grammar.

    In terms of &quot;speaking for itself&quot;, I'm assuming readers know both Fusebox and Model-Glue...

    I think it also shows how custom lexicons let you seamlessly use CFCs with Fusebox which was one of my goals for this release.
  • 4 John Farrar // Apr 26, 2006 at 6:55 PM

    This is progressive and double KUDOS Sean!!! While some developers may not benifit (or even know how to use XML, Lexicons and such... that is not the point). What you have claimed here is excellent! This could be the another step in the &quot;right&quot; direction for CF. We need more methodologies where the systems work together as community solutions. Fusebox and Model-Glue working together is great for MVC cross application development! This can only work for the good of the community.
  • 5 Stephen Cassady // Jan 24, 2007 at 8:59 AM

    Is there an updated or release-stable version of MG through FB available?

    I really want to take Canvas Wiki and drop it into a FB format and the lexicon would be a great process.
  • 6 Sean Corfield // Jan 25, 2007 at 8:15 AM

    @Stephen, the most up to date version (based on the concepts in Model-Glue 1.0 - be warned!) was discussed in this blog entry with a download link:

    http://corfield.org/entry/Fusebox_5_in_a_ModelGlue_style
  • 7 Stephen Cassady // Jan 25, 2007 at 1:40 PM

    @Sean - warned I am but also a fantastic thankyou as well for the starting point. Yummy! :-)