Viewing by month: October 2007

Oct 25 2007

Adrock says: ColdFusion Rocks.

Adam Lehman put a comment over on the Alagad Blog that I thought was fantastic, and I hope he doesn't mind me reprinting it here. It's a great comment in a longish discussion.

"ColdFusion was the very first web application server on the market. Our community has been around since the dawn of the internet. We invented this game! ColdFusion developers defined the Rich Internet Application back in 2001 with ColdFusion MX and Flash Remoting. People thought we were crazy, flash wasn't for building applications, it was for stupid web cartoons and skip intros. Now, everyone and their mothers are pickung up Flex and sweating our style. The fact is, our community has been defining the web since it's inception and we continue to do so...[non CFers will eventually ask] how the heck did you build that? How did you integrate with all those aspects of the enterprise? How did you do it so damn fast?"

I think I'm going to memorize that.

3 comments - Posted by Joe Rinehart at 9:39 PM - Categories: ColdFusion MX

Oct 18 2007

CFLDAP: JRun vs. JBoss gotcha

One of the teams I'm working with right now is in the process of moving an application that was developed on CF7 + JRun to a CF8 + JBoss deployment stack. Overall, it's been pretty smooth, but we've found one gotcha.

Summary for <cfldap /> pros:

The error message sent back from the LDAP authentication attempt differs, so if you're testing what went wrong based on the error message / error code, you'll need to change what you're testing.

Details:

When using the <cfldap /> tag for authentication, the underlying LDAP implementation throws an error when username and password are invalid.

Basically, you have to try/catch your authentication. The most easily Google'd example of this results in a <cfldap /> example shown in a recently defunct ColdFusion "journal" to which I'd rather not link. It looks like this:

<cftry>
<cfldap action="QUERY"
name="AuthenticateUser"
attributes="givenname,samaccountname,dn,cn,mail"
start="dc=adtest,dc=com"
maxrows="1"
scope="subtree"
filter="(&(objectclass=user)(samaccountname=#form.cfusername#))"
server="ns1.adtest.com"
username="#form.cfusername#@adtest.com"
password="#form.cfpassword#">

<cfset LoginMessage = "User Authentication Passed">
<cfcatch type="any">
<cfset LoginMessage = "User Authentication Failed">
</cfcatch>
</cftry>

That's not a very good way to do it: it considers all errors thrown during an authentication request equivalent. Handling the "invalid password" error would be much different than handling a "LDAP server isn't online" error: one should notify the user, the other should notify the user and set off a pager.

To that end, my use of LDAP authentication looks more like this:

<cftry>
<cfldap ... />

<!--- Invalid password or username --->
<cfcatch message="Inappropriate Authentication">
<!--- Do stuff --->
</cfcatch>
<cfcatch message="Connection to LDAP server failed.">
<!--- Do more serious stuff --->
</cfcatch>
</cftry>

On JBoss, instead of "Inappropriate Authentication," you get "Authentication failed:[LDAP: error code 49 - Invalid Credentials]", which obviously threw our code for a loop.

Conclusion

Literals like these should be configured outside of code (yes, I slopped and used a magic string), and they're likely to change between environments.

5 comments - Posted by Joe Rinehart at 5:15 PM - Categories: ColdFusion MX | Best Practices

Oct 18 2007

Flex bits: Accordion with Open/Closed Icons and Header Styles

One thing that's bugged me for a bit about the native Accordion control in Flex is that there's no default way (that I can find) to state an alternate icon or style for the header of the open child.

You can manually watch it for changes, changing the style (or other properties) of the header for the selected child, but that's a bit of an "outside in" approach.

I'm by no means a styling or skinning expert for Flex, so I wanted a solution that'd let me work in my more "developerish" and less "designerish" mindset.

To this end, I knocked together an extension of the default AccordionHeader that has two properties: openStyleName and closedStyleName. Pretty self-explanatory: it'll assign the open or closed style when the header's parent according changes its selected child.

Demo w/ view source is available at http://www.firemoss.com/blogsamples/accordionheader/.

Basic usage:

