Wednesday, July 23, 2008

Populate coldfusion bean from query

I thought of a nice way to populate coldfusion beans from a query. It might be obvious, but we have code all over in our mach-ii application that explicitly calls setters on a bean after query. So following method got added to BaseComponent.cfc (thanks Hal Helms). It's not checking anything so the burden is on query to have the right data.


If you use generic setter the line:

can be replaced with:


So this allows me to do something like this:

No comments: