Wednesday, March 31, 2010

Grails Wizardry: FCKEditor

So I am working on this side project, and obviously I chose Groovy and Grails to do the work.  I continuously marvel at how awesome, easy-to-use, and powerful the framework is, but lately I've been even more amazed at the plugins and how many there are now, how well documented (most) are, and how the quality has increased greatly.

We are using rich editors, and the FCKeditor was a no-brainer.  I was delighted to find out that it was available as a grails plugin.  I pulled it into my project, and defining an editor in one of my views was as hard as this:

value="${fieldValue(bean:mybean, field:'materials').decodeHTML()}">               ${fieldValue(bean:contentInstance, field:'materials').decodeHTML()}

The important parts here are:

  1. toolbar:  This gives you the ability to choose the set of tools for your editor.  More on this one later
  2. value: You can identify the preset value.  If this is html that was saved, then you must include the decodeHTML() call or else the value you will see is raw html.
The rest is pretty much boilerplate - obviously the height/width will depend on your site.

To customize the contents of your toolbar, you will need to specify a custom configuration file, which is in the form of javascript.  Your gsp page must contain:

<fckeditor:config CustomConfigurationsPath="${resource(dir:'js',file:'myconfig.js')}"/>

This file looks like this:

FCKConfig.ToolbarSets["ed-limited"] = [

You can define as many of these as you want.  See this link for configuration details.

Once you defined this, you can simply update the toolbar attribute on the FCKeditor to point to your new toolbar, in this case 'ed-limited'.

One big gotcha is that this uses 2.6 currently, while the newest stable version seems to be 3.1.

Sunday, March 28, 2010

The Brilliance of Southwest

When watching the yearly installation of March Madness, CEOs of all the major airlines not named Southwest must be furious.  Nearly every commercial break during the games features an advertisement touting Southwest's baggage policy.  In fact, most Southwest ads feature ridicule of other airlines.  I fly almost exclusively on Southwest.  Make no mistake - it's not perfect.  Sometimes flights are late.  Sometimes you have to too much taxiing, or to wait a while for a gate assignment.  The difference between Southwest and the rest is clear:  Southwest makes it a bit easier to deal with the stressful travel day by being cordial, helpful, and by performing their jobs professionally and with a smile.  Because of this advantage, Southwest can charge a little more than the bargain carriers, and not charge for baggage.

The CEOs of United, American, et al. can only be furious at themselves.  Jena and I were talking about how the show 'Undercover Boss' (which we love by the way) should feature a CEO of an airline, but then we joked that they would have to shut down the entire operation after all employees in the airport were fired by the undercover boss for being surly, unpleasant, and incompetent.

An example of the rank ineptitude:  'The Rest' has employed a baggage fee policy that encourages people to cram all their stuff into oversized baggage that they attempt, usually unsuccessfully, to cram into an overhead bin.  After being berated by the rude airplane staff (who let them on the plane with the large bag in the first place), the thrifty passengers are allowed to check their bags FOR FREE.  Now the people who played by the rules are mad because they had to pay and the people who cheated didn't.  The people who didn't pay aren't happy because they have been treated rudely by the flight attendants.  All of the people are wondering why they didn't fly another airline, like...hmmm...Southwest maybe?

Lesson to any managers of any company, any size, any industry, any location:  there is no excuse for rude, unprofessional behavior, no matter how hard or stressful your job may be.  If this behavior is tolerated, then it becomes accepted practice, and all of a sudden a few years pass by and you can't watch basketball without your company being made fun of by a company that never accepted that sort of behavior.