<mx:Accordion>
<mx:headerRenderer>
<mx:Component>
<accordion:MultistyleAccordionHeader
openStyleName="accordionHeaderOpen"
closedStyleName="accordionHeaderClosed" />

</mx:Component>
</mx:headerRenderer>
</mx:Accordion>

2 comments - Posted by Joe Rinehart at 3:26 PM - Categories: Flex

Oct 10 2007

Flex Builder 3 Beta 2 forgets ColdFusion?

I fired up Beta 2 of Flex Builder 3 last night. It starts with a nice new splash screen, but it has a glaring omission: the sample application is available in PHP, Java, and ASP.NET, but not Adobe's own Web application server, ColdFusion?

While it does add CFEclipse.org to the default update site and make the ColdFusion wizards easier to install, there's just no good reason I can see to omit ColdFusion from the sample app list. What's with that?

If anyone at Adobe wants to correct this, feel free to drop me a line at contact@firemoss.com. I'd be happy to port the app to ColdFusion.

12 comments - Posted by Joe Rinehart at 8:30 AM - Categories: Flex and ColdFusion

Oct 8 2007

Converted: From Flex Hack to Flex Developer

I wouldn't quite say I've been a Flex "Hack" up until recently, but I definitely haven't had the same level of tooling and formality behind my Flex applications as I have in the ColdFusion realm.

After working with slippery beasts like the dynamic typing of ColdFusion and the unpredictability of HTML interfaces, Flex is such a wonderful development environment that I've often felt it unnecessary to use many of the tools and techniques I've relied on in HTML-focused ColdFusion development.

On my current project, however, I'm changing my ways. Here's a quick list (not a tutorial) of tools I'm using that are changing my world:

FlexUnit

On the server side, unit tests have saved me when it comes to developing ColdFusion-backed Flex applications. It's a lot easier to develop services against programmatic tests than it is to work through a Flex UI.

Until today, though, I'd never used FlexUnit. In the past half-hour, I've installed it, written tests against the four Cairngorm commands (we just started it yesterday!) in the application I'm working on, and I can now test the controller, model, and services tier of my application without clicking through a UI. It's good stuff, and I'd recommend downloading the tool and reading Darron Schall's tutorial.

FlexAnt

Why use Ant when you can compile via Flex Builder?

In my current situation, it allows us to set up daily builds of our application on a testing server.

In other situations, it'd allow you to automate builds of your application pointing to alternate resources (such as environment-specific services-config.xml files, etc).

Additionally, my current project is to be "brandable," allowing alternate UIs to be used while keeping a single code base of controller, model, and service tier code. We're accomplishing this by writing the application in a code-behind style (see next section), using Ant to compile against a Flex library projects for each "brand" containing view-tier assets.

By doing all of this via Ant, we can use a single build script to compile and deploy changes to all brands of the application simultaneously.

Code-Behind

Code-behind is a technique that separates UI code from UI component declaration. I'm still a bit on the fence about it.

On the positive side, code-behind allows me to write UI code that'll be common across all of our "brands," allowing the actual view implementation to change drastically without altering underlying functionality.

In other words, presentation-focused developers only worry about the MXML tags. I worry about handling their behavior and linking them together in a code-behind class.

It's not without its quirks - Binding is nearly broken, requiring me to manually bind in the code-behind, which could trip up presentation developers wanting to more with bindings (or require them to write AS code in their view, which somewhat defeats the point of code behind).

Additionally, I'm afraid of how much code some folks may cram into a code-behind, mistaking code-behind for a full separation of concerns / MVC style architecture. Especially on the AIR side of the fence, it wouldn't be surprising to see an ASP.NET-style mess of SQL queries being placed inside of UI-tier event handlers (creationComplete on ContactListCodeBehind.as fires an SQL query to list contacts - whoa, it sounded OK in theory!).

Conclusion

If you're looking to make a shift from occasionally writing Flex applications to making them a large part of your development life, I'd encourage you to explore all three of these techniques / technologies. They're fairly lightweight ways to make Flex development easier, more productive, and more professional!

5 comments - Posted by Joe Rinehart at 9:24 AM - Categories: Flex | Best Practices