Sunday, November 27

Ideograms

For my research at UCL, I ran IM log analysis focusing on the English and Chinese languages. The statistical analysis assumed each individual Mandarin character/pictogram as 1 individual character, in order to compare them with their English equivalent.
This disturbed me then and disturbs me still,
because each Mandarin ideograph can in fact contain more than one pictogram.
Hence, how accurate and precise are results obtained this way, since there is no one-to-one mapping between all Mandarin characters and English words?
Perhaps I need to check each set of ideograms before matching them to an English word.

Monday, November 21

Disable form submission via Enter key

Here are 3 ways to disable form submission by hitting the ENTER key.

1. Submit the form using the onClick event handler instead of onSubmit event handler. It is necessary to return false from the onSubmit event handler to prevent submit on hitting the ENTER key.

2. Create a function that disables the Enter key, and apply it to each input textfield, ie, onkeypress="return noenter()"
Sample javascript code below:

function noenter() {
  return !(window.event && window.event.keyCode == 13);
}


Or

function disableEnterKey(e) {
  var key;
  if(window.event) key = window.event.keyCode; //IE
  else key = e.which; //firefox
  if (key == 13) return false;
  else return true;
}

3. Create a dummy form with a single hidden field.

Friday, November 18

A wink at Wicket

Choice is good.
Right now I can happily choose between several frameworks that I'm comfortable and familiar with (Spring, WebWork, Struts) for RAD development in J2EE. Struts seems to have been somewhat stagnant, since about mid-2004, and Spring comes across as having gained a lot of momentum these days.
However, this scenario can change. The "merger" of WebWork and Struts might inject (talk about dependency injection, huh?) new blood (and the good features of WebWork) into Struts; the rate of framework ideas and projects hasn't showed any signs of slowing down (Turbine, Expresso, Tapestry, Cocoon, Maverik, Laszlo, Echo, SOFIA, Verge, VRaptor, Jucas, MyFaces, Chrysalis, Wicket, and, the most recent one in my knowledge, Swato).

Because I want to be aware of developments within the frameworksphere and its future, I've been paying some attention to Wicket recently.
There are some reports claiming very high adoption levels for Wicket, which I frankly find hard to believe. Nevertheless, I'll keep an open mind -and an open eye to its future development.
There is a clean post at Code Poet on creating an Ajax autocomplete field with Wicket which I find attractive in its simplicity:


http://jroller.com/page/wireframe/?anchor=choice_is_good

Tuesday, November 15

Text Editor for the Web

One of the biggest usability issues of Web-applications is the text-editing support. Forcing users (often computer illiterate) to surround their text with HTML tags to bold or italicize it cannot be any more user-unfriendly.
Today Conor, my colleague at work, pointed me to this Text Editor for
the Web: http://www.fckeditor.net/

It looks good,


and it is pretty simple to use and integrate.






[Update:] And then there were t
wo. TinyMCE also looks good, it is even easier to install and configure, and in its simplest has a smaller footprint than FCK. Thanks to Micah for the link.

[Update:] I found a few more, each with different size/functionality tradeoffs. Screenshots below (click to
visit their respective sites):


widgEditor (from the very respectable Man In Blue)

Whizzywig (don't be put off by the uglier screenshot)

Monday, November 14

UUID Generators

In my J2EE world, every now and then I am asked to generate sets of a few hundreds/thousands of unique Strings -for reasons such as unique identification of vouchers sent. I usually *borrow* code that has been widely used and tested, such as Hibernate's UUIDHexGenerator or Tomcat's session id generator, the choice depending on the requirements for the String size.
Well, for future reference, here's a link to a very useful (and open-source) UUID generator library:

http://jug.safehaus.org/

String are
128-bit Universally Unique IDentifiers according to the IETF UUID draft specification. To give an example, generated Strings can look like this: a02c73a6-b8c9-46e9-a368-8b9f9ef8ff7f

[Update]
From this thread on Jason Carreira's blog, I found out about J-GUID by Steve Woodcock, whose code is currently used as the UUID generator in the XDoclet project.
Darren Hobbs usefully points out that Java has built-in GUID generation:
java.rmi.server.UID (unique over time within a JVM) and java.rmi.dgc.VMID (unique across all JVM's).
Finally, and to our utter joy, the JDK 5.0 already ships with a built-in UUID package.