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 void addErrors(ActionMessages errors) { if (errors == null) { return; } this.actionErrors.add(errors); }
public class ErrorForm extends ValidatorForm{ public ActionErrors validateForm(ActionMapping mapping, HttpServletRequest request){ ActionErrors errs= super.validate(mapping, request); errs.add(ActionErrors.GLOBAL_MESSAGE, new ActionMessage(WebGlobals.CUSTOM_ERROR)); return errs; } }
private void addMissingValueError(ActionErrors errors, String field) { ActionMessage error = new ActionMessage("field.value.missing", field); errors.add(ActionMessages.GLOBAL_MESSAGE, error); } }
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = super.validate(mapping, request); if (idNumber.length() < 1 && packageNumber .length() < 1) { errors.add("emptyForm", new ActionError("error.form.empty", "emptyForm")); } return errors;
@Override public ActionErrors validate( ActionMapping mapping, HttpServletRequest request) { // errors return from validator framework (validation.xml file rules) ActionErrors errors = super.validate(mapping, request); // Now check other properties (outside of validation.xml) if(somefield == "" ) { errors.add("example", new ActionMessage("some.resource.file.key")); } ... continue to validate your properties return errors; }
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { try { MessageResources resources = getResources(request); ActionErrors errors = super.validate(mapping, request); if (getEmpname() == null || getEmpname().length() < 1) { errors.add("name", new ActionMessage("error.name.required")); throw new Exception(getResources(request).getMessage("error.name.required")); } return errors; } catch (Exception ex) { request.setAttribute(Globals.EXCEPTION_KEY, ex); return null; } }
ActionErrors actionErrors = super.validate(mapping, request); actionErrors.add(ActionErrors.GLOBAL_MESSAGE, new ActionMessage("error.invalidCredentials"));
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; }
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; }
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; }
ActionErrors errors = new ActionErrors(); errors.add(ActionErrors.GLOBAL_MESSAGE, new ActionMessage("error.invalidCredentials")); request.setAttribute(Globals.ERROR_KEY, errors); return mapping.findForward("failure");
public void addGlobalError(String key, Object[] values) { this.actionErrors.add(ActionErrors.GLOBAL_MESSAGE, new ActionMessage(key, convertMaxArguments(values))); }
public void addError(String property, String key, Object[] values) { this.actionErrors.add(property, new ActionMessage(key, convertMaxArguments(values))); }
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"); }
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 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); }