Using a ColdFusion Ternary Operator for an Optional Tag Attribute

Today I had to write a script to process a form and send an email as part of the processing. The form allows the user to specify an email address to bcc, but it’s not required. I’m a big fan of using the Ternary Operator for doing either/or stuff like css classes. So I decided to extend that fandom to set the bcc attribute of the <cfmail> tag if the email specified in the form was valid.

Assumptions for this example:

1. You have validated form.bccEmail as a valid email.
2. You have a default mail server specified in Application.cfc or CFADMIN.
3. You may see more utility in using the Ternary Operator for other conditional cases.

The “magic” is in the bcc attribute below:

    
	    Message Body here...
    

ColdFusion function returns space before value

I had an annoying issue this morning where a function I wrote that rounds and formats values for use in an internal financial app kept sticking a single space before the value returned. This was obviously not good for a financial app. After spending 10-15 minutes tearing the function’s innards apart it turns out what was going on in the function was not the cause. The cause was simple.

In a tag based ColdFusion function you need to be sure to include the ‘output=”no”‘ attribute.

 
     ... MAGIC STUFF HERE ...

Helpful Commands for ColdFusion 10 on OSX… aka Start and Stop CF10 from the command line

This post assumes you are working with the default instance (cfsusion) and that you installed ColdFusion 10 to the default location on you Mac.

STATUS:
/Applications/ColdFusion10/cfusion/bin/coldfusion status

START:
/Applications/ColdFusion10/cfusion/bin/cf-standalone-startup
OR
/Applications/ColdFusion10/cfusion/bin/coldfusion start

STOP:
/Applications/ColdFusion10/cfusion/bin/coldfusion stop

RESTART:
/Applications/ColdFusion10/cfusion/bin/coldfusion restart

Launch GUI for configuring Web Connectors:
sudo /Applications/ColdFusion10/cfusion/runtime/bin/wsconfig

RESET CFADMIN PASSWORD:
/Applications/ColdFusion10/cfusion/bin/passwordreset.sh
(Then Enter 1 for changing Admin Password and put in your new super strong password!)

.

RDS Query Viewer not working: How to fix the ColdFusion Builder error: ‘/YOURPROJECTFOLDER/.rdsTempFiles/RDS Query Viewer’ does not exist

I have had this issue for a while and it finally made me crazy enough to try to figure it out. It appears that this error occurs when the “RDS Query Viewer” file does not exist in the .rdsTempFiles folder within your project.

On Mac

  1. Open Terminal
  2. Navigate to the directory where your project is located. For example type: cd /Applications/ColdFusion9/wwwroot/YOURPROJECTFOLDER and hit <enter>
  3. If the “.rdsTempFiles” directory does not exist type: mkdir .rdsTempFiles and hit <enter>
  4. If the “RDS Query Viewer” file does not exist type: touch “.rdsTempFiles/RDS Query Viewer” and hit <enter>. BE SURE TO SURROUND THE COMMAND WITH THE DOUBLE QUOTES BECAUSE THE FILE NAME HAS SPACES.
  5. Refresh the “RDS Query Viewer” view. RDS Query View should work now.

On Windows

  1. Open DOS
  2. Navigate to the directory where your project is located. For example type: cd C:\ColdFusion9\wwwroot\YOURPROJECTFOLDER and hit <enter>
  3. If the “.rdsTempFiles” directory does not exist type: mkdir .rdsTempFiles\rdsTempFiles and hit <enter>
  4. If the “RDS Query Viewer” file does not exist type: fsutil file createnew “RDS Query Viewer” 0 and hit <enter>. BE SURE TO SURROUND THE COMMAND WITH THE DOUBLE QUOTES BECAUSE THE FILE NAME HAS SPACES.
  5. Refresh the “RDS Query Viewer” view. RDS Query View should work now.