Skip to content

Actionerrors In Struts 1 Example Of Narrative Essay

Java Code Examples for org.apache.struts.action.ActionErrors

The following are top voted examples for showing how to use org.apache.struts.action.ActionErrors. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.

Example 1

Example 2

Example 3

Example 4

Example 5

Example 6

Example 7

Example 8

Example 9

Example 10

Example 11

Example 12

Example 13

Example 14

Example 15

Example 16

Example 17

Example 18

Example 19

Example 20

Example 21

Example 22

Example 23

Example 24

Example 25

Example 26

Example 27

Example 28

Example 29

Example 30

Example 31

Example 32

Example 33

Example 34

Example 35

Example 36

Example 37

Example 38

Example 39

Example 40

Example 41

public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if(name==null || name.trim().length()==0) errors.add("name", new ActionMessage("errors.required", "")); else { if ("Save".equals(op)) { SolverParameterGroup gr = SolverParameterGroup.findByName(name); if (gr!=null) errors.add("name", new ActionMessage("errors.exists", name)); } } if(description==null || description.trim().length()==0) errors.add("description", new ActionMessage("errors.required", "")); return errors; }
/** * Validate imageGallery item. * * @param itemForm * @return */ private ActionErrors validateImageFile(AuthoringForm itemForm) { ActionErrors errors = new ActionErrors(); // validate file size FileValidatorUtil.validateFileSize(itemForm.getFile(), true, errors); // for edit validate: file already exist if (!itemForm.isHasFile() && ((itemForm.getFile() == null) || StringUtils.isEmpty(itemForm.getFile().getFileName()))) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(PixlrConstants.ERROR_MSG_FILE_BLANK)); } // check for allowed format : gif, png, jpg if (itemForm.getFile() != null) { String contentType = itemForm.getFile().getContentType(); if (StringUtils.isEmpty(contentType) || !(contentType.equals("image/gif") || contentType.equals("image/png") || contentType.equals("image/jpg") || contentType.equals("image/jpeg") || contentType.equals("image/pjpeg"))) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(PixlrConstants.ERROR_MSG_NOT_ALLOWED_FORMAT)); } } return errors; }
/** * Validate imageGallery item. * * @param multipleForm * @return */ public static ActionErrors validateMultipleImages(MultipleImagesForm multipleForm, boolean largeFile) { ActionErrors errors = new ActionErrors(); List<FormFile> fileList = createFileListFromMultipleForm(multipleForm); // validate files size for (FormFile file : fileList) { FileValidatorUtil.validateFileSize(file, largeFile, errors); // check for allowed format : gif, png, jpg String contentType = file.getContentType(); if (isContentTypeForbidden(contentType)) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(ImageGalleryConstants.ERROR_MSG_NOT_ALLOWED_FORMAT_FOR, file.getFileName())); } } return errors; }
/** * The idea is to do minimal validation on inputs. */ public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); // boolean validName = false, validEmail = false; try { validName = ESAPI.validator().isValidInput("TestForm_name", name, "name", 20, false); validEmail = ESAPI.validator().isValidInput("TestForm_email", email, "email", 45, false); } catch (IntrusionException e) { log.severe(e.getMessage()); } if (!validName) errors.add("name", new ActionMessage("TestForm.name.invalid")); if (!validEmail) errors.add("email", new ActionMessage("TestForm.email.invalid")); return errors; }
private void validateChildClassExistence(ActionErrors errors){ for(int index = 0 ; index < this.getClassIds().size(); index++){ if (Boolean.valueOf((String) this.getMustHaveChildClasses().get(index)).booleanValue()){ String classId = (String) this.getClassIds().get(index); if ((index + 1) == this.getClassIds().size()){ errors.add("mustHaveChildClasses", new ActionMessage("errors.generic", MSG.errorClassMustHaveChildClasses((String) this.getClassLabels().get(index)))); this.getClassHasErrors().set(index, new Boolean(true)); } else { String parentOfNextClass = (String) this.getParentClassIds().get(index + 1); if (parentOfNextClass == null || !parentOfNextClass.equals(classId)){ errors.add("mustHaveChildClasses", new ActionMessage("errors.generic", MSG.errorClassMustHaveChildClasses((String) this.getClassLabels().get(index)))); this.getClassHasErrors().set(index, new Boolean(true)); } } } } }
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if (iExternalId ==null || iExternalId.trim().length()==0) errors.add("externalId", new ActionMessage("errors.required", "")); else if (!"Update".equals(getOp()) && User.findByExternalId(getExternalId())!=null) { errors.add("externalId", new ActionMessage("errors.exists", iExternalId)); } if (iName==null || iName.trim().length()==0) errors.add("name", new ActionMessage("errors.required", "")); else { try { User user = User.findByUserName(iName); if (user!=null && !user.getExternalUniqueId().equals(iExternalId)) errors.add("name", new ActionMessage("errors.exists", iName)); } catch (Exception e) { errors.add("name", new ActionMessage("errors.generic", e.getMessage())); } } if (iPassword==null || iPassword.trim().length()==0) errors.add("password", new ActionMessage("errors.required", "")); return errors; }
/** * */ private void setHolidays( HttpServletRequest request, SessionEditForm sessionEditForm, ActionErrors errors, Session sessn) throws ParseException { sessionEditForm.validateDates(errors); if (errors.size()==0) { setSessionData(request, sessionEditForm, sessn); request.setAttribute("Sessions.holidays", sessn.getHolidaysHtml()); } else saveErrors(request, new ActionMessages(errors)); }
/** * Validate ScratchieConfigItems. * * @param adminForm * @return */ private ActionErrors validateAdminForm(AdminForm adminForm) { ActionErrors errors = new ActionErrors(); String presetMarks = adminForm.getPresetMarks(); if (StringUtils.isNotBlank(presetMarks)) { //it's not a comma separated numbers if (!presetMarks.matches("[0-9]+(,[0-9]+)*")) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(ScratchieConstants.ERROR_MSG_ENTERED_MARKS_NOT_COMMA_SEPARATED_INTEGERS)); } } else { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(ScratchieConstants.ERROR_MSG_REQUIRED_FIELDS_MISSING)); } return errors; }
/** * Method validate * @param mapping * @param request * @return ActionErrors */ public ActionErrors validate( ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if (deptSize != 1) { if (deptCode== null || deptCode.equals("")) { errors.add("dept", new ActionMessage("errors.required", "Department")); } } if(bldgId==null || bldgId.equalsIgnoreCase("")) { errors.add("bldg", new ActionMessage("errors.required", "Building") ); } if(roomNum==null || roomNum.equalsIgnoreCase("")) { errors.add("roomNum", new ActionMessage("errors.required", "Room Number") ); } return errors; }
/** * Validate imageGallery item. * * @param itemForm * @return */ public static ActionErrors validateImageGalleryItem(ImageGalleryItemForm itemForm, boolean largeFile) { ActionErrors errors = new ActionErrors(); // validate file size FileValidatorUtil.validateFileSize(itemForm.getFile(), largeFile, errors); // for edit validate: file already exist if (!itemForm.isHasFile() && ((itemForm.getFile() == null) || StringUtils.isEmpty(itemForm.getFile().getFileName()))) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(ImageGalleryConstants.ERROR_MSG_FILE_BLANK)); } // check for allowed format : gif, png, jpg if (itemForm.getFile() != null) { String contentType = itemForm.getFile().getContentType(); if (isContentTypeForbidden(contentType)) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(ImageGalleryConstants.ERROR_MSG_NOT_ALLOWED_FORMAT)); } } return errors; }
/** * Validate the properties that have been set from this HTTP request, * and return an <code>ActionErrors</code> object that encapsulates any * validation errors that have been found. If no errors are found, return * <code>null</code> or an <code>ActionErrors</code> object with no * recorded error messages. * * @param mapping The mapping used to select this instance. * @param request The servlet request we are processing. * @return <code>ActionErrors</code> object that encapsulates any validation errors. */ public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { this.setPageFromDynaProperty(); ServletContext application = getServlet().getServletContext(); ActionErrors errors = new ActionErrors(); String validationKey = getValidationKey(mapping, request); Validator validator = Resources.initValidator(validationKey, this, application, request, errors, page); try { validatorResults = validator.validate(); } catch (ValidatorException e) { log.error(e.getMessage(), e); } return errors; }
/** * Update the edited values for the StatusEntry corresponding to "entryKey" * * @param mapping NOT YET DOCUMENTED * @param form NOT YET DOCUMENTED * @param request NOT YET DOCUMENTED * @param response NOT YET DOCUMENTED * @return NOT YET DOCUMENTED * @exception Exception NOT YET DOCUMENTED */ private ActionForward handleUpdateEntry(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionErrors errors = new ActionErrors(); StatusForm statusForm = (StatusForm) form; String entryKey = statusForm.getEntryKey(); String id = statusForm.getRecId(); DcsDataRecord dcsDataRecord = statusForm.getDcsDataRecord(); StatusEntry statusEntry = dcsDataRecord.getStatusEntry(entryKey); if (statusEntry == null) throw new Exception("status entry not found for " + entryKey); statusEntry.setStatusNote(statusForm.getStatusNote()); dcsDataRecord.replaceStatusEntry(entryKey, statusEntry); repositoryService.updateRecord(id); dcsDataRecord.flushToDisk(); statusForm.setHash(entryKey); statusForm.clear(); statusForm.setEntryKey(""); errors.add("message", new ActionError("generic.message", "status entry updated")); saveErrors(request, errors); return mapping.findForward("edit.status"); }
/** * Get answer by special question. */ private ActionErrors getAnswer(HttpServletRequest request, AnswerDTO answerDto) { ActionErrors errors = new ActionErrors(); // get sessionMap String sessionMapID = request.getParameter(SurveyConstants.ATTR_SESSION_MAP_ID); SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession() .getAttribute(sessionMapID); Long sessionID = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); SurveyAnswer answer = getAnswerFromPage(request, answerDto, sessionID); answerDto.setAnswer(answer); validateAnswers(request, answerDto, errors, answer); if (!errors.isEmpty()) { addErrors(request, errors); } return errors; }
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if(iSetting==null || iSetting.intValue()<0) errors.add("setting", new ActionMessage("errors.lookup.config.required", "")); for (Iterator i=iParamValues.entrySet().iterator();i.hasNext();) { Map.Entry entry = (Map.Entry)i.next(); Long parm = (Long)entry.getKey(); String val = (String)entry.getValue(); if (val==null || val.trim().length()==0) errors.add("parameterValue["+parm+"]", new ActionMessage("errors.required", "")); } return errors; }
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if(name==null || name.trim().length()==0) errors.add("name", new ActionMessage("errors.required", "")); else { if ("Add New".equals(op)) { SolverInfoDef info = SolverInfoDef.findByName(name); if (info!=null) errors.add("name", new ActionMessage("errors.exists", name)); } } if(description==null || description.trim().length()==0) errors.add("description", new ActionMessage("errors.required", "")); if(implementation==null || implementation.trim().length()==0) errors.add("implementation", new ActionMessage("errors.required", "")); return errors; }
/** * Validate the properties that have been set from this HTTP request, * and return an <code>ActionErrors</code> object that encapsulates any * validation errors that have been found. If no errors are found, return * <code>null</code> or an <code>ActionErrors</code> object with no * recorded error messages. * * @param mapping The mapping used to select this instance * @param request The servlet request we are processing * @return <code>ActionErrors</code> object that encapsulates any validation errors */ public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ServletContext application = getServlet().getServletContext(); ActionErrors errors = new ActionErrors(); String validationKey = getValidationKey(mapping, request); Validator validator = Resources.initValidator(validationKey, this, application, request, errors, page); try { validatorResults = validator.validate(); } catch (ValidatorException e) { log.error(e.getMessage(), e); } return errors; }
/** * Validate ImageGalleryConfigItems. * * @param adminForm * @return */ private ActionErrors validateAdminForm(AdminForm adminForm) { ActionErrors errors = new ActionErrors(); if ((adminForm.getMediumImageDimensions() != null) && !adminForm.getMediumImageDimensions().equals("")) { if (!isParsableToInt(adminForm.getMediumImageDimensions())) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(ImageGalleryConstants.ERROR_MSG_ENTERED_VALUES_NOT_INTEGERS)); } } else { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(ImageGalleryConstants.ERROR_MSG_REQUIRED_FIELDS_MISSING)); } if ((adminForm.getThumbnailImageDimensions() != null) && !adminForm.getThumbnailImageDimensions().equals("")) { if (!isParsableToInt(adminForm.getThumbnailImageDimensions())) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(ImageGalleryConstants.ERROR_MSG_ENTERED_VALUES_NOT_INTEGERS)); } } else { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(ImageGalleryConstants.ERROR_MSG_REQUIRED_FIELDS_MISSING)); } return errors; }
/** * Add confirmation message if this collection is managed in the ndr. * *@param resultDoc Description of the Parameter *@param sef Description of the Parameter *@param errors Description of the Parameter */ private void confirmNdrWrite(ResultDoc resultDoc, SchemEditForm sef, ActionErrors errors) { try { XMLDocReader docReader = (XMLDocReader) resultDoc.getDocReader(); String collection = docReader.getCollection(); CollectionConfig config = this.collectionRegistry.getCollectionConfig(collection); if (config.isNDRCollection()) { DcsDataRecord dcsDataRecord = dcsDataManager.getDcsDataRecord(sef.getRecId(), repositoryManager); if (dcsDataRecord == null) { return; } String handle = dcsDataRecord.getNdrHandle(); String syncError = dcsDataRecord.getNdrSyncError(); if (handle != null && handle.trim().length() > 0 && (syncError == null || syncError.trim().length() == 0)) { errors.add("message", new ActionError("ndr.save.confirmation")); } } } catch (Throwable t) { prtln("could not determine ndr save success: " + t.getMessage()); } }
public void validateSessionToRollForwardTo(ActionErrors errors){ Session toAcadSession = Session.getSessionById(getSessionToRollForwardTo()); if (toAcadSession == null){ errors.add("mustSelectSession", new ActionMessage("errors.rollForward.missingToSession")); return; } validateDepartmentRollForward(toAcadSession, errors); validateManagerRollForward(toAcadSession, errors); validateBuildingAndRoomRollForward(toAcadSession, errors); validateDatePatternRollForward(toAcadSession, errors); validateTimePatternRollForward(toAcadSession, errors); validateSubjectAreaRollForward(toAcadSession, errors); // TODO: remove this line of code once testing is done. // validateInstructorDataRollForward(toAcadSession, errors); validateCourseOfferingRollForward(toAcadSession, errors); validateTeachingRequestsRollForward(toAcadSession, errors); validateClassInstructorRollForward(toAcadSession, errors); validateOfferingCoordinatorsRollForward(toAcadSession, errors); validateExamConfigurationRollForward(toAcadSession, errors); validateMidtermExamRollForward(toAcadSession, errors); validateFinalExamRollForward(toAcadSession, errors); validateLastLikeDemandRollForward(toAcadSession, errors); validateCurriculaRollForward(toAcadSession, errors); }
/** * Vaidate survey item regards to their type (url/file/learning object/website zip file) * * @param itemForm * @param instructionList * @return */ private ActionErrors validateSurveyItem(QuestionForm itemForm, List<String> instructionList) { ActionErrors errors = new ActionErrors(); if (StringUtils.isBlank(itemForm.getQuestion().getDescription())) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(SurveyConstants.ERROR_MSG_DESC_BLANK)); } short type = getQuestionType(itemForm); if (type != SurveyConstants.QUESTION_TYPE_TEXT_ENTRY) { if (instructionList == null || instructionList.size() < 2) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(SurveyConstants.ERROR_MSG_LESS_OPTIONS)); } } return errors; }
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if(deptCode==null || deptCode.equalsIgnoreCase("")) { errors.add("deptCode", new ActionMessage("errors.required", "Department") ); } return errors; }
private ActionForward doPutRecord( DDSEditRecordForm def, RepositoryManager rm, ActionMapping mapping, HttpServletRequest request, HttpServletResponse response) { ActionErrors errors = new ActionErrors(); String recordXml = request.getParameter("recordXml"); String recordId = request.getParameter("recordId"); String collection = request.getParameter("collection"); String xmlFormat = request.getParameter("xmlFormat"); if (recordXml != null && collection != null && xmlFormat != null) { try { FileIndexingPlugin indexingPlugin = new SimpleFileIndexingPlugin(); rm.putRecord(recordXml, xmlFormat, collection, recordId, indexingPlugin, true); errors.add("message", new ActionError("generic.message", "Record saved successfully")); errors.add("redirect.fullview", new ActionError("generic.message", "")); } catch (Throwable e) { errors.add("error", new ActionError("generic.error", "Could not save record: " + e.getMessage())); e.printStackTrace(); } } saveErrors(request, errors); return (mapping.findForward("ddseditrecord.index")); }
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); // Get Message Resources MessageResources rsc = (MessageResources) super.getServlet() .getServletContext().getAttribute(Globals.MESSAGES_KEY); // Distribution Type must be selected if(distType==null || distType.equals(Preference.BLANK_PREF_VALUE)) { errors.add("distType", new ActionMessage( "errors.generic", "Select a distribution type. ") ); } // Distribution Pref Level must be selected if(prefLevel==null || prefLevel.equals(Preference.BLANK_PREF_VALUE)) { errors.add("prefLevel", new ActionMessage( "errors.generic", "Select a preference level. ") ); } // Save/Update clicked if(op.equals(rsc.getMessage("button.addNew")) || op.equals(rsc.getMessage("button.update")) ) { } return errors; }
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if (iSelectedSolutionBean<0 || iSelectedSolutionBean>=iSolutionBeans.size()) { errors.add("selectedSolutionBean", new ActionMessage("errors.general", "No solution selected")); } return errors; }
private ActionForward doSetRepositoryInfo(ActionErrors errors, ActionMapping mapping, RepositoryManager rm, HttpServletRequest req, RepositoryAdminForm raf, RepositoryInfoForm repositoryInfoForm) { prtln("doSetRepositoryInfo()"); // Save the new set definition try { rm.setRepositoryName(repositoryInfoForm.getRepositoryName()); rm.setRepositoryIdentifier(repositoryInfoForm.getNamespaceIdentifier()); // For now, only one description is used (but could have more later): rm.removeDescription(0); rm.addDescription(repositoryInfoForm.getRepositoryDescription()); // For now, only one e-mail is used (but could have more later): rm.removeAdminEmail(0); rm.addAdminEmail(repositoryInfoForm.getAdminEmail()); } catch (Throwable t) { errors.add("error", new ActionError("generic.error", "Error saving repository information: " + t.getMessage())); if (t instanceof NullPointerException) t.printStackTrace(); saveErrors(req, errors); return mapping.findForward("display.repository.settings"); } errors.add("message", new ActionError("generic.message", "The repository information has been updated.")); saveErrors(req, errors); return mapping.findForward("display.repository.settings"); }
/** * NOT YET DOCUMENTED * * @param mapping NOT YET DOCUMENTED * @param form NOT YET DOCUMENTED * @param request NOT YET DOCUMENTED * @param response NOT YET DOCUMENTED * @return NOT YET DOCUMENTED * @exception ServletException NOT YET DOCUMENTED */ protected ActionForward initializeSuggestor( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException { SuggestResourceForm srf = (SuggestResourceForm) form; ActionErrors errors = validateUrl(form, mapping, request); // this suggestor only cares about DuplicatePrimaries (not similars, etc) if (errors.isEmpty() && srf.getDupRecord() != null) { prtln("getDupRecord found"); return mapping.findForward("duplicate"); } if (!errors.isEmpty()) { saveErrors(request, errors); return mapping.findForward("home"); } // if validateUrl has been set in form by validateUrl String verifiedUrl = srf.getUrl(); prtln("verifiedUrl: " + verifiedUrl); return mapping.findForward("form"); }
/** * Vaidate taskList item regards to their type (url/file/learning object/website zip file) * * @param itemForm * @return */ private ActionErrors validateTaskListItem(TaskListItemForm itemForm) { ActionErrors errors = new ActionErrors(); if (StringUtils.isBlank(itemForm.getTitle())) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(TaskListConstants.ERROR_MSG_TITLE_BLANK)); } return errors; }
/** * NOT YET DOCUMENTED * * @param mapping NOT YET DOCUMENTED * @param form NOT YET DOCUMENTED * @param request NOT YET DOCUMENTED * @param response NOT YET DOCUMENTED * @return NOT YET DOCUMENTED * @exception ServletException NOT YET DOCUMENTED */ protected ActionForward handleOtherCommands( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException { SuggestCommentForm scf = (SuggestCommentForm) form; ActionErrors errors = new ActionErrors(); String command = request.getParameter("command"); prtln("command: " + command); throw new ServletException("unsupported command: " + command); }
/** * Method validate * @param mapping * @param request * @return ActionErrors */ public ActionErrors validate( ActionMapping mapping, HttpServletRequest request) { return null; }
private ActionErrors setFramework (MetaDataFramework mdf, SchemaViewerForm svf ) throws ServletException { // MetaDataFramework mdf = getMetaDataFramework (xmlFormat); // mdf = (MetaDataFramework) servlet.getServletContext().getAttribute(xmlFormat); ActionErrors errors = new ActionErrors(); String errorMsg = ""; if (mdf == null) { errorMsg = "setFramework: Framework is NULL"; errors.add (errors.GLOBAL_ERROR, new ActionError ("generic.error", errorMsg)); return errors; } // if the framework has changed, set the form bean path to the default String rootElementName = mdf.getRootElementName(); String rootPath = "/" + rootElementName; svf.setPath (rootPath); SchemaHelper schemaHelper = mdf.getSchemaHelper(); SchemaNode schemaNode = schemaHelper.getSchemaNode (rootPath); if (schemaNode == null) { errors.add(errors.GLOBAL_ERROR, new ActionError("schema.schemaNode.notfound.error", rootPath)); return errors; } svf.setSchemaNode(schemaNode); svf.setFramework(mdf); svf.setSchemaHelper(mdf.getSchemaHelper()); errors.add (setGlobalDef (rootPath, mdf.getSchemaHelper(), svf)); return errors; }
/** * This method will get necessary information from imageGallery item form and save or update into * <code>HttpSession</code> ImageGalleryItemList. Notice, this save is not persist them into database, just save * <code>HttpSession</code> temporarily. Only they will be persist when the entire authoring page is being * persisted. * * @param mapping * @param form * @param request * @param response * @return * @throws ServletException */ private ActionForward saveOrUpdateImage(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { ImageGalleryItemForm itemForm = (ImageGalleryItemForm) form; ActionErrors errors = ImageGalleryUtils.validateImageGalleryItem(itemForm, true); try { if (errors.isEmpty()) { extractFormToImageGalleryItem(request, itemForm); } } catch (Exception e) { // any upload exception will display as normal error message rather then throw exception directly errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(ImageGalleryConstants.ERROR_MSG_UPLOAD_FAILED, e.getMessage())); } if (!errors.isEmpty()) { this.addErrors(request, errors); return mapping.findForward("image"); } // set session map ID so that itemlist.jsp can get sessionMAP request.setAttribute(ImageGalleryConstants.ATTR_SESSION_MAP_ID, itemForm.getSessionMapID()); // return null to close this window return mapping.findForward(ImageGalleryConstants.SUCCESS); }
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if(iLevel==null || iLevel.trim().length()==0) errors.add("level", new ActionMessage("errors.required", "")); return errors; }
/** * Validate the properties that have been set from this HTTP request, * and return an <code>ActionErrors</code> object that encapsulates any * validation errors that have been found. If no errors are found, return * <code>null</code> or an <code>ActionErrors</code> object with no * recorded error messages. * * @param mapping The mapping used to select this instance * @param request The servlet request we are processing */ public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { // System.out.println ("\nLogonForm.validate()"); ActionErrors errors = new ActionErrors(); if ((username == null) || (username.length() < 1)) errors.add("error", new ActionError("error.username.required")); if ((password == null) || (password.length() < 1)) errors.add("error", new ActionError("error.password.required")); return errors; }
/** * NOT YET DOCUMENTED * * @param mapping the ActionMapping * @param form the ActionForm * @param request the Request * @param response the Response * @return NOT YET DOCUMENTED * @exception Exception NOT YET DOCUMENTED */ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { FileUploadForm uploadForm = (FileUploadForm) form; ActionErrors errors = new ActionErrors(); prtln("\nFileUploadAction"); String command = request.getParameter("command"); SchemEditUtils.showRequestParameters(request, null); if (command != null) { try { if (command.equals("upload")) { return doUpload(mapping, form, request, response); // return doUploadFake (mapping, form, request, response); } else throw new Exception("unrecognized command: \"" + command + "\""); } catch (Exception e) { errors.add("error", new ActionError("generic.error", e.getMessage())); saveErrors(request, errors); } } return mapping.findForward("ndr.upload.form"); }
public void validateClassInstructorRollForward(Session toAcadSession,ActionErrors errors){ if (getRollForwardClassInstructors().booleanValue()){ validateRollForward(errors, toAcadSession, getSessionToRollCourseOfferingsForwardFrom(), "Class Instructors", new ArrayList<ClassInstructor>()); ClassInstructorDAO ciDao = new ClassInstructorDAO(); for (int i = 0; i < getRollForwardClassInstrSubjectIds().length; i++){ String queryStr = "from ClassInstructor c inner join c.classInstructing.schedulingSubpart.instrOfferingConfig.instructionalOffering.courseOfferings as co where c.classInstructing.schedulingSubpart.instrOfferingConfig.instructionalOffering.session.uniqueId = " + toAcadSession.getUniqueId().toString() + " and co.isControl = 1 and co.subjectArea.uniqueId = '" + getRollForwardClassInstrSubjectIds()[i] + "'"; validateRollForwardSessionHasNoDataOfType(errors, toAcadSession, ("Class Instructors - " + getRollForwardClassInstrSubjectIds()[i]), ciDao.getQuery(queryStr).list()); } } }
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if (iType == 0) errors.add("type", new ActionMessage("errors.generic", "Please specify category of this inquiry:")); if (iMessage.trim().length() == 0) errors.add("message", new ActionMessage("errors.generic", "Message is required.")); return errors; }
/** * Method validate * @param mapping * @param request * @return ActionErrors */ public ActionErrors validate( ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if(value==null || value.trim().length()==0) errors.add("value", new ActionMessage("errors.required", "")); return errors; }
/** * Method validate * @param mapping * @param request * @return ActionErrors */ public ActionErrors validate( ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if(key==null || key.trim().length()==0) errors.add("key", new ActionMessage("errors.required", "")); if(value==null) value = ""; return errors; }
/** * This method will get necessary information from taskList item form and save or update into * <code>HttpSession</code> TaskListItemList. Notice, this save is not persist them into database, just save * <code>HttpSession</code> temporarily. Only they will be persist when the entire authoring page is being * persisted. * * @param mapping * @param form * @param request * @param response * @return * @throws ServletException */ private ActionForward saveOrUpdateItem(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { TaskListItemForm itemForm = (TaskListItemForm) form; ActionErrors errors = validateTaskListItem(itemForm); if (!errors.isEmpty()) { this.addErrors(request, errors); return mapping.findForward("task"); } try { extractFormToTaskListItem(request, itemForm); } catch (Exception e) { // any upload exception will display as normal error message rather then throw exception directly errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(TaskListConstants.ERROR_MSG_UPLOAD_FAILED, e.getMessage())); if (!errors.isEmpty()) { this.addErrors(request, errors); return mapping.findForward("task"); } } // set session map ID so that itemlist.jsp can get sessionMAP request.setAttribute(TaskListConstants.ATTR_SESSION_MAP_ID, itemForm.getSessionMapID()); // return null to close this window return mapping.findForward(TaskListConstants.SUCCESS); }
@Override public ActionErrors validate(ActionMapping arg0, HttpServletRequest arg1) { ActionErrors ac = new ActionErrors(); ac.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("this is an error")); return ac; }

Она не клюнет на твою тактику «разделяй и властвуй», - сказал Стратмор, подходя еще ближе.  - Отпусти. - Чатрукьян был совсем мальчишка.