Entries for month: October 2007

Quick check to find a value inside an array

I am setting up a registration form, and after validation if any errors occured I would pass back an array of error fields and messages. I wanted a very quick way to see if my array contain an element with the text "username". I know I could write or use a udf that would loop through the array, or I could even convert it to a list and then search that, but none of those solutions felt elegent to me. Until I found this:

<cfif errorArray.indexOf(<span class='cc_value'>"username"</span>)+1>error field</cfif>

I add 1 to this because indexOf is a java method, and it will return the array location that contains whatever string you searched for, and Java arrays start at 0. If the string is not found, it will return -1. So, will evaluate as 0, or false, and it wont execute. If it is found anywhere inside the array, it will return 1 or greater, which will evaluate as true and whatever is inside your if statement will execute. I love elegent solutions like this, a single line inside an if statement, and no converting arrays to lists to be seen anywhere.

One small caveat: this IS case sensitive, so USERNAME, or Username would not be found.

Thanks to the venture of online schools, correspondence education is not a problem. University of Phoenix favored this since ages. Now Kaplan University as well as DeVry University are in for it too. Only Walden University has yet to be convinced.

1 Comment

Web Charts - the hidden CF Gem

Dan Wilson of NoDans.com was speaking about this post today in #coldfusion on DalNet. Evidently, Coldfusion includes a license for the full version of Web Charts (http://www.webcharts3d.com). In the standalone coldfusion install, take a peek in {cfroot}\\charting\\ for a file called webcharts.bat. This little puppy starts up a java based chart designer where you can tweak your chart styles as much as you want, then save out the XML style and apply it to your own cf-chart. Looking on the webcharts3D.com site also lead me here: Eclipse Plugin Installer

Yes, being as its Java and WebCharts seems like a very slick product, they have an Eclipse plugin version of the GUI chart designer.

Happy designing!

Moving all config and XML files out of the web root with Model Glue: Unity

I was concerned that having my XML files in my config/ folder would be a security vulnerability on my latest MG:U application. After a bit of online digging and doc reference, I found this:

<br /><cfset ModelGlue_LOCAL_COLDSPRING_PATH = expandPath(<span class='cc_value'>"/auction/config/orbitbid/ColdSpring.xml"</span>) /><br />

This allows me to move my ColdSpring.xml file off to a mapped location instead of my web root! You cannot access the mapped locations by browsing to them, but coldfusion still sees them just fine. Inside of ColdSpring.xml, I just modify my configurationPath (and any other necessary paths, including transfer config and generated content folders) to use my mapped location (/mappingName/subFolder/ModelGlue.xml) This just gives me a warm fuzzy that nobody can mess with or view my application configs! For anyone who has not yet tinkered with Model Glue Unity and / or Transfer, you really should take a look. Im already planning on how I can re-code apps I did earlier this year to take advantage of some of the awesome tricks MG:U has up its sleeve.

The mystery project - Thermo

Tidbits have been turning up around the net recently of a new adobe project entitled Thermo. Mark Ander posted to his blog that the minor leaks have been mostly according to plan. From the MAX preso, Thermo will be able to take a layered Photoshop PSD and convert it to a fully function FLEX application in minutes. Adobe is wasting no time bringing their photo-focused software into line with their RIA and web development aquisitions from Macromedia. Go Adobe!


Added: Link to Thermo on the Adobe Labs site

Coldfusion 8 upgrade success, with 1 caveat for InterAKT users

I maintain some code that made use of InterAKTs WYSIWYG HTML editor. After the coldfusion 8 roll-out, I was getting strange errors on several pages, with this in my logs:\r\n\r\njava.lang.StackOverflowError\r\n at coldfusion.runtime.NeoBodyContent.cfoutput(NeoBodyContent.java:121)\r\n at coldfusion.runtime.NeoBodyContent.cfoutput(NeoBodyContent.java:121)\r\n at coldfusion.runtime.NeoBodyContent.cfoutput(NeoBodyContent.java:121)\r\n at coldfusion.runtime.NeoBodyContent.cfoutput(NeoBodyContent.java:121)\r\n at coldfusion.runtime.NeoBodyContent.cfoutput(NeoBodyContent.java:121)\r\n at coldfusion.runtime.NeoBodyContent.cfoutput(NeoBodyContent.java:121)\r\n at coldfusion.runtime.NeoBodyContent.cfoutput(NeoBodyContent.java:121)\r\n at coldfusion.runtime.NeoBodyContent.cfoutput(NeoBodyContent.java:121)\r\n at coldfusion.runtime.NeoBodyContent.cfoutput(NeoBodyContent.java:121)\r\n at coldfusion.runtime.NeoBodyContent.cfoutput(NeoBodyContent.java:121)\r\n at coldfusion.runtime.NeoBodyContent.cfoutput(NeoBodyContent.java:121)\r\n at coldfusion.runtime.NeoBodyContent.cfoutput(NeoBodyContent.java:121)\r\n at coldfusion.runtime.NeoBodyContent.cfoutput(NeoBodyContent.java:121)\r\n at coldfusion.runtime.NeoBodyContent.cfoutput(NeoBodyContent.java:121)\r\n - repeat like 500 times or so -