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 | 0 | 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 | 0 | return this.docNum; |
53 | |
} |
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
public void setDocNum(String docNum) { |
59 | 0 | this.docNum = docNum; |
60 | 0 | } |
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
public String getShowReasonField() { |
66 | 0 | return showReasonField; |
67 | |
} |
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | |
public void setShowReasonField(String showReasonField) { |
73 | 0 | this.showReasonField = showReasonField; |
74 | 0 | } |
75 | |
|
76 | |
|
77 | |
|
78 | |
|
79 | |
public ArrayList getButtons() { |
80 | 0 | return buttons; |
81 | |
} |
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | |
public String getCaller() { |
87 | 0 | return caller; |
88 | |
} |
89 | |
|
90 | |
|
91 | |
|
92 | |
|
93 | |
public String getFormKey() { |
94 | 0 | return formKey; |
95 | |
} |
96 | |
|
97 | |
|
98 | |
|
99 | |
|
100 | |
public String getQuestionIndex() { |
101 | 0 | return questionIndex; |
102 | |
} |
103 | |
|
104 | |
|
105 | |
|
106 | |
|
107 | |
public String getQuestionText() { |
108 | 0 | return questionText != null ? WebUtils.filterHtmlAndReplaceRiceMarkup(questionText) : questionText; |
109 | |
} |
110 | |
|
111 | |
|
112 | |
|
113 | |
|
114 | |
public String getQuestionType() { |
115 | 0 | return questionType; |
116 | |
} |
117 | |
|
118 | |
|
119 | |
|
120 | |
|
121 | |
public String getTitle() { |
122 | 0 | return title; |
123 | |
} |
124 | |
|
125 | |
|
126 | |
|
127 | |
|
128 | |
public void populate(HttpServletRequest request) { |
129 | 0 | super.populate(request); |
130 | |
|
131 | |
|
132 | 0 | title = KRADConstants.QUESTION_PAGE_TITLE; |
133 | |
|
134 | 0 | if (request.getAttribute(KRADConstants.DOC_FORM_KEY) != null) { |
135 | 0 | this.setFormKey((String) request.getAttribute(KRADConstants.DOC_FORM_KEY)); |
136 | |
} |
137 | 0 | else if (request.getParameter(KRADConstants.DOC_FORM_KEY) != null) { |
138 | 0 | this.setFormKey(request.getParameter(KRADConstants.DOC_FORM_KEY)); |
139 | |
} |
140 | |
|
141 | 0 | if (request.getAttribute(KRADConstants.DOC_NUM) != null) { |
142 | 0 | this.setFormKey((String) request.getAttribute(KRADConstants.DOC_NUM)); |
143 | |
} |
144 | |
|
145 | |
|
146 | 0 | if (request.getParameter(KRADConstants.RETURN_LOCATION_PARAMETER) != null) { |
147 | 0 | this.setBackLocation(request.getParameter(KRADConstants.RETURN_LOCATION_PARAMETER)); |
148 | |
} |
149 | |
|
150 | 0 | if (getMethodToCall().equals(KRADConstants.START_METHOD)) { |
151 | 0 | Question kualiQuestion = KRADServiceLocatorWeb.getQuestion(questionType); |
152 | 0 | if (kualiQuestion == null) { |
153 | 0 | throw new RuntimeException("question implementation not found: " + request.getParameter(KRADConstants.QUESTION_IMPL_ATTRIBUTE_NAME)); |
154 | |
} |
155 | |
|
156 | |
|
157 | |
|
158 | |
|
159 | 0 | if (questionText == null) { |
160 | 0 | questionText = kualiQuestion.getQuestion(); |
161 | |
} |
162 | |
|
163 | 0 | if (buttons == null) { |
164 | 0 | buttons = kualiQuestion.getButtons(); |
165 | |
} |
166 | |
} |
167 | 0 | } |
168 | |
|
169 | |
|
170 | |
|
171 | |
|
172 | |
public void setButtons(ArrayList buttons) { |
173 | 0 | this.buttons = buttons; |
174 | 0 | } |
175 | |
|
176 | |
|
177 | |
|
178 | |
|
179 | |
public void setCaller(String caller) { |
180 | 0 | this.caller = caller; |
181 | 0 | } |
182 | |
|
183 | |
|
184 | |
|
185 | |
|
186 | |
public void setFormKey(String formKey) { |
187 | 0 | this.formKey = formKey; |
188 | 0 | } |
189 | |
|
190 | |
|
191 | |
|
192 | |
|
193 | |
public void setQuestionIndex(String questionIndex) { |
194 | 0 | this.questionIndex = questionIndex; |
195 | 0 | } |
196 | |
|
197 | |
|
198 | |
|
199 | |
|
200 | |
public void setQuestionText(String questionText) { |
201 | 0 | this.questionText = questionText; |
202 | 0 | } |
203 | |
|
204 | |
|
205 | |
|
206 | |
|
207 | |
public void setQuestionType(String questionName) { |
208 | 0 | this.questionType = questionName; |
209 | 0 | } |
210 | |
|
211 | |
|
212 | |
|
213 | |
|
214 | |
public void setTitle(String title) { |
215 | 0 | this.title = title; |
216 | 0 | } |
217 | |
|
218 | |
public String getContext() { |
219 | 0 | return context; |
220 | |
} |
221 | |
|
222 | |
public void setContext(String context) { |
223 | 0 | this.context = context; |
224 | 0 | } |
225 | |
|
226 | |
|
227 | |
|
228 | |
|
229 | |
public String getReason() { |
230 | 0 | return reason; |
231 | |
} |
232 | |
|
233 | |
|
234 | |
|
235 | |
|
236 | |
public void setReason(String reason) { |
237 | 0 | this.reason = reason; |
238 | 0 | } |
239 | |
|
240 | |
public String getQuestionAnchor() { |
241 | 0 | return questionAnchor; |
242 | |
} |
243 | |
|
244 | |
public void setQuestionAnchor(String questionAnchor) { |
245 | 0 | this.questionAnchor = questionAnchor; |
246 | 0 | } |
247 | |
|
248 | |
public String getMethodToCallPath() { |
249 | 0 | return methodToCallPath; |
250 | |
} |
251 | |
public void setMethodToCallPath(String methodToCallPath) { |
252 | 0 | this.methodToCallPath = methodToCallPath; |
253 | 0 | } |
254 | |
|
255 | |
} |