Wednesday, January 13, 2010

Spring Lessons

In the past few days, the veils obstructing a couple rules-of-thumb have slowly melted away:

1. Don't use model objects as form backing objects. Use simple value objects instead. This adds an extra layer, but eliminates complications. This is especially true in Spring WebFlow (2.0.7) which does not instrument the "open session in view" pattern, unlike Spring MVC which odes.

2. Make sure your value object fields are Strings as much as possible. If a field represents a number, you can convert it later. Doing this avoids the need to configure pretty binding error messages for the user, when, for example, the user enters characters into a form field which binds to an Integer field in the value object.

Added (2-19-2010): More generally, if you are discontinuing the use of a database column that has been in existence for a long time, do not delete the column, because removing all mentions of that column from all the code can prove to be quite hairy.

Tuesday, January 5, 2010

Is Spring WebFlow worth the trouble?

This post begs to be fleshed out, and I hope to return and do so. The question is: Is Spring WebFlow really worth all the trouble? It's a nice abstraction, but does it save time? I'm not so sure. For one, there's no OpenSessionInViewFilter pattern in WebFlow.

A work colleague pointed out that WebFlow saves you from writing a lot of controller code for transitioning from screen to screen. Also, it aims to solve the "back button" problem and related issues.

Monday, January 4, 2010

Invoke window.open() from a link

Jennifer Madden does a great job explaining how to invoke JavaScript's window.open() method from a link, avoiding some common pitfalls. Thanks Jennifer!