1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package edu.sampleu.travel.krad.controller; |
17 | |
|
18 | |
import edu.sampleu.travel.bo.FiscalOfficer; |
19 | |
import edu.sampleu.travel.bo.TravelAccount; |
20 | |
import edu.sampleu.travel.krad.form.UITestForm; |
21 | |
import org.kuali.rice.core.api.util.type.KualiPercent; |
22 | |
import org.kuali.rice.krad.util.GlobalVariables; |
23 | |
import org.kuali.rice.krad.web.controller.UifControllerBase; |
24 | |
import org.kuali.rice.krad.web.form.UifFormBase; |
25 | |
import org.springframework.stereotype.Controller; |
26 | |
import org.springframework.validation.BindingResult; |
27 | |
import org.springframework.web.bind.annotation.ModelAttribute; |
28 | |
import org.springframework.web.bind.annotation.RequestMapping; |
29 | |
import org.springframework.web.bind.annotation.RequestMethod; |
30 | |
import org.springframework.web.servlet.ModelAndView; |
31 | |
|
32 | |
import javax.servlet.http.HttpServletRequest; |
33 | |
import javax.servlet.http.HttpServletResponse; |
34 | |
import java.util.ArrayList; |
35 | |
import java.util.List; |
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | 0 | @Controller |
43 | |
@RequestMapping(value = "/uitest") |
44 | 0 | public class UITestController extends UifControllerBase { |
45 | |
|
46 | |
@Override |
47 | |
protected UITestForm createInitialForm(HttpServletRequest request) { |
48 | 0 | return new UITestForm(); |
49 | |
} |
50 | |
|
51 | |
@Override |
52 | |
@RequestMapping(params = "methodToCall=start") |
53 | |
public ModelAndView start(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result, |
54 | |
HttpServletRequest request, HttpServletResponse response) { |
55 | 0 | UITestForm uiTestForm = (UITestForm) form; |
56 | |
|
57 | |
|
58 | 0 | TravelAccount travelAccount = new TravelAccount(); |
59 | 0 | travelAccount.setNumber("101"); |
60 | 0 | travelAccount.setName("Account 101"); |
61 | |
|
62 | 0 | FiscalOfficer fiscalOfficer = new FiscalOfficer(); |
63 | 0 | fiscalOfficer.setId(new Long(1)); |
64 | 0 | FiscalOfficer fiscalOfficer2 = new FiscalOfficer(); |
65 | 0 | fiscalOfficer.setId(new Long(1)); |
66 | 0 | FiscalOfficer fiscalOfficer3 = new FiscalOfficer(); |
67 | 0 | fiscalOfficer.setId(new Long(1)); |
68 | 0 | FiscalOfficer fiscalOfficer4 = new FiscalOfficer(); |
69 | 0 | fiscalOfficer.setId(new Long(1)); |
70 | |
|
71 | |
|
72 | 0 | List<TravelAccount> officerAccounts = new ArrayList<TravelAccount>(); |
73 | |
|
74 | 0 | TravelAccount travelAccount2 = new TravelAccount(); |
75 | 0 | travelAccount2.setNumber("102"); |
76 | 0 | travelAccount2.setName("Account 102"); |
77 | 0 | travelAccount2.setSubAccount("34"); |
78 | 0 | travelAccount2.setSubAccountName("G34 So"); |
79 | 0 | travelAccount2.setSubsidizedPercent(new KualiPercent(45.0)); |
80 | 0 | officerAccounts.add(travelAccount2); |
81 | |
|
82 | 0 | TravelAccount travelAccount3 = new TravelAccount(); |
83 | 0 | travelAccount3.setNumber("103"); |
84 | 0 | travelAccount3.setName("Account 103"); |
85 | 0 | officerAccounts.add(travelAccount3); |
86 | |
|
87 | 0 | TravelAccount travelAccount4 = new TravelAccount(); |
88 | 0 | travelAccount4.setNumber("104"); |
89 | 0 | travelAccount4.setName("Account 104"); |
90 | 0 | travelAccount4.setSubAccount("i84n"); |
91 | 0 | travelAccount4.setSubAccountName("Supplies"); |
92 | 0 | travelAccount4.setSubsidizedPercent(new KualiPercent(10)); |
93 | 0 | officerAccounts.add(travelAccount4); |
94 | |
|
95 | 0 | fiscalOfficer.setAccounts(officerAccounts); |
96 | 0 | travelAccount.setFiscalOfficer(fiscalOfficer); |
97 | |
|
98 | |
|
99 | 0 | travelAccount2.setFiscalOfficer(fiscalOfficer2); |
100 | 0 | travelAccount3.setFiscalOfficer(fiscalOfficer3); |
101 | 0 | travelAccount4.setFiscalOfficer(fiscalOfficer4); |
102 | |
|
103 | 0 | uiTestForm.setTravelAccount1(travelAccount); |
104 | 0 | uiTestForm.setTravelAccount2(travelAccount2); |
105 | 0 | uiTestForm.setTravelAccount3(travelAccount3); |
106 | 0 | uiTestForm.setTravelAccount4(travelAccount4); |
107 | |
|
108 | 0 | uiTestForm.setField5("a14"); |
109 | |
|
110 | 0 | uiTestForm.setField1("Field1"); |
111 | 0 | uiTestForm.setField2("Field2"); |
112 | |
|
113 | 0 | uiTestForm.setHidden1("Hidden1"); |
114 | 0 | uiTestForm.setHidden2("Hidden2"); |
115 | |
|
116 | 0 | return super.start(uiTestForm, result, request, response); |
117 | |
} |
118 | |
|
119 | |
@RequestMapping(method = RequestMethod.POST, params = "methodToCall=save") |
120 | |
public ModelAndView save(@ModelAttribute("KualiForm") UITestForm uiTestForm, BindingResult result, |
121 | |
HttpServletRequest request, HttpServletResponse response) { |
122 | |
|
123 | 0 | if(uiTestForm.getField2().equals("server_error")){ |
124 | 0 | GlobalVariables.getMessageMap().putError("field2", "serverTestError"); |
125 | 0 | GlobalVariables.getMessageMap().putError("field2", "serverTestError2"); |
126 | 0 | GlobalVariables.getMessageMap().putWarning("field2", "serverTestWarning"); |
127 | 0 | GlobalVariables.getMessageMap().putInfo("field2", "serverTestInfo"); |
128 | 0 | GlobalVariables.getMessageMap().putInfo("field3", "serverTestInfo"); |
129 | 0 | GlobalVariables.getMessageMap().putError("field13", "serverTestError"); |
130 | 0 | GlobalVariables.getMessageMap().putWarning("field4", "serverTestWarning"); |
131 | 0 | GlobalVariables.getMessageMap().putWarning("TEST_WARNING", "serverTestError3"); |
132 | 0 | GlobalVariables.getMessageMap().putError("TEST_ERROR", "serverTestError3"); |
133 | 0 | GlobalVariables.getMessageMap().putError("vField5", "serverTestError"); |
134 | 0 | GlobalVariables.getMessageMap().putError("vField6", "serverTestError"); |
135 | |
|
136 | 0 | return getUIFModelAndView(uiTestForm, uiTestForm.getViewId(), uiTestForm.getPageId()); |
137 | |
} |
138 | |
|
139 | 0 | return getUIFModelAndView(uiTestForm, uiTestForm.getViewId(), "page2"); |
140 | |
} |
141 | |
|
142 | |
@RequestMapping(method = RequestMethod.POST, params = "methodToCall=close") |
143 | |
public ModelAndView close(@ModelAttribute("KualiForm") UITestForm uiTestForm, BindingResult result, |
144 | |
HttpServletRequest request, HttpServletResponse response) { |
145 | |
|
146 | 0 | return getUIFModelAndView(uiTestForm, uiTestForm.getViewId(), "page1"); |
147 | |
} |
148 | |
|
149 | |
} |