A BrainTeaser for ya...

1 view
Skip to first unread message

Mike G

unread,
Jul 12, 2019, 12:40:46 PM7/12/19
to hou...@googlegroups.com
So, I have a page where folks are submitting shipment info and getting a label back to the browser in pdf format using cfcontent, cfheader in a separate page called getLabels.cfm.  All the shipment processing is Ajaxy and wonderful, and at the end a bit of javascript says...
window.location.replace("/pathTo/getShippingLabel.cfm?invoice="+o.invoice);

Simple and easy, normal stuff, been there, done that a million times..

<cfheader name="Content-Disposition" value="attachment; filename=labels-#url.invoice#.pdf">
<cfcontent type="application/unknown" file="#application.props.getproperty("labelsPath","")##url.invoice#.pdf">

So, here is the brain teaser. (and yeah, I left all the other code out)

When the label pdf doesn't exist, how to I stop the original calling page from going to getLabels.cfm and displaying "File not found" message?  I want the user to stay on the page they are working in.

Instead I would like to do this in getLabels.cfm

<cfif not fileexists("#application.props.getproperty("labelsPath","")##url.invoice#.pdf")>
Do something magic and abort the request so the page doesn't change
<cfelse>
<cfheader name="Content-Disposition" value="attachment; filename=labels-#url.invoice#.pdf">
<cfcontent type="application/unknown" file="#application.props.getproperty("labelsPath","")##url.invoice#.pdf">
</cfif>

in 20 years of CF, I have never tried this...

M

james....@bakerbotts.com

unread,
Jul 12, 2019, 2:20:01 PM7/12/19
to hou...@googlegroups.com

I think you already answered your own question…

 

“Do something magic and ABORT the request so the page doesn’t change”

 

</cfabort>, maybe trigger a warning message to appear that something’s gone wrong…

 

From: hou...@googlegroups.com <hou...@googlegroups.com> On Behalf Of Mike G
Sent: 12 July, 2019 11:41 AM
To: hou...@googlegroups.com
Subject: [houcfug] A BrainTeaser for ya...

 

[EXTERNAL EMAIL]

--
--
You received this message because you are subscribed to the "Houston ColdFusion Users' Group" discussion list.
To unsubscribe, send email to houcfug-u...@googlegroups.com
For more options, visit http://groups.google.com/group/houcfug?hl=en

---
You received this message because you are subscribed to the Google Groups "Houston ColdFusion Users' Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to houcfug+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/houcfug/CAKb7GJME%3DrtnZ5ebYPGWi62Aye9XSF1a1dCzfMdd%2BewtRw3vXw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.



Confidentiality Notice:

The information contained in this email and any attachments is intended only for the recipient[s] listed above and may be privileged and confidential. Any dissemination, copying, or use of or reliance upon such information by or to anyone other than the recipient[s] listed above is prohibited. If you have received this message in error, please notify the sender immediately at the email address above and destroy any and all copies of this message.

Reply all
Reply to author
Forward
0 new messages