1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.krms.impl.ui; |
17 | |
|
18 | |
import javax.servlet.http.HttpServletRequest; |
19 | |
import javax.servlet.http.HttpServletResponse; |
20 | |
|
21 | |
import org.kuali.rice.krad.service.BusinessObjectService; |
22 | |
import org.kuali.rice.krad.service.KRADServiceLocator; |
23 | |
import org.kuali.rice.krad.web.controller.UifControllerBase; |
24 | |
import org.kuali.rice.krms.impl.repository.AgendaBo; |
25 | |
import org.kuali.rice.krms.impl.repository.ContextBo; |
26 | |
import org.springframework.stereotype.Controller; |
27 | |
import org.springframework.validation.BindingResult; |
28 | |
import org.springframework.web.bind.annotation.ModelAttribute; |
29 | |
import org.springframework.web.bind.annotation.RequestMapping; |
30 | |
import org.springframework.web.bind.annotation.RequestMethod; |
31 | |
import org.springframework.web.servlet.ModelAndView; |
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | 0 | @Controller |
39 | |
@RequestMapping(value = "/krmsEditor") |
40 | 0 | public class EditorController extends UifControllerBase { |
41 | |
|
42 | |
@Override |
43 | |
protected EditorForm createInitialForm(HttpServletRequest request) { |
44 | 0 | return new EditorForm(); |
45 | |
} |
46 | |
|
47 | |
@RequestMapping(params = "methodToCall=start") |
48 | |
public ModelAndView start(@ModelAttribute("KualiForm") EditorForm editorForm, BindingResult result, |
49 | |
HttpServletRequest request, HttpServletResponse response) { |
50 | |
|
51 | |
|
52 | 0 | ContextBo context = new ContextBo(); |
53 | 0 | AgendaBo agenda = new AgendaBo(); |
54 | |
|
55 | 0 | String[] agendaIds = request.getParameterValues("agendaId"); |
56 | 0 | if (agendaIds == null || agendaIds.length != 1) { |
57 | |
|
58 | |
} else { |
59 | |
|
60 | 0 | String agendaId = agendaIds[0]; |
61 | |
|
62 | 0 | agenda = getBoService().findBySinglePrimaryKey(AgendaBo.class, agendaId); |
63 | 0 | String contextId = agenda.getContextId(); |
64 | |
|
65 | 0 | context = getBoService().findBySinglePrimaryKey(ContextBo.class, contextId); |
66 | |
} |
67 | |
|
68 | 0 | editorForm.setContext(context); |
69 | 0 | editorForm.setAgenda(agenda); |
70 | |
|
71 | 0 | return getUIFModelAndView(editorForm, editorForm.getViewId()); |
72 | |
} |
73 | |
|
74 | |
@RequestMapping(method = RequestMethod.POST, params = "methodToCall=save") |
75 | |
public ModelAndView save(@ModelAttribute("KualiForm") EditorForm editorForm, BindingResult result, |
76 | |
HttpServletRequest request, HttpServletResponse response) { |
77 | |
|
78 | |
|
79 | |
|
80 | |
|
81 | |
|
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | 0 | return getUIFModelAndView(editorForm, editorForm.getViewId()); |
88 | |
} |
89 | |
|
90 | |
@RequestMapping(method = RequestMethod.POST, params = "methodToCall=close") |
91 | |
public ModelAndView close(@ModelAttribute("KualiForm") EditorForm editorForm, BindingResult result, |
92 | |
HttpServletRequest request, HttpServletResponse response) { |
93 | |
|
94 | 0 | return getUIFModelAndView(editorForm, editorForm.getViewId()); |
95 | |
} |
96 | |
|
97 | |
private BusinessObjectService getBoService() { |
98 | 0 | return KRADServiceLocator.getBusinessObjectService(); |
99 | |
} |
100 | |
|
101 | |
} |