Louie Warren
Louie Warren

Reputation: 41

<cfif isdefined("URL.openFile")> coldfusion

I am severely new to ColdFusion... I have searched for help on this statement and have found a bunch of material, but still don't understand what is going on. All of the parts of this statement make sense, but when I put them all together, it's confusing... the ColdFusion 8: IsDefined("URL.variable) and is not"" thread is the closest, but I still don't understand. This is the 1st statement in the index.cfm file of my application. It's not throwing an error, I just want to understand how it works. Thank you.

I have yet to be able to successfully post code here, so here is a link to a text version of the index.cfm.

Edit: The code below should be the relevant sections related to URL.openFile

   <cfif isdefined("URL.openFile")> 
      <cfquery name="getFile" datasource="xxxxxxxx">
         SELECT filename, filename2, filecontent, filesize
         FROM Help_FooterInfo
         WHERE Help_id=5 and Section='Registration'
       </cfquery>
       <cfset sproot=#getDirectoryFromPath(getTemplatePath())#>
       <cfset newDest = #sproot#&"temp\">
       <cfoutput query="getFile">
          <cfheader name="Content-Disposition" value="attachment; filename=#getfile.FileName2#">
          <cfcontent type="application/msword" variable="#getfile.filecontent#">
       </cfoutput>
   </cfif>
   ...
   <cfquery name="getRegistration" datasource="xxxxxxxx">
      select * from help_footerinfo where help_id=5
   </cfquery>
   ....
   <cfoutput>#getRegistration.Content#</cfoutput><br>
   <a href="<cfif #getRegistration.filename2# neq "">index.cfm?openfile=Yes</cfif>" target="_blank">
       <u><cfoutput>#getRegistration.FileName#</cfoutput></u>
   </a>

The error message I am receiving (see comment below): ORA-00942: table or view does not exist (ColdFusion application)

Upvotes: 1

Views: 814

Answers (1)

Dan Bracuk
Dan Bracuk

Reputation: 20804

This:

<cfif IsDefined("URL.variable") and URL.variable is not "" >

means, "If url.variable actually exists and is not an empty string".

A better alternative for isDefined("URL.variable") is StructKeyExists(url,"variable").

Other alternatives for is not "" include len(trim(url.variable)) gt 0, and isNumeric(url.variable).

Upvotes: 1

Related Questions