Package org.apache.struts.action

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


      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

    // 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

        } 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

    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

  @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

  @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

  @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

  {
    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

  private static final long serialVersionUID = 1L;

  @Override
  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request)
  {
    ActionErrors errors = new ActionErrors();
    errors.add("projectName", new ActionMessage("another.error"));
    return errors;
  }
View Full Code Here

TOP

Related Classes of org.apache.struts.action.ActionErrors

Copyright © 2018 www.massapicom. 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.