Ok, for some reason (and I'm beyond newbie /w CF) I just cannot figure out what I'm doing wrong.
I have web page in cf that is supposed to query a table and create a SwiffChart in Flash to then be displayed.
The problem - process_opinion_linechart.
cfm - refuses to create the flash chart. ... It returns this message :
'
http://www.fred.com/charts/0015720040827.swfhttp://www.fred.com/charts/0015720040827.swf 10010075857371636133305515
0157157157
157'
BUT IF i run the process_opinion_linechart.
cfm DIRECTLY ... (calling it via browser) ... then it runs just fine!
What the heck am I doing wrong!?
page - called <page_viewopinion.cfm>
--------------------------
----------
---------
This page has some tables and general html crap ... for layout etc.
I have these two items:
<cfinclude template="process_opinion_
linechart.
cfm">
<cfinclude template="template_opinion
timeline.c
fm">
and the page ends with other crap like a footer etc.
process_opinion_linechart.
cfm
--------------------------
---------
This code creates my SwiffChart flash chart file UNLESS it already exists.
<cfset string_opid = #numberformat(url.op,"0000
0")#>
<cfset string_date = #dateformat(now(),"yyyymmd
d")#>
<cfset swfFilename = #string_opid# & #string_date# & ".swf">
<CFSET dirpath = "c:\web\fred\dev\htdocs\ch
arts\">
<cfif fileexists(#dirpath# & #swfFilename#) eq 'yes'>
<cfelse>
<!--- Sets the filename of the style. This assumes that the style is in the same directory as this script --->
<cfset chartStyle = "newline460.scs">
<!--- Load Opinion Data --->
<cfquery name="loadData" datasource="fred">
select opinionvotes.vote_date, sum(opinionvotes.vote_want
_yes) as want_yes, sum(opinionvotes.vote_want
_no) as want_no, sum(opinionvotes.vote_agre
e_yes) as agree_yes, sum(opinionvotes.vote_agre
e_no) as agree_no from opinionvotes where opinionvotes.opinion_id=#u
rl.op# group by opinionvotes.vote_date order by opinionvotes.vote_date
</cfquery>
<!--- Don't have to touch this --->
<CFSETTING ENABLECFOUTPUTONLY="Yes" SHOWDEBUGOUTPUT="No">
<CFOBJECT TYPE="COM"
NAME="chart"
CLASS="SwiffChartObject.Ch
artObj.1"
ACTION="CREATE">
<!--- Define seperators rules. Don't have to touch this --->
<CFSET sep= ";">
<CFSET ignoremultseparators= true>
<CFSET chart.SetSeparators(sep, ignoremultseparators)>
<cfset agree_total_yes = 0><cfset agree_total_no = 0>
<cfset want_total_yes = 0><cfset want_total_no = 0>
<cfset agree_string = ''><cfset want_string = ''>
<cfset myCategories = ''>
<cfset pointer = 0>
<cfloop query="loadData">
<!--- Create a string for each series --->
<CFSET myCategories= myCategories & "#dateformat(loadData.vote
_date,'mm/
dd')#" & sep>
<cfset agree_total_yes = agree_total_yes + #loadData.agree_yes#>
<cfset agree_total_no = agree_total_no + #loadData.agree_no#>
<cfset want_total_yes = want_total_yes + #loadData.want_yes#>
<cfset want_total_no = want_total_no + #loadData.want_no#>
<!--- Create a string for each series --->
<cfset agree_percent = #round(agree_total_yes / (agree_total_yes + agree_total_no) * 100)#>
<cfset want_percent = #round(want_total_yes / (want_total_yes + want_total_no) * 100)#>
<cfset agree_string = agree_string & "#agree_percent#" & sep>
<cfset want_string = want_string & "#want_percent#" & sep>
</cfloop>
<!--- Fill the chart with the series --->
<CFSET chart.SetCategoriesFromStr
ing(myCate
gories)>
<CFSET chart.AddSeries()>
<CFSET chart.SetSeriesValuesFromS
tring(0, agree_string)>
<CFSET chart.AddSeries()>
<CFSET chart.SetSeriesValuesFromS
tring(1, want_string)>
<CFSET style = dirpath & chartStyle>
<CFSET chart.LoadStyle( style )>
<!--- Set the dimensions of the movie. IF YOU CHANGE THIS, YOU NEED TO CHANGE THE SIZE BELOW TO REFLECT THIS! --->
<CFSET chart.SetWidth( 460 )>
<CFSET chart.SetHeight( 200 )>
<!--- This just sets where the graph gets generated --->
<CFSET account_id = "100">
<CFSET filename = dirpath & swfFilename>
<CFSET chart.ExportAsFile(filenam
e)>
<cfset chartInfo.filename = swfFilename>
</cfif>
template_opiniontimeline.c
fm
--------------------------
--------
This page is supposed to display the bloody swiff chart but never gets this far!!!!!!!!!!!
UNLESS the swiff chart alread EXISTS (has been created!) and this it displays it just fine.
<cfset string_opid = numberformat(url.op,"00000
")>
<cfset string_date = dateformat(now(),"yyyymmdd
")>
<cfset swfFilename = string_opid & string_date & ".swf">
<cfset dirpath = "c:\web\fred\dev\htdocs\ch
arts\">
<cfset lookupFilename = dirpath & swfFilename>
<cfscript>
tStop=DateAdd('s',20,now()
);
o_file = CreateObject('java','java.
io.File').
init(looku
pFilename)
;
thread = CreateObject("java", "java.lang.Thread");
fileFound = false;
while(DateCompare(now(),tS
top) lt 0) {
if(o_file.exists() AND o_file.length() gt 0) {
fileFound = true;
break;
}
else thread.sleep(1000);
}
</cfscript>
<cfif fileFound>
found found found found [placed to test the code]
<cfset string_opid = #numberformat(url.op,"0000
0")#>
<cfset string_date = #dateformat(now(),"yyyymmd
d")#>
<cfset swfFilename = "
http://www.fred.com/charts/" & #string_opid# & #string_date# & ".swf">
<table width="460" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td width="460" colspan="1"><img name="label_hottopics" src="/newopex_graphics/lab
el_opinion
timeline46
0x30.jpg" width="460" height="30" alt="" border="0"></td>
</tr>
<tr>
<td width="460" height="200">
<object classid="clsid:D27CDB6E-AE
6D-11cf-96
B8-4445535
40000" codebase="
http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="460" height="200">
<param name="movie" value="<cfoutput>#swfFilen
ame#</cfou
tput>">
<param name="quality" value="high">
<embed src="<cfoutput>#swfFilenam
e#</cfoutp
ut>" quality="high" pluginspage="
http://www.macromedia.com/go/getflashplayer" type="application/x-shockw
ave-flash"
width="460" height="200"></embed>
</object>
</td>
</tr>
</table>
<cfelse>
not found not found not found [i placed to test the code ...]
</cfif>
What gives!? I just don't get what I'm doing wrong!
For some reason the <cfinclude template="process_opinion_
linechart.
cfm"> does not finish!
DRIVING ME NUTS!
Any ideas?
Richard