Listing 1

<!--- Retrieve the new show id --->
<cfquery datasource="#request.default_dsn#" username="ttnew" password="secretphrase" name="SearchInfo">
	SELECT count(show_id) as mainshowCount, artist_name, artist.artist_id
	FROM show, artist
	WHERE show.artist_id = artist.artist_id
	AND user_id = #thisUserId#
	GROUP BY artist_name, artist.artist_id
	ORDER BY artist_name
</cfquery>

<!--- Retrieve the media counts--->
<cfquery datasource="#request.default_dsn#" username="ttnew" password="secretphrase" name="MediaInfo">
	SELECT count(show_id) as mediashowCount, media_name, media.media_id	
	FROM show, media
	WHERE show.media_id = media.media_id	
	AND user_id = #thisUserId#
	GROUP BY media_name, media.media_id
	ORDER BY mediashowCount DESC
</cfquery>

<cfoutput>

<cfif thisUserId EQ session.user.user_id>
	<span class="headline">My Show List</span><br><br>
<cfelse>
	<span class="headline">
	<a href="##" onClick="popupWindow('#request.root_dir#/members/popup_trader_details.cfm?user_id=#thisUserId#','traderdetails',
'menubar=no,scrollbars=yes,width=475,height=450,top=70');"><span class="headline">#checkForUser.username#</span></a><span class="headline">'s List</span><br><br>
</cfif>

<table border="0" cellspacing="0" cellpadding="0" width="553" align="center">
  	<tr>
		<td bgcolor="##CC6600" rowspan="700"><img src="#request.clear#" width="8" height="1" border="0"></td>
		<td bgcolor="##CC6600"><img src="#request.clear#" width="526" height="1" border="0"></td>
		<td bgcolor="##CC6600" rowspan="700"><img src="#request.clear#" width="1" height="1" border="0"></td>
	</tr>
	<tr>
		<td bgcolor="##FFE198">
			<br><span class="forminstruct">
			  <cfif thisUserId EQ session.user.user_id>You have<cfelse>#checkForUser.username#
			 has</cfif><b>#NumberFormat(numberOfHours,"999,999,999")#</b> hours of music in <cfif
			  getShowInfo.recordCount><a
			  href="#request.root_dir#/members/show_list_detail.cfm?uid=#thisUserId#">#NumberFormat(getShowInfo.recordcount,
"999,999,999")# shows</a><cfelse>0 Hours</cfif></span><br>    
			<cfloop query="MediaInfo">
				<a href="#request.root_dir#/members/show_list_detail.cfm?uid=#thisUserId#&mid=#mediaInfo.media_id#">
#mediaInfo.mediashowCount# #mediaInfo.media_name#</a><cfif mediaInfo.currentrow NEQ mediaInfo.recordcount>,  </cfif>
			</cfloop><br> 
		</td>
	</tr>
	<tr>
		<td bgcolor="##CC6600"><img src="#request.clear#" height="1" width="1" border="0"></td>
	</tr>
	<cfif searchInfo.recordCount>
		<cfloop query="SearchInfo">
			<!--- Get Show Count For Each Artist --->
			<cfquery datasource="#request.default_dsn#" username="ttnew" password="secretphrase" name="showCount">
				SELECT media_name, media.media_id, count(show_id) as showCount
				FROM show, media
				WHERE show.media_id = media.media_id
				AND user_id = #thisUserId#
				AND artist_id = #searchInfo.artist_id#
				GROUP BY media.media_name, media.media_id
			</cfquery>
			<cfset RowColor = "FDF9CE">
			<cfif searchInfo.currentrow MOD 2 EQ 0>
				<cfset RowColor = "FBF49C">
			</cfif>
			<cfset thisArtist = searchInfo.artist_id>
			<tr>
				<td bgcolor="#RowColor#" nowrap><img src="#request.clear#" height="5" width="1"
				 border="0"><br>   #searchInfo.artist_name#  -  <a
				  href="#request.root_dir#/members/show_list_detail.cfm?uid=#thisUserId#&aid=#thisArtist#">#searchInfo.mainshowCount#
 shows</a><br>     <cfloop query="showCount"><a href="#request.root_dir#/members/show_list_detail.cfm?uid=#thisUserId#&aid=#thisArtist#&mid=#showCount.media_id#">
