hal helm's logo  

Computers are incorporated in modern ice cream vending machines to enhance their functionality. Ice Cream Vending machines are manufactured by many companies. Your competition will try to overcome all requests for high-tech ice cream vending machines and credit card acceptors
home Home

training Training

writing Writings

code Code

tutorials Tutorials

newsletters Newsletters

consulting Consulting

Hal Helms logo
hal.helms

What Students Say...

"The best class I've ever taken, by far." - Frank D

"I really like your casual approach and the way you keep everyone involved. Well done!" - Roger R.

"I was extremely satisifed with the class and impressed with your patience. Paying for the class myself, I was very, very worried about feeling like I didn't get my money's worth. I have no doubt the class was much more than worth it and hopefully I can attend another training with you" - Sarah S.

newsletters section Untitled Document
 
Fusebox Conference Issue
 
FastTrack to Fusebox 3.0
3-6 December
The Venetian
Las Vegas, NV USA


Hal Helms & John Quarto-vonTivadar and you.
Learn Fusebox 3!
Back from the Conference
We just finished up with a fantastic conference. Despite all of the events that seemed to conspire to keep Fuseboxers away, the Fusebox community showed up in force. There were over 200 of us at the conference, a fact that impressed Jeremy Allaire, our keynote speaker. Many Fuseboxers came at considerable cost and inconvenience, several from other countries. It was really tremendous to be a part of this. You folks rock.

For those of you who wanted to make it, but just couldn't, we have a "Conference in a Box". This includes sample code, 80-page whitepaper, speaker Powerpoints and video of the keynote. The price on this is US $97 with keynote video and US $74 without keynote video. You can order it from here. The rest of this newsletter is devoted to the key features of Fusebox 3. If you want an immersion course in Fusebox 3.0, consider coming to the FastTrack to Fusebox 3.0 class John Quarto-vonTivadar and I are teaching 3-6 December in Las Vegas. Details at www.halhelms.com under TRAINING.

Nested Circuits and Layouts
(Portions of the following are taken from the Fusebox Conference whitepaper written by John Quarto-vonTivadar and me.)

When we discuss nesting a fusebox, we refer to the integration of multiple fuseboxes into a singular application--or the partition of a fusebox application into a multiple fuseboxes. In either case, the result will be a series of one or more physical file directories that are so integrated that the end user would find his experience to be indistinguishable from a singular (and very large) fusebox.

In Fusebox 2, there was some small measure of integration between separate fuseboxes but it consisted largely of sending a browser from one insular fusebox to another. But the true goal is a "drag-and-drop" type of functionality, wherein a fusebox consists of one of more circuits (a file directory), all of which can access each other without direct dependence on the underlying directory structure, and that, when done, can be drag-and-dropped to another fusebox, requiring only a few small settings changed to the definition of the circuits.

In Fusebox, we typically had a home circuit with several child circuits. In Fusebox 3.0, this idea has been extended to allow for parent/child relationships among circuits. I have built a small example application to show a four-level nested application, available at www.halhelms.com under the CODE section. Here is its circuit structure

If this type of nesting is combined with a some sort of a standard with respect to how a fusebox operates within its own framework, we gain the ability to write large amounts of reusable code. If we further adhere strictly to a standard for doing that, like Fusebox3.0, then people can write entire applications that can be stamped as "Fusebox 3.0 compliant" and which can then be dropped into our own code, saving time and money.

When thinking about nesting in Fusebox 3.0, it will be helpful to keep a few ideas in mind. The first is that even though Fusebox is not an object-orientated methodology (nor is ColdFusion an OO language), it is helpful to retain some of the best ideas from OO. One of these is that a the idea of encapsulation--that a given object (or circuit, in our case)--should be as independent as possible of other objects. Fusebox 3.0 has its own concept of inheritance that, while very different from OO languages, still allows children to inherit properties from their parent, grandparent, etc.

The second idea to keep in mind is a visual one: as each of these circuits gets drag-and-dropped into a parent circuit, we are reminded of wooden Russian dolls thatto reveal another doll. This pattern continues for as long as the artistry of the maker can sustain itself. In Fusebox 3.0, the grandparent circuit may contain one or more parent circuits, that, themselves, may contain one or more child circuits-and so on.

