Examples of ActionErrors


Examples of com.dotcms.repackage.org.apache.struts.action.ActionErrors

    }



    public ActionErrors validate(ActionMapping arg0, HttpServletRequest request) {
    ActionErrors errors = new ActionErrors();      
    if (!UtilMethods.isSet(password1) ){
      errors.add(Globals.MESSAGES_KEY, new ActionMessage("message.contentlet.required","password"));
    }
    if(UtilMethods.isSet(password1) && !password1.equals(verifyPassword)){                       
      errors.add(Globals.MESSAGES_KEY, new ActionMessage("error.passwordsDontMatch"));       
    }
      if (!UtilMethods.isSet(emailAddress))
      {
        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("message.contentlet.required","eMail"));       
      }
     
      if (UtilMethods.isSet(userName))
      {
        User user = null;
      try {
        user = APILocator.getUserAPI().loadByUserByEmail(userName, APILocator.getUserAPI().getSystemUser(), false);
      } catch (Exception ex) {
        Logger.error(this, ex.getMessage(), ex);
      }
        if(user != null)
        {
          errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.inquiryUserExists"));
        }               
      }
      if (!UtilMethods.isSet(firstName))
      {       
        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("message.contentlet.required","First Name"));       
      }
      if (!UtilMethods.isSet(lastName))
      {
        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("message.contentlet.required","Last Name"));
      }
       if(FormSpamFilter.isSpamRequest(request)){
         errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Potential Spam Message"));
        }
       
       
      return errors;
    }
View Full Code Here

Examples of org.apache.struts.action.ActionErrors

      Mapping.begin();
      User user = User.getInstance(login);
      Mapping.rollback();
      if (!lform.getPassword().equals(user.getPassword())) {
        ActionError error = new ActionError("error.login.badPassword");
        ActionErrors errors = new ActionErrors();
        errors.add("password", error);
        request.setAttribute(ERROR_KEY, errors);
        return (new ActionForward(mapping.getInput()));
      }
      Mapping.begin();
      boolean result = new SecurityManagerImpl().canLogIntoBackoffice(user);
      Mapping.rollback();
      if ( !result ) {
        ActionError error = new ActionError("error.login.notAuthorized");
        ActionErrors errors = new ActionErrors();
        errors.add("login", error);
        request.setAttribute(ERROR_KEY, errors);
        return (new ActionForward(mapping.getInput()));
      }
      request.getSession().setAttribute("userLogin",user.getLogin());
    } catch (Exception e) {
      Mapping.rollback();
      ActionError error = new ActionError("error.login.badLogin");
      ActionErrors errors = new ActionErrors();
      errors.add("login", error);
      request.setAttribute(ERROR_KEY, errors);
      return (new ActionForward(mapping.getInput()));
    }  

    // Forward to the newt page
View Full Code Here

Examples of org.apache.struts.action.ActionErrors

      Mapping.rollback();
    }

    // get the form
    CreateUserForm sform = (CreateUserForm) form;
    ActionErrors errors = sform.myValidate(request);

    // user need cancel
    if (request.getParameter("cancel") != null) {
      // Forward to the next page
      return (mapping.findForward("cancel"));
    }

    // fill data | first time
    if (sform.getName() == null) {
      try {
        Mapping.begin();
        Vector groups = Group.listAll();
        Mapping.rollback();

        request.setAttribute("groups", groups);

      } catch (Exception e) {
        Mapping.rollback();
        throw new ServletException(e);
      }

      // Forward to the view page
      return (mapping.findForward("view"));
    }

    // fill data | errors
    if (errors.size() > 0) {
      try {
        Mapping.begin();
        Vector groups = Group.listAll();
        Mapping.rollback();
View Full Code Here

Examples of org.apache.struts.action.ActionErrors

    // check if user is correctly logged
    checkUser(request);

    // get the form
    EditUserForm sform = (EditUserForm) form;
    ActionErrors errors = sform.myValidate(request);

    // user need cancel
    if (request.getParameter("cancel") != null) {
      // Forward to the next page
      return (mapping.findForward("cancel"));
    }

    // retrieve id
    String id = request.getSession().getAttribute("userLogin")+"";     

    // fill data | first time
    if (sform.getName() == null) {
      try {   
        Mapping.begin();
        User user = User.getInstance(id);       
        Mapping.rollback();
       
        sform.setEmail((String)user.getMetaData("email"));
        sform.setName((String)user.getMetaData("name"));
        sform.setGroups(user.getGroupsIds());
        sform.setPassword(user.getPassword());       
       
      } catch (Exception e) {
        Mapping.rollback();
        throw new ServletException(e);
      }

      // Forward to the view page
      return (mapping.findForward("view"));
    }   

    // fill data | errors
    if (errors.size() > 0) {
      try {
        request.setAttribute(ERROR_KEY, errors);
               
      } catch (Exception e) {
        Mapping.rollback();
View Full Code Here

Examples of org.apache.struts.action.ActionErrors

        } catch (Exception e) {
          Mapping.rollback();
          throw new ServletException(e);
        }
      } else {
        ActionErrors errors = new ActionErrors();
        ActionError error = new ActionError("error.search.noKeyWords");
        errors.add("keys",error);
        request.setAttribute(ERROR_KEY,errors);
      }
    }

    // Forward to the next page
View Full Code Here

Examples of org.apache.struts.action.ActionErrors

    HolidayBookingService holidayBookingService = (HolidayBookingService) getWebApplicationContext().getBean(
        "holidayBookingService");

    boolean isInputError = false;
    ActionErrors errors = (ActionErrors) request.getAttribute(Globals.ERROR_KEY);
   
    if (errors != null && !errors.isEmpty())
    {
      isInputError = true;
    }

    HolidayBookingForm holidayForm = (HolidayBookingForm) form;
View Full Code Here

Examples of org.apache.struts.action.ActionErrors

  @Test
  public void testProjectMissingData()
  {
    form.setProjectName(null);
    form.setSelectedProjectType("");
    ActionErrors errors = delegator.validate(null, null);
    assert "Project name is required".equals(getValidationMessage(errors, "projectName"));
    assert "A non-empty project type must be selected".equals(getValidationMessage(errors, "selectedProjectType"));
  }
View Full Code Here

Examples of org.apache.struts.action.ActionErrors

  @Test
  public void testProjectNameEmpty()
  {
    form.setProjectName("");
    ActionErrors errors = delegator.validate(null, null);
    assert "Project name is required".equals(getValidationMessage(errors, "projectName"));
  }
View Full Code Here

Examples of org.apache.struts.action.ActionErrors

  @Test
  public void testDateInvalid()
  {
    form.setReadyDate("invalid ready date");

    ActionErrors errors = delegator.validate(null, null);
    System.out.println(errors);
    String validationMessage = getValidationMessage(errors, "readyDate");
    assert "Value 'invalid ready date' is an invalid date. Use the format 'd MMM yyyy' (e.g. 19 October 2005)"
        .equals(validationMessage);
  }
View Full Code Here

Examples of org.apache.struts.action.ActionErrors

  {
    form.setProjectName("");
    form.setReadyDate("aaa");

    // we still okay with this at the moment
    ActionErrors validate = delegator.validate(null, null);

    for (Iterator iterator = validate.get(); iterator.hasNext();)
    {
      ActionMessage message = (ActionMessage) iterator.next();
      System.out.println("Message 1: " + message);
    }
  }
View Full Code Here
TOP
Copyright © 2015 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.