For Adobe ColdFusion application servers How do I use TerraForm in a Fusebox application?

To use TerraForm within a Fusebox application, you need to change two settings.

  1. A Fusebox app works primarily in the attributes scope, so you need to tell TerraForm to retrieve from and write to this scope instead of the form scope.
  2. TerraForm works by ensuring that any form is submitted back to itself for validation. Therefore it needs to know the format of the appropriate URL. This is different in Fusebox.

Open customtags/terraform/defaults.cfm and make the following changes:

  1. Find the line that begins:
    <cfparam name="Attributes.Action"...
    and replace it with:
    <cfparam
      name="Attributes.Action"
      default="index.cfm?fuseaction=#Caller.Attributes.FuseAction#"
    >
    (note that caller. is used as we are accessing this value from within a custom tag).

  2. Find the line that begins:
    <cfparam name="Attributes.Scope"...
    and replace it with:
    <cfparam name="Attributes.Scope" default="ATTRIBUTES">

That's it! You're ready to make a TerraForm form in Fusebox. In your fusebox (the cfswitch statement) you could call the form like this:

<cfcase value="displayform">
  <cfinclude template="frm_myform.cfm">          <!--- this is the form --->
  <cfif attributes.myform EQ "Valid">
    <cfinclude template="act_myform.cfm">        <!--- process the form data --->
    <cflocation
      ="index.cfm?fuseaction=myform.thanks">  <!--- jump to a follow-up page --->
  </cfif>
</cfcase>

Remember that when you call frm_myform.cfm initially, it will display the form. After the page has been submitted, instead of displaying the form, frm_myform.cfm will validate the form. If the form fails validation then frm_myform.cfm will display it, otherwise it will set attributes.myform to "Valid" but display nothing.

Note that if you use a custom validation template, all your attributes-scoped variables will need to be addressed with a prefix: caller., such as caller.attributes.myValue. The reason for this is that code inside custom tags occupies a new scope, and your custom template is included into the cf_terraform tag, effectively extending its functionality.

A sample is available for download in the Code Gallery.

Uniform Resource Locator
No comments yet