1 package org.kuali.ole.select.document.web;
2
3
4 import org.kuali.rice.kns.question.Question;
5 import org.kuali.rice.kns.service.KNSServiceLocator;
6 import org.kuali.rice.kns.util.WebUtils;
7 import org.kuali.rice.kns.web.struts.form.KualiForm;
8 import org.kuali.rice.krad.util.GlobalVariables;
9 import org.kuali.rice.krad.util.KRADConstants;
10
11 import javax.servlet.http.HttpServletRequest;
12 import java.util.ArrayList;
13
14
15
16
17
18
19
20
21 public class OLEReqPOAskQuestionForm extends KualiForm {
22
23 private String cancellationReason;
24 private static final long serialVersionUID = 1L;
25 private ArrayList buttons;
26 private String caller;
27
28 private String formKey;
29 private String questionIndex;
30 private String questionText;
31 private String questionType;
32 private String title;
33 private String context;
34 private String showReasonField;
35 private String questionAnchor;
36 private String methodToCallPath;
37 private String docNum;
38 private String reason;
39
40
41 public String getCancellationReason() {
42 return cancellationReason;
43 }
44
45 public void setCancellationReason(String cancellationReason) {
46 this.cancellationReason = cancellationReason;
47 }
48
49
50
51
52
53 public String getDocNum() {
54 return this.docNum;
55 }
56
57
58
59
60 public void setDocNum(String docNum) {
61 this.docNum = docNum;
62 }
63
64
65
66
67 public String getShowReasonField() {
68 return showReasonField;
69 }
70
71
72
73
74 public void setShowReasonField(String showReasonField) {
75 this.showReasonField = showReasonField;
76 }
77
78
79
80
81 public ArrayList getButtons() {
82 return buttons;
83 }
84
85
86
87
88 public String getCaller() {
89 return caller;
90 }
91
92
93
94
95 public String getFormKey() {
96 return formKey;
97 }
98
99
100
101
102 public String getQuestionIndex() {
103 return questionIndex;
104 }
105
106
107
108
109 public String getQuestionText() {
110 return questionText != null ? WebUtils.filterHtmlAndReplaceRiceMarkup(questionText) : questionText;
111 }
112
113
114
115
116 public String getQuestionType() {
117 return questionType;
118 }
119
120
121
122
123 public String getTitle() {
124 return title;
125 }
126
127
128 public String getReason() {
129 return reason;
130 }
131
132 public void setReason(String reason) {
133 this.reason = reason;
134 }
135
136 @Override
137 public void populate(HttpServletRequest request) {
138 super.populate(request);
139
140
141 title = KRADConstants.QUESTION_PAGE_TITLE;
142
143 if (request.getAttribute(KRADConstants.DOC_FORM_KEY) != null) {
144 this.setFormKey((String) request.getAttribute(KRADConstants.DOC_FORM_KEY));
145 }
146 else if (request.getParameter(KRADConstants.DOC_FORM_KEY) != null) {
147 this.setFormKey(request.getParameter(KRADConstants.DOC_FORM_KEY));
148 }
149
150 if (request.getAttribute(KRADConstants.DOC_NUM) != null) {
151 this.setFormKey((String) request.getAttribute(KRADConstants.DOC_NUM));
152 }
153
154
155 if (request.getParameter(KRADConstants.RETURN_LOCATION_PARAMETER) != null) {
156 this.setBackLocation(request.getParameter(KRADConstants.RETURN_LOCATION_PARAMETER));
157 }
158
159 if (getMethodToCall().equals(KRADConstants.START_METHOD)) {
160 Question kualiQuestion = KNSServiceLocator.getQuestion(questionType);
161 if (kualiQuestion == null) {
162 throw new RuntimeException("question implementation not found: " + request.getParameter(KRADConstants.QUESTION_IMPL_ATTRIBUTE_NAME));
163 }
164
165
166 String questionId = request.getParameter(KRADConstants.QUESTION_INST_ATTRIBUTE_NAME);
167 String questionTextAttributeName = KRADConstants.QUESTION_TEXT_ATTRIBUTE_NAME + questionId;
168
169 if (GlobalVariables.getUserSession().retrieveObject(questionTextAttributeName)!=null) {
170 this.setQuestionText((String)GlobalVariables.getUserSession().retrieveObject(questionTextAttributeName));
171 GlobalVariables.getUserSession().removeObject(questionTextAttributeName);
172 }
173
174
175
176 if (questionText == null) {
177 questionText = kualiQuestion.getQuestion();
178 }
179
180 if (buttons == null) {
181 buttons = kualiQuestion.getButtons();
182 }
183 }
184 }
185
186
187
188
189 public void setButtons(ArrayList buttons) {
190 this.buttons = buttons;
191 }
192
193
194
195
196 public void setCaller(String caller) {
197 this.caller = caller;
198 }
199
200
201
202
203 public void setFormKey(String formKey) {
204 this.formKey = formKey;
205 }
206
207
208
209
210 public void setQuestionIndex(String questionIndex) {
211 this.questionIndex = questionIndex;
212 }
213
214
215
216
217 public void setQuestionText(String questionText) {
218 this.questionText = questionText;
219 }
220
221
222
223
224 public void setQuestionType(String questionName) {
225 this.questionType = questionName;
226 }
227
228
229
230
231 public void setTitle(String title) {
232 this.title = title;
233 }
234
235 public String getContext() {
236 return context;
237 }
238
239 public void setContext(String context) {
240 this.context = context;
241 }
242
243 public String getQuestionAnchor() {
244 return questionAnchor;
245 }
246
247 public void setQuestionAnchor(String questionAnchor) {
248 this.questionAnchor = questionAnchor;
249 }
250
251 public String getMethodToCallPath() {
252 return methodToCallPath;
253 }
254 public void setMethodToCallPath(String methodToCallPath) {
255 this.methodToCallPath = methodToCallPath;
256 }
257
258 }
259