• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CFHeader/CFContent is halting the rest of my page

Guest
Jan 30, 2012 Jan 30, 2012

Copy link to clipboard

Copied

I am posting to another page form information, and then spitting out a generated document.

<cfheader name="content-disposition" value="filename=#rejectSearchResults.RejectTempPath#">

<cfcontent type="application/msword"><cfoutput>#documentGen#</cfoutput>

This code right here pops open my RTF document to the user, but instead of going to the posted page it instead stays on the same page and halts further processing. How do I make the document open up and continue processing the rest of the code?

Views

3.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 30, 2012 Jan 30, 2012

Copy link to clipboard

Copied

cfthread might help, but what you are describing is very strange.  What exactly is supposed to happen once the user is presented with the document?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 30, 2012 Jan 30, 2012

Copy link to clipboard

Copied

Well, what is happening is I have a page, index.cfm, that is basically a big form that users enter in information. Then I set the action page of that form to another .cfm file that is running stored procedures, and I'm using those queries plus the form paramaters to do a find/replace inside a RTF Word document.

The thing is, as soon as they click the submit button, the generated document pops up right away (the browser never sends the user to the action page). I want the user to be able to go to the action page, where I have a table with additional documents to download.

<table align="center">

   <h4>Document Created</h5>

   <cfoutput>

    <p>

     Document Downloads: [<a href="#pathToCover#">Cover Template</a>]

     [<a href="#pathToRedetermination#">Redetermination Template</a>] <br />

     Please click <a href="./index.cfm">here</a> to return to DocGen.

    </p>

   </cfoutput>

  

   <cfheader name="content-disposition" value="filename=#rejectSearchResults.RejectTempPath#">

   <cfcontent type="application/msword"><cfoutput>#documentGen#</cfoutput>

  </table>

As you can see, on the page that is receiving the form paramaters, I have a table with the cfheader/cfcontent tags below. Above that is my Replace() commands, stored procedure, conitionals, etc. The user never even sees any of the HTML (they never even leave the form once they click submit, the generated document just pops up right away).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 30, 2012 Jan 30, 2012

Copy link to clipboard

Copied

That's how cfcontent works.  Maybe an iframe will give you what you want.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 31, 2012 Jan 31, 2012

Copy link to clipboard

Copied

cold_blue wrote:

Well, what is happening is I have a page, index.cfm, that is basically a big form that users enter in information. Then I set the action page of that form to another .cfm file that is running stored procedures, and I'm using those queries plus the form paramaters to do a find/replace inside a RTF Word document.

The thing is, as soon as they click the submit button, the generated document pops up right away (the browser never sends the user to the action page). I want the user to be able to go to the action page, where I have a table with additional documents to download.

<table align="center">

   <h4>Document Created</h5>

   <cfoutput>

    <p>

     Document Downloads: [<a href="#pathToCover#">Cover Template</a>]

     [<a href="#pathToRedetermination#">Redetermination Template</a>] <br />

     Please click <a href="./index.cfm">here</a> to return to DocGen.

    </p>

   </cfoutput>

  

   <cfheader name="content-disposition" value="filename=#rejectSearchResults.RejectTempPath#">

   <cfcontent type="application/msword"><cfoutput>#documentGen#</cfoutput>

  </table>

As you can see, on the page that is receiving the form paramaters, I have a table with the cfheader/cfcontent tags below. Above that is my Replace() commands, stored procedure, conitionals, etc. The user never even sees any of the HTML (they never even leave the form once they click submit, the generated document just pops up right away).

From what you describe, the implementation requires one more step between the action page and the download page. Something like this:

(1) form_page => (2) action_page (running stored procedures, using those queries plus the form paramaters to do a find/replace inside a RTF Word document, etc., etc.) => (3) CFM page that uses cfheader and cfcontent to generate document for download.

Provide, for example, a link or button to enable the user to go from (2) to (3).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jan 31, 2012 Jan 31, 2012

Copy link to clipboard

Copied

You cannot do both of those on the same page (unless you are talking about embedding). An html page can only return a single content type. So the action page can return text/html OR the rtf document, but not both. For that you would need a separate frame or window, as mentioned above.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 31, 2012 Jan 31, 2012

Copy link to clipboard

Copied

I see, that makes sense. I guess I would have to go the iframe route, but then comes the issue of getting the storedprocedure return values to the cfheader/cfcontent, since if it's a seperate instance of the browser, I'm going to take a guess that it wont be able to read them.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jan 31, 2012 Jan 31, 2012