#showCount# #media_name#</a><cfif showCount.currentrow NEQ showCount.recordcount>,  </cfif></cfloop><br><img src="#request.clear#" height="5" width="1" border="0"></td>
			</tr>
			<tr>
				<td bgcolor="##CC6600"><img src="#request.clear#" height="1" width="1" border="0"></td>
			</tr>
		</cfloop>		
	<cfelse>
		<tr>
			<td bgcolor="##FBF49C" align="center">
				<br>
				<cfif thisUserId EQ session.user.user_id>
					<span class="errorred">You have no shows in your list.</span><br><br>
					<a href="#request.root_dir#/members/show_addedit.cfm">Add A Show</a><br><br><br><br><br>
				<cfelse>
					<span class="errorred">#checkForUser.username# has no shows listed.</span><br><br><br><br><br><br><br>
				</cfif>
			</td>
		</tr>
		<tr>
			<td bgcolor="##CC6600"><img src="#request.clear#" width="1" height="1" border="0"></td>
		</tr>
	</cfif>
</table>
</cfoutput>


Listing 2:

CDF Records for TapeTrader Query Results
<?xml version="1.0" ?>
<data jsxid="jsxroot">
  <meta jsxid="meta" traderID="9172" traderName="mpeachey" lastVisit="2006-10-16T13.46.13" email="m@peachey.com"
   totalHours="3517" CassetteHours="812" DATHours="843" SHNHours="971" CDRHours="881" VideoHours="4" DVDAHours="6"/>
  <record jsxid="715" artist_name="ALLMAN BROTHERS BAND" shows="0">
    <record jsxid="357208" date="07/29/2000" media="CDR" media_length="3" venue="" location="" sets="All"
	 gen="Clone" equip="Unknown" source="DAUD" grade="Ungraded" sNotes="" rNotes=""/>
    <record jsxid="98" date="03/01/1996" media="DAT" media_length="180" venue="Beacon Theatre" location="NY"
	 sets="All" gen="Clone" equip="B&K 4021>Tascam DAP1" source="DAUD" grade="A" sNotes="" rNotes=""/>
  </record>

...

  <record jsxid="2711" artist_name="ZED, LEPPLIN" shows="0">
    <record jsxid="13402" date="02/21/2001" media="SHN" media_length="2" venue="- not listed -" location=""
	 sets="All" gen="Clone" equip="Unknown" source="DAUD" grade="A" sNotes="" rNotes=""/>
    <record jsxid="13403" date="02/22/2001" media="SHN" media_length="2" venue="- not listed -" location=""
	 sets="All" gen="Clone" equip="Unknown" source="DAUD" grade="A" sNotes="" rNotes=""/>
    <record jsxid="13404" date="03/03/2001" media="SHN" media_length="2" venue="- not listed -" location=""
	 sets="All" gen="Clone" equip="Unknown" source="DAUD" grade="A" sNotes="" rNotes=""/>
  </record>
</data>


Listing 3:

CDF Records for TapeTrader Query Results


<!---++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
File:			show_list.cfm
Author:			Nate Weisiger
Date Created:	08/23/2006

This script is used to output a trader's entire show list in XML format.
The output XML is will be consumed by the General Interface display application.

Required Imputs:
	URL.trader_id - numeric

Example GI call:
	http://www.tapetrader.com/gi_api/show_list/show_list.cfm?trader_id=9165

 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--->


