Results 1 to 3 of 3

Thread: Spring MVC 3.0 with Apache Tiles Question

Hybrid View

  1. #1
    Join Date
    Jul 2011
    Posts
    3

    Default Spring MVC 3.0 with Apache Tiles Question

    Hi,
    I'm using spring mvc (3.0) with apache tiles in my project. I have multiple forms (listed below) in my pages and each of them is a separate tile (search.jsp, userlogin.jsp and xxxBody.jsp).
    1. Search
    2. UserLogin
    3. Other form in the body.

    The Search and UserLogin sections are common in all the pages. And for each of the form(s) I have to set and send a command object in the model -
    1. model.put("userBO", userBO);
    2. model.put("searchBO", searchBO);
    3. model.put("otherBO", otherBO);

    Since the userBO and searchBO are common, I have to explicitly set them in all the mvc controller methods. Is there a common place I can set these? I am not using any ajax.

  2. #2
    Join Date
    Jul 2011
    Posts
    3

    Default

    I tried creating a CommonController and created two methods with the url pattern @RequestMapping(value = "/SearchPortlet") and @RequestMapping(value = "/LoginPortlet"). I had then set the “searchBO” and “userBO” in these methods respectively and modified my tiles-definition as shown below (see search/userLogin).

    <definition name="baseLayout" template="/WEB-INF/layout/brownstone-layout.jsp">
    <put-attribute name="title" value="" />
    <put-attribute name="content" value="/WEB-INF/jsp/content/common/home/body.jsp" />
    <put-attribute name="logo" value="/WEB-INF/jsp/content/common/logo.jsp" />
    <put-attribute name="menu" value="/WEB-INF/jsp/content/common/menu.jsp" />
    <put-attribute name="search" value="/Machete/SearchPortlet" />
    <put-attribute name="userlogin" value="/Machete/LoginPortlet" />
    <put-attribute name="stats" value="/WEB-INF/jsp/content/common/stats.jsp" />
    <put-attribute name="categories" value="/WEB-INF/jsp/content/common/categories.jsp" />
    <put-attribute name="footer" value="/WEB-INF/jsp/content/common/footer.jsp" />
    </definition>

    But I ended up with another problem. The validations do not work. If I do a search (RequestMethod.POST) it displays the validation error messages for userLogin as well.

    I am new to spring mvc. I’m sure there should be a better way :-) Any advice would be greatly appreciated. I’m open to restructure my application.

    Cheers
    Joseph

  3. #3
    Join Date
    Jul 2011
    Posts
    3

    Default

    Can somebody please advice?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •