How to replace < with < in ColdFusion - regex

I'm creating an XML document from database entries using ColdFusion and when the XML is created the < and > are in the format of < and >. So before it creates the XML is there a way to change the < to a <?
Below is the code and an example of the output:
<cfquery name="messages" datasource="showcase_Uk">
select * from t_items where pid = 2 and spid = 45
</cfquery>
<cfset myStruct = StructNew() />
<cfset mystruct.link = "http://showcase.com" />
<cfset myStruct.title = "Examples" />
<cfset mystruct.description = "Examples from UK Showcase" />
<cfset mystruct.pubDate = Now() />
<cfset mystruct.version = "rss_2.0" />
<cfset myStruct.item = ArrayNew(1) />
<cfloop query="messages">
<cfset myStruct.item[currentRow] = StructNew()>
<cfset myStruct.item[currentRow].guid = structNew()>
<cfset myStruct.item[currentRow].guid.isPermaLink="YES">
<cfset myStruct.item[currentRow].guid.value = xmlFormat(#messages.id#)>
<cfset myStruct.item[currentRow].pubDate = createDate(year(#messages.uploadDate#), month(#messages.uploadDate#), day(#messages.uploadDate#))>
<cfset myStruct.item[currentRow].title = xmlFormat(#messages.name#)>
<cfset myStruct.item[currentRow].description = StructNew() />
<cfset myStruct.item[currentRow].description.value = xmlFormat(#messages.description#)>
</cfloop>
<cffeed action="create" name="#myStruct#" overwrite="true" xmlVar="myXML">
<cffile action="write" file="e:\domains\showcase.com\wwwroot\ukshowcasefeed.xml" nameconflict="overwrite" output="#XMLFormat(myXML)#">
<cffile action="read" file="e:\domains\showcase.com\wwwroot\ukshowcasefeed.xml" variable="myfile">
<cfoutput>#myfile#</cfoutput>
Then here is a screenshot of the code it produces:
I've tried ReplaceNoCase and that doesn't change it at all. I believe it maybe something to do with Regex but I don't really know.

Simple answer:
Don't XmlFormat() when you write the file, that's what causes the double encoding you see.
Longer answer:
I recommend you use mapping to create your feed:
<cfquery name="messages" datasource="showcase_Uk">
select
id, uploadDate, name, description, 'yes' as isPermaLink
from
t_items
where
pid = 2 and spid = 45
</cfquery>
<cfset feedMeta = {
version: "rss_2.0",
title: "Examples",
link: "http://showcase.com",
publisheddate: Now(),
description: "Examples from UK Showcase"
}>
<cfset feedMap = {
title: "name",
content: "description",
publisheddate: "uploadDate",
id: "id",
idpermalink: "isPermaLink"
}>
<cffeed
action="create"
properties="#feedMeta#" columnMap="#feedMap#" query="#messages#"
xmlvar="feedXml"
>
<cffile
action="write"
file="#ExpandPath('/ukshowcasefeed.xml')#" nameconflict="overwrite" charset="utf-8"
output="#feedXml#"
>
Note the easy declarative approach to feed creation. No loops, no manual struct creation, only data-driven mapping of input to output.
Also note the charset="utf-8" on the <cffile>, that's essential if you don't want to run into encoding problems.
If you modify your query so that it has the correct column names right-away, then you don't even need the feedMap structure:
<cfquery name="messages" datasource="showcase_Uk">
select
id,
'yes' as idpermalink
uploadDate as publisheddate,
name as title,
description as content
from
t_items
where
pid = 2 and spid = 45
</cfquery>
<cffeed
action="create"
properties="#feedMeta#" query="#messages#"
xmlvar="feedXml"
>

Related

How to use ZingCharts utility with my existing code in ColdFusion 11?

I recently migrated my application from ColdFusion 10 to ColdFusion 11. Though the migration was successful, the charts have been destroyed.
Up until ColdFusion 10 there was a WebCharts JAR file, called wc50.jar, in the \lib directory. It contained, amongst others, chart modules such as com.gp.api.jsp.MxServerComponent. That JAR file is absent from ColdFusion 11. Hence we have decided to update the our "charting code" and decided to use the new ZingChart.
ZingChart is JSON based. I analysed and found there is a utility in ColdFusion 11 for us to convert the XML stuff to JSON. The name of the utility is cfchart_xmltojson.bat. So this is my analysis by far. My question is - how to run/use this utility to do conversion and then modify my charting code?
My current charting code look something like this:
<cfsaveContent variable="chartStyle">
<cfoutput>
<?xml version="1.0" encoding="UTF-8"?>
<frameChart isMultiline="false" is3D="#is3D#">
<frame outline="##666666"/>
<yAxis scaleMin="0" scaleMax="100"/>
<legend allowSpan="true" equalCols="false" placement="Right" isMultiline="true">
<decoration style="None"/>
</legend>
<cfif ShowPyramidNums>
<dataLabels style="value" placement="Inside" font="Arial-12-bold" >
</dataLabels>
</cfif>
<elements place="Stacked" shape="PyramidCut" shapeSize="100">
<movie framesPerSecond="2"/>
<cfset sPerfCtr = 0>
<cfloop index="i" from="#q_PerformanceDetailsByTemp.RecordCount#" to="1" step="-1">
<series index="#Evaluate(sPerfCtr)#">
<paint color="###q_PerformanceDetailsByTemp.ChartColor[i]#"/>
</series>
<cfset sPerfCtr = sPerfCtr+1>
</cfloop>
</elements>
<table>
<decoration style="Shadow"/>
</table>
<background maxColor="white"/>
<decoration foreColor="white" backColor="##90FFFF"/>
<popup showOn="Disabled" isAntialiased="true"/>
<paint palette="Transluent" paint="Plain" max="52"/>
</frameChart>
</cfoutput>
</cfsaveContent>
<cfsavecontent variable="chartModel">
<cfoutput>
<?xml version="1.0" encoding="UTF-8"?>
<XML type="default">
<COL>Fall</COL>
<COL>Winter</COL>
<COL>Spring</COL>
<cfset over100FallFixed = false>
<cfset over100WinterFixed = false>
<cfset over100SpringFixed = false>
<cfloop index="i" from="#ArrayLen(PerfStats)#" to="1" step="-1">
<cfset rowVal = Evaluate((1/q_PerformanceDetailsByTemp.recordCount)*100)>
<cfif isDefined("over100Alert")>
<!--- This set of if statements is to modify value to show triangle correctly --->
<!--- Without this modification, the total ia 100.1 which cuts off the top of the triangle --->
<cfif right(PerfStats[i].FallPercentage, 1) GT 0 AND NOT over100FallFixed>
<cfset PerfStats[i].FallPercentage = PerfStats[i].FallPercentage - .1>
</cfif>
<cfif right(PerfStats[i].WinterPercentage, 1) GT 0 AND NOT over100WinterFixed>
<cfset PerfStats[i].WinterPercentage = PerfStats[i].WinterPercentage - .1>
</cfif>
<cfif right(PerfStats[i].SpringPercentage, 1) GT 0 AND NOT over100SpringFixed>
<cfset PerfStats[i].SpringPercentage = PerfStats[i].SpringPercentage - .1>
</cfif>
<ROW col0="#PerfStats[i].FallPercentage#" col1="#PerfStats[i].WinterPercentage#" col2="#PerfStats[i].SpringPercentage#">% #PerfStats[i].Name#</ROW>
<cfelse>
<ROW col0="#round(PerfStats[i].FallPercentage)#" col1="#round(PerfStats[i].WinterPercentage)#" col2="#round(PerfStats[i].SpringPercentage)#">% #PerfStats[i].Name#</ROW>
</cfif>
</cfloop>
</XML>
</cfoutput>
</cfsavecontent>
<cfscript>
ImageName = "TierTrans_" & CreateUUID() & ".png";
oMyWebChart = createObject("Java","com.gp.api.jsp.MxServerComponent");
oMyApp = getPageContext().getServletContext();
oSvr = oMyWebChart.getDefaultInstance(oMyApp);
oMyChart2 = oSvr.newImageSpec();
if(NOT Session.PDFIng)
{
oMyChart2.width = 650;
} else
{
oMyChart2.width = 550;
}
oMyChart2.height= 230;
oMyChart2.type = "png";
oMyChart2.style = "#chartStyle#";
oMyChart2.model = "#chartModel#";
</cfscript>
<cfif NOT DirectoryExists(ImagesDir)>
<CFDIRECTORY ACTION="CREATE" DIRECTORY="#ImagesDir#">
</cfif>
<!--- Save image to a different location --->
<cfset oSvr.saveBytesTo(oMyChart2,"#ImagesDir##ImageName#")>
<cfoutput><img src="Images/Reports/#ImageName#" border="0"/></cfoutput>
It used to draw a chart something like the image below. (The watermark you see is because I copied the wc50.jar from ColdFusion 10 directory to ColdFusion 11 lib directory):

Adding Colored Events to the Calendar

I have the following working Calendar page (lqCalendar.cfm) that places events from MySQL to the calendar.
<html>
<head>
<link rel="stylesheet" href="../fullcalendar-3.1.0/fullcalendar.min.css" />
<script src="../fullcalendar-3.1.0/lib/jquery.min.js"></script>
<script src="../fullcalendar-3.1.0/lib/moment.min.js"></script>
<script src="../fullcalendar-3.1.0/fullcalendar.min.js"></script>
<script>
$(document).ready(function() {
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
var calendar = $('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
selectable: true,
selectHelper: true,
select: function(start, end, allDay) {
var title = prompt('Event Title:');
if (title) {
calendar.fullCalendar('renderEvent',
{
title: title,
start: start,
end: end,
allDay: allDay
},
true // make the event "stick"
);
}
calendar.fullCalendar('unselect');
},
editable: true,
events: "getLeaveRequests.cfc?method=getMyData",
eventDrop: function(event, delta) {
alert(event.title + ' was moved ' + delta + ' days\n' +
'(should probably update your database)');
}
});
});
</script>
</head>
<body>
<div id='calendar'>
</div>
</body>
</html>
Here is my working CFC (getLeaveRequests.cfc) which queries the data:
<!--- Don't forget to VAR scope all local variables. --->
<cfset var getEvents = "">
<cfset var row = "">
<cfset var result = "">
<cfquery name="getEvents" datasource="care">
SELECT lqID AS id,
lqStartDate AS myStart,
lqEndDate AS myEnd,
CONCAT(lqUser, " (",lqTotalHours,") ", (COALESCE(lqDescription,'')),"") AS title
FROM tblleaverequest
</cfquery>
<cfset result = []>
<cfloop query="getEvents">
<!--- start new structure. must use array notation to preserve case of structure keys--->
<cfset row = {}>
<cfset eventurl ="leave_request_a01z.cfm?id=" & "id">
<cfset row["id"] = id>
<cfset row["title"] = title>
<cfset row["start"] = myStart>
<cfset row["end"] = myEnd>
<!--- append to results --->
<cfset arrayAppend(result, row)>
</cfloop>
<!--- convert to json --->
<cfreturn serializeJSON(result)>
<!---
<cfreturn getEvents>
--->
</cffunction>
</cfcomponent>
What is the best way to "color" the calendar items based on the value of "lqUser"?
- The colors can be dynamically assigned, or if needed, I can add a color field to the User table for each user, but how do I assign it to the FullCalendar?
Here is my updated CFC trying to get colors to work: (using code from "dwayne anderson" post on Raymond Camden site)
- I added a field to my User table called "category_id", then assigned values 1 thru 9 for colors.
The page gives me no errors, just a blank calendar?
<!--- Component to get all of the Leave Request Dates and place on FullCalendar page--->
<cfcomponent>
<cfsetting showDebugOutput='No'>
<cffunction name="getMyData" output="false" access="remote" returntype="any" returnformat="JSON">
<cfargument name="filter" type="string" required="no" default="">
<cfquery name="getallevents" datasource="care">
SELECT lqID AS id,
lqStartDate AS event_start_datetime,
lqEndDate AS event_end_datetime,
IF(category_id IS NULL, '1', category_id) AS color_id,
CONCAT(lqUser, " (",lqTotalHours,") ", (COALESCE(lqDescription,'')),"") AS title
FROM tblusers RIGHT OUTER JOIN tblleaverequest ON tblusers.username = tblleaverequest.lqUser
</cfquery>
<cfquery name="getallcolors" dbtype="query">
Select distinct color_id
from getallevents
</cfquery>
<cfset colorlist="red,green,blue,yellow,black,brown,aqua,orange,darkred">
<cfset colorpos=1>
<cfset colors = []>
<cfloop query = "getallcolors">
<cfset thecolor='#listgetat(colorlist,colorpos)#'>
<cfif colorpos eq listlen(colorlist)>
<cfset colorpos=0>
</cfif>
<cfset colorpos=colorpos+1>
<cfset colors[#color_id#] = thecolor>
</cfloop>
<cfset url.returnformat="json">
<cfset results = []>
<cfloop query = "getallevents">
<cfset eventurl ="eventdetails.cfm?id=" & "id">
<cfset eventcolor ="#colors[color_id]#">
<cfset s = structnew()>
<cfset s["id"] = id>
<cfset s["title"] = title>
<cfset s["start"] = getEpochTime(event_start_datetime)>
<cfset s["end"] = getEpochTime(event_end_datetime)>
<cfset s["url"] = eventurl>
<cfset s["color"] = eventcolor>
<cfset s["allDay"] = false>
<cfset arrayappend(results, s)>
</cfloop>
<cfreturn results>
</cffunction>
<cffunction access="private" name="getEpochTime" returntype="date">
<cfargument name="thedatetime" type="date"/>
<cfif (ArrayLen(Arguments) is 0)>
<cfset thedatetime = Now() />
<cfelseif IsDate(Arguments[1])>
<cfset thedatetime=Arguments[1] />
<cfelse>
return NULL;
</cfif>
<cfreturn DateDiff("s", DateConvert("utc2Local", "January 1 1970 00:00"), thedatetime) />
</cffunction>
</cfcomponent>
What is the best way to "color" the calendar items based on the value of "lqUser"?
You have two options if I am understanding this correctly.
You could set the color for the user in the query itself so its easier to manage at query level via case statments or any other logic
You could do div with classes for specific user or type of user.
HTH.
Got it working! Here is the final & working CFC that includes coloring the calendar events. Thanks for the help.
<!--- Component to get all of the Leave Request Dates and place on FullCalendar page--->
<cfcomponent>
<cfsetting showDebugOutput='No'>
<cffunction name="getMyData" output="false" access="remote" returntype="any" returnformat="JSON">
<cfargument name="filter" type="string" required="no" default="">
<!--- Don't forget to VAR scope all local variables. --->
<cfset var getEvents = "">
<cfset var row = "">
<cfset var result = "">
<cfset var getallcolors = "">
<!--- Query the Leave Requests table and get data for all employees --->
<cfquery name="getEvents" datasource="care">
SELECT lqID AS id,
lqStartDate AS myStart,
lqEndDate AS myEnd,
IF(category_id IS NULL, "", category_id) AS color_id,
CONCAT(lqUser, " (",lqTotalHours,") ", (COALESCE(lqDescription,'')),"") AS title
FROM tblusers RIGHT OUTER JOIN tblleaverequest ON tblusers.username = tblleaverequest.lqUser
</cfquery>
<!--- Do a Query of Queries to get all of the users color values --->
<cfquery name="getallcolors" dbtype="query">
Select distinct color_id
FROM getEvents
</cfquery>
<cfset result = []>
<!--- Assign colors to be used by the FullCalendar variable --->
<cfset colorlist="red,green,blue,black,gray,brown,orange,darkred,darkgreen,darkblue,darkgrey,purple,darkorange,">
<cfset colorpos=1>
<cfset colors = []>
<cfloop query = "getallcolors">
<cfset thecolor='#listgetat(colorlist,colorpos)#'>
<cfif colorpos eq listlen(colorlist)>
<cfset colorpos=0>
</cfif>
<cfset colorpos=colorpos+1>
<cfset colors[#color_id#] = thecolor>
</cfloop>
<cfloop query="getEvents">
<!--- start new structure. must use array notation to preserve case of structure keys--->
<cfset row = {}>
<cfset eventcolor ="#colors[color_id]#">
<cfset eventurl ="leave_request_a01z.cfm?id=" & "id">
<cfset row["id"] = id>
<cfset row["title"] = title>
<cfset row["start"] = myStart>
<cfset row["end"] = myEnd>
<cfset row["color"] = eventcolor>
<!--- append to results --->
<cfset arrayAppend(result, row)>
</cfloop>
<!--- convert to json --->
<cfreturn serializeJSON(result)>
<!---
<cfreturn getEvents>
--->
</cffunction>
</cfcomponent>

Randomize cfoutput

The following code changes the body BG dependent on if the /home url is active else use a different BG. We have the pageID = 206 containing the /home BG image and pageID = 207 containing the else BG image. We currently have it setup this way so the client can go into the CMS and change the BG image without an issue.
However, the client would like the ability to add additional backgrounds and have them randomize. In theory I would add a page to the CMS and include the pageID and add randomize. I'm familiar with ColdFusion but this is a little over my head. Any input or direction would be greatly appreciated.
<cfsavecontent variable="HOME_BG">
<cfoutput>
<cfset includeID = '206'><cfinclude emplate='/PageInclude/PageInclude.cfm'/>
</cfoutput>
</cfsavecontent>
<cfset BG1 = getToken(HOME_BG,3, """") >
<cfsavecontent variable="COMM_BG">
<cfoutput>
<cfset includeID = '207'><cfinclude template='/PageInclude/PageInclude.cfm'/>
</cfoutput>
</cfsavecontent>
<cfset BG2 = getToken(COMM_BG,3, """") >
<body onload="checkCookie()" style="background-image: url(<cfoutput><cfif fpath EQ "home">#BG1#<cfelse>#BG2#</cfif></cfoutput>);">
I was looking for the ability to randomize between two different < cfset > but didn't find much luck.
Solution using an array and randrange
<cfset bgHomeIDArray = ArrayNew(1)> <!--- Create the array --->
<cfset ArrayAppend(bgHomeIDArray, 214)> <!--- Adds an array value --->
<cfset ArrayAppend(bgHomeIDArray, 215)> <!--- Adds an array value --->
<cfsavecontent variable="HOME_BG">
<cfoutput>
<cfset includeID = bgHomeIDArray[randRange(1, len(bgHomeIDArray))]> <cfinclude template='/PageInclude/PageInclude.cfm'/>
</cfoutput>
</cfsavecontent>
<cfset BG1 = getToken(HOME_BG,3, """") >
<cfset bgCommIDArray = ArrayNew(1)> <!--- Create the array --->
<cfset ArrayAppend(bgCommIDArray, 216)> <!--- Adds an array value --->
<cfset ArrayAppend(bgCommIDArray, 217)> <!--- Adds an array value --->
<cfsavecontent variable="COMM_BG">
<cfoutput>
<cfset includeID = bgCommIDArray[randRange(1, len(bgCommIDArray))]><cfinclude template='/PageInclude/PageInclude.cfm'/>
</cfoutput>
</cfsavecontent>
<cfset BG2 = getToken(COMM_BG,3, """") >
<body onLoad="checkCookie()" style="background-image: url(<cfoutput><cfif fpath EQ "home">#BG1#<cfelse>#BG2#</cfif></cfoutput>?03202014);">

CFRETURN to .CFM page

Trying to display structExcelResult["strUrl"] created by the function on my .cfm page.
<cffunction name="getBuyerReport" output="false" access="public" returntype="struct">
<cfargument name="intRegionId" required="yes">
<cfargument name="intBuyerId" required="yes">
<cfargument name="intStage" required="yes">
<cfargument name="strSortField" required="yes">
<cfargument name="strSortDirection" required="yes">
<cfset var structExcelResult = StructNew()>
<cfset var qRead="" />
<cfquery name="qRead" datasource="#variables.dsn#">
SELECT CONVERT(varchar,t.RECEIVED_DATE,101) AS [Received Date]
, t.REQUISITION_NO AS [Requisition Number]
, t.REQUISITION_TITLE AS [Requisition Title]
, t.TECHNICAL_AUTHORITY_NAME AS [Technical Authority]
, bm.BID_START_DATE AS [Solicitation Date]
, bm.BID_END_DATE AS [Closing Date]
, CAST(t.REQ_AMOUNT AS MONEY) AS [Requisition Value]
, CAST(t.APPROVAL_AMOUNT AS MONEY) AS [Approval Value]
, t.CURRENT_STAGE AS [Current Stage]
, CONVERT(varchar,t.ESTIMATED_AWARD_DATE,101) AS [Estimated Award Date]
, replace(replace(n.NOTE,CHAR(13),''),CHAR(10),'') as [Comments]
, DATEDIFF(day, t.RECEIVED_DATE, getdate()) AS [Age of Requisition (days)]
, cb.USER_NAME as [Buyer Name]
, o.OFFICE_LOCATION_NAME as [Office Location]
FROM VW__TOMBSTONES__CLIENT_CODES t
LEFT OUTER JOIN TB__OFFICE_LOCATIONS o
ON o.ID = t.OFFICE__ID
LEFT OUTER JOIN TB__USERS cb
ON t.CURRENT_BUYER__ID = cb.ID
LEFT OUTER JOIN TB__BID_MANAGEMENTS bm
ON bm.TB__TOMBSTONES__ID = t.ID
LEFT OUTER JOIN TB__REQUISITIONS r
ON r.TOMBSTONES__ID = t.ID
LEFT OUTER JOIN TB__NOTES n
ON n.REQUISITION__ID = r.ID
AND t.CURRENT_STAGE = n.NOTE_TYPE
WHERE t.CURRENT_STAGE <= 4
AND n.NOTE_TYPE BETWEEN 1 AND 4
AND t.REGION__ID = #arguments.intRegionId#
</cfquery>
<!--- Create new spreadsheet --->
<cfset sObj = SpreadsheetNew()>
<!--- Excel Functions --->
<cfset countFormula="COUNTA(A8:A20000)">
<cfset sumFormula="SUM(G2:G2000)">
<!--- Create header row --->
<cfset SpreadsheetMergeCells(sObj,1,1,1,2)>
<cfset SpreadsheetSetCellValue(sObj, "BUYER REGISTER REPORT",1,1)>
<cfset SpreadsheetFormatRow(sObj, {bold=TRUE, alignment="center"}, 1)>
<cfset SpreadsheetSetCellValue(sObj, "Report Generated Date:",3,1)>
<cfset SpreadsheetFormatCell(sObj, {bold=TRUE, alignment="right"}, 3,1)>
<cfset SpreadsheetSetCellValue(sObj, "#ToString(DateFormat(now(), "mmmm d yyyy"))#",3,2 )>
<cfset SpreadsheetFormatCell(sObj, {bold=TRUE, alignment="left"}, 3,2)>
<cfset SpreadsheetSetCellValue(sObj, "Number of Requisitions:",4,1)>
<cfset SpreadsheetFormatCell(sObj, {bold=TRUE, alignment="right"}, 4,1)>
<cfset SpreadsheetSetCellFormula(sObj,countFormula, 4, 2)>
<cfset SpreadsheetFormatCell(sObj, {bold=TRUE, alignment="left"}, 4,2)>
<cfset SpreadsheetSetCellValue(sObj, "Value of Requisitions:",5,1 )>
<cfset SpreadsheetFormatCell(sObj, {bold=TRUE, alignment="right"}, 5,1)>
<cfset SpreadsheetSetCellFormula(sObj,sumFormula, 5, 2)>
<cfset SpreadsheetFormatCell(sObj, {bold=TRUE, alignment="left"}, 5,2)>
<cfset SpreadsheetFormatCell(sObj, {dataformat="$##,##0.00"}, 5,2)>
<cfset SpreadsheetAddRow(sObj, "" )>
<cfset SpreadsheetAddRow(sObj, "RECEIVED DATE,REQUISITION NUMBER,REQUISITION TITLE,TECHNICAL AUTHORITY,SOLICITATION DATE,CLOSING DATE,REQUISITION VALUE,APPROVAL VALUE,CURRENT STAGE,ESTIMATED AWARD DATE,COMMENTS,AGE OF REQUISITION (DAYS),BUYER NAME,OFFICE LOCATION")>
<cfset SpreadsheetFormatRow(sObj, {bold=TRUE}, 7)>
<!--- Add orders from query --->
<cfset SpreadsheetAddRows(sObj, qRead)>
<cfset SpreadsheetFormatColumns(sObj, {dataformat="$##,##0.00"}, "7-8")>
<cfset SpreadsheetFormatColumns(sObj, {alignment="center"}, "9-10")>
<cfset SpreadsheetFormatColumns(sObj, {alignment="center"}, "12-15")>
<!--- Excel document naming and storing location --->
<cfset strDir=GetDirectoryFromPath(GetCurrentTemplatePath())&"/../assets/generatedXLS/">
<cfset strFilePrepend = "-BuyerReport-" />
<cfset strFileNameStamp = "Galileo" & "#strFilePrepend#" & "#ToString(DateFormat(now(), "yy-mm-dd"))#" & "-#ToString(TimeFormat(now(), "HHmmss"))#" & ".xls"/>
<cfspreadsheet action="write"
filename="#strDir##strFileNameStamp#"
name="sObj"
overwrite="true"
sheetname="Active (Stages 1-4)">
<cfset structExcelResult["strURL"] = "/web_apps/app/assets/generatedXLS/" & #strFileNameStamp# />
<cfset structExcelResult["strNoRecordsFoundMsg"] = "" />
<cfreturn structExcelResult>
How do I fetch that data (structExcelResult["strURL"]) and display it on my .cfm page?
I'm new at this and going through Ben Forta books... Thanks!
Since you have a cfreturn in your code, I'll assume that was meant to have been wrapped in cffunction.
You can call a cffunction a couple of different ways. It could be on the same .cfm page that you're on:
<cffunction name="sayHello" output="false">
<cfargument name="username" type="string" required="false" default="Anonymous" />
<cfreturn "Hello, " & username />
</cffunction>
<cfoutput>#sayHello( 'Charlie' )#</cfoutput>
However, it's more likely that your function is part of a ColdFusion Component (CFC). To call a function that's part of a CFC, you first have to instantiate the CFC:
<cfset myCFC = createObject( 'component', 'path.to.my.cfc' ) />
Now you can call any method that resides in the CFC via:
<cfoutput>#myCFC.myFunction( 'foo' )#</cfoutput>
Going back to my first (very simple) example, let's say the sayHello() function resided in the Greeting.cfc file that was at /com/Greeting.cfc.
<cfset greeting = createObject( 'component', 'com.greeting' ) />
<cfoutput>#greeting.sayHello( 'Charlie' )#</cfoutput>
You can use anything you'd like for the name. It doesn't have to be myCFC or greeting. It's just a variable that represents a hook into your component.
Hope that helps.

Populate object with multidimensional menu

I'm wondering if there is an effective way to put a menu into an array or any other data type.
With php I would do something like this:
$menu[1] = "home";
$menu[2] = "news";
$menu[3]["item"] = "products";
$menu[3]["subMenu"][1] = "jackets";
$menu[3]["subMenu"][2] = "T-shirts";
$menu[4] = "contact";
However I have no clue how one would do this in coldfusion.
I want to grab this data from the DB and push it into an object, this will allow me to generate the html from the array.
To take Ciaran's answer a step farther, you can do it completely with object literals in CF 9:
<cfset menu = ["home",
"news",
{"item"="products",
"subMenu"= ["jackets",
"T-shirts"]},
"contact"]>
<cfdump var="#menu#" /> <!--- Output --->
It's actually very similar. This presumes ColdFusion 8 (or higher) for array ([]) and struct ({}) literals:
<cfset menu = [] /> <!--- Create initial array --->
<cfset menu[1] = "home" />
<cfset menu[2] = "news" />
<cfset menu[3] = {} /> <!--- Create structure --->
<cfset menu[3]["item"] = "products" /> <!--- Address structure by key --->
<cfset menu[3]["subMenu"] = [] />
<cfset menu[3]["subMenu"][1] = "jackets" />
<cfset menu[3]["subMenu"][2] = "T-shirts" />
<cfset menu[4] = "contact" />
<cfdump var="#menu#" /> <!--- Output --->
Hope that helps!