1 | package edu.iu.uis.sit.portal.portlet.admin.web; |
2 | |
3 | import javax.portlet.PortletRequest; |
4 | |
5 | import org.springframework.web.portlet.ModelAndView; |
6 | import org.springframework.web.portlet.mvc.SimpleFormController; |
7 | |
8 | import edu.iu.uis.sit.portal.portlet.admin.domain.ApplicationConstant; |
9 | import edu.iu.uis.sit.portal.portlet.admin.services.AdminService; |
10 | |
11 | public class ApplicationConstantController extends SimpleFormController { |
12 | private AdminService adminService; |
13 | |
14 | protected void onSubmitAction(Object command) throws Exception { |
15 | ApplicationConstant applicationConstant = (ApplicationConstant) command; |
16 | getAdminService().saveApplicationConstant(applicationConstant); |
17 | } |
18 | |
19 | protected ModelAndView onSubmitRender(Object command) throws Exception { |
20 | ModelAndView modelAndView = new ModelAndView("message"); |
21 | modelAndView.addObject("message", "Saved successfully"); |
22 | return modelAndView; |
23 | } |
24 | |
25 | protected Object formBackingObject(PortletRequest request) throws Exception { |
26 | if (request.getParameter("constantId") != null) { |
27 | return getAdminService().findApplicationConstantById(Long.parseLong(request.getParameter("constantId"))); |
28 | } |
29 | return new ApplicationConstant(); |
30 | } |
31 | |
32 | public AdminService getAdminService() { |
33 | return adminService; |
34 | } |
35 | |
36 | public void setAdminService(AdminService adminService) { |
37 | this.adminService = adminService; |
38 | } |
39 | } |