1 24 package org.riotfamily.riot.list.ui; 25 26 import java.util.HashMap ; 27 28 import javax.servlet.http.HttpServletRequest ; 29 import javax.servlet.http.HttpServletResponse ; 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 41 public class ListController implements Controller { 42 43 protected Log log = LogFactory.getLog(ListController.class); 44 45 private String 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 viewName) { 55 this.viewName = viewName; 56 } 57 58 protected String getViewName() { 59 return viewName; 60 } 61 62 public final ModelAndView handleRequest(HttpServletRequest request, 63 HttpServletResponse response) throws Exception { 64 65 String editorId = (String ) request.getAttribute(EditorConstants.EDITOR_ID); 66 String parentId = (String ) request.getAttribute(EditorConstants.PARENT_ID); 67 String choose = request.getParameter("choose"); 68 69 ListSession session = listService.getOrCreateListSession( 70 editorId, parentId, choose, request); 71 72 HashMap model = new HashMap (); 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 |