KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > riotfamily > riot > list > ui > ListController


1 /* ***** BEGIN LICENSE BLOCK *****
2  * Version: MPL 1.1
3  * The contents of this file are subject to the Mozilla Public License Version
4  * 1.1 (the "License"); you may not use this file except in compliance with
5  * the License. You may obtain a copy of the License at
6  * http://www.mozilla.org/MPL/
7  *
8  * Software distributed under the License is distributed on an "AS IS" basis,
9  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
10  * for the specific language governing rights and limitations under the
11  * License.
12  *
13  * The Original Code is Riot.
14  *
15  * The Initial Developer of the Original Code is
16  * Neteye GmbH.
17  * Portions created by the Initial Developer are Copyright (C) 2006
18  * the Initial Developer. All Rights Reserved.
19  *
20  * Contributor(s):
21  * Felix Gnass [fgnass at neteye dot de]
22  *
23  * ***** END LICENSE BLOCK ***** */

24 package org.riotfamily.riot.list.ui;
25
26 import java.util.HashMap JavaDoc;
27
28 import javax.servlet.http.HttpServletRequest JavaDoc;
29 import javax.servlet.http.HttpServletResponse JavaDoc;
30
31 import org.apache.commons.logging.Log;
32 import org.apache.commons.logging.LogFactory;
33 import org.riotfamily.common.util.ResourceUtils;
34 import org.riotfamily.riot.editor.EditorConstants;
35 import org.springframework.web.servlet.ModelAndView;
36 import org.springframework.web.servlet.mvc.Controller;
37
38 /**
39  * Controller that displays lists defined in the ListRepository.
40  */

41 public class ListController implements Controller {
42
43     protected Log log = LogFactory.getLog(ListController.class);
44
45     private String JavaDoc viewName = ResourceUtils.getPath(
46             ListController.class, "ListView.ftl");
47
48     private ListService listService;
49
50     public void setListService(ListService listService) {
51         this.listService = listService;
52     }
53
54     public void setViewName(String JavaDoc viewName) {
55         this.viewName = viewName;
56     }
57
58     protected String JavaDoc getViewName() {
59         return viewName;
60     }
61
62     public final ModelAndView handleRequest(HttpServletRequest JavaDoc request,
63             HttpServletResponse JavaDoc response) throws Exception JavaDoc {
64
65         String JavaDoc editorId = (String JavaDoc) request.getAttribute(EditorConstants.EDITOR_ID);
66         String JavaDoc parentId = (String JavaDoc) request.getAttribute(EditorConstants.PARENT_ID);
67         String JavaDoc choose = request.getParameter("choose");
68
69         ListSession session = listService.getOrCreateListSession(
70                 editorId, parentId, choose, request);
71
72         HashMap JavaDoc model = new HashMap JavaDoc();
73         model.put(EditorConstants.EDITOR_ID, editorId);
74         model.put(EditorConstants.PARENT_ID, parentId);
75         model.put("filterForm", session.getFilterFormHtml());
76         model.put("search", session.getSearchProperties());
77         model.put("searchQuery", session.getSearchQuery());
78         model.put("hasCommands", Boolean.valueOf(session.hasListCommands()));
79         model.put("listKey", session.getKey());
80         model.put("title", session.getTitle());
81
82         return new ModelAndView(viewName, model);
83     }
84
85 }
86
Popular Tags