Monday, May 08, 2006

Spring and Bodington

Currently Bodington doesn't use the typical MVC model and each web request maps directly to a controlling template. This makes handling things like errors in forms and redirects difficult. To try and improve matters I have attempted to integrate the Spring MVC framework into Bodington. This is a quick summary of the current state of play.
  • When a request comes in the normal request handling of loading the resource and permission checking takes place.
  • Extra URL handling has been added that means that any file beginning with bs_spring is handed off to the Spring servlet.
  • The Spring servlet has a Bodington specific mapper that looks for the resource in the request and then attempts for find a bean matching /facilityname/page.
  • Control then passes to the bean which is a normal Spring controller.
  • The controller then returns its model and view which are mapped to a JSP.
One problem is that the Spring code depends on a facility name, maybe it should depend on the resource directly? We also have alot of duplication of the facilityname all over the code, it's in the spring configuration for the bean names and it's in the view names that are returned by the controllers. Maybe we could use the package names to infer the facilityname? However this depends on having utility code that is called as you can't have the view resolved do the work as it only knows about the view string and the locale.