Announcement Announcement Module
No announcement yet.
Form bind breaks when loading page via non form controller Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Form bind breaks when loading page via non form controller


    New to Spring from Struts and loving it. However, have a structural issue that I would like to put to you.

    We represent web pages in our database as Page rows. The URL for a given request is used with a wildcard URL mapping to push the request to a PageController which uses a DAO to load the Page object before returning the ModelAndView with a logical name of page.getTemplate() which stores the Page's layout. This is because the same Page table stores Pages from multiple different sites, all with different layouts.

    The template is a Tiles definition. In this case, all is very well. We can browse the navigation tree and the URLs get mapped to their Page rows via PageController, and the tiles layout renders the various page parts.

    The issue is with forms. You see, each Page row also contains a collection of Assets. An Asset could be a HTML fragement, or a JSP or whatever. The tiles layout iterates these assets for the loaded Page using JSP includes.

    We need to have a validated form as an Asset. We therefore wrote a JSP which just contained a form and which used Spring's bind taglib. That got assigned to the contact Page row. When we click Contact, the page throws an error relating that neither Errors nor the model object contactInfo is available.

    Well, of course not, this is a fresh arrival at the form. This is a different mechanism to Struts:HTML whereby you can use the tag library to "draw" the form without actually doing any processing logic/validation output at that stage. The form's ACTION attribute would of course point to a Controller that was derived from a form Controller and therefore the Command contactForm would be available and so on.

    There is another issue of course in that the success view returned by the form controller must somehow get the result back through the page controller so the Page row is loaded for configuring the view but I have to define formView and Success as logical names rather than URLs, but this is a whole other issue.

    Right now we need to know if we can use Spring's validation mechanisms for our circumstances where arrival at the form will not be via a form controller but rather a page controller who does work relating to setting a Page model object for the tiles to draw.