Nesting/inheritance in Fusebox 3.0 is done for you automatically by the core fusebox file, FBX_Fusebox_CFxx.cfm. One of its functions is to handle nesting, which it does in the following manner: each circuit from the top "home" circuit down each intervening circuit to the target circuit, has a settings file, called FBX_Settings.cfm. The more global an item in a settings file is, the "higher up" the circuits tree that item would be loaded. So if your application accesses a datasource called customers, you may want to set Request.DSN in the home circuit.

But suppose you dropped in a shopping cart circuit, which itself needs a products datasource. It might set one as part of its own settings file since that DSN may only be needed by that circuit or one of its child circuits. Of course, you, as the architect of your program, can determine whether you want to force it to have a certain value by using cfset or whether you want it to inherit a value from a higher level circuit-if such a value has already been set-by using a cfparam. In earlier versions of Fusebox, you included the app_globals.cfm once, and then used app_locals.cfm for all second-tier circuits. In Fusebox 3.0, there is no hard meaning to "global" or "local"--anything set in a circuit is available to all circuits nested beneath that circuit. Again, remember the Russian Doll; this is where we've taken it apart and gotten into smaller and smaller pieces. Further, circuits initially written as parents may find themselves incorporated into larger applications, where they become child circuits.

Once all the settings (via the FBX_Settings.cfm files) have been inherited-in order-from the home circuit to the target circuit, we then "reach" into the target circuit to examine its FBX_Switch.cfm in order to execute the target fuseaction within that circuit. This central switch concept has not changed from Fusebox 1.0.

That fuseaction may fire off one or more fuses. This is where you will also set any XFAs required by the fuses(s). You will find that breaking your fuses up into smaller component fuses will leave you with more re-usable code for your next application. Many times people will break out the query fuses this way, to separate them from the display or action fuses that use them or to use their XFAs (exit fuseactions) to set values for an URL fuse to further distinguish between performing an action for the application versus performing a relocation for the user.

In Fusebox 1.0 and 2.0 this is where the Fusebox would have finished, having completed its mission of executing a fuseaction. It's the Russian doll again: now we've gotten to the very heart of the toy, and weup that final itsy-bitsy doll and find a piece of candy, the fuse.

Next, the fusebox will now walk "up" the tree from the bottom "target" circuit where the fuseaction was found, up through each parent circuit up to the home circuit. Each of those circuits, in order, will have the opportunity to apply its own layout as determined by the FBX_Layouts file. If you've followed the Russian doll analogy, we're beginning to put back together each of the larger and larger dolls take what they got from the smaller doll and wrap their own wrapper around it, all the way up until the largest doll, the home circuit, that encompasses everything.

That's it. It's a pretty simple process if you keep the Russian doll in mind. And even so, most of the time you won't have much stuff in the deeper level FBX_Settings files, and even less often will you have multiple levels of layout to be applied from the deeper level layouts files. In subsequent newsletters, we're doing to take a deeper look at applying layout files but suffice it to say that most of your use of it will be to apply GUI design elements such as logos, meta tags, graphic interface components, primary and secondary navigational links and the like to the real target of what you what your visitor to be concentrating on: that little nugget of candy in the center of the doll, commonly referred to as "content".

Calling Fusebox 3.0 Applications Recursively
In this section, we'll look at an example of calling the application recursively--from within itself--as a custom tag. Though the example is simple, the technique itself is very helpful and can provide functionality that would be difficult to achieve without using it.

In my sample application, within the Grandparent/FBX_Settings.cfm file, I set the default fuseaction to Grandchild.sayHi. For the example, I've had each circuit set its own layout file. The layout files do nothing more than define a style for that circuit, declare the circuit alias, and then output the preceding content in a table. Here, for example, is the code for the layout file for the Child circuit, SayWho.cfm.
<cfoutput>
<style>
.#Fusebox.thisCircuit# {
  border : groove;
  margin : 14;
}
</style>

<table class="#Fusebox.thisCircuit#">
  <tr>
    <td>
      <font size="-2">Don't mind me, I'm just the #Fusebox.thisCircuit#
    </td>
  </tr>
  <tr>
    <td>
      #Fusebox.layout#
    </td>
  </tr>
