ActionErrors errors = new ActionErrors(); if (badInput) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.bad.input", badString); // key in messages resource file // badString will replace {0} in message }
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if (m_actionType == null) return errors; if (!m_actionType.equalsIgnoreCase("edit") && !m_actionType.equalsIgnoreCase("delete")){ return errors; } if (m_selectedEnforcementPointId == null || m_selectedEnforcementPointId.equals("")) { errors.add("selectedEnforcementPoint", new ActionMessage("mgmt.error.selectEnforcementPoint")); } return errors; }
/** * @param request * @return org.apache.struts.action.ActionErrors * @roseuid 4398DA2A03E4 */ public static ActionMessages getErrors(HttpServletRequest request) { ActionErrors errors = null; HttpSession session = request.getSession(false); if (request.getAttribute(Globals.ERROR_KEY) != null) { errors = (ActionErrors) request.getAttribute(Globals.ERROR_KEY); } else if (session != null && session.getAttribute(Globals.ERROR_KEY) != null) { errors = (ActionErrors) session.getAttribute(Globals.ERROR_KEY); } else { errors = new ActionErrors(); saveErrors(request, errors); } return errors; }
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if (null == username || 0 == username.length()) { addMissingValueError(errors, "username"); } if (null == password || 0 == password.length()) { addMissingValueError(errors, "password"); } return errors; }
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if ((username==null) || (username.length() < 1)) errors.add("username", new ActionError("error.username.required")); return errors; }
ActionErrors errors = new ActionErrors(); errors.add(ActionErrors.GLOBAL_MESSAGE, new ActionMessage("error.invalidCredentials")); request.setAttribute(Globals.ERROR_KEY, errors); return mapping.findForward("failure");
private ActionErrors checkTimeIntervalAndWeekDay(Calendar begining, Calendar end, DiaSemana weekday) { ActionErrors actionErrors = new ActionErrors(); String beginMinAppend = ""; String endMinAppend = ""; if (begining.get(Calendar.MINUTE) == 0) { beginMinAppend = "0"; } if (end.get(Calendar.MINUTE) == 0) { endMinAppend = "0"; } if (begining.getTime().getTime() >= end.getTime().getTime()) { actionErrors.add( INVALID_TIME_INTERVAL, new ActionError(INVALID_TIME_INTERVAL, "" + begining.get(Calendar.HOUR_OF_DAY) + ":" + begining.get(Calendar.MINUTE) + beginMinAppend + " - " + end.get(Calendar.HOUR_OF_DAY) + ":" + end.get(Calendar.MINUTE) + endMinAppend)); } if (weekday.getDiaSemana().intValue() < 1 || weekday.getDiaSemana().intValue() > 7) { actionErrors.add(INVALID_WEEKDAY, new ActionError(INVALID_WEEKDAY, "")); } return actionErrors; } }
/** * @param request * @param key * @param error * @roseuid 4398DA2A0235 */ public static void addError(HttpServletRequest request, String key, ActionError error) { ActionMessages errors = getErrors(request); if (errors == null) { errors = new ActionErrors(); } errors.add(key, error); saveErrors(request, errors); }
public ActionErrors validate(final ActionMapping mapping, final HttpServletRequest request) { ActionErrors errors = super.validate(mapping, request); if (errors == null) { errors = new ActionErrors(); } if (!m_anonymous) { if (m_username == null || "".equals(m_username)) { errors.add("username", new ActionMessage("error.username.required")); } if (m_password == null || "".equals(m_password)) { errors.add("password", new ActionMessage("error.password.required")); } } return errors; }
public ActionErrors validate() { ActionErrors errors = new ActionErrors(); if (...) errors.add("name", new ActionError("error.field.mandatory")); if (...) errors.add("surname", new ActionError("error.field.mandatory")); return errors; }
public ActionForward removeShifts(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { DynaActionForm removeShiftsForm = (DynaActionForm) form; String[] selectedShifts = (String[]) removeShiftsForm.get("selectedItems"); if (selectedShifts.length == 0) { ActionErrors actionErrors = new ActionErrors(); actionErrors.add("errors.shifts.notSelected", new ActionError("errors.shifts.notSelected")); saveErrors(request, actionErrors); return mapping.getInputForward(); } List<String> shiftOIDs = new ArrayList<String>(); for (String selectedShift : selectedShifts) { shiftOIDs.add(selectedShift); } InfoClass infoClass = (InfoClass) request.getAttribute(PresentationConstants.CLASS_VIEW); RemoveShifts.run(infoClass, shiftOIDs); return mapping.findForward("EditClass"); }
/** * @param request * @param key * @param errorKey */ public static void addError(HttpServletRequest request, String key, String errorKey){ ActionMessages errors = getErrors(request); if (errors == null) { errors = new ActionErrors(); } errors.add(key, new ActionError(errorKey)); saveErrors(request, errors); }
public ActionForward removeClasses(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { DynaActionForm removeClassesForm = (DynaActionForm) form; String[] selectedClasses = (String[]) removeClassesForm.get("selectedItems"); if (selectedClasses.length == 0) { ActionErrors actionErrors = new ActionErrors(); actionErrors.add("errors.classes.notSelected", new ActionError("errors.classes.notSelected")); saveErrors(request, actionErrors); return mapping.getInputForward(); } List<String> classOIDs = new ArrayList<String>(); for (String selectedClasse : selectedClasses) { classOIDs.add(selectedClasse); } InfoShift infoShift = (InfoShift) request.getAttribute(PresentationConstants.SHIFT); RemoveClasses.run(infoShift, classOIDs); return mapping.findForward("EditShift"); }
public ActionForward deleteClasses(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { DynaActionForm deleteClassesForm = (DynaActionForm) form; String[] selectedClasses = (String[]) deleteClassesForm.get("selectedItems"); if (selectedClasses.length == 0) { ActionErrors actionErrors = new ActionErrors(); actionErrors.add("errors.classes.notSelected", new ActionError("errors.classes.notSelected")); saveErrors(request, actionErrors); return mapping.getInputForward(); } List<String> classOIDs = new ArrayList<String>(); for (String selectedClasse : selectedClasses) { classOIDs.add(selectedClasse); } DeleteClasses.run(classOIDs); return listClasses(mapping, form, request, response); }
public ActionForward deleteLesson(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { List<String> lessons = new ArrayList<String>(); lessons.add(request.getParameter(PresentationConstants.LESSON_OID)); try { DeleteLessons.run(lessons); } catch (FenixServiceMultipleException e) { final ActionErrors actionErrors = new ActionErrors(); for (final DomainException domainException : e.getExceptionList()) { actionErrors.add(domainException.getMessage(), new ActionError(domainException.getMessage(), domainException.getArgs())); } saveErrors(request, actionErrors); return mapping.findForward("LessonDeleted"); } request.removeAttribute(PresentationConstants.LESSON_OID); return mapping.findForward("LessonDeleted"); }
public ActionForward deleteExecutionDegrees(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws FenixActionException { DynaActionForm deleteForm = (DynaActionForm) form; List<String> executionDegreesIds = Arrays.asList((String[]) deleteForm.get("internalIds")); try { List<String> undeletedExecutionDegreesYears = DeleteExecutionDegreesOfDegreeCurricularPlan.run(executionDegreesIds); if (!undeletedExecutionDegreesYears.isEmpty()) { ActionErrors actionErrors = new ActionErrors(); for (String undeletedExecutionDegreesYear : undeletedExecutionDegreesYears) { // Create an ACTION_ERROR for each EXECUTION_DEGREE ActionError error = new ActionError("errors.invalid.delete.not.empty.execution.degree", undeletedExecutionDegreesYear); actionErrors.add("errors.invalid.delete.not.empty.execution.degree", error); } saveErrors(request, actionErrors); } return readExecutionDegrees(mapping, form, request, response); } catch (FenixServiceException fenixServiceException) { throw new FenixActionException(fenixServiceException.getMessage()); } }
public ActionForward deleteLessonInstance(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { NextPossibleSummaryLessonsAndDatesBean bean = NextPossibleSummaryLessonsAndDatesBean.getNewInstance(request.getParameter("lessonDate")); try { DeleteLessonInstance.run(bean.getLesson(), bean.getDate()); ActionErrors actionErrors = new ActionErrors(); actionErrors.add(null, new ActionError("message.deleteLesson", bean.getDate())); saveErrors(request, actionErrors); } catch (UnsupportedOperationException unsupportedOperationException) { ActionErrors actionErrors = new ActionErrors(); actionErrors.add(unsupportedOperationException.getMessage(), new ActionError("error.Lesson.not.instanced", bean.getDate())); saveErrors(request, actionErrors); } catch (DomainException domainException) { ActionErrors actionErrors = new ActionErrors(); actionErrors.add(domainException.getMessage(), new ActionError(domainException.getMessage())); saveErrors(request, actionErrors); } return viewAllLessonDates(mapping, form, request, response); }
public ActionForward removeTeacher(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { Professorship professorship = getDomainObject(request, "teacherOID"); try { DeleteProfessorshipWithPerson.run(professorship.getPerson(), getExecutionCourse(request)); } catch (NotAuthorizedException e) { final ActionMessages actionErrors = new ActionErrors(); actionErrors.add("error", new ActionMessage("label.not.authorized.action")); saveErrors(request, actionErrors); } catch (DomainException domainException) { final ActionMessages actionErrors = new ActionErrors(); actionErrors.add("error", new ActionMessage(domainException.getMessage())); saveErrors(request, actionErrors); } return viewTeachersByProfessorship(mapping, form, request, response); }
public ActionForward changeRoom(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { final InfoLesson infoLesson = (InfoLesson) request.getAttribute(PresentationConstants.LESSON); final Space space = getDomainObject(request, "spaceOID"); try { EditLesson.run(infoLesson.getLesson(), space); } catch (final DomainException domainException) { final ActionErrors actionErrors = new ActionErrors(); actionErrors.add(domainException.getMessage(), new ActionError(domainException.getMessage(), domainException.getArgs())); saveErrors(request, actionErrors); } return viewAllLessonDates(mapping, form, request, response); }
public ActionForward prepareCreate(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { DynaActionForm manageLessonForm = (DynaActionForm) form; InfoShift infoShift = (InfoShift) request.getAttribute(PresentationConstants.SHIFT); Shift shift = FenixFramework.getDomainObject(infoShift.getExternalId()); GenericPair<YearMonthDay, YearMonthDay> maxLessonsPeriod = shift.getExecutionCourse().getMaxLessonsPeriod(); if (maxLessonsPeriod != null) { request.setAttribute("executionDegreeLessonsStartDate", maxLessonsPeriod.getLeft().toString("dd/MM/yyyy")); request.setAttribute("executionDegreeLessonsEndDate", maxLessonsPeriod.getRight().toString("dd/MM/yyyy")); manageLessonForm.set("newBeginDate", maxLessonsPeriod.getLeft().toString("dd/MM/yyyy")); manageLessonForm.set("newEndDate", maxLessonsPeriod.getRight().toString("dd/MM/yyyy")); manageLessonForm.set("createLessonInstances", Boolean.TRUE); } else { ActionErrors actionErrors = new ActionErrors(); actionErrors.add("error.executionDegree.empty.lessonsPeriod", new ActionError( "error.executionDegree.empty.lessonsPeriod")); saveErrors(request, actionErrors); return mapping.findForward("EditShift"); } return mapping.findForward("ShowLessonForm"); }