<cfsilent>

	<!--- Include needed functions --->
	<cfinclude template="../common_functions/prepare_gi_output.cfm">

	<!--- Initialize response XML string --->
	<cfparam name="xmlOutput" default="" type="string">

	<!--- Validate Trader ID is passed in --->
	<cfif NOT isDefined("URL.trader_id") OR NOT isNumeric(trim(URL.trader_id))>
		<cfsavecontent variable="xmlOutput">
			<response success="false">Input Error. Trader ID NOT passed In Or is NOT numeric. URL.trader_id is
			 required.</response>
		</cfsavecontent>
	<cfelse>	
		<!--- Validate that a valid Trader ID was passed in --->
		<cfset thisTraderID = trim(URL.trader_id)>
		<cfquery name="getUserInfo" datasource="#request.default_dsn#" username="ttnew" password="caspian">
			SELECT
				user_id,
				username,
				user_email,
				user_lastvisited
			FROM users
			WHERE user_id = <cfqueryparam value="#thisTraderID#" cfsqltype="CF_SQL_INTEGER">
		</cfquery>
		<cfif NOT getUserInfo.recordCount>
			<cfsavecontent variable="xmlOutput">
				<response success="false">Input Error. Trader ID: <cfoutput>#thisTraderID#</cfoutput> is an
				 invalid trader.</response>
			</cfsavecontent>
		</cfif>
	</cfif>
	
	
	<cfif NOT len(xmlOutput)>

		<!--- Retrieve the media counts for meta tag--->
		<cfquery datasource="#request.default_dsn#" username="ttnew" password="secretphrase" name="MediaInfo">
			SELECT
				count(show_id) as mediashowCount,
				(sum(media_length) * minutes_per_unit) / 60 as total_length,
				media.media_id,
				media_name
			FROM show, media
			WHERE show.media_id = media.media_id
			AND user_id = <cfqueryparam value="#getUserInfo.user_id#" cfsqltype="CF_SQL_INTEGER">
			GROUP BY media_name, media.media_id, minutes_per_unit
			ORDER BY mediashowCount DESC
		</cfquery>

		<!--- Calculate total trader media hours --->
		<cfset totalHours = 0>
		<cfloop query="MediaInfo">
			<cfset totalHours = totalHours + MediaInfo.total_length>
		</cfloop>

		<!--- Get show details --->
		<cfquery name="getShows" datasource="#request.default_dsn#" username="ttnew" password="caspian">
			SELECT
				A.artist_id,
				A.artist_name,
				SH.show_id,
				SH.show_Month,
				SH.show_Day,
				SH.show_Year,
				SH.show_venue,
				SH.show_state,
				SH.sets,
				SH.generation,
				SH.show_notes,
				SH.recording_notes,
				SH.recording_equipment,
				M.media_name,
				SH.media_length,
				G.grade_name,
				SO.source_name
			FROM
				show SH,
				artist A,
				source SO,
				media M,
				grade G
			WHERE SH.artist_id = A.artist_id
			AND SH.source_id = SO.source_id
			AND M.media_id = SH.media_id
			AND G.grade_id = SH.grade_id
			AND SH.user_id = <cfqueryparam value="#getUserInfo.user_id#" cfsqltype="CF_SQL_INTEGER">
			ORDER BY artist_name
		</cfquery>

		<!--- Create return XML for GI application --->
		<cfsavecontent variable="xmlOutput">
			<meta jsxid="meta" traderID="<cfoutput>#getUserInfo.user_id#</cfoutput>"
			 traderName="<cfoutput>#xmlFormat(getUserInfo.username)#</cfoutput>"
			 lastVisit="<cfoutput>#dateFormat(getUserInfo.user_lastvisited,'YYYY-MM-DD')#T#timeFormat
(getUserInfo.user_lastvisited,'HH.mm.ss')#</cfoutput>" email="<cfoutput>#getUserInfo.user_email#</cfoutput>" totalHours="<cfoutput>#totalHours#</cfoutput>" <cfloop query="MediaInfo"><cfoutput>#MediaInfo.media_name#</cfoutput>Hours="<cfoutput>
#MediaInfo.total_length#</cfoutput>" </cfloop> />
			<cfoutput query="getShows" group="artist_id">
				<cfif getShows.currentrow NEQ 1>
					</record>
				</cfif>
				<record jsxid="#getShows.artist_id#" artist_name="#xmlFormat(getShows.artist_name)#" shows="0">
				<cfoutput>
					<record jsxid="#getShows.show_id#" date="#getShows.show_Month#/#getShows.show_Day#/#getShows.show_Year#" media="#xmlFormat(getShows.media_name)#"
 <cfif len(getShows.media_length)>media_length="#getShows.media_length#"</cfif> venue="#xmlFormat(getShows.show_venue)#" location="#xmlFormat(getShows.show_state)#" sets="#xmlFormat(getShows.sets)#"
 gen="#xmlFormat(getShows.generation)#" equip="#xmlFormat(getShows.recording_equipment)#"
  source="#trim(xmlFormat(getShows.source_name))#" grade="#xmlFormat(getShows.grade_name)#"
   sNotes="#xmlFormat(replace(getShows.show_notes,chr(13),'<br>'))#"
    rNotes="#xmlFormat(replace(getShows.recording_notes,chr(13),'<br>'))#" />
				</cfoutput>
				<cfif getShows.currentrow EQ getShows.recordCount>
					</record>
				</cfif>
			</cfoutput>
		</cfsavecontent>
	</cfif>

	<!--- Set up xml for return to GI application --->
	<cfset xmlOutput = prepareGiOutput(xmlOutput)>

	<!--- Set content type --->
	<cfcontent type="text/xml; charset=utf-8">