</table>
</cfoutput> 

I've altered the style definition for each circuit slightly. The end result looks like this:


All that's going on is that the grandchild is saying "Hi there"-not much of a fuse. Let's say, though, that while we're executing the fuseaction, grandchild.sayHi, we suddenly realize (probably based upon some condition that is true in some cases) that we need to execute another fuseaction. We want to execute a new fuseaction in the background without the user noticing that anything is going on.

To effect this, we'll call the application itself as a custom tag from within our fuse. The new fuse code will look like this:
<cfoutput>
  <cfmodule template="#Fusebox.RootPath#/#self#" fuseaction=#XFA.writeTime#>
</cfoutput>

<table>
  <tr>
    <td>
      Hi there!		
    </td>
  </tr>
</table>

Note that we use one of the new Fusebox API variables, Fusebox.RootPath, to refer back to the home circuit, where we call self (index.cfm in our case) and send a variable called fuseaction. When custom tags are called-and here, we're calling self as a custom tag-it must use the attributes. prefix to refer to variables passed into it. It is just this case that prompted the idea of copying all form and url variables to the attributes scope. Once that is done, all references to variables passed-including fuseaction-can use the attributes. prefix, regardless of whether called as custom tag or called directly.

In the grandchild circuit's FBX_Switch.cfm file, I've set XFA.writeTime to child.writeTimeToFile. This fuseaction calls act_WriteTimeToFile.cfm that has this code:
<cffile 
  action="WRITE" 
  file="c:\inetpub\wwwroot\test\timeFile.txt" 
  output="#Now()#">
Now, when I call the fuseaction, grandchild.sayHi, I see this:


Something's gone wrong-and that something is that even though we're still applying layout when the custom tag code is executing. That means that it is applied when the custom tag is called, then again when the grandchild.sayHi fuseaction resumes.

Clearly, we don't want this--and there are a couple of solutions to the problem. If you, as application architect, decide that you do not want your layouts applied when the application is called as a custom tag, you can make use of the Fusebox API variable, Fusebox.isCustomTag. This would be applied to the circuits' FBX_Layouts.cfm files like this:
<cfif Fusebox.isCustomTag>
  <cfset fusebox.layoutFile = "">
  <cfset fusebox.layoutDir = "">
<cfelse>
  <cfset fusebox.layoutFile = "SayWho.cfm">
  <cfset fusebox.layoutDir="">
</cfif>
Fusebox.isCustomTag is a Boolean variable that returns TRUE if self is called as custom tag and FALSE otherwise. Now, if I run the code, I see the code without the extraneous layouts, I lose the extra baggage, as shown in the first screenshot of the program executing.

This is probably the way you'll want to handle it most of the time. Occasionally, rather than using this blanket approach, you'll want to determine on an individual basis which fuseactions should not use the layout file. One approach is to set a variable in the <cfcase> statement of FBX_Switch.cfm that can be read by FBX_Layouts.cfm. Here is the <cfcase> statement for child.writeTimeToFile:
<cfcase value="writeTimeToFile">
  <cfset suppressLayout = TRUE>  
  <cfinclude template="act_WriteTimeToFile.cfm">
</cfcase>
Though the variable, suppressLayout, is not part of the Fusebox specification (notice that it is not part of the Fusebox structure), you may want to adopt it-or something similar to it-so that by convention your FBX_Layouts.cfm files can react to it:
<cfparam name="suppressLayout" default="FALSE">

<cfif suppressLayout>
  <cfset fusebox.layoutFile = "">
  <cfset fusebox.layoutDir = "">
<cfelse>
  <cfset fusebox.layoutFile = "SayWho.cfm">
  <cfset fusebox.layoutDir="">
</cfif>
Shameless Plugging Redux
We'll cover all of this--and a great deal more--in depth at our Las Vegas training class. Hope to see you there. Registration is at http://www.halhelms.com/index.cfm?fuseaction=training.detail.

hal helms' personal site Updates

Computers are incorporated in modern ice cream vending machines to enhance their functionality. Ice Cream Vending machines are manufactured by many companies. Your competition will try to overcome all requests for high-tech ice cream vending machines and credit card acceptors

teamallaire.com v 4_3
©copyright      designed by in-tuition.co.uk