Debugging ColdFusion 9 on shared hosting

With ColdFusion 9 debugging can be enabled on a page by page basis. This is super handy in a shared hosting environment where you don’t have access to the CFADMIN.

Step 1

Set debuggingipaddress and enablerobustexception in the THIS scope of your Application.cfc.  You can use http://www.whatismyip.com if you don’t know your ip address.

	<!--- define a debugging ip --->
	<cfset this.debuggingipaddresses="xxx.xxx.xxx.xxx">
	<!--- enable robust exception --->
	<cfset this.enablerobustexception="yes">

Step 2

Enable show debug output at the top of your page’s code.

	<!--- enable show debug output --->
	<cfsetting showdebugoutput="true">

You should now see your debugging info appended to the page.

Just to verify!

You can verify debugging is enabled by outputting the value of IsDebugMode().

	<!--- Is debugging on?  Should be yes when showdebugoutput="true" --->
	<cfoutput>#IsDebugMode()#</cfoutput>

Saving to a database with ColdFusion using jQuery

A commenter asked me how to extend a previous jQuery post to perform the database save via ColdFusion.  It is REALLY easy (and please keep in mind this is meant to be a SIMPLE example, not production code).  From the jQuery side my example only required the following code to ship the data off to ColdFusion:

function fSave(){
you=$("#you").val();
// Try to save
$.get("adduser.cfm?"+"you="+you , function(data){
// Result
alert(data);
window.location=location.href;
});
}

The adduser.cfm page then validates and inserts the data and returns a success or failure message.

See it hereGet it here.

Use jQuery to enable submit button and set form action

I recently had to do a quick bit of coding to only accept data from a form if JavaScript was enabled.

This example starts with a form that has no action and a disabled submit button.  When jQuery’s .ready() fires though it enables the submit button and attaches the appropriate action.

Please note the example file is in ColdFusion so your mileage may vary slightly for your own use.

See it here | Get it here.

Using jQuery style a cftooltip span

It’s not hard to figure out how to style the box that pops up when using cftooltip.  It is controlled by the .yui-tt class.

/* Tool tip styling */
.yui-tt {
color: #444;
font-size:110%;
border: 2px solid #1C64D1;
background-color: #eee;
padding: 10px;
width:250px;
cursor:help;
}

But how do you style the text that is triggering the tooltip?  cftooltip is going to generate a span around your text with the id of cf_tooltip_999999999 (where 999999999 is some random number).  I didn’t want to add another span to the mix to provide styling so I turned to jQuery for a simple, quick solution.

In the css file I added a class:

.terms{
color:#168FC0;
border-bottom:1px dashed #168FC0;
text-decoration:none;
margin-bottom:10px;
font-weight:bold;
}

In the jQuery .ready() function I added this line:

$("[id^=cf_tooltip_]").addClass("terms");

The result is that the text which triggers all cftooltips is now controlled by the .terms class.

CF quickie: cfqueryparam with SQL’s LIKE operator

If you are using cfqueryparam to build a SQL statement from a search form and need to use the SQL’s LIKE operator here is how it’s done in the most basic way:

<cfquery name="qData" datasource="myDsn">
SELECT DISTINCT last_name
FROM person
WHERE last_name LIKE <cfqueryparam cfsqltype="cf_sql_varchar" value="#FORM.last_name#%">
ORDER BY last_name
</cfquery>

The magic is all in the % sign at the end of the cfqueryparam value attribute.

I’m an ACE (Adobe Certified Expert) in Advanced ColdFusion 8

Two months of studying paid off today.  I took my ACE exam for ColdFusion 8 and passed with a 98%, which also means I qualified for the Advanced status.  The Web Application Construction Kit is all you’ll ever need to become a CF Ninja.  For the exam I’d recommend reading the first volume cover to cover. Additionally I found the ColdFusion MX 7 Certified Developer Study Guide to be very useful.  Even if you don’t need it for your job challenge yourself and go for it.

ColdFusion Dying… Again

So I took some database training with Global Knowledge last week.¬† My office paid for the training.¬† Apparently that “back end” training may be all for naught though since my front end programming language is on life support.

Today’s Global Knowledge newsletter letter informed me (in very cheeky fashion) that ColdFusion is # 5 on their “Dying Technology” list:

“If any of these skills are your main expertise, perhaps it’s time to retrain.”

Here’s the whole article: http://www.globalknowledge.com/training/generic.asp?pageid=2347&country=United+States

The notion of ColdFusion being dead has been debated into the ground so I’m not going to belabor it.

IMHO, ColdFusion is the best thing that ever happened to me from an IT standpoint.¬† If you want to get things done quickly, easily and reliably use it.¬† If you are thinking of ColdFusion along with COBOL, Netware, Flannel Shirts and “Grunge” Bands From Seattle, and¬† you might want step outside your house more.¬† It’s not the mid 90’s anymore.

Change background color of fckeditor / ColdFusion rich textarea

Preface: I work on a project for my office that is hosted by a third party.  Therefore, I do not have access to all the inner workings of ColdFusion.  Specifically I do not have access to the fck_editorarea.css file.

For a new form in the project I need to add a rich textarea.¬† The rich textarea will sit atop a div with a background color so I need to change the textarea’s background color to white.¬† If I can’t access fck_editorarea.css to change the style what can I do?¬† I can change it via the DOM with JavaScript.¬† For kicks I also added a border.¬† Place the following script just before the </html> tag.

<script type="text/javascript">
fckItem=document.getElementById('NEWSBODY___Frame');
// change bgcolor
fckItem.style.backgroundColor="#FFFFFF";
// add a border
fckItem.style.border="1px solid #0A0A4F";
</script>

Easy enough.

ColdFusion Idol Worship

When I was a kid I idolized athletes. In college I idolized musicians. As a middle aged dude I idolize superior programmers.

Today I achieved something I am very excited about. I got a couple of lines (and one of those is a comment) of code included in one of Ray Camden’s projects at RIAForge. The project is GoogleCal. It’s a ColdFusion CFC for interacting with Google’s Calendar service. My tiny, wee contribution: helping to submit an “all day” event. It is such a small, small, small, small, small (keep going), minuscule piece of Ray’s project, but just to be able to contribute ANYthing to someone who gives so much to the CF community is freaking AWESOME.

Check it GoogleCal out here.