Archive for January 2006

moving to Spring (part 1)

January 31, 2006

I have been working with Java and Struts for web development for the past few years. Recently I tried to write a reasonably complicated site using the Spring MVC. Here are some of my observations.

I felt like the first thing I needed was some working examples. I dounf some reasonable ones from the Manning book Spring in Action. There was some good use of Tiles in the sample site and it helped me get off the ground with basics.

However (and I’ll probably devote most of this entry to this) the place I really got stuck adjusting to the Spring MVC was the fact that it is difficult (impossible?) to post data to a simple form controller. Apparently I had been doing this far too often in Struts. I understand exactly what the framework is trying to do with separating out the class’ response to a post vs. a get and it required me to rethink things a bit.

I ended up utilizing the AbstractWizardFormController. I was really off the ground now. The trouble is that I felt like I was now trying to fight the way the framework manipulates the movement through the pages instead of focusing on my business logic. In the end everything mostly worked out but it wasn’t without pain.

A side issue that I had with using the wizard approach is that some of my pages appeared elsewhere as standalone pages for updating a user’s profile, etc. They were nearly the same but not quite. I was able to successfully refactor a lot of validation code between controllers without much trouble but did have to resort to duplicating some JSP in the project.