Experimenting with flashMessages() in ColdFusion on Wheels

Wednesday, August 4th, 2010

On my Labs site, I’ve written another page exploring a view helper coming up in ColdFusion on Wheels version 1.1 called flashMessages(). Read on about it if you want more details, but here’s the gist.

In my layouts, I can reduce this logic:

<cfoutput>
 
<!--- Display error message from the Flash --->
<cfif flashKeyExists("error")>
	<div class="error-message">
		#flash("error")#
	</div>
</cfif>
 
<!--- Display success message from the Flash --->
<cfif flashKeyExists("success")>
	<div class="success-message">
		#flash("success")#
	</div>
</cfif>
 
</cfoutput>

To this line of code:

<cfoutput>
	#flashMessages()#
</cfoutput>

This takes care of 80% of your potential usage of the Flash in Wheels, and it reduces the logic to a single function call. Win!

Leave a Reply