Examples of ActionError


Examples of org.apache.struts.action.ActionError

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

Examples of org.apache.struts.action.ActionError

   * @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

Examples of org.apache.struts.action.ActionError

   * @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

Examples of org.apache.struts.action.ActionError

            err = true;
        }

        if ( err )
        {
            errors.add( "ActionForm", new ActionError( msg ) );
        }
    }
View Full Code Here

Examples of org.apache.struts.action.ActionError

                             String       msg,
                             ActionErrors errors )
    {
        if ( ( value == null ) || ( value.length(  ) < len ) )
        {
            errors.add( "ActionForm", new ActionError( msg ) );
        }
    }
View Full Code Here

Examples of org.apache.struts.action.ActionError

                               String       msg,
                               ActionErrors errors )
    {
        if ( ( value == null ) || ( value.trim(  ).length(  ) == 0 ) )
        {
            errors.add( "ActionForm", new ActionError( msg ) );
        }
    }
View Full Code Here

Examples of org.apache.struts.action.ActionError

public class Validator {
    public static boolean validateRequired(String fieldValue,
                                           String fieldName,
                                           ActionErrors errors){
        if(fieldValue==null||fieldValue.length()==0){
            errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(
                    WebErrorCodes.ERROR_REQUIRED, fieldName));
            return false;
        }
        return true;
    }
View Full Code Here

Examples of org.apache.struts.action.ActionError

                                          String fieldName,
                                          ActionErrors errors){
        try {
            Integer.parseInt(fieldValue);
        } catch (NumberFormatException e) {
            errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(
                    WebErrorCodes.ERROR_INVALID, fieldName));
            return false;
        }
        return true;
    }
View Full Code Here

Examples of org.apache.struts.action.ActionError

                }
            }
            ActionErrors errors = new ActionErrors();
            if(invalidValue){
                errors.add(ActionErrors.GLOBAL_ERROR,
                        new ActionError(ErrorCodes.INVALID_CHAR_APP_NAME));
                return errors;
            }else if(nullValue && !validValue){
                errors.add(ActionErrors.GLOBAL_ERROR,
                        new ActionError("errors.required", "application name"));
                return errors;
            }
            return null;
        }else{
            final String configName = request.getParameter("name");
            ActionErrors errors = new ActionErrors();
            if(GenericValidator.isBlankOrNull(configName)){
                errors.add(ActionErrors.GLOBAL_ERROR,
                        new ActionError("errors.required", "application name"));
                return errors;
            }else if(configName.indexOf("/") != -1){
                errors.add(ActionErrors.GLOBAL_ERROR,
                        new ActionError(ErrorCodes.INVALID_CHAR_APP_NAME));
                return errors;
            }else{
                return null;
            }
        }
View Full Code Here

Examples of org.apache.struts.action.ActionError

    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request){
        ActionErrors errors = super.validate(mapping, request);
        if(errors==null || errors.isEmpty()){
            if(name.indexOf("/") != -1){
                errors.add(ActionErrors.GLOBAL_ERROR,
                        new ActionError(ErrorCodes.INVALID_CHAR_APP_NAME));
            }
            ApplicationType appType = ApplicationTypes.getApplicationType(type);
            MetaApplicationConfig metaAppConfig =
                    appType.getModule().getMetaApplicationConfig();
            if(metaAppConfig.isDisplayHost()){
View Full Code Here
TOP
Copyright © 2018 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.