How to set the default input focus on a field in an HTML web form

When I create a web-based user interface I tend to be a fanatic about making sure that the first input field on a form gets input focus when the form is first displayed. It always drives me crazy when I go to a web form that requires text input, but the developer of the page hasn't taken the time to put the default focus in the first field of the form.

So ... after looking around at some HTML/JSF/Struts/JSP code I've written over the last few years, the following JSF example shows the most concise way I know of setting default input focus on an HTML form field:

How to run an AppleScript from the Mac OS X Unix shell

AppleScript FAQ: How can I run an AppleScript script from the Mac Unix terminal (Unix command line)?

A cool thing about Mac OS X is that you can run AppleScript programs from the Unix shell. (Well, I guess it's cool if you're a Unix user.)

Running an AppleScript program from the Unix shell turns out to be surprising easy. For instance, if my current working directory has a script named OpenUrls.scpt in it, I can run that script from the command line like this:

Sample Mac Jar Bundler Ant build script

I was going to write a little tutorial on how to use the Jar Bundler Ant task for Mac OS X, but I don't have the time to do that right now.

So, I'll just share my Mac OS X Java Ant build script, which includes the JarBundler task. You should be able to use this Ant build script to build a Java application so it appears to the user to be a native Mac OS X application, even though it's really a Java application under the covers.

AppleScript error: Can't make (handler) into type string

If you ever get the following error message in an AppleScript program (at least while editing the program in the ScriptEditor):

Can't make (handler) into type string

fear not, it seems to be pretty simple to cure. In my case I got this more-specific error message:

Can't make (handler getDayOfWeek) into type string

This error just means that I tried to call a function like this:

How to run JRuby from a Ruby script on a Windows PC

I'm doing some crazy things at the moment, basically calling JRuby from a Ruby script on a Windows 2000 system. I'm doing this because there are a bunch of JRuby scripts that I want to run sequentially, and I also want to check for errors after each run, so what better way to invoke them and look for resulting errors than with Ruby, especially on a Windows system? :)

Syndicate content