</cfsilent>

<cfoutput>#xmlOutput#</cfoutput>

<!---++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
File:			prepare_gi_output.cfm
Author:			Nate Weisiger
Date Created:	09/04/2006

This function (prepareGiOutput) is used to:
	- Add XML header tag
	- Add standard GI root node
	- Remove extra, unneeded whitespace

Required Imputs:
	xmlOutput - Sting (Body XML)

Returns:
	Formated XML based on GI application standards

 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--->
 
 <cffunction name="prepareGiOutput" access="private" returntype="string" output="No">
 
	<!--- Initialize arguments --->
	<cfargument name="xmlOutput" required="Yes" type="string">

	<!--- Initialize return var --->
	<cfset var giOutput = "">
	
	<!--- Add header and root node --->
	<cfsavecontent variable="giOutput">
		<?xml version="1.0" encoding="UTF-8"?>
		<data jsxid="jsxroot"><cfoutput>#trim(xmlOutput)#</cfoutput></data>
	</cfsavecontent>
	
	<!--- Clean up unneeded white space --->
	<cfset giOutput = replace(giOutput,"	","","ALL")>
	<cfset giOutput = replace(giOutput,chr(10),"","ALL")>
	<cfset giOutput = replace(giOutput,chr(13),"","ALL")>
	
	<!--- Return prepared XML string --->
	<cfreturn giOutput>
 
 </cffunction>
 

Listing 4

// File:			logic.js

/**
 * Static class to control the display and filtering of tape trader show lists
 */
jsx3.lang.Package.definePackage("com.tapetrader.shows", function(shows) {

  //local variables
  var newWindow1, newWindow2, newWindow3;
  showlist._responsetimeout

  /**
   * Called by the 'onload' event for the application/project.
   * NOTE: uses local test data when running off the file system.
   * NOTE: Open the 'project setting dialog' in GI Builder to see where the call originates.
   */
  shows.requestData = function() {
    //assume that the web page that this app is embedded in has an overloaded URL with the traderID
    var objURI = new jsx3.net.URI(window.location.href);
    var strTraderId = objURI.getQueryParam("trader_id");

    //get the path for the data set to use; use test data if a trader_id was not passed
    var strURL = (!strTraderId) ?
      showlist.resolveURI("xml/sample_data.xml") :
      "/gi_api/show_list/show_list.cfm?trader_id=" + strTraderId;

    //contact the server for the user data (in CDF format). Use an asynchronous call for better perceived performance
    var objHttp = new jsx3.net.Request("myrequest");
    objHttp.open("GET",strURL,true);
    objHttp.subscribe(jsx3.net.Request.EVENT_ON_RESPONSE,shows,"onServerResponse");
    objHttp.send();
  };


  /**
   * Called when the server responds to the data request. Repaints affected on-screen controls to display the returned
    data.
   * @param objEvent {Object} JavaScript map of name/value pairs. This object is published by the event dispatcher when
    the server responds with data
   */
  shows.onServerResponse = function(objEvent) {
    //the event 'target' is the jsx3.net.Request instance comminicating with the remote server
    var objHttp = objEvent.target;

    //get the XML data and place in the cache (use two pointers to the same document).
    //the first document pointer will serve as the master document reference. the second is the 'filtered' instance
    var objCdfDocument = objHttp.getResponseXML();
    showlist.getCache().setDocument("master_source_xml",objCdfDocument);
    showlist.getCache().setDocument("source_xml",objCdfDocument);

    //call method to display filtered data (data limited per the audio type--for now, ALL is the filter, meaning show
	 everything on the initial paint)
    this.filter("ALLHours");

    //Method 1: run the mapping rules to extract values from the server's response document and insert them into
	 various UI text blocks
    var objService = showlist.loadResource("mymappings_xml");
    objService.setInboundDocument(objCdfDocument);
    objService.doInboundMap();

    //Method 2: repaint those objects that consume the server data (these are jsx3.gui.Block instances that leverage
	 custom XSLT to create their view)
    showlist.getJSXByName("xRollup").repaint();
  };