Java Code Examples for org.apache.struts.action.ActionMessages#isEmpty()
The following examples show how to use
org.apache.struts.action.ActionMessages#isEmpty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RecipientAction.java From openemm with GNU Affero General Public License v3.0 | 6 votes |
private ActionForward saveRecipientAndGetDestination(HttpServletRequest request, ActionMessages errors, ActionMessages messages, ActionMapping mapping, RecipientForm form, GetSuccessfulDestinationFunction successfulDestinationFunction) throws Exception { if (StringUtils.isNotEmpty(request.getParameter("cancel.x"))) { return forwardToList(request, mapping, form); } final ComAdmin admin = AgnUtils.getAdmin(request); validateForm(admin, form, errors); if (errors.isEmpty()) { saveRecipient(form, request, errors); messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("default.changes_saved")); return successfulDestinationFunction.apply(request, mapping, form); } else { saveErrors(request, errors); return mapping.findForward("messages"); } }
Example 2
Source File: EmmActionAction.java From openemm with GNU Affero General Public License v3.0 | 6 votes |
private boolean isValidActions(EmmActionForm form, ActionMessages errors){ List<AbstractActionOperationParameters> list = form.getActions(); if (list != null) { for ( Object action : list) { if (action instanceof ActionOperationExecuteScriptParameters) { ActionOperationExecuteScriptParameters scriptAction = (ActionOperationExecuteScriptParameters) action; try { this.velocityDirectiveScriptValidator.validateScript(scriptAction.getScript()); } catch(ScriptValidationException e) { String directive = ((IllegalVelocityDirectiveException) e).getDirective(); errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage( "error.action.illegal_directive", directive)); } } } if(isInvalidBcc(list)){ errors.add(ActionMessages.GLOBAL_MESSAGE,new ActionMessage("error.action.invalid.bbc")); } } return errors.isEmpty(); }
Example 3
Source File: OldMarkSheetCreateDispatchAction.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 6 votes |
@Override public ActionForward createMarkSheetStepOne(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) { MarkSheetManagementCreateBean createBean = (MarkSheetManagementCreateBean) RenderUtils.getViewState().getMetaObject().getObject(); request.setAttribute("edit", createBean); Teacher teacher = Teacher.readByIstId(createBean.getTeacherId()); createBean.setTeacher(teacher); ActionMessages actionMessages = createActionMessages(); prepareCreateEnrolmentEvaluationsForMarkSheet(createBean, request, actionMessages); if (!actionMessages.isEmpty()) { return mapping.findForward("createMarkSheetStep1"); } else { return mapping.findForward("createMarkSheetStep2"); } }
Example 4
Source File: StrutsDelegate.java From spacewalk with GNU General Public License v2.0 | 5 votes |
/** * Add messages to the request * @param request Request where messages will be saved. * @param messages Messages to be saved. */ // TODO Write unit tests for saveMessages(HttpServletRequest, ActionMessages) public void saveMessages(HttpServletRequest request, ActionMessages messages) { HttpSession session = request.getSession(); if ((messages == null) || messages.isEmpty()) { session.removeAttribute(Globals.ERROR_KEY); session.removeAttribute(Globals.MESSAGE_KEY); return; } String key = Globals.MESSAGE_KEY; if (messages instanceof ActionErrors) { key = Globals.ERROR_KEY; } ActionMessages newMessages = new ActionMessages(); // Check for existing messages ActionMessages sessionExisting = (ActionMessages) session.getAttribute(key); if (sessionExisting != null) { newMessages.add(sessionExisting); } newMessages.add(messages); session.setAttribute(key, newMessages); request.setAttribute(key, newMessages); }
Example 5
Source File: FormComponentsAction.java From openemm with GNU Affero General Public License v3.0 | 5 votes |
public ActionForward downloadArchive(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionMessages errors = new ActionMessages(); ActionMessages actionMessages = new ActionMessages(); if (!AgnUtils.isUserLoggedIn(request)) { return mapping.findForward("logon"); } FormComponentsForm actionForm = (FormComponentsForm) form; if (!AgnUtils.allowed(request, Permission.MAILING_COMPONENTS_CHANGE)) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.permissionDenied")); } else { writeAllComponentsZipArchiveToResponse(actionForm, request, response); return null; } if (!errors.isEmpty()) { saveErrors(request, errors); } if (!actionMessages.isEmpty()) { saveMessages(request, actionMessages); } loadFormData(actionForm, request); AgnUtils.setAdminDateTimeFormatPatterns(request); return mapping.findForward("list"); }
Example 6
Source File: FormComponentsAction.java From openemm with GNU Affero General Public License v3.0 | 5 votes |
public ActionForward uploadArchive(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionMessages errors = new ActionMessages(); ActionMessages actionMessages = new ActionMessages(); if (!AgnUtils.isUserLoggedIn(request)) { return mapping.findForward("logon"); } FormComponentsForm actionForm = (FormComponentsForm) form; if (!AgnUtils.allowed(request, Permission.MAILING_COMPONENTS_CHANGE)) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.permissionDenied")); } else { List<String> errorneousFiles = saveComponentsFromZipArchive(actionForm, request, actionForm.isOverwriteExisting()); if (!errorneousFiles.isEmpty()) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("FilesWithError", StringUtils.join(errorneousFiles, ", "))); } else { actionMessages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("default.changes_saved")); } loadImagesData(actionForm, request); // Set overwrite default value (is reseted in form when sending actionForm.setOverwriteExisting(true); } if (!errors.isEmpty()) { saveErrors(request, errors); } if (!actionMessages.isEmpty()) { saveMessages(request, actionMessages); } loadFormData(actionForm, request); AgnUtils.setAdminDateTimeFormatPatterns(request); return mapping.findForward("list"); }
Example 7
Source File: FormComponentsAction.java From openemm with GNU Affero General Public License v3.0 | 5 votes |
public ActionForward deleteconfirm(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionMessages errors = new ActionMessages(); ActionMessages actionMessages = new ActionMessages(); if (!AgnUtils.isUserLoggedIn(request)) { return mapping.findForward("logon"); } FormComponentsForm actionForm = (FormComponentsForm) form; if (!AgnUtils.allowed(request, Permission.MAILING_COMPONENTS_CHANGE)) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.permissionDenied")); } else { boolean success = componentService.deleteFormComponent(actionForm.getFormID(), AgnUtils.getCompanyID(request), actionForm.getFilename()); if (!success) { actionMessages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("changes_not_saved")); } else { actionMessages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("default.selection.deleted")); } loadImagesData(actionForm, request); } if (!errors.isEmpty()) { saveErrors(request, errors); } if (!actionMessages.isEmpty()) { saveMessages(request, actionMessages); } loadFormData(actionForm, request); AgnUtils.setAdminDateTimeFormatPatterns(request); return mapping.findForward("list"); }
Example 8
Source File: FormComponentsAction.java From openemm with GNU Affero General Public License v3.0 | 5 votes |
public ActionForward upload(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionMessages errors = new ActionMessages(); ActionMessages actionMessages = new ActionMessages(); if (!AgnUtils.isUserLoggedIn(request)) { return mapping.findForward("logon"); } FormComponentsForm actionForm = (FormComponentsForm) form; if (!AgnUtils.allowed(request, Permission.MAILING_COMPONENTS_CHANGE)) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.permissionDenied")); } else { saveComponents(actionForm, request, actionMessages, errors); // Always show "changes saved" actionMessages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("default.changes_saved")); loadImagesData(actionForm, request); // Set overwrite default value (is reseted in form when sending actionForm.setOverwriteExisting(true); } if (!errors.isEmpty()) { saveErrors(request, errors); } if (!actionMessages.isEmpty()) { saveMessages(request, actionMessages); } loadFormData(actionForm, request); AgnUtils.setAdminDateTimeFormatPatterns(request); return mapping.findForward("list"); }
Example 9
Source File: FormComponentsAction.java From openemm with GNU Affero General Public License v3.0 | 5 votes |
public ActionForward list(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionMessages errors = new ActionMessages(); ActionMessages actionMessages = new ActionMessages(); if (!AgnUtils.isUserLoggedIn(request)) { return mapping.findForward("logon"); } FormComponentsForm actionForm = (FormComponentsForm) form; final int companyID = AgnUtils.getCompanyID(request); if (!AgnUtils.allowed(request, Permission.MAILING_COMPONENTS_CHANGE)) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.permissionDenied")); } else { UserForm userForm = userFormDao.getUserForm(actionForm.getFormID(), companyID); request.setAttribute("userformNameAndDescription", userForm.getFormName() + (StringUtils.isBlank(userForm.getDescription()) ? "" : " | " + userForm.getDescription())); request.setAttribute("userForm", userForm); loadImagesData(actionForm, request); // Set overwrite default value (is reseted in form when sending actionForm.setOverwriteExisting(true); } if (!errors.isEmpty()) { saveErrors(request, errors); } if (!actionMessages.isEmpty()) { saveMessages(request, actionMessages); } loadFormData(actionForm, request); AgnUtils.setAdminDateTimeFormatPatterns(request); return mapping.findForward("list"); }
Example 10
Source File: ComTrackableUserFormLinkAction.java From openemm with GNU Affero General Public License v3.0 | 5 votes |
/** * For setting the standard extended link values * * @param mapping * - action mapping * @param form * - action form * @param request * - HTTP request object * @param response * - HTTP response object * @return * @throws Exception */ public ActionForward setExtendLinks(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { if (logger.isDebugEnabled()) { logger.debug("Starting action method extendLinks"); } ComAdmin admin = AgnUtils.getAdmin(request); if (admin == null) { return mapping.findForward("logon"); } else { ActionForward destination = mapping.findForward("list"); ActionMessages errors = new ActionMessages(); ComTrackableUserFormLinkForm comTrackableUserFormLinkForm = (ComTrackableUserFormLinkForm) form; try { saveExtendLinks(comTrackableUserFormLinkForm, request); saveLinkExtensionToFormular(comTrackableUserFormLinkForm, request); loadUserFormData(admin, comTrackableUserFormLinkForm, request); } catch (Exception e) { logger.error("execute: " + e, e); errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.exception", configService.getValue(ConfigValue.SupportEmergencyUrl))); } // Report any errors we have discovered back to the original form if (!errors.isEmpty()) { saveErrors(request, errors); logger.error("saving errors: " + destination); } if (logger.isDebugEnabled()) { logger.debug("Finished action method extendLinks"); } return destination; } }
Example 11
Source File: MessageQueueAction.java From rice with Educational Community License v2.0 | 5 votes |
public ActionForward executeMessageFetcher(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { MessageQueueForm routeQueueForm = (MessageQueueForm) form; ActionMessages messages = new ActionMessages(); if (routeQueueForm.getMaxMessageFetcherMessages() == null || routeQueueForm.getMaxMessageFetcherMessages() <= 0) { messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("routequeue.RouteQueueService.invalidMessages", routeQueueForm.getMaxMessageFetcherMessages())); } if (!messages.isEmpty()) { saveMessages(request, messages); return mapping.findForward("report"); } new MessageFetcher(routeQueueForm.getMaxMessageFetcherMessages()).run(); return mapping.findForward("report"); }
Example 12
Source File: MarkSheetCreateDispatchAction.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 5 votes |
public ActionForward createMarkSheetStepOne(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) { MarkSheetManagementCreateBean createBean = (MarkSheetManagementCreateBean) RenderUtils.getViewState().getMetaObject().getObject(); request.setAttribute("edit", createBean); Teacher teacher = Teacher.readByIstId(createBean.getTeacherId()); createBean.setTeacher(teacher); ActionMessages actionMessages = createActionMessages(); checkIfTeacherIsResponsibleOrCoordinator(createBean.getCurricularCourse(), createBean.getExecutionPeriod(), createBean.getTeacherId(), teacher, request, createBean.getEvaluationSeason(), actionMessages); if (!actionMessages.isEmpty()) { createBean.setTeacherId(null); } checkIfEvaluationDateIsInExamsPeriod(createBean.getDegreeCurricularPlan(), createBean.getExecutionPeriod(), createBean.getEvaluationDate(), createBean.getEvaluationSeason(), request, actionMessages); prepareCreateEnrolmentEvaluationsForMarkSheet(createBean, request, actionMessages); if (!actionMessages.isEmpty()) { return mapping.findForward("createMarkSheetStep1"); } else { return mapping.findForward("createMarkSheetStep2"); } }
Example 13
Source File: SalutationAction.java From openemm with GNU Affero General Public License v3.0 | 5 votes |
private ActionForward prepareList(ActionMapping mapping, HttpServletRequest req, ActionMessages errors, SalutationForm salutationForm) { ActionForward destination = null; ActionMessages messages; try { FormUtils.syncNumberOfRows(webStorage, WebStorage.SALUTATION_OVERVIEW, salutationForm); destination = mapping.findForward("loading"); String key = FUTURE_TASK + "@" + req.getSession(false).getId(); if (!futureHolder.containsKey(key)) { Future<PaginatedListImpl<SalutationEntry>> salutationFuture = getSalutationlistFuture(req, salutationForm); futureHolder.put(key, salutationFuture); } if (futureHolder.containsKey(key) && futureHolder.get(key).isDone()) { req.setAttribute("salutationEntries", futureHolder.get(key).get()); destination = mapping.findForward("list"); futureHolder.remove(key); salutationForm.setRefreshMillis(RecipientForm.DEFAULT_REFRESH_MILLIS); messages = salutationForm.getMessages(); if (messages != null && !messages.isEmpty()) { saveMessages(req, messages); salutationForm.setMessages(null); } } else { if (salutationForm.getRefreshMillis() < 1000) { // raise the refresh time salutationForm.setRefreshMillis(salutationForm.getRefreshMillis() + 50); } salutationForm.setError(false); } } catch (Exception e) { logger.error("salutation: " + e, e); errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.exception", configService.getValue(ConfigValue.SupportEmergencyUrl))); salutationForm.setError(true); // do not refresh when an error has been occurred } return destination; }
Example 14
Source File: FenixAction.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 4 votes |
protected boolean hasActionMessage(HttpServletRequest request) { final ActionMessages actionMessages = (ActionMessages) request.getAttribute(ACTION_MESSAGES_REQUEST_KEY); return actionMessages != null && !actionMessages.isEmpty(); }
Example 15
Source File: FenixAction.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 4 votes |
protected void saveMessages(final HttpServletRequest request) { final ActionMessages actionMessages = (ActionMessages) request.getAttribute(ACTION_MESSAGES_REQUEST_KEY); if (actionMessages != null && !actionMessages.isEmpty()) { saveMessages(request, actionMessages); } }
Example 16
Source File: KSBAction.java From rice with Educational Community License v2.0 | 4 votes |
@Override public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { checkAuthorization(form, ""); if(isModuleLocked(form, findMethodToCall(form, request), request)) { return mapping.findForward(RiceConstants.MODULE_LOCKED_MAPPING); } try { ActionMessages messages = null; messages = establishRequiredState(request, form); if (messages != null && !messages.isEmpty()) { // XXX: HACK: FIXME: // obviously this implies that we can't return both ActionErrors // and ActionMessages... :( // probably establishRequiredState should be refactored to have // a generic 'should-we-continue' // boolean return, so that control flow can be more explicitly // specified by the subclass if (messages instanceof ActionErrors) { saveErrors(request, messages); } else { saveMessages(request, messages); } return mapping.findForward("requiredStateError"); } LOG.info(request.getQueryString()); ActionForward returnForward = null; if (request.getParameterMap() != null) { for (Iterator iter = request.getParameterMap().entrySet().iterator(); iter.hasNext();) { String parameterName = (String) ((Map.Entry) iter.next()).getKey(); if (parameterName.startsWith("methodToCall.") && parameterName.endsWith(".x")) { String methodToCall = parameterName.substring(parameterName.indexOf("methodToCall.") + 13, parameterName.lastIndexOf(".x")); if (methodToCall != null && methodToCall.length() > 0) { returnForward = this.dispatchMethod(mapping, form, request, response, methodToCall); } } } } if (returnForward == null) { if (request.getParameter("methodToCall") != null && !"".equals(request.getParameter("methodToCall")) && !"execute".equals(request.getParameter("methodToCall"))) { LOG.info("dispatch to methodToCall " + request.getParameter("methodToCall") + " called"); returnForward = super.execute(mapping, form, request, response); } else { LOG.info("dispatch to default start methodToCall"); returnForward = start(mapping, form, request, response); } } messages = establishFinalState(request, form); if (messages != null && !messages.isEmpty()) { saveMessages(request, messages); return mapping.findForward("finalStateError"); } return returnForward; } catch (Exception e) { LOG.error("Error processing action " + mapping.getPath(), e); throw new RuntimeException(e); } }
Example 17
Source File: ExamPdfReportAction.java From unitime with Apache License 2.0 | 4 votes |
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ExamPdfReportForm myForm = (ExamPdfReportForm) form; sessionContext.checkPermission(Right.ExaminationPdfReports); ExamSolverProxy examSolver = examinationSolverService.getSolver(); if (examSolver!=null) { if (ApplicationProperty.ExaminationPdfReportsCanUseSolution.isTrue()) request.setAttribute(Constants.REQUEST_WARN, "Examination PDF reports are generated from the current solution (in-memory solution taken from the solver)."); else request.setAttribute(Constants.REQUEST_WARN, "Examination PDF reports are generated from the saved solution (solver assignments are ignored)."); } // Read operation to be performed String op = (myForm.getOp()!=null?myForm.getOp():request.getParameter("op")); if ("Generate".equals(op)) myForm.save(sessionContext); myForm.load(sessionContext); myForm.setSubjectAreas(SubjectArea.getUserSubjectAreas(sessionContext.getUser(), false)); if (myForm.getAddress() == null) myForm.setAddress(sessionContext.getUser().getEmail()); if ("Generate".equals(op)) { ActionMessages errors = myForm.validate(mapping, request); if (!errors.isEmpty()) { saveErrors(request, errors); } else { solverServerService.getQueueProcessor().add(new PdfExamReportQueueItem( SessionDAO.getInstance().get(sessionContext.getUser().getCurrentAcademicSessionId()), sessionContext.getUser(), (ExamPdfReportForm) myForm.clone(), request, examSolver)); } } if (request.getParameter("remove") != null) { solverServerService.getQueueProcessor().remove(request.getParameter("remove")); } WebTable table = getQueueTable(request); if (table != null) { request.setAttribute("table", table.printTable(WebTable.getOrder(sessionContext,"examPdfReport.ord"))); } LookupTables.setupExamTypes(request, sessionContext.getUser(), DepartmentStatusType.Status.ExamView, DepartmentStatusType.Status.ExamTimetable); return mapping.findForward("show"); }
Example 18
Source File: RollForwardSessionAction.java From unitime with Apache License 2.0 | 4 votes |
/** * Method execute * @param mapping * @param form * @param request * @param response * @return ActionForward * @throws Exception */ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { MessageResources rsc = getResources(request); RollForwardSessionForm rollForwardSessionForm = (RollForwardSessionForm) form; // Get operation String op = request.getParameter("op"); if (op != null && op.equals(rsc.getMessage("button.rollForward"))) { sessionContext.checkPermission(Right.SessionRollForward); ActionMessages errors = rollForwardSessionForm.validate(mapping, request); if (errors.isEmpty()) { solverServerService.getQueueProcessor().add(new RollForwardQueueItem( SessionDAO.getInstance().get(rollForwardSessionForm.getSessionToRollForwardTo()), sessionContext.getUser(), (RollForwardSessionForm)rollForwardSessionForm.clone())); } else { saveErrors(request, errors); } } if (request.getParameter("remove") != null) { solverServerService.getQueueProcessor().remove(request.getParameter("remove")); } WebTable table = getQueueTable(request, rollForwardSessionForm); if (table != null) { request.setAttribute("table", table.printTable(WebTable.getOrder(sessionContext,"rollForwardSession.ord"))); } setToFromSessionsInForm(rollForwardSessionForm); rollForwardSessionForm.setSubjectAreas(getSubjectAreas(rollForwardSessionForm.getSessionToRollForwardTo())); rollForwardSessionForm.setDepartments(getDepartments(rollForwardSessionForm.getSessionToRollForwardTo())); rollForwardSessionForm.setFromPointInTimeDataSnapshots(getPointInTimeDataSnapshots(rollForwardSessionForm.getSessionToRollForwardTo())); if (op == null) setExpirationDates(rollForwardSessionForm); if (rollForwardSessionForm.getSubpartLocationPrefsAction() == null){ rollForwardSessionForm.setSubpartLocationPrefsAction(SessionRollForward.ROLL_PREFS_ACTION); } if (rollForwardSessionForm.getSubpartTimePrefsAction() == null){ rollForwardSessionForm.setSubpartTimePrefsAction(SessionRollForward.ROLL_PREFS_ACTION); } if (rollForwardSessionForm.getClassPrefsAction() == null){ rollForwardSessionForm.setClassPrefsAction(SessionRollForward.DO_NOT_ROLL_ACTION); } if (rollForwardSessionForm.getRollForwardDistributions() == null) rollForwardSessionForm.setRollForwardDistributions(SessionRollForward.DistributionMode.MIXED.name()); if (rollForwardSessionForm.getCancelledClassAction() == null) { rollForwardSessionForm.setCancelledClassAction(SessionRollForward.CancelledClassAction.REOPEN.name()); } if (rollForwardSessionForm.getMidtermExamsPrefsAction() == null) rollForwardSessionForm.setMidtermExamsPrefsAction(SessionRollForward.EXAMS_ROOM_PREFS); if (rollForwardSessionForm.getFinalExamsPrefsAction() == null) rollForwardSessionForm.setFinalExamsPrefsAction(SessionRollForward.EXAMS_ROOM_PREFS); return mapping.findForward("displayRollForwardSessionForm"); }
Example 19
Source File: CampaignAction.java From openemm with GNU Affero General Public License v3.0 | 4 votes |
/** * Process the specified HTTP request, and create the corresponding HTTP * response (or forward to another web component that will create it). * Return an <code>ActionForward</code> instance describing where and how * control should be forwarded, or <code>null</code> if the response has * already been completed. * <br> * ACTION_LIST: loads list of campaigns into request and forwards to campaign list page. * <br><br> * ACTION_SAVE: saves campaign entry and forwards to the campaign list page. * <br><br> * ACTION_VIEW: resets campaign form, loads data of chosen campaign into form, * loads list of campaign mailings into request, forwards to campaign view page * <br><br> * ACTION_NEW: creates new campaign db entry; reloads form data; loads list of mailings into request; * forwards to campaign list page. * <br><br> * <br><br> * ACTION_VIEW_WITHOUT_LOAD: is used after failing form validation for loading essential data into request * before returning to the view page. Does not reload form data. * <br><br> * ACTION_CONFIRM_DELETE: loads campaign data into form; forwards to jsp with question to confirm deletion * <br><br> * ACITON_DELETE: deletes the entry of certain campaign, forwards to campaign list page. * <br><br> * Any other ACTION_* would cause a forward to "list" * <br><br> * @param mapping The ActionMapping used to select this instance * @param form The optional ActionForm bean for this request (if any) * @param req The HTTP request we are processing * @param res The HTTP response we are creating * * @exception IOException if an input/output error occurs * @exception ServletException if a servlet exception occurs */ @Override public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { // Validate the request parameters specified by the user CampaignForm aForm = (CampaignForm) form; ActionMessages errors = new ActionMessages(); ActionMessages messages = new ActionMessages(); ActionForward destination = null; if (logger.isInfoEnabled()) logger.info("Action: "+aForm.getAction()); try { switch(aForm.getAction()) { case CampaignAction.ACTION_VIEW_WITHOUT_LOAD: loadCampaignFormData(aForm, req); aForm.setAction(CampaignAction.ACTION_SAVE); destination=mapping.findForward("view"); if ( aForm.getColumnwidthsList() == null) { aForm.setColumnwidthsList(getInitializedColumnWidthList(4)); } break; default: aForm.setAction(CampaignAction.ACTION_LIST); destination=mapping.findForward("list"); } } catch (Exception e) { logger.error("execute: "+e, e); errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.exception", configService.getValue(ConfigValue.SupportEmergencyUrl))); } processListDestination(destination, aForm, req, errors); // Report any errors we have discovered back to the original form if (!errors.isEmpty()) { saveErrors(req, errors); } // Report any message (non-errors) we have discovered if (!messages.isEmpty()) { saveMessages(req, messages); } return destination; }
Example 20
Source File: AddNonUnivLocationAction.java From unitime with Apache License 2.0 | 4 votes |
/** * Method execute * @param mapping * @param form * @param request * @param response * @return ActionForward * @throws Exception */ public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { NonUnivLocationForm nonUnivLocationForm = (NonUnivLocationForm) form; MessageResources rsc = getResources(request); ActionMessages errors = new ActionMessages(); sessionContext.checkPermission(Right.AddNonUnivLocation); Set<Department> departments = Department.getUserDepartments(sessionContext.getUser()); if (nonUnivLocationForm.getDoit() != null) { String doit = nonUnivLocationForm.getDoit(); if (doit.equals(rsc.getMessage("button.returnToRoomList"))) { return mapping.findForward("showRoomList"); } if (doit.equals(rsc.getMessage("button.addNew"))) { // Validate input prefs errors = nonUnivLocationForm.validate(mapping, request); if (errors.isEmpty() && !sessionContext.hasPermission(nonUnivLocationForm.getDeptCode(), "Department", Right.AddNonUnivLocation)) { errors.add("nonUniversityLocation", new ActionMessage("errors.generic", "Acess denied.")); } // No errors if(errors.size()==0) { update(request, nonUnivLocationForm); return mapping.findForward("showRoomList"); } else { setDepts(request, departments); saveErrors(request, errors); return mapping.findForward("showAdd"); } } } setDepts(request, departments); nonUnivLocationForm.setDeptSize(departments.size()); if (departments.size() == 1) { Department d = departments.iterator().next(); nonUnivLocationForm.setDeptCode(d.getDeptCode()); } else if (sessionContext.getAttribute(SessionAttribute.DepartmentCodeRoom) != null) { nonUnivLocationForm.setDeptCode((String) sessionContext.getAttribute(SessionAttribute.DepartmentCodeRoom)); } return mapping.findForward("showAdd"); }