ColdFusion Iterating Business Objects (IBOs) From The Ground-Up

<!--- Kill extra output. --->
<cfsilent>
 
	<!--- Param the tag attributes. --->
 
	<!--- This is the IBO object that we are using to iterate. --->
	<cfparam
		name="ATTRIBUTES.IBO"
		type="any"
		/>
 
 
	<!---
		Check to see which mode of the tag we are executing. This
		tag is being used to loop back over itself using the LOOP
		value of the CFExit tag. When that happens, the Start mode
		of the tag only gets fired once. Every other iteration fired
		the End mode of the tag. Therefore, most of our actions are
		done in the End mode.
	--->
	<cfswitch expression="#THISTAG.ExecutionMode#">
 
		<cfcase value="START">
 
			<!---
				Move the IBO to it's first record. While this is not always
				necessary, if this IBO has already been used for iteration,
				then this is required.
			--->
			<cfset ATTRIBUTES.IBO.First() />
 
		</cfcase>
 
		<cfcase value="END">
 
			<!--- Move on to next row iteration. --->
			<cfset ATTRIBUTES.IBO.Next() />
 
			<!--- Check to see if we have a record to point to. --->
			<cfif ATTRIBUTES.IBO.IsRecord()>
 
				<!---
					We are still at a valid record. Allow this tag to
					execute again. Loop to next record.
				--->
				<cfexit method="LOOP" />
 
			<cfelse>
 
				<!---
					The Next() command we just performed put out IBO outside
					the range of valid records. Do not let this tag execute
					again. Exit out of the tag.
				--->
				<cfexit method="EXITTAG" />
 
			</cfif>
 
		</cfcase>
 
	</cfswitch>
 
</cfsilent>

For Cut-and-Paste