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