Copy link to clipboard

Copied

The code generating the data and the cfheader/cfcontent must be grouped together in the same script.

Keep in mind you only need an iframe if you want to display the document in-line within the browser.

 

-Leigh

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 31, 2012 Jan 31, 2012

Copy link to clipboard

Copied

Well, the stored procedure shoots out the paths to additional documents, which I want to supplement with my generated document. So all of this is coming from the same script/cfm file. Those additional files can't be displayed for download since cfheader/cfcontent wont allow that. I really don't know how I can use an iframe to circumvent this since the stored procedure that generates the document and additional paths to files for download has to be grouped togethor in the same script.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jan 31, 2012 Jan 31, 2012

Copy link to clipboard

Copied

shoots out the paths to additional documents ... my generated document

Is there a reason you must do both in the same procedure? Because it sounds like it might be trying to do too much at once.

If you really cannot separate them, one possibility is to write the main content to a temporary file which could be accessed from either location. Then display it with cfcontent's "file" attribute.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 31, 2012 Jan 31, 2012

Copy link to clipboard

Copied

cold_blue wrote:

Well, the stored procedure shoots out the paths to additional documents, which I want to supplement with my generated document. So all of this is coming from the same script/cfm file. Those additional files can't be displayed for download since cfheader/cfcontent wont allow that. I really don't know how I can use an iframe to circumvent this since the stored procedure that generates the document and additional paths to files for download has to be grouped togethor in the same script.

From what you describe, the implementation requires one more step between the action page and the download page. Something like this:

(1) form_page => (2) action_page (running stored procedures, using those queries plus the form paramaters to do a find/replace inside a RTF Word document, etc., etc.) => (3) CFM page that uses cfheader and cfcontent to generate document for download.

Provide, for example, a link or button to enable the user to go from (2) to (3).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 31, 2012 Jan 31, 2012

Copy link to clipboard

Copied

The problem I am experiencing with going from step 2, to step 3, is the issue of sending what cfheader/cfcontent needs.

<cfheader name="content-disposition" value="filename=#rejectSearchResults.RejectTempPath#">

<cfcontent type="application/msword"><cfoutput>#documentGen#</cfoutput>

I tried having a link using this format: <a href="./download.cfm?documentGen=#documentGen#"> Download File</a> but I guess it is just way, way too big to pass via URL. I've been trying to use cfhttp to do it wont work, unless I'm doing it wrong.

   

How do I send #documentGen# to the 3rd step? For a more general view on how I am constructiing this: http://www.jensbits.com/2009/06/21/using-coldfusion-to-generate-a-word-document/ I'm modeling it after her blog post, since I couldn't really find a way to manipulate MS Word docs.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 01, 2012 Feb 01, 2012

Copy link to clipboard

Copied

cold_blue wrote:

The problem I am experiencing with going from step 2, to step 3, is the issue of sending what cfheader/cfcontent needs.

<cfheader name="content-disposition" value="filename=#rejectSearchResults.RejectTempPath#">

<cfcontent type="application/msword"><cfoutput>#documentGen#</cfoutput>

That is no problem at all. For example, you can solve the problem using a form, a database or the session scope, or a combination of all three, on the action page.

1) form

<form method="post">

<!--- Store data as value in hidden fields (ideal for small amounts of data). Show user submit button to take him to document page--->

</form>

2) session

<cfset session.RejectTempPath = rejectSearchResults.RejectTempPath>

<cfset session.documentGen = documentGen>

<!--- Add link or button to take user to document page. The data will then be available in the session scope--->

3) database

Store in the database all the values you will need to create the document page. Add a link to take the user to the document page. On the document page, start with a query to retrieve the data from the database.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 24, 2014 Mar 24, 2014

Copy link to clipboard

Copied

LATEST

I want to create a Word doc so I am using cfcontent to create a word doc that I archive. I've left the default not to delete, but as cold_blue has explained above, CF server sends the doc to the requesting browser and no further code runs. Instead of sending the document back to the user I need to hash the saved document, enter that information into my database for later secure retrieval, and then send other html back to the requesting browser instead of the document that cfcontent rendered. I can do this operation with cfdocument format="pdf" and it works just fine: user submits to accept/commit the doc, CF server generates and stores the pdf, gets a hash of it, enters that and other info into my table_documents, returns to the requesting browser a link to the pdf and other updated html. I have not found any such analogous functionality with cfcontent.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation