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