Cold Fusion Help Needed!

BadThad

Lifer
Feb 22, 2000
12,100
49
91
Since we lost our CF Webmaster, I've been duped into filling in...it's only been 4 years now....and I know very, very little about CF.....excuse my ignorance.

We use CF for our intranet site and I was trying to see if I could get rid of a pop-up window when a client requested a specific report. The window is being blocked by the IE pop-up blocker (or even the google tool bar) and it's killing me with support calls. I'd like the report to display in the SAME window, but I don't know how to change the behavior. The following is the code to generate the page and display the report:

<CFSET cPageTitle = "Central System Reports">
<CFSET cMyInitials = "JGB">
<CFOUTPUT>
<!-- Content manager: #cMyInitials# -->
<CFINCLUDE TEMPLATE="#cSiteLogicalRoot#/includes/topstuff.inc">
<HTML>
<HEAD>
<CFINCLUDE TEMPLATE="#cSiteLogicalRoot#/includes/headstuff.inc">
<TITLE>#cPageTitle#</TITLE>
</HEAD>
<BODY>
<CFINCLUDE TEMPLATE="#cSiteLogicalRoot#/includes/bodystuff.inc">
<CFINCLUDE TEMPLATE="#cSiteLogicalRoot#/includes/mainmenu.inc">
<CFINCLUDE TEMPLATE="#cSiteLogicalRoot#/includes/header01.inc">

<!--- Initialize --->
<CFSET cDirectory = "d:\data\csreports">
<CFSET cVirtualDirectory = "/content/rep/pdfs/csreports">
<CFSET cThisScript = "#CGI.SCRIPT_NAME#">
<CFSET bShowSearchForm = "NO">

<CFPARAM NAME="FORM.cSearchString" DEFAULT="">
<CFPARAM NAME="FORM.cInitLetter" DEFAULT="">
<CFPARAM NAME="FORM.cFileName" DEFAULT="">

<!-- Content table begins -->
<TABLE class="content_table" border="0">
<TR>
<TD class="content_table" width="75%">

<!-- #################################### -->
<!-- #### BEGIN ADDING CONTENT HERE! #### -->

<!---
PSEUDOCODE
IF [search string passed] OR [letter passed]
Query directory for all filenames containing search string OR beginning with initial letter
Compile filename list
IF list has zero elements
Inform user
Set search form flag
ELSEIF list has only one element
Put it in hidden filename field
Invoke this form again
ELSE
Create dropdown list
ENDIF
ELSEIF [filename passed]
Display file
Set search form flag
ENDIF

IF search form flag set
Construct search form
ENDIF
--->

<table width="80%" border="0" cellspacing="0" cellpadding="0" align="CENTER" valign="MIDDLE">
<tr><td>

<CFIF (Len(FORM.cSearchString) GT 0) OR (Len(FORM.cInitLetter) GT 0)>

<!--- If we got a search string or initial letter, find the matching files --->
<!--- Get listing of csreports directory --->
<CFDIRECTORY ACTION="LIST" DIRECTORY="d:\Data\csreports" NAME="qFiles" SORT="name">
<!--- Put all matches in a list --->
<CFSET lFiles = "">
<CFLOOP QUERY="qFiles">
<CFIF (Len(FORM.cSearchString) GT 0)>
<!--- Match on search string --->
<CFIF qFiles.name contains "#FORM.cSearchString#">
<CFSET lFiles = ListAppend(lFiles, "#UCase(qFiles.name)#")>
</CFIF>
<CFELSEIF (Len(FORM.cInitLetter) GT 0)>
<!--- Match on first letter --->
<CFIF Left(qFiles.name,1) IS "#FORM.cInitLetter#">
<CFSET lFiles = ListAppend(lFiles, "#UCase(qFiles.name)#")>
</CFIF>
</CFIF>
</CFLOOP>

<!--- How many filenames in list? --->
<CFSET nNumberOfFiles = ListLen(lFiles)>

<!--- Handle list --->
<CFIF nNumberOfFiles IS 0>
<!--- No files... Danger, Will Robinson! --->
<H3>There are no Central System Reports that match your search. Please try again.</H3>
<CFSET bShowSearchForm = "YES">

<CFELSEIF nNumberOfFiles IS 1>
<!--- One file... Pass it on --->
<H3>Autosubmit...</H3>
<FORM ACTION="#cThisScript#" METHOD="post" NAME="selectfile" ID="selectfile">
<INPUT TYPE="hidden" NAME="cFileName" ID="cFileName" VALUE="#lFiles#">
<INPUT TYPE="hidden" NAME="newWindow" value="yes">
</FORM>
<!--- Autosubmit this form --->
<SCRIPT LANGUAGE="JavaScript1.2">this.document.selectfile.submit();</SCRIPT>

