001: /*
002: * Copyright 2005-2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.opensource.org/licenses/ecl1.php
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.kuali.core.web.struts.form;
018:
019: import java.util.ArrayList;
020:
021: import javax.servlet.http.HttpServletRequest;
022:
023: import org.kuali.RiceConstants;
024: import org.kuali.core.question.Question;
025: import org.kuali.rice.KNSServiceLocator;
026:
027: /**
028: * This class is the action form for all Question Prompts.
029: *
030: *
031: */
032: public class QuestionPromptForm extends KualiForm {
033: private static final long serialVersionUID = 1L;
034: private String backLocation;
035: private ArrayList buttons;
036: private String caller;
037:
038: private String formKey;
039: private String questionIndex;
040: private String questionText;
041: private String questionType;
042: private String title;
043: private String context;
044: private String reason;
045: private String showReasonField;
046: private String questionAnchor;
047: private String methodToCallPath;
048:
049: /**
050: * @return boolean
051: */
052: public String getShowReasonField() {
053: return showReasonField;
054: }
055:
056: /**
057: * @param showReasonField
058: */
059: public void setShowReasonField(String showReasonField) {
060: this .showReasonField = showReasonField;
061: }
062:
063: /**
064: * @return Returns the backLocation.
065: */
066: public String getBackLocation() {
067: return backLocation;
068: }
069:
070: /**
071: * @return Returns the buttons.
072: */
073: public ArrayList getButtons() {
074: return buttons;
075: }
076:
077: /**
078: * @return Returns the caller.
079: */
080: public String getCaller() {
081: return caller;
082: }
083:
084: /**
085: * @return Returns the formKey.
086: */
087: public String getFormKey() {
088: return formKey;
089: }
090:
091: /**
092: * @return Returns the questionIndex.
093: */
094: public String getQuestionIndex() {
095: return questionIndex;
096: }
097:
098: /**
099: * @return Returns the questionText.
100: */
101: public String getQuestionText() {
102: return questionText;
103: }
104:
105: /**
106: * @return Returns the questionName.
107: */
108: public String getQuestionType() {
109: return questionType;
110: }
111:
112: /**
113: * @return Returns the title.
114: */
115: public String getTitle() {
116: return title;
117: }
118:
119: /**
120: * @see org.kuali.core.web.struts.pojo.PojoForm#populate(javax.servlet.http.HttpServletRequest)
121: */
122: public void populate(HttpServletRequest request) {
123: super .populate(request);
124:
125: // set the title of the jsp, this should come from a resource bundle
126: title = RiceConstants.QUESTION_PAGE_TITLE;
127:
128: if (request.getAttribute(RiceConstants.DOC_FORM_KEY) != null) {
129: this .setFormKey((String) request
130: .getAttribute(RiceConstants.DOC_FORM_KEY));
131: } else if (request.getParameter(RiceConstants.DOC_FORM_KEY) != null) {
132: this .setFormKey(request
133: .getParameter(RiceConstants.DOC_FORM_KEY));
134: }
135:
136: if (request
137: .getParameter(RiceConstants.RETURN_LOCATION_PARAMETER) != null) {
138: this
139: .setBackLocation(request
140: .getParameter(RiceConstants.RETURN_LOCATION_PARAMETER));
141: }
142:
143: if (getMethodToCall().equals(RiceConstants.START_METHOD)) { // don't do this for the processAnswer action otherwise it blows up
144: Question kualiQuestion = KNSServiceLocator
145: .getQuestion(questionType);
146: if (kualiQuestion == null) {
147: throw new RuntimeException(
148: "question implementation not found: "
149: + request
150: .getParameter(RiceConstants.QUESTION_IMPL_ATTRIBUTE_NAME));
151: }
152:
153: // some questions types default these so we should default if not
154: // present in request
155: if (questionText == null) {
156: questionText = kualiQuestion.getQuestion();
157: }
158:
159: if (buttons == null) {
160: buttons = kualiQuestion.getButtons();
161: }
162: }
163: }
164:
165: /**
166: * @param backLocation The backLocation to set.
167: */
168: public void setBackLocation(String backLocation) {
169: this .backLocation = backLocation;
170: }
171:
172: /**
173: * @param buttons The buttons to set.
174: */
175: public void setButtons(ArrayList buttons) {
176: this .buttons = buttons;
177: }
178:
179: /**
180: * @param caller The caller to set.
181: */
182: public void setCaller(String caller) {
183: this .caller = caller;
184: }
185:
186: /**
187: * @param formKey The formKey to set.
188: */
189: public void setFormKey(String formKey) {
190: this .formKey = formKey;
191: }
192:
193: /**
194: * @param questionIndex The questionIndex to set.
195: */
196: public void setQuestionIndex(String questionIndex) {
197: this .questionIndex = questionIndex;
198: }
199:
200: /**
201: * @param questionText The questionText to set.
202: */
203: public void setQuestionText(String questionText) {
204: this .questionText = questionText;
205: }
206:
207: /**
208: * @param questionName The questionName to set.
209: */
210: public void setQuestionType(String questionName) {
211: this .questionType = questionName;
212: }
213:
214: /**
215: * @param title The title to set.
216: */
217: public void setTitle(String title) {
218: this .title = title;
219: }
220:
221: public String getContext() {
222: return context;
223: }
224:
225: public void setContext(String context) {
226: this .context = context;
227: }
228:
229: /**
230: * @return String
231: */
232: public String getReason() {
233: return reason;
234: }
235:
236: /**
237: * @param reason
238: */
239: public void setReason(String reason) {
240: this .reason = reason;
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:
255: public void setMethodToCallPath(String methodToCallPath) {
256: this.methodToCallPath = methodToCallPath;
257: }
258:
259: }
|