You Can’t Proxy TransferObjects in ColdSpring

In an attempt to use TransferObjects as event-beans I created a class called TransferObjectBindingAdvice that would wrap around the setter methods called by the Mach-II event-beans, to be installed and called via the AOP hooks in ColdSpring. I had high hopes that this proxied object would be able to take the place of the more advanced data binding hooks that I would’ve liked to see in the upcoming 1.9 release of Mach-II.

I wanted to be able to verify that setters expecting a Date object would get a valid date string, sure; but I also wanted to be able to bind more complex objects to the event-beans. For example, I could pass in the TransferFactory in the aspect’s declaration in the ColdSpring configuration file, and use it on a setter for a many-to-many relationship which would be represented as a checkbox group on a form. Simply loop through the list of IDs passed as that checkbox group and build your relationship, all before the controller gets called.

Unfortunately Sean Corfield pointed out this approach was technically impossible. He told me that TransferObjects are generated dynamically and the methods only exist at runtime, so they can’t be proxied by ColdSpring.

Which brings me back to square one. What is the best way to handle form-binding cleanly in Mach-II? Do I need to create model objects and be done with it? Should I use Transfer decorators? Should I give up hope of using TransferObjects, the event-bean command, and the <form> taglib in harmony?

Nah. Next up: decorators!

Leave a Reply

Powered by WP Hashcash