2008-05-19

A Grails WebFlow observation

Objects created and persisted either explicitly or implicitly to the flow context must implement the java.io.Serializable interface. But, closures can not be serialized. That means that any class that uses a closure such as constraints will probably have to do custom serialization. This is very easy to implement in Groovy since all objects have a properties map and maps can serialize. Just be certain to pick the right keys to serialize.

I've noticed that even objects created by the onChange event handler may end up serialized if the change happens inside an action node of a WebFlow.

EDIT: I stand corrected. It is much easier to mark the closures with transient instead of just def. This just works and requires no further thinking. I should probably put this in an example somewhere.