Thursday, July 2, 2009

Dynamically resizing a CFWindow

I've recently been exploring the underlying ext javascript framework that Coldfusion uses for some of its tags (cfwindow, cfgrid, etc.). In one of my projects I needed to dynamically resize a cfwindow through an onclick event. Take this simple html page for example:

<a href="#" onclick="ColdFusion.Window.show('myWindow')">Click Me</a>
<table>
<tr>
<td>Height:</td><td><input type="text" name="theHeight" id="myHeight" /></td>
</tr>
<tr>
<td>Width:</td><td><input type="text" name="theWidth" id="myWidth" /></td>
</tr>
<tr>
<td colspan="2" align="right"><input type="button" value="change" name="submitIt" onclick="myWindow()" /></td>
</tr>
</table>

<cfwindow name="myWindow" initshow="false" height="300" width="600" >This is a CFWINDOW</cfwindow>

The anchor tag at the top shows the window and the input elements are for showing and resizing the window. Next we add the javascript for resizing the window.

function myWindow(){
var theView = ColdFusion.Window.getWindowObject('myWindow');
theView.resizeTo(document.getElementById('myWidth').value, document.getElementById('myHeight').value);
ColdFusion.Window.show('myWindow');
}

You'll notice an unfamiliar function called resizeTo. This is actually diving a bit into the EXT library (1.1). It can be found here. Make sure you use 1.1 and not the most current version since ColdFusion uses 1.1. After reading a little from Adobe livedocs you'll find that getWindowObject returns the Ext object "Basic Dialog". To find all the functions available go to the ext docs and find BasicDialog and voila. You now have all of the properties and methods for that object.

Wednesday, July 1, 2009

Hello World

This is my first posting and I'm not quite sure who will read this but my hope is that this will prove helpful information for novice and experienced Coldfusion programmers. My plan is to keep it dedicated to Coldfusion but you'll find some other subjects thrown in that I find interesting. I'm a die hard Mariner's fan, so you might find some M's ramblings. You'll soon also discover my extreme hatred for Internet Explorer. They'll be some hating on that as well. I use jQuery quite a bit so they'll be some topics on that. But all in all, this is geared for Coldfusion.