<CFELSEIF nNumberOfFiles GT 1>
<!--- Many files... Pick one and pass it on --->
<!--- Construct dropdown list --->
<H2>Select a report to display:</H2>
<FORM ACTION="#cThisScript#" METHOD="post" NAME="selectfile" ID="selectfile">
<SELECT NAME="cFileName" ID="cFileName">
<CFLOOP INDEX="cThisFile" LIST="#lFiles#">
<OPTION VALUE="#cThisFile#">#cThisFile#</OPTION>
</CFLOOP>
</SELECT>
<INPUT TYPE="hidden" NAME="newWindow" value="yes">
<INPUT TYPE="submit" NAME="selectfile" ID="selectfile" VALUE="Go" CLASS="teeny">
</FORM>

</CFIF>

<CFELSEIF (LEN(FORM.cFileName) GT 0)>
<!--- Got the file... show it! --->
<H2>Central Systems Report<BR>#cFileName#</H2>
</td></tr>
<CF_PDFSHOW pcDefaultPDF="#cVirtualDirectory#/#cFileName#">
<CFSET bShowSearchForm = "YES">

<CFELSE>
<!--- Nothing else happening... show the search form --->
<CFSET bShowSearchForm = "YES">

</CFIF>


<CFIF bShowSearchForm>
<!-- Search form -->
<TR><TD><BR><H2>Central Systems Search</H2>
<!-- Search by string -->
<P><FORM ACTION="#cThisScript#" METHOD="post" NAME="selectstring" ID="selectstring">
Enter company name, system name, or city:<INPUT TYPE="text" NAME="cSearchString" SIZE="20" MAXLENGTH="999">
<!--- Search by first letter --->
<BR> ...or...<BR>
Select first letter of company name:
<SELECT NAME="cInitLetter">
<!--- Construct alphabet dropdown --->
<CFLOOP INDEX="ltr" FROM="65" TO="90">
<OPTION VALUE="#Chr(ltr)#">#Chr(ltr)#</OPTION>
</CFLOOP>
</SELECT>
<BR><INPUT TYPE="submit" NAME="cssearch" ID="cssearch" VALUE="Search" class="teeny" STYLE="margin-left:5em;margin-top:1em;">
</FORM></P>
</CFIF>

</td></tr>
</table>
</CFOUTPUT>
<!-- #### END CONTENT HERE! #### -->
<!-- ########################### -->
</tr>
</TABLE>

<!-- Content table ends -->
<CFINCLUDE TEMPLATE="#cSiteLogicalRoot#/includes/footer01.inc">
<CFINCLUDE TEMPLATE="#cSiteLogicalRoot#/includes/endbody.inc">
</BODY>
</HTML>

How can I stop the report from opening up in a new window?
 
Dec 27, 2001
11,272
1
0
Have you tried changing

<INPUT TYPE="hidden" NAME="newWindow" value="yes">

to

<INPUT TYPE="hidden" NAME="newWindow" value="no">

?
 

BadThad

Lifer
Feb 22, 2000
12,100
49
91
No, I have not tried that....will it work for certain?

We have a mirror of the main site I use for development work and somehow I hosed it. All I did was remove the entire NAME="newWindow" statement from that line. After I did that, it opened in the same window, but did not invoke Acrobat to display the document....I dunno why the hell that happened! I put it back in and now the pop-up window is blank! I even copied the file back from the live directory and it still won't invoke Acrobat....which is odd because the code parses the file name to the HTML document for display, I see the PDF file name, but Acrobat never launches. I even tested on another machine, so it's not just my machine....the live Intranet site is working fine.
 

BadThad

Lifer
Feb 22, 2000
12,100
49
91
Looks like it's starting Acrobat, but there's no file to display. For some reason, it's not finding the file even though it's parsing the correct name to the HTML document....arggggg...I suck at this!

The file exists, I checked, but it's not opening it. Any ideas to get my development site working again?

It's like this is just not working:

<CF_PDFSHOW pcDefaultPDF="#cVirtualDirectory#/#cFileName#">

Guess I don't understand the "VirtualDirectory" part...what the hell is that?
 
Dec 27, 2001
11,272
1
0
Originally posted by: BadThad
Guess I don't understand the "VirtualDirectory" part...what the hell is that?

It's a variable pointing to /content/rep/pdfs/csreports. Let me take a closer look.
 

BadThad

Lifer
Feb 22, 2000
12,100
49
91
Originally posted by: HeroOfPellinor
Have you tried changing

<INPUT TYPE="hidden" NAME="newWindow" value="yes">

to

<INPUT TYPE="hidden" NAME="newWindow" value="no">

?

Yes...that did the job! Now my problem is trying to figure out why my development site doesn't display the reports anymore. The live site is working fine and the files are identical.
 
Dec 27, 2001
11,272
1
0
Originally posted by: BadThad
Originally posted by: HeroOfPellinor
Have you tried changing

<INPUT TYPE="hidden" NAME="newWindow" value="yes">

to

<INPUT TYPE="hidden" NAME="newWindow" value="no">

?

Yes...that did the job! Now my problem is trying to figure out why my development site doesn't display the reports anymore. The live site is working fine and the files are identical.

Are the sites on the same physical server?
 

BadThad

Lifer
Feb 22, 2000
12,100
49
91
Yes, and even on the same drive. There's just two directories: wwwroot and wwwrootd. Both are on the same level, right off the C: drive.