Archive for April 2008

CSS Naked Day 2008

Monday, April 7th, 2008

I’ve signed up to participate in the third annual CSS Naked Day, which will be celebrated on April 9th! For the entire day, my site will be without style!

If this is the first time you’ve heard of CSS Naked Day, it was started by Dustin Diaz to promote Web Standards:

“This includes proper use of (x)html, semantic markup, a good hierarchy structure, and of course, a good ‘ol play on words. It’s time to show off your <body>”

Are you brave enough to strip naked for a day?

Note: Only my content delivered through WordPress will be “naked”, the rest will be left “fully clothed”.

Struts 2 ParametersInterceptor

Saturday, April 5th, 2008

Are your logs being filled up with errors like:

ERROR - ParametersInterceptor.setParameters(204) | ParametersInterceptor - [setParameters]: Unexpected Exception caught setting '_' on 'class com.company.web.MyAction: Error setting expression '_' with value '[Ljava.lang.String;@1491ddc'

If so, it’s because Struts 2 is parsing the query string/post data and trying to “set” a value for each parameter it finds.

I’m working on an Struts 2 application utilizing the jQuery JavaScript library for the UI and the Displaytag tag library for displaying tables.

With jQuery, I’m using the “no-cache” option (cache: false) on all Ajax calls, which adds “_=timestamp” to each request. Since I don’t have a property called “_” in my Action class, I get an error (mentioned above) in my logs for each request.

Same with Displaytag, except the parameters causing errors are in the form of “d-#-X“, where “#” is a unique id (usually 4 or 5 digits) and “X” is either p, s or o. They are used to determine the page (p) and/or the table sort order (o for asc/desc and s for which column).

The solution: configure Struts (struts.xml) to ignore these parameters:

<interceptors>
   <interceptor-stack name="defaultStack">
      <interceptor-ref name="params">
         <!--
            Excludes the jQuery no-cache _ parameter and
            the Displaytag d-#-X parameter(s)
         -->
         <param name="excludeParams">
            _,d-\d+?-[sop]
         </param>
      </interceptor-ref>
   </interceptor-stack>
</interceptors>

If you have a different parameters that are causing problems, just put them in the excludeParams node, comma separating multiple parameters.

Symbolic links in Windows

Friday, April 4th, 2008

Symbolic links can be very useful, but if you are a Windows user, you’ve had to use junction points because there hasn’t been native support for symbolic links until recently.

Windows Vista and Windows Server 2008 now support symbolic links mklink command. See Junfeng Zhang’s write up on the mklink command.

For those using Windows 2000 or XP, you’ll still need to use junction points to achieve a similar effect. Microsoft has a KB article on creating junction points, but there are some drawbacks to manually trying to manually manage junction points.

Fortunately, there are tools available that ease the pain of using junction points and prevent you from having to know all of the command line options. One such tool is NTFS Link, which provides shell integration for junction points. You can simply right-click in a folder and select New > NTFS Junction Point. Then select the target folder to link to and a “new” folder, named “Link to target folder” will be created in the directory you are in.

So, if you are a Windows user, you now have a couple of different options for creating and using symbolic links!