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 100100758573716361333055150157157157157'
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_opiniontimeline.cfm">
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,"00000")#>
<cfset string_date = #dateformat(now(),"yyyymmdd")#>
<cfset swfFilename = #string_opid# & #string_date# & ".swf">
<CFSET dirpath = "c:\web\fred\dev\htdocs\charts\">
<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_agree_yes) as agree_yes, sum(opinionvotes.vote_agree_no) as agree_no from opinionvotes where opinionvotes.opinion_id=#url.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.ChartObj.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.SetCategoriesFromString(myCategories)>
<CFSET chart.AddSeries()>
<CFSET chart.SetSeriesValuesFromString(0, agree_string)>
<CFSET chart.AddSeries()>
<CFSET chart.SetSeriesValuesFromString(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(filename)>
<cfset chartInfo.filename = swfFilename>
</cfif>
template_opiniontimeline.cfm
----------------------------------
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\charts\">
<cfset lookupFilename = dirpath & swfFilename>
<cfscript>
tStop=DateAdd('s',20,now());
o_file = CreateObject('java','java.io.File').init(lookupFilename);
thread = CreateObject("java", "java.lang.Thread");
fileFound = false;
while(DateCompare(now(),tStop) 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,"00000")#>
<cfset string_date = #dateformat(now(),"yyyymmdd")#>
<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/label_opiniontimeline460x30.jpg" width="460" height="30" alt="" border="0"></td>
</tr>
<tr>
<td width="460" height="200">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 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>#swfFilename#</cfoutput>">
<param name="quality" value="high">
<embed src="<cfoutput>#swfFilename#</cfoutput>" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-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
by: pinaldavePosted on 2004-08-27 at 13:59:28ID: 11917599
Hi rcbuchanan, ); io.File'). init(looku pFilename) ; top) lt 0) {
seems like ...
<cfscript>
tStop=DateAdd('s',20,now()
o_file = CreateObject('java','java.
thread = CreateObject("java", "java.lang.Thread");
fileFound = false;
while(DateCompare(now(),tS
if(o_file.exists() AND o_file.length() gt 0) {
fileFound = true;
break;
}
else thread.sleep(1000);
}
</cfscript>
doing some improper behaviour...may be jyokum can have some opinion... why do not you write down more in your previous thread and so he will know that you have posted another question and can guide you...
Regards,
---Pinal