Package org.apache.struts.action

Examples of org.apache.struts.action.ActionError


    try {
      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()));
    }  
View Full Code Here


          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);
      }
    }
View Full Code Here

    ActionErrors errors = new ActionErrors()
    SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
    try {
      formatter.parse(getDate());
    } catch( Exception e ) {
      ActionError error = new ActionError("error.general.badDate");
      errors.add("date",error);
    }
    return errors;
  }
View Full Code Here

   * @see org.apache.struts.action.ActionForm#validate(ActionMapping, HttpServletRequest)
   */
  public ActionErrors myValidate(HttpServletRequest request) {
    ActionErrors errors = new ActionErrors()
    if ("".equals(getName()) || getName()==null) {
      ActionError error =
        new ActionError("error.createUser.nameMissing");
      errors.add("name", error);
    }
    if ("".equals(getEmail()) || getEmail()==null) {
      ActionError error =
        new ActionError("error.createUser.emailMissing");
      errors.add("email", error);
    }
    if ("".equals(getLogin()) || getLogin()==null) {
      ActionError error =
        new ActionError("error.createUser.loginMissing");
      errors.add("login", error);
    }
    if ("".equals(getPassword()) || getPassword()==null) {
      ActionError error =
        new ActionError("error.createUser.passwordMissing");
      errors.add("password", error);
   
    return errors;
  }
View Full Code Here

   * @see org.apache.struts.action.ActionForm#validate(ActionMapping, HttpServletRequest)
   */
  public ActionErrors myValidate(HttpServletRequest request) {
    ActionErrors errors = new ActionErrors()
    if ("".equals(getName()) || getName()==null) {
      ActionError error =
        new ActionError("error.editUser.nameMissing");
      errors.add("name", error);
    }
    if ("".equals(getEmail()) || getEmail()==null) {
      ActionError error =
        new ActionError("error.editUser.emailMissing");
      errors.add("email", error);
    }
    if ("".equals(getPassword()) || getPassword()==null) {
      ActionError error =
        new ActionError("error.editUser.passwordMissing");
      errors.add("password", error);
   
    return errors;
  }
View Full Code Here

          e.printStackTrace();
        }
   
    ActionErrors errors = new ActionErrors();
    if (getName() == null) {
      ActionError error =
        new ActionError("error.uploadResource.missingName");
      errors.add("name", error);     
    } else {
      if (getName().trim().equals("")) {
        ActionError error2 =
          new ActionError("error.uploadResource.missingName");
        errors.add("name", error2);
      } else {
        if (getName().indexOf(".") != -1
          || getName().indexOf("/") != -1
          || getName().indexOf("\\") != -1
          || getName().indexOf("%") != -1
          || getName().indexOf("&") != -1) {
          ActionError error3 =
            new ActionError("error.uploadResource.badName");
          errors.add("name", error3);

        }
      }
    }
    if (getFile().getFileSize() == 0) {
      ActionError error =
        new ActionError("error.uploadResource.missingFile");
      errors.add("file", error);     
    }
    return errors;
  }
View Full Code Here

   * @see org.apache.struts.action.ActionForm#validate(ActionMapping, HttpServletRequest)
   */
  public ActionErrors myValidate(HttpServletRequest request) {
    ActionErrors errors = new ActionErrors();
    if( "".equals(getName()) ) {
      ActionError error = new ActionError("error.createPublication.nameMissing");
      errors.add("name",error);
    }
    if( "".equals(getType()) ) {
      ActionError error = new ActionError("error.createPublication.typeMissing");
      errors.add("type",error);
    }
    if( "".equals(getWorkflow()) ) {
      ActionError error = new ActionError("error.general.missingField");
      errors.add("workflow",error);
    }
    return errors;
  }
View Full Code Here

   */
  public ActionErrors myValidate(HttpServletRequest request) {
    ActionErrors errors = new ActionErrors();
    SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
    if (getType() == null) {
      ActionError error = new ActionError("error.general.missingField");
      errors.add("type", error);
    } else {
      if (getType().equals("P_D")) {
        Date dateBegin = null;
        Date dateEnd = null;
        try {
          dateBegin = formatter.parse(getDateBegin());
        } catch (Exception e) {
          ActionError error =
            new ActionError("error.general.badDate");
          errors.add("date", error);
        }
        if (dateBegin != null) {
          try {
            dateEnd = formatter.parse(getDateEnd());
          } catch (Exception e) {
            ActionError error =
              new ActionError("error.general.badDate");
            errors.add("date", error);
          }
        }
        if (dateBegin != null && dateEnd != null) {
          if (dateEnd.before(dateBegin)) {
            ActionError error =
              new ActionError("error.publishPublication.badEnd");
            errors.add("date", error);
          }
        }
      }
    }
View Full Code Here

   * @see org.apache.struts.action.ActionForm#validate(ActionMapping, HttpServletRequest)
   */
  public ActionErrors myValidate(HttpServletRequest request) {
    ActionErrors errors = new ActionErrors();
    if ("".equals(getName())) {
      ActionError error =
        new ActionError("error.editSection.nameMissing");
      errors.add("name", error);
    }
    if (getTemplate() == null || "".equals(getTemplate())) {
      ActionError error =
        new ActionError("error.editSection.templateMissing");
      errors.add("template", error);
    }
    // validate metadata
    try {
      Enumeration names = request.getParameterNames();
      // dangerous ?
      TypeBean type = SectionTypes.getSectionBean(null, getTemplate());
      while (names.hasMoreElements()) {
        String name = names.nextElement() + "";
        if (name.startsWith("META_")) {
          String tname = name.substring(5);
          String value = request.getParameter(name);
          PropertyBean prop = type.getProperty(tname);
          if ("".equals(value.trim())) {
            if ("true".equalsIgnoreCase(prop.getRequired())) {
              ActionError error =
                new ActionError("error.editSection.propertyMissing");
              errors.add("META_" + tname, error);
            }
          } else {
            if (prop.getRegexp() != null) {
              RE re = new RE(prop.getRegexp());
              if (!re.match(value)) {
                ActionError error =
                  new ActionError("error.editSection.propertyMalformed", prop.getErrorMessage());
                errors.add("META_" + tname, error);
              }
            }
          }
        }
View Full Code Here

   * @see org.apache.struts.action.ActionForm#validate(ActionMapping, HttpServletRequest)
   */
  public ActionErrors validate(ActionMapping arg0, HttpServletRequest request) {
    ActionErrors errors = new ActionErrors();
    if( "".equals(getLogin()) ) {
      ActionError error = new ActionError("error.login.loginMissing");
      errors.add("login",error);
    }
    if( "".equals(getPassword()) ) {
      ActionError error = new ActionError("error.login.passwordMissing");
      errors.add("password",error);
    }
    return errors;
  }
View Full Code Here

TOP

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

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.