-
Jul 19th, 2011, 04:15 AM
#1
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.
-
Jul 19th, 2011, 04:28 AM
#2
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
-
Jul 20th, 2011, 04:58 AM
#3
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
-
Forum Rules