CFGrid Problem Solved!
In my previous post My Adventure with CFGrid, I wrote about troubles I was having meeting some minor last minute client requirements. In short, they want a cool table with Ajax features like paging, but they also want links in the table in an Actions column that are not Ajax and take the user to a detail page. Sounds like an odd request for Ajax functionality but what the client wants the client gets.
My initial problem was how to add the links to the Actions column. This was solved with the help of Ray Camden who suggested using the querySetCell() method to add my link data to the query recordset after the query is executed. This worked well enough and my manager was impressed. Something I didn’t pay attention to initially was that the pagesize attribute of cfgrid is ignored when the query attribute is specified. The client definitely wants paging for larger recordsets, so the solution turned out to be using the bind parameter rather than the query attribute.
Having never used databinding before, I jumped right in and quickly found all sorts of little things that normally work, suddenly didn’t. None of my APPLICATION or SESSION variables seemed to be available. Variable not defined was what the error read. By the way, I highly recommend Firebug for debugging Ajax requests. The solution was to either hardcode my variables or add hidden form elements and then pass them in my bind parameter to the CFC. I ended up using both to finally get my awesome looking cfgrid that pages through 10 records at a time and has an Actions column which takes the user to a detail page.

While at CFUnited this I decided to ask around about why my SESSION and APPLICATION variables were coming up undefined when called via the bind parameter. It was explained to me that bind is accessing the CFC directly rather than as a normal ColdFusion request and that is why they were not available. This sounds reasonable to me, but I would like to get some confirmation. So I pose the question to all my fellow CFers out there. Is this really the case with databinding?
Add comment August 14, 2009
My Adventure With CFGrid
I’m using a cfgrid to display some data returned from a query. Not exactly rocket science, but I’ve managed to run into a bit of difficulty meeting a couple of final client requirements. Let me set up the scene here. First I have a form with several different search criteria, which are independent of each other. Depending on which search criterion is selected, a different grid will display. Each grid will has an Action column with links to another page.
Continue Reading Add comment August 11, 2009
Am I My Brother’s Keeper?
This is a departure for me, but I with all the talk about healthcare reform and all the rumors, lies, and confusion out there, I felt I could get away from programming for a bit to talk about this most important issue. I hope you’ll bear with me.
I continue to be amazed by those, particularly on the right. You know who I’m talking about. Most of them call themselves Christians. They rail against healthcare reform saying it’s too expensive or that they shouldn’t have to pay for those unfortunate enough to not have coverage. People, we are our brothers’/sisters’ keepers. If we don’t invest in them, who will? Remember the first Christians lived a communal life. We read in Acts 4:32-37 that they sold their possessions and share the proceeds so that no one among them was wanting for anything. I for one believe that in the greatest country in the world, with all our advances and resources, every American, even the least among us, is entitled to basic healthcare at the very least. We don’t get ahead at the expense of others. We move forward together or not at all. If we don’t invest in our own people, we have wasted our most precious resource. Reform will cost money, a lot of it. There’s no doubt about that. But I believe it is money well spent. I am fortunate enough to have health insurance that provides for me and my family. I don’t worry when my child gets sick or if I should suddenly develop a heart condition. I have absolutely no problem paying more in taxes, whatever the cost, so that the uninsured may have the same peace of mind. I do however worry that if I should become too sick, that my insurance provider could simply drop me, making care much more difficult to get. Again I have no problem paying more, whatever the cost, if it takes that worry away. People need to get over themselves. Our taxes go for programs and purposes we disagree with every single day. That will never stop. I think we can all agree that it is absolutely ridiculous that the greatest country on earth can’t be a leader in healthcare even though we have the most advanced medical technology and pharmaceutical research, the best medicines and doctors. It’s time we start acting like the leader that we are.
Add comment August 11, 2009
ColdFusion 8 CFC Not Generating Well Formed XML
I’m relaunching my parish’s web site using ColdFusion 8 and Fusebox 4 for the front end with a Flex 3 admin tool. My CFCs are doing just fine retrieving content for the front end. Now I have turned my attention to the flex backend and am having trouble. I’m using <mx:HTTPService> in a Flex component to call a .cfm page which make s a call to the CFC then generates XML with the following code:
<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Panel xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute” creationComplete=”sectionData.send()”>
<mx:HTTPService id=”sectionData” url=”http://path-to-my-server/act_mainMenuFlex.cfm“/>
<mx:DataGrid dataProvider=”{sectionData.lastResult.sections.section}” width=”600” height=”400“>
<mx:columns>
<mx:DataGridColumn dataField=”strSection” headerText=”Name” />
<mx:DataGridColumn dataField=”strDescription” headerText=”Description“/>
</mx:columns>
</mx:DataGrid>
</mx:Panel>
My .cfm page:
<cfprocessingdirective pageencoding = “utf-8″ suppressWhiteSpace = “Yes”>
<cfparam name=“strSection” default=“”/>
<cfparam name=“strDescription” default=“”/>
<cfparam name=“cntParent” default= 0 />
<cfif isDefined(“strDescription”) and isDefined(“strSection”) and strSection NEQ “”>
<cfinvoke component=“#APPLICATION.SectionManager#” method=“createSection” returnvariable=“qCreateSection” strSection=“#strSection#” strDescription=“#strDescription#”/>
</cfif>
<cfinvoke component=“#APPLICATION.SectionManager#” method=“retrieveSections” returnvariable=“qRetrieveSections” cntParent=“#cntParent#”/>
<cfoutput>
<cfxml variable=“sectionXML”>
<sections>
<cfloop query=“qRetrieveSections”>
<section>
<cntSection>#toString(cntSection)#</cntSection>
<strSection>#strSection#</strSection>
<strDescription>#strDescription#</strDescription>
</section>
</cfloop>
</sections>
</cfxml>
</cfoutput>
<cfoutput>#sectionXML#</cfoutput>
</cfprocessingdirective>
Executing the above I received: “Error #1090: XML parser failure: element is malformed.” I have to be missing something because when I simply <cfdump> the query result set, I see the XML which looks fine. However, if I execute the .cfm page by itself, I get no errors, but my code contains no XML tags. Rather it looks like this:
1 Home This is the home page for the St. Martin web site. 2 Ministries This is the section under which ministry pages belong. 7 Ministerio Hispano Nothing 8 Religious Education English relgious education 9 Educacion Religiosa Spanish religious education pages 3 Parish News This is the menu link to the news section. 10 FAQ Frequently asked questions 6 Parish InformationClergy and parish contact information. 4 Mass Schedule Link to the Mass schedule.
Obviously, not XML. I found the code for my .cfm page on the Flex 3 help pages at Adobe.com. Any thoughts on what I’m doing wrong? This seems like such an easy thing to do. I know I have to be missing something.
Add comment July 26, 2009
Fuseboxing progress – Navigation menu
I’ve been working to convert my church’s old site to Fusebox 4 for ColdFusion in order to get cleaner, more modular code and to make maintenance simpler for parish staff. I started off diagramming a database schema in which the content would be stored. This got me thinking about just how the site would work when finished. I then dropped the core FB4 files into my local webroot and started working.
With a schema in place, I was able to determine the necessary circuit.
- home – this is the default circuit
- sections – drives the navigation menu
- pages – handles page content
- news – drives the news module
- links – drives the links module
- contacts – drives the parish contacts module

Current static navigation menu
I began with the sections circuit and began coding fuseactions. The sections circuit will be the foundation for the navigation menu. Each section corresponds to a link in the navigation. I added a ‘parent’ to facilitate subsections which will appear as flyouts. I then began writing the sections CFC which will access the data. The section CFC contains your basic CRUD methods and one special method to handle subsections. Right now, since there is only test data in the DB, the menu isn’t fully populated with subsections. I should note, that I first considered using the built in ColdFusion 8 <cfmenu> and <cfmenuitem> tags to generate the menu. I actually built the menu, but then decide to go back to the CSS/JavaScript that is used in the current site. All I had to do was invoke the section CFC to display the section data as links in the navigation menu.

Dynamically generated fusebox navigation
Using the Frameworks explorer in CFEclipse, it was really easy to create circuit files and their corresponding fuseactions.
Add comment July 24, 2009