Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 988
  • Last Modified:

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

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
rcbuchanan
Asked:
rcbuchanan
  • 4
  • 4
  • 2
1 Solution
 
pinaldaveCommented:
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
 
rcbuchananAuthor Commented:
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
 
pinaldaveCommented:
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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
jyokumCommented:
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
 
rcbuchananAuthor Commented:
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
 
pinaldaveCommented:
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
 
rcbuchananAuthor Commented:
Forget. Have solved problem myself.
0
 
pinaldaveCommented:
glad to listen that.
Have a good day,
Regards,
---Pinal
0
 
jyokumCommented:
so what was it?
0
 
rcbuchananAuthor Commented:
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now