Archive for March, 2011

Handling Date Parameters in Grails

Mar 28 2011

Grails generally makes it very easy to bind request parameters to domain objects or command objects with properties of varying types. For most request parameters, a simple call to a controller’s bindData() method is all you need to handle property binding and type conversion. Unfortunately, the default Date binder is very rigid and only handles […]

Highlight text using Lucene

Mar 06 2011

The following code illustrates how to use the Lucene highlighter to highlight text in any String.

This code will wrap matching values with a bold tag. Example usage is as follows: java -cp LuceneHighlighter http://site/index “words”

Scale an Image in Java

Mar 06 2011

Java has a rich Image manipulation layer. The following code shows how you can scale an input BufferedImage.

Let’s step through the code. The method scale creates a new BufferedImage object with the new scaled dimensions. The following rendering hints are then set on the new BufferedImage.

These instructions tell the Image IO […]