1 | package edu.iu.uis.sit.portal.portlet.admin.web; |
2 | |
3 | import java.util.Iterator; |
4 | |
5 | import javax.portlet.PortletRequest; |
6 | |
7 | import org.springframework.web.portlet.ModelAndView; |
8 | import org.springframework.web.portlet.mvc.SimpleFormController; |
9 | |
10 | import edu.iu.uis.sit.portal.portlet.admin.domain.PortletApplication; |
11 | import edu.iu.uis.sit.portal.portlet.admin.services.AdminService; |
12 | |
13 | public class PortletApplicationController extends SimpleFormController { |
14 | private AdminService adminService; |
15 | |
16 | protected void onSubmitAction(Object command) throws Exception { |
17 | WebPortalConfig webPortalConfig = (WebPortalConfig) command; |
18 | getAdminService().savePortletApplication(webPortalConfig.getPortalConfig(), webPortalConfig.getPortletApplication()); |
19 | } |
20 | |
21 | protected ModelAndView onSubmitRender(Object command) throws Exception { |
22 | ModelAndView modelAndView = new ModelAndView("displayPortletApplications"); |
23 | modelAndView.addObject("portletApplications", getAdminService().getPortalConfig().getPortletApplications()); |
24 | return modelAndView; |
25 | } |
26 | |
27 | protected Object formBackingObject(PortletRequest request) throws Exception { |
28 | WebPortalConfig webPortalConfig = new WebPortalConfig(getAdminService().getPortalConfig()); |
29 | if (request.getParameter("portletApplicationId") != null) { |
30 | for (Iterator iter = webPortalConfig.getPortalConfig().getPortletApplications().iterator(); iter.hasNext();) { |
31 | PortletApplication application = (PortletApplication) iter.next(); |
32 | if (application.getPortletApplicationId().longValue() == Long.parseLong(request.getParameter("portletApplicationId"))) { |
33 | webPortalConfig.setPortletApplication(application); |
34 | } |
35 | } |
36 | } |
37 | return webPortalConfig; |
38 | } |
39 | |
40 | public AdminService getAdminService() { |
41 | return adminService; |
42 | } |
43 | |
44 | public void setAdminService(AdminService adminService) { |
45 | this.adminService = adminService; |
46 | } |
47 | } |