Solved

Using <cfinclude template=" ... "> and problems generating a SwiffChart within page!

Posted on 2004-08-27
12
963 Views
Last Modified: 2013-12-24
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
0
Comment
Question by:rcbuchanan
  • 4
  • 4
  • 2
12 Comments
 
LVL 21

Expert Comment

by:pinaldave
ID: 11917599
Hi rcbuchanan,
seems like ...
<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>
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
0
 

Author Comment

by:rcbuchanan
ID: 11917624
no. actually even when i take this <cfscript> OUT ... the process function template STILL does not work when called as a template but DOES work when called directly via browser.

So was not jyokum.
(did u think my point award was unfair or something?)

Richard
0
 
LVL 21

Expert Comment

by:pinaldave
ID: 11917668
Hi Richard,
 
no man... do not think like that...I never worry about points... do not worry buddy.
I mean may be he was involved much so may be can have more input.
The imp thing is that we can all learn together.

If you are talkign about points. You are always fair. You have also awarded points for efforts and input.
That may be another reason, why everybody want to have opinion in your thread. :-)
I will try to look into the problem now as you have said <cfscript> is not issue.

Take it easy, bro.

Regards,
---Pinal
0
 
LVL 12

Expert Comment

by:jyokum
ID: 11919262
just curious, if you remove the check for the file existance and size, and just wait for 20 seconds... does it work?

<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) {
     // removed all the checks for existance and size
     thread.sleep(1000);
}
</cfscript>
0
 

Author Comment

by:rcbuchanan
ID: 11921203
no. :-(

i'm wondering if it's simply a problem of me calling the template - process - (that creates the swiff chart) - using <cfinclude template="process_opinion_linechart.cfm">

perhaps it does not like com objects or something via this method?

what is the alternative to cfinclude? how do i create cfc's? component functions?

Richard
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 21

Expert Comment

by:pinaldave
ID: 11921594
hello Richard,
I know very well how to create the CFC as I work with CFC but I am sure that will not make any differance. CFC's have many advantage but will be not applicable to you for sure.
Though, it is always good to learn. for more info and easiest tutorial http://www.macromedia.com/devnet/mx/coldfusion/articles/creating_cfcs.html
Regards,
---Pinal
0
 

Author Comment

by:rcbuchanan
ID: 11943133
Forget. Have solved problem myself.
0
 
LVL 21

Expert Comment

by:pinaldave
ID: 11943333
glad to listen that.
Have a good day,
Regards,
---Pinal
0
 
LVL 12

Expert Comment

by:jyokum
ID: 11943359
so what was it?
0
 

Accepted Solution

by:
rcbuchanan earned 0 total points
ID: 11943692
changing the function to a cfc was not the solution.
it appeared me assumption that the cfinclude was failing was a red herring.

i needed to include this:
<CFCONTENT TYPE="application/x-shockwave-flash" FILE="#filename#">

simple! huh!?

R.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now