Archive for the ‘AJAX’ Category

Cflayout first tab does not show content bug

Monday, March 29th, 2010

Another issue I ran into when converting some older Coldfusion 8 applications over to a Coldfusion 9 server concerning tabs using the tag. Unlike getDataSource() this issue is a Coldfusion 9 bug. The issue is that if you create a tab layout the first tab does not have an auto-height property. That being said, no matter how much content you put inside the region it will never expand to show the content.

MrTee posted on the Coldfusion 9 docs both the problem and the solution. This is not my solution, I’m just spreading the word here. The link to his comment is here. He has also posted the correct javascript file here.

The problem needs to be corrected in the layout.js file. If you are in your wwwroot folder look under CFIDE/scripts/ajax/package directory. Once you have this file open you can make the changes as expressed by MrTee himself.

The change I made is on line 70 and changed from

var _70=new Ext.Panel({title:_6a,contentEl:_68,_cf_body:_68,id:_69,closable:_6c,tabTip:_6b, autoScroll:_6f,autoShow:true});

to

var _70=new Ext.Panel({title:_6a,contentEl:_68,_cf_body:_68,id:_69,closable:_6c,tabTip:_6b, autoScroll:_6f,autoShow:true,autoHeight:true});

I hope this helps anyone with the same problem out.

All in all an ‘autoHeight:true’ needs added to the Panel() method. As far as I know this has not been addressed in an update by Adobe, but has been acknowledged. I used this solution and it worked perfect with no known side-effects on my own applications.

Coldfusion 9 getDataSource() now getStore()

Monday, March 29th, 2010

This doesn’t directly pertain to Coldfusion 9, but to the ExtJs library.  That being said, Coldfusion 8 runs off of an older version of the ExtJs library while Coldfusion 9 updated to the latest version 3 of the library.  If you are converting any Coldfusion 8 applications over to a Coldfusion 9 server keep in mind that your use of the Coldfusion AJAX components will no longer work for any components that looked for the underlying datasource.  So, for example, if you had a Coldfusion 8 grid implemented using the <cfgrid> tag and for whatever reason needed to grab some of the underlying ExtJs functionality of that grid by grabbing the grid datasource, you will need to make the update in your javascript.  Let’s pretend we have a grid named ‘mygrid’.  The Coldfusion 8 javascript code probably looked something like the following.

Coldfusion 8

//get our grid object
var mygrid = ColdFusion.Grid.getGridObject("mygrid");

//get the datasource of our grid
var mygrid_ds = mygrid.getDataSource();

//get data when the grids load
mygrid_ds.on("load", get_my_grid_data);

Once you move that code to the Coldfusion 9 server the ‘getDatasource()’ method will need to be changed to ‘getStore()’. So our new javascript would look like the following.

Coldfusion 9

//get our grid object
var mygrid = ColdFusion.Grid.getGridObject("mygrid");

//get the datasource of our grid
var mygrid_ds = mygrid.getStore();

//get data when the grids load
mygrid_ds.on("load", get_my_grid_data);

No idea why this change was made, but certainly no reason to panic. Simple fix.

Using jQuery, AJAX, and Coldfusion to filter SQL results

Sunday, March 7th, 2010

The following post will explain the logic behind the ‘live’ search results that are becoming more and more popular on the web.  The idea is that you have a record set at hand ready to be searched as a user types into an input box what they are looking for.  While in traditional software programming this has never been a huge deal, the request/response nature of the web makes our lives as web developers a little more difficult.  To bypass the request/response model we let the searching happen via the client using AJAX.

For this example three files will be needed.  The client file (the file with the filter tool and search results), a javascript file to handle the AJAX and jQuery output, and a Coldfusion component to handle the data processing.  I’ve set up a demo here to check out so you’ll know what we’ll be building.

Let’s take a look at the client file first.

jquery_result_filter.cfm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<!--- PROXY --->
<cfajaxproxy cfc="path.to.jquery_result_filter" jsclassname="filter">

<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title>Untitled Document</title>

		<!-- JQUERY LIBRARY -->
		<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js" type="text/javascript"></script>

		<!-- JQUERY_RESULT_FILTER.JS -->
		<script src="js/jquery_result_filter.js" type="text/javascript"></script>
	</head>

	<body>
		Filter:
		<input type="text" name="filter" id="filter" value="" /><br /><br /><br />

		<p>Data:</p>
		<div id="output"></div>
	</body>
</html>

We have here a a proxy at the top that allows us to make asynchronous AJAX calls to the Coldfusion server. For javascript we load in the jQuery library and our javascript file that handles the AJAX calls and the data output to the DOM. In the body there is an input field which serves as our filter and an empty div which will have data loaded into it dynamically using jQuery.

Let’s take a look at our component to see how the data is being processed as the user types their filter.

(more…)