Actionmessage Struts 1 Example Of Narrative Essay

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

The following are top voted examples for showing how to use org.apache.struts.action.ActionMessage. 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

/** * 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 */ protected ActionForward handleCancelCommand( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { SuggestCommentForm scf = (SuggestCommentForm) form; ActionErrors errors = new ActionErrors(); scf.clear(); scf.setItemID(""); errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("comment.cancel")); saveMessages(request, errors); return mapping.findForward("home"); }
/** * Validates that the field value is an existing directory on the server that the application is running on. * * @param bean The Struts bean * @param va the ValidatorAction * @param field The Field * @param messages The ActionMessages * @param validator The Validator * @param request The HttpServletRequest * @param servletContext The ServletContext * @return True if the directory exists */ public static boolean validateIsDirectory( Object bean, ValidatorAction va, Field field, ActionMessages messages, Validator validator, HttpServletRequest request, ServletContext servletContext) { // Get the value the user entered: String value = ValidatorUtils.getValueAsString(bean, field.getProperty()); File dir = new File(value.trim()); // Validate that this is a directory on the server that already exists: if (!dir.isDirectory()) { ActionMessage message = Resources.getActionMessage(validator, request, va, field); messages.add(field.getKey(), message); return false; } else return true; }
/** * Validates that the String is a valid namespace identifier for OAI. * * @param bean The Struts bean * @param va the ValidatorAction * @param field The Field * @param messages The ActionMessages * @param validator The Validator * @param request The HttpServletRequest * @param servletContext The ServletContext * @return True if valid */ public static boolean validateNamespaceIdentifier( Object bean, ValidatorAction va, Field field, ActionMessages messages, Validator validator, HttpServletRequest request, ServletContext servletContext) { // Get the value the user entered: String repositoryIdentifier = ValidatorUtils.getValueAsString(bean, field.getProperty()); boolean isValid = ( repositoryIdentifier == null || repositoryIdentifier.length() == 0 || repositoryIdentifier.matches("[a-zA-Z][a-zA-Z0-9\\-]*(\\.[a-zA-Z][a-zA-Z0-9\\-]+)+")); if(!isValid) { ActionMessage message = Resources.getActionMessage(validator, request, va, field); messages.add(field.getKey(), message); } return isValid; }
/** * 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; }
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; }
/** * Creates two ActionErrors signifying a Generic error, one for the top of * page message, and one for the error message that is attached to a specific * field. * * @param errors error list to which we add * @param msg error msg content * @param xpath The feature to be added to the GenericError attribute */ public static void addGenericError(SchemEditActionErrors errors, String xpath, String msg) { prtln("addGenericError()"); //debegging messages prtln("\txpath: " + xpath); prtln("\tmsg: " + msg); String encodedPath = XPathUtils.encodeXPath(xpath); String id = xpath2Id(xpath); String fieldProperty = "valueOf(" + encodedPath + ")"; String msgKey = "generic.field.error"; errors.add(fieldProperty, new ActionMessage(msgKey, msg)); errors.add("pageErrors", new ActionMessage(msgKey + ".link", msg, id)); }
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; }
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)) { SolverParameterDef def = SolverParameterDef.findByNameGroup(name, group); if (def!=null) errors.add("name", new ActionMessage("errors.exists", name)); } } if(group==null || group.trim().length()==0) errors.add("group", new ActionMessage("errors.required", "")); if(type==null || type.trim().length()==0) errors.add("type", new ActionMessage("errors.required", "")); if(description==null || description.trim().length()==0) errors.add("description", new ActionMessage("errors.required", "")); return errors; }
/** * Creates two ActionErrors, one for the top of page message, and one for the * error message that is attached to a specific field. * * @param errors ActionErrors object to which the new errors are added * @param field The InputField containing an error * @param errorMsg The feature to be added to the EntityError attribute */ public static void addEntityError(SchemEditActionErrors errors, InputField field, String errorMsg) { prtln("addEntityError()"); String elementName = field.getFieldName(); // String pathArg = XPathUtils.encodeXPath(field.getXPath()); String fieldProperty = field.getParamName(); String msgKey = "entity.error"; String id = xpath2Id(field.getXPath()); //debegging messages prtln("\txpath (field.xpath): " + field.getXPath()); // prtln ("\tpathArg (encoded xpath): " + pathArg); prtln("\tid: " + id); prtln("\tfieldProperty (field.paramName): " + fieldProperty); prtln("\t errors class: " + errors.getClass().getName()); errors.add(fieldProperty, new ActionMessage(msgKey, errorMsg)); errors.add("entityErrors", // new ActionMessage(msgKey + ".link", elementName, errorMsg, pathArg)); new ActionMessage(msgKey + ".link", elementName, id)); }
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if (iOrgName==null || iOrgName.length()==0) { errors.add("orgName", new ActionMessage("errors.generic", "Please enter the name of the organization.")); } else { for (Iterator i=SponsoringOrganization.findAll().iterator(); i.hasNext();) { SponsoringOrganization so2 = (SponsoringOrganization) i.next(); if (iOrgName.compareToIgnoreCase(so2.getName())==0) { if (iId != null) { if (iId.compareTo(so2.getUniqueId())!=0) { errors.add("orgNameExists", new ActionMessage("errors.generic", "Another organization with this name already exists.")); break; } } else { errors.add("orgNameExists", new ActionMessage("errors.generic", "Another organization with this name already exists.")); break; } } } } return 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; }
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)); } } } } }
private void validateAnswers(HttpServletRequest request, AnswerDTO question, ActionErrors errors, SurveyAnswer answer) { boolean isAnswerEmpty = ((answer.getChoices() == null) && StringUtils.isBlank(answer.getAnswerText())); // for mandatory questions, answer can not be null. if (!question.isOptional() && isAnswerEmpty) { errors.add(SurveyConstants.ERROR_MSG_KEY + question.getUid(), new ActionMessage(SurveyConstants.ERROR_MSG_MANDATORY_QUESTION)); } if ((question.getType() == SurveyConstants.QUESTION_TYPE_SINGLE_CHOICE) && question.isAppendText() && !isAnswerEmpty) { // for single choice, user only can choose one option or open text (if it has) if (!StringUtils.isBlank(answer.getAnswerChoices()) && !StringUtils.isBlank(answer.getAnswerText())) { errors.add(SurveyConstants.ERROR_MSG_KEY + question.getUid(), new ActionMessage(SurveyConstants.ERROR_MSG_SINGLE_CHOICE)); } } }
/** * Method validate * @param mapping * @param request * @return ActionErrors */ public ActionErrors validate( ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if (op.equals(MSG.actionAddCourseToCrossList())) { // Check Added Course if (this.addCourseOfferingId==null || this.addCourseOfferingId.intValue()<=0) { errors.add("addCourseOfferingId", new ActionMessage("errors.generic", MSG.errorRequiredCourseOffering())); } } if (op.equals(MSG.actionUpdateCrossLists())) { // Check controlling course if (this.ctrlCrsOfferingId==null || this.ctrlCrsOfferingId.intValue()<=0) { errors.add("ctrlCrsOfferingId", new ActionMessage("errors.generic", MSG.errorRequiredControllingCourse())); } } return errors; }
private boolean validateBeforeFinish(HttpServletRequest request, String sessionMapID) { SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession().getAttribute(sessionMapID); Long sessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); HttpSession ss = SessionManager.getSession(); UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); Long userID = new Long(user.getUserID().longValue()); IResourceService service = getResourceService(); int miniViewFlag = service.checkMiniView(sessionId, userID); // if current user view less than reqired view count number, then just return error message. if (miniViewFlag > 0) { ActionErrors errors = new ActionErrors(); errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("lable.learning.minimum.view.number.less", miniViewFlag)); this.addErrors(request, errors); return false; } return true; }
public ActionForward deleteSession( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { Long id = new Long(Long.parseLong(request.getParameter("sessionId"))); if (id.equals(sessionContext.getUser().getCurrentAcademicSessionId())) { ActionMessages errors = new ActionMessages(); errors.add("sessionId", new ActionMessage("errors.generic", "Current academic session cannot be deleted -- please change your session first.")); saveErrors(request, errors); return mapping.findForward("showEdit"); } sessionContext.checkPermission(id, "Session", Right.AcademicSessionDelete); Session.deleteSessionById(id); return mapping.findForward("showSessionList"); }
private boolean validateBeforeFinish(HttpServletRequest request, String sessionMapID) { SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession().getAttribute(sessionMapID); Long sessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); HttpSession ss = SessionManager.getSession(); UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); Long userID = new Long(user.getUserID().longValue()); ICommonCartridgeService service = getCommonCartridgeService(); int miniViewFlag = service.checkMiniView(sessionId, userID); // if current user view less than reqired view count number, then just return error message. if (miniViewFlag > 0) { ActionErrors errors = new ActionErrors(); errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("lable.learning.minimum.view.number.less", miniViewFlag)); this.addErrors(request, errors); return false; } return true; }
@Override public ActionMessages validate() { ActionMessages errors = new ActionMessages(); boolean valid = true; boolean allEmpty = true; if (nomination != null && !nomination.isEmpty()) { for (String item : nomination) { if (!StringUtils.isEmpty(item)) { allEmpty = false; break; } } } if (allEmpty) { ActionMessage error = new ActionMessage("nominations.none.submitted"); errors.add(ActionMessages.GLOBAL_MESSAGE, error); valid = false; nomination = null; } setValid(valid); 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; }
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", "")); } if (iOwner==null || iOwner.length==0) errors.add("owner", new ActionMessage("errors.required", "")); 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 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; }
protected void addDistPref( HttpServletRequest request, PreferencesForm frm, ActionMessages errors ) { List lst = frm.getDistPrefs(); if(frm.checkPrefs(lst)) { for (int i=0; i<Constants.PREF_ROWS_ADDED; i++) { frm.addToDistPrefs( Preference.BLANK_PREF_VALUE, Preference.BLANK_PREF_VALUE ); } request.setAttribute(HASH_ATTR, HASH_DIST_PREF); } else { errors.add("distPrefs", new ActionMessage( "errors.generic", MSG.errorInvalidDistributionPreference()) ); saveErrors(request, errors); } }
/** * Gets the <code>ActionMessage</code> based on the * <code>ValidatorAction</code> message and the <code>Field</code>'s * arg objects. * @param request the servlet request * @param va Validator action * @param field the validator Field */ public static ActionMessage getActionMessage( HttpServletRequest request, ValidatorAction va, Field field) { String args[] = getArgs( va.getName(), getMessageResources(request), RequestUtils.getUserLocale(request, null), field); String msg = field.getMsg(va.getName()) != null ? field.getMsg(va.getName()) : va.getMsg(); return new ActionMessage(msg, args); }
/** * Validates node form fields. * * @param node * @param form * @return */ private ActionMessages validateNodeForm(PedagogicalPlannerSequenceNode node, PedagogicalPlannerSequenceNodeForm form) { ActionMessages errors = new ActionMessages(); // Title must not be blank if (StringUtils.isEmpty(form.getTitle())) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(PedagogicalPlannerAction.ERROR_KEY_NODE_TITLE_BLANK)); } // Template must a proper file if (PedagogicalPlannerSequenceNodeForm.NODE_TYPE_TEMPLATE.equals(form.getNodeType()) && (node.getLearningDesignTitle() == null)) { errors.add(validateFormFile(form)); } return errors; }
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if(iReference==null || iReference.trim().length()==0) errors.add("reference", new ActionMessage("errors.required", "")); else { try { RoomType rt = RoomType.findByReference(iReference); if (rt!=null && !rt.getUniqueId().equals(iUniqueId)) errors.add("reference", new ActionMessage("errors.exists", iReference)); } catch (Exception e) { errors.add("reference", new ActionMessage("errors.generic", e.getMessage())); } } if(iLabel==null || iLabel.trim().length()==0) errors.add("label", new ActionMessage("errors.required", "")); return errors; }
private void addRoomGroup(HttpServletRequest request, PreferencesForm frm, ActionMessages errors) { List lst = frm.getRoomGroups(); if(frm.checkPrefs(lst)) { for (int i=0; i<Constants.PREF_ROWS_ADDED; i++) { frm.addToRoomGroups( Preference.BLANK_PREF_VALUE, Preference.BLANK_PREF_VALUE ); } request.setAttribute(HASH_ATTR, HASH_RM_GROUP); } else { errors.add("roomGroup", new ActionMessage( "errors.generic", MSG.errorInvalidRoomGroup())); saveErrors(request, errors); } }
public void rollTimePatternsForward(ActionMessages errors, RollForwardSessionForm rollForwardSessionForm) { Session toSession = Session.getSessionById(rollForwardSessionForm.getSessionToRollForwardTo()); Session fromSession = Session.getSessionById(rollForwardSessionForm.getSessionToRollTimePatternsForwardFrom()); List<TimePattern> fromDatePatterns = TimePattern.findAll(fromSession, null); TimePattern fromTimePattern = null; TimePattern toTimePattern = null; TimePatternDAO tpDao = new TimePatternDAO(); try { for(Iterator<TimePattern> it = fromDatePatterns.iterator(); it.hasNext();){ fromTimePattern = it.next(); if (fromTimePattern != null){ toTimePattern = (TimePattern) fromTimePattern.clone(); toTimePattern.setSession(toSession); rollTimePatternOntoDepartments(fromTimePattern, toTimePattern); tpDao.saveOrUpdate(toTimePattern); tpDao.getSession().flush(); } } tpDao.getSession().flush(); tpDao.getSession().clear(); } catch (Exception e) { iLog.error("Failed to roll all time patterns forward.", e); errors.add("rollForward", new ActionMessage("errors.rollForward", "Time Patterns", fromSession.getLabel(), toSession.getLabel(), "Failed to roll all time patterns forward.")); } }
private ActionMessages validateQuestionAnswer(String newAnswer, Integer questionIndex, GeneralLearnerFlowDTO generalLearnerFlowDTO) { ActionMessages errors = new ActionMessages(); Map<Integer, QaQuestionDTO> questionMap = generalLearnerFlowDTO.getMapQuestionContentLearner(); QaQuestionDTO dto = questionMap.get(questionIndex); // if so, check if the answer is blank and generate an error if it is blank. boolean isRequiredQuestionMissed = dto.isRequired() && isEmpty(newAnswer); if (isRequiredQuestionMissed) { errors.add(Globals.ERROR_KEY, new ActionMessage("error.required", questionIndex)); } boolean isMinWordsLimitReached = ValidationUtil.isMinWordsLimitReached(newAnswer, dto.getMinWordsLimit(), Boolean.parseBoolean(generalLearnerFlowDTO.getAllowRichEditor())); if (!isMinWordsLimitReached) { errors.add(Globals.ERROR_KEY, new ActionMessage("label.minimum.number.words", ": " + dto.getMinWordsLimit())); } 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; }
@Override public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); MessageResources resources = MessageResources.getMessageResources(Constants.APP_RESOURCES); if (StringUtils.isBlank(this.serverURL)) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.mandatoryField", resources.getMessage("config.serverURL"))); } if (StringUtils.isBlank(this.securitySalt)) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.mandatoryField", resources.getMessage("config.securitySalt"))); } return errors; }
public void validateLastLikeDemandRollForward(Session toAcadSession,ActionErrors errors){ if (getRollForwardStudents().booleanValue()) { if (getRollForwardStudentsMode().equals(SessionRollForward.StudentEnrollmentMode.LAST_LIKE.name())) { validateRollForwardSessionHasNoDataOfType(errors, toAcadSession, "Last-like Student Course Requests", LastLikeCourseDemandDAO.getInstance().getQuery("from LastLikeCourseDemand d where d.subjectArea.session.uniqueId = " + toAcadSession.getUniqueId().toString()).list()); } else if (getRollForwardStudentsMode().equals(SessionRollForward.StudentEnrollmentMode.STUDENT_CLASS_ENROLLMENTS.name())) { validateRollForwardSessionHasNoDataOfType(errors, toAcadSession, "Student Class Enrollments", StudentClassEnrollmentDAO.getInstance().getQuery("from StudentClassEnrollment d where d.courseOffering.subjectArea.session.uniqueId = " + toAcadSession.getUniqueId().toString()).list()); } else if (getRollForwardStudentsMode().equals(SessionRollForward.StudentEnrollmentMode.STUDENT_COURSE_REQUESTS.name())) { validateRollForwardSessionHasNoDataOfType(errors, toAcadSession, "Course Requests", CourseRequestDAO.getInstance().getQuery("from CourseRequest r where r.courseOffering.subjectArea.session.uniqueId = " + toAcadSession.getUniqueId().toString()).list()); } else if (getRollForwardStudentsMode().equals(SessionRollForward.StudentEnrollmentMode.POINT_IN_TIME_CLASS_ENROLLMENTS.name())) { validateRollForwardSessionHasNoDataOfType(errors, toAcadSession, "Point In Time Data Student Class Enrollments", StudentClassEnrollmentDAO.getInstance().getQuery("from PitStudentClassEnrollment d where d.pitCourseOffering.subjectArea.session.uniqueId = " + toAcadSession.getUniqueId().toString()).list()); } else { errors.add("invalidCancelAction", new ActionMessage("errors.generic", "Invalid last like course demand roll forward action: " + getRollForwardStudentsMode())); } } }
protected void addCoursePref( HttpServletRequest request, PreferencesForm frm, ActionMessages errors ) { List lst = frm.getCoursePrefs(); if(frm.checkPrefs(lst)) { for (int i=0; i<Constants.PREF_ROWS_ADDED; i++) { frm.addToCoursePrefs( Preference.BLANK_PREF_VALUE, Preference.BLANK_PREF_VALUE ); } request.setAttribute(HASH_ATTR, HASH_COURSE_PREF); } else { errors.add("coursePrefs", new ActionMessage( "errors.generic", MSG.errorInvalidCoursePreference()) ); saveErrors(request, errors); } }
private boolean validateBeforeFinish(HttpServletRequest request, String sessionMapID) { SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession().getAttribute(sessionMapID); Long sessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); HttpSession ss = SessionManager.getSession(); UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); Long userID = new Long(user.getUserID().longValue()); ITaskListService service = getTaskListService(); int numberCompletedTasks = service.getNumTasksCompletedByUser(sessionId, userID); int minimumNumberTasks = service.getTaskListBySessionId(sessionId).getMinimumNumberTasks(); // if current user view less than reqired view count number, then just return error message. if ((minimumNumberTasks - numberCompletedTasks) > 0) { ActionErrors errors = new ActionErrors(); errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("lable.learning.minimum.view.number", minimumNumberTasks, numberCompletedTasks)); this.addErrors(request, errors); return false; } return true; }
/** * This is the action called from the Struts framework. * @param mapping The ActionMapping used to select this instance. * @param request The HTTP Request we are processing. * @return */ public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { System.out.println("LoginForm:validate()"); ActionErrors errors = new ActionErrors(); if (userName == null || userName.length() < 1) { errors.add("userName", new ActionMessage("error.userName.required")); // TODO: add 'error.name.required' key to your resources } if (password == null || password.length() < 1) { errors.add("password", new ActionMessage("error.password.required")); // TODO: add 'error.name.required' key to your resources } return errors; }
/** * Return user to suggestor front page and show message explaining that they * were apparently trying to edit or submit data from a cancelled form * * @param mapping Description of the Parameter * @param request Description of the Parameter * @param form NOT YET DOCUMENTED * @return Description of the Return Value */ protected ActionForward handleStaleData( ActionMapping mapping, ActionForm form, HttpServletRequest request) { SuggestForm sForm = (SuggestForm) form; sForm.clear(); prtln("handleStaleData"); ActionMessages actionMessages = new ActionMessages(); actionMessages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("stale.data")); saveMessages(request, actionMessages); return mapping.findForward("home"); }
/** * Validates that the field value is a directory that is not already configured in the repository * (RepositoryManager). Checks the request parameter 'edit' for the previous directory setInfo, if editing. * * @param bean The Struts bean * @param va the ValidatorAction * @param field The Field * @param messages The ActionMessages * @param validator The Validator * @param request The HttpServletRequest * @param servletContext The ServletContext * @return True if the directory exists */ public static boolean validateDirectoryNotInRepository( Object bean, ValidatorAction va, Field field, ActionMessages messages, Validator validator, HttpServletRequest request, ServletContext servletContext) { // Get the value the user entered: String value = ValidatorUtils.getValueAsString(bean, field.getProperty()); File dir = new File(value.trim()); RepositoryManager rm = (RepositoryManager) servletContext.getAttribute("repositoryManager"); // If editing the same dir, allow it: String prevKey = request.getParameter("edit"); SetInfo setInfo = rm.getSetInfo(prevKey); if(setInfo != null && setInfo.getDirectory().equals(dir.getAbsolutePath())) return true; if (rm != null && rm.isDirectoryConfigured(dir)) { ActionMessage message = Resources.getActionMessage(validator, request, va, field); messages.add(field.getKey(), message); return false; } else return true; }
/** Perform password checks */ private boolean passwordFieldCheck(HttpServletRequest request) { boolean valid = true; String pass1 = getPassword1WM().getValue(); if (pass1 != null && pass1.length() == 0) pass1 = null; pass1 = Parser.parseString(pass1); String pass2 = getPassword2WM().getValue(); if (pass2 != null && pass2.length() == 0) pass2 = null; pass2 = Parser.parseString(pass2); if (pass1 == null && ((UserRequestMaintenanceComponent) getComponent()).isCreateMode()) { raiseError(request, UserMeta.META_PASSWORD.getLabelToken(), new MandatoryFieldException(UserMeta.META_PASSWORD.getLabelToken())); valid = false; } if (pass2 == null && ((UserRequestMaintenanceComponent) getComponent()).isCreateMode()) { raiseError(request, "[label.Jaffa.User.User.VerifyPassword]", new MandatoryFieldException("[label.Jaffa.User.User.VerifyPassword]")); valid = false; } if((pass1 != null && !pass1.equals(pass2)) || (pass2 != null && !pass2.equals(pass1))) { raiseError(request, UserMeta.META_PASSWORD.getLabelToken(), new ActionMessage("error.Jaffa.User.UserMaintenance.InvalidPassword.Different")); valid = false; } return valid; }

Беккер понимающе кивнул, но ему хотелось знать. Используя вместо классной доски салфетки ресторана Мерлутти или концертные программы, Сьюзан дала этому популярному и очень привлекательному преподавателю первые уроки криптографии. Она начала с «совершенного квадрата» Юлия Цезаря.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *