@Override public ActionForward display( ActionMapping pActionMapping, ActionForm pActionForm, HttpServletRequest pHttpServletRequest, HttpServletResponse pHttpServletResponse) { User lLoggedInUser = AhpActionHelper.getLoggedInUser(pHttpServletRequest); CreateQuestionForm lCreateQuestionForm = (CreateQuestionForm) pActionForm; String lNextPage = StringUtils.trimToEmpty(lCreateQuestionForm.getNextPage()); ActionForward lActionForward = pActionMapping.findForward(NavigateActions.DisplayCreateQuestion.toString()); if (NavigateActions.DisplayCreateQuestion.toString().equals(lNextPage) || NavigateActions.DisplayCreateQuestionStart.toString().equals(lNextPage) || NavigateActions.DisplayCreateQuestionNext.toString().equals(lNextPage)) { if (NavigateActions.DisplayCreateQuestionStart.toString().equals(lNextPage)) { this.setDefaultValues(lCreateQuestionForm); pHttpServletRequest.getSession().removeAttribute(QUIZ_UNDER_CREATION); } if (NavigateActions.DisplayCreateQuestionNext.toString().equals(lNextPage)) { this.setDefaultValues(lCreateQuestionForm); } if (lCreateQuestionForm.isSubmitAction(SubmitActions.ADD_OPTION)) { Option lOption = new Option(); lOption.setOptionDescription(""); lCreateQuestionForm.getOptions().add(lOption); } if (lCreateQuestionForm.isSubmitAction(SubmitActions.DELETE_OPTION)) { int lDeleteIndex = Integer.parseInt(lCreateQuestionForm.getHiddenDeleteOptionIndex()); if (lCreateQuestionForm.getOptions().size() > lDeleteIndex) lCreateQuestionForm.getOptions().remove(lDeleteIndex); while (lCreateQuestionForm.getOptions().size() < 3) { Option lOption = new Option(); lOption.setOptionDescription(""); lCreateQuestionForm.getOptions().add(lOption); } } if (lCreateQuestionForm.isSubmitAction(SubmitActions.RESET)) { this.setDefaultValues(lCreateQuestionForm); } } if (NavigateActions.DisplayCreateQuizConfirmation.toString().equals(lNextPage)) { lActionForward = pActionMapping.findForward(NavigateActions.DisplayCreateQuestionConfirmation.toString()); } if (NavigateActions.DisplayCreateQuizCancelled.toString().equals(lNextPage)) { lActionForward = pActionMapping.findForward(NavigateActions.DisplayQuizConsole.toString()); } return lActionForward; }
/** @return */ private void setDefaultValues(CreateQuestionForm lCreateQuestionForm) { lCreateQuestionForm.setMaximumSizeTypeDisplaySet( EnumWrapper.enumerateDescriptionQuestionMaximumSizeDisplayStyle()); lCreateQuestionForm.setHoursDisplaySet(AhpTimeUtil.getHourInDay()); lCreateQuestionForm.setMinutesDisplaySet(AhpTimeUtil.getMinutes()); lCreateQuestionForm.setSecondsDisplaySet(AhpTimeUtil.getSeconds()); List<Option> lDefaultOptions = new LinkedList<Option>(); while (lDefaultOptions.size() < 3) { Option lOption = new Option(); lOption.setOptionDescription(""); lDefaultOptions.add(lOption); } lCreateQuestionForm.setOptions(lDefaultOptions); lCreateQuestionForm.setQuestionDescription(null); lCreateQuestionForm.setQuestionObjective(null); lCreateQuestionForm.setQuestionPoints(1); lCreateQuestionForm.setSelectedQuestionCategory(0); lCreateQuestionForm.setSelectedQuestionSkillLevel(0); lCreateQuestionForm.setResponseDurationInHours(null); lCreateQuestionForm.setResponseDurationInMinutes(null); lCreateQuestionForm.setResponseDurationInSeconds(null); }