Thursday, July 23, 2009

Looping in ColdFusion

I really wish you could loop an array, query and struct in a consistent manner in ColdFusion. In truth, you're just iterating over a collection of data. Why does it need to be so different? For example, here's looping over a collection of Users and retrieving a single User record.


<cfloop array="#users#" index="user">

</cfloop>



<cfloop collection="#users#" item="i">
<cfset user = users[i] />
</cfloop>



<cfloop query="users">
<!--- convert the row into a struct in order to access all the user's data in a single collection --->
<cfset user = {} />
<cfloop list="#users.columnList#" index="i">
<cfset user[i] = users[i][currentRow] />
</cfloop>
</cfloop>


I really wish I could do...


<cfloop collection="#users#" index="user">

</cfloop>



<cfloop query="#users#" index="user">

</cfloop>


... but that might make too much sense.

Seriously, someone just needs to take all the nice parts of ColdFusion and re-write the damn language. It would make me so much happier. Also, don't get me started on the lack of #'s in cfloop query.

Thursday, June 18, 2009

ColdFusion Inconsistencies

One of my biggest pet peeves in programming is inconsistency. I absolutely hate it when things aren't consistent, especially when it's something really, really simple.

ColdFusion 9 is going to include some new functionality for dealing with spreadsheets. While this should be a huge win for ColdFusion, I'm a little disappointed in the implementation. Why? Let's take a look at the tags:


<cfspreadsheet action="read" src="c:\Sales.xls" query="sales" />


Hmmm... that looks pretty similar to...


<cffile action="read" file="c:\Sales.xls" variable="sales" />


But they changed "file" to "src" and "variable" to "query". Odd. That also looks pretty similar to...


<cffile action="write" file="c:\Sales.xls" output="#sales#" />


Well at least that's a little consistent. And the spreadsheet equivalent...


<cfspreadsheet action="write" filename="c:\Sales.xls" name="sales" />


What? Now it's "filename"? And now they're using a "name" attribute instead of the "variable" attribute? Huh? Why?

Just for fun, let's check out one last cffile action...


<cffile action="copy" source="Sales.xls" destination="Sales2.xls" />


Now they're using "source" again, but this time spelled out.

Honestly, am I the only person that's bothered by this?

Friday, June 5, 2009

Button "Padding" in IE

Ran into a weird issue today with IE automatically adding a percentage-based padding around text inside buttons. The following post does a good job explaining the problem and the solution, which is a little wonky.

http://latrine.dgx.cz/the-stretched-buttons-problem-in-ie

Thursday, May 14, 2009

cf.Objective()

I'm at cf.Objecive() right now and so far things look pretty promising for the future of ColdFusion. I'm especially excited about the use of Hibernate, Ehcache, implicit getters and setters, explicit local scope, and full scripting of components. Granted I've known about most of this stuff since Max, but it's refreshing to hear about it again.

Tuesday, May 5, 2009

Spin Move!

I decided to play around with the ColdFusion/ColdSpring/Spring/Groovy/Hibernate stack again. So far I've got 4 out of 5 working in a very simple test project without too much of a headache. I'm actually pretty surprised how easy it was to hook up Spring to ColdSpring as a parent bean factory. Now I just need to get Hibernate working, which should be interesting since I've never played with it before. I'm pretty excited since I'm thisclose to using transient objects in ColdFusion without worrying about performance.