Package com.opensymphony.xwork2.validator.validators

Examples of com.opensymphony.xwork2.validator.validators.VisitorFieldValidator


  }

  protected ClassLoaderInterface getClassLoaderInterface() {
    if (isReloadEnabled()) return new ClassLoaderInterfaceDelegate(reloadingClassLoader);
    else {
      ClassLoaderInterface classLoaderInterface = null;
      ActionContext ctx = ActionContext.getContext();
      if (ctx != null) classLoaderInterface = (ClassLoaderInterface) ctx
          .get(ClassLoaderInterface.CLASS_LOADER_INTERFACE);
      return (ClassLoaderInterface) ObjectUtils.defaultIfNull(classLoaderInterface,
          new ClassLoaderInterfaceDelegate(getClassLoader()));
View Full Code Here


  }

  private Set<URL> buildUrls() {
    Set<URL> urls = CollectUtils.newHashSet();
    Enumeration<URL> em;
    ClassLoaderInterface classloader = getClassLoaderInterface();
    try {
      em = classloader.getResources("struts-plugin.xml");
      while (em.hasMoreElements()) {
        URL url = em.nextElement();
        urls.add(new URL(substringBeforeLast(url.toExternalForm(), "struts-plugin.xml")));
      }
      em = classloader.getResources("struts.xml");
      while (em.hasMoreElements()) {
        URL url = em.nextElement();
        urls.add(new URL(substringBeforeLast(url.toExternalForm(), "struts.xml")));
      }
    } catch (IOException e) {
View Full Code Here

    logger.info("Action scan completely,create {} action in {} ms", newActions,
        System.currentTimeMillis() - start);
  }

  protected ClassLoaderInterface getClassLoaderInterface() {
    if (isReloadEnabled()) return new ClassLoaderInterfaceDelegate(reloadingClassLoader);
    else {
      ClassLoaderInterface classLoaderInterface = null;
      ActionContext ctx = ActionContext.getContext();
      if (ctx != null) classLoaderInterface = (ClassLoaderInterface) ctx
          .get(ClassLoaderInterface.CLASS_LOADER_INTERFACE);
      return (ClassLoaderInterface) ObjectUtils.defaultIfNull(classLoaderInterface,
          new ClassLoaderInterfaceDelegate(getClassLoader()));
    }
  }
View Full Code Here

        // happen
        // This is a critical exception, so we better throw a
        // ValidationException
        // no need to continue
        logger.error(e);
        throw new ValidationException("Could not open inputstream for "
            + i);
      }
      imageSize = (int) i.length();
    } else {
      // it's .. uhm, something else. A football ? A hot blonde's address
      // ? Fourty Two ? We'll never know ..
      throw new ValidationException(
          "Invalid object. Expect either a String or File object. Object is "
              + image.getClass().getName());
    }
    if (!ii.check()) {
      setMessageKey(getMessageKey() + ".invalid");
View Full Code Here

        // customer
        final RequiredFieldValidator customerRequiredValidator = new RequiredFieldValidator();
        customerRequiredValidator.setFieldName("customer");
        customerRequiredValidator.setDefaultMessage("Customer is required");
        customerRequiredValidator.setValueStack(stack);
        final VisitorFieldValidator customerVisitorValidator = new VisitorFieldValidator();
        customerVisitorValidator.setAppendPrefix(true);
        customerVisitorValidator.setFieldName("customer");
        customerVisitorValidator.setValueStack(stack);

        /* Customer.class */
        // customer -> name
        final RequiredStringValidator customerNameRequiredStringValidator = new RequiredStringValidator();
        customerNameRequiredStringValidator.setFieldName("name");
        customerNameRequiredStringValidator.setDefaultMessage("Name is required");
        customerNameRequiredStringValidator.setValueStack(stack);

        // customer -> age
        final RequiredFieldValidator customerAgeRequiredValidator = new RequiredFieldValidator();
        customerAgeRequiredValidator.setFieldName("age");
        customerAgeRequiredValidator.setDefaultMessage("Age is required");
        customerAgeRequiredValidator.setValueStack(stack);

        // customer -> Address
        final RequiredFieldValidator customerAddressRequiredFieldValidator = new RequiredFieldValidator();
        customerAddressRequiredFieldValidator.setFieldName("address");
        customerAddressRequiredFieldValidator.setDefaultMessage("Address is required");
        customerAddressRequiredFieldValidator.setValueStack(stack);

        final VisitorFieldValidator customerAddressVisitorFieldValidator = new VisitorFieldValidator();
        customerAddressVisitorFieldValidator.setFieldName("address");
        customerAddressVisitorFieldValidator.setAppendPrefix(true);
        //customerAddressVisitorFieldValidator.setDefaultMessage("");
        customerAddressVisitorFieldValidator.setValueStack(stack);



        /* Address.class */
        // customer -> Address -> street
        final RequiredStringValidator customerAddressStreetRequiredFieldValidator = new RequiredStringValidator();
        customerAddressStreetRequiredFieldValidator.setFieldName("street");
        customerAddressStreetRequiredFieldValidator.setDefaultMessage("Street is required");
        customerAddressStreetRequiredFieldValidator.setShortCircuit(true);
        customerAddressStreetRequiredFieldValidator.setValueStack(stack);

        final RequiredStringValidator customerAddressStreetRequiredFieldValidator2 = new RequiredStringValidator();
        customerAddressStreetRequiredFieldValidator2.setFieldName("street");
        customerAddressStreetRequiredFieldValidator2.setDefaultMessage("Street is required 2");
        customerAddressStreetRequiredFieldValidator2.setShortCircuit(true);
        customerAddressStreetRequiredFieldValidator2.setValueStack(stack);

        // customer -> Address -> pobox
        final RequiredStringValidator customerAddressPoboxRequiredFieldValidator = new RequiredStringValidator();
        customerAddressPoboxRequiredFieldValidator.setFieldName("pobox");
        customerAddressPoboxRequiredFieldValidator.setDefaultMessage("PO Box is required");
        customerAddressPoboxRequiredFieldValidator.setShortCircuit(false);
        customerAddressPoboxRequiredFieldValidator.setValueStack(stack);

        final RequiredStringValidator customerAddressPoboxRequiredFieldValidator2 = new RequiredStringValidator();
        customerAddressPoboxRequiredFieldValidator2.setFieldName("pobox");
        customerAddressPoboxRequiredFieldValidator2.setDefaultMessage("PO Box is required 2");
        customerAddressPoboxRequiredFieldValidator2.setShortCircuit(false);
        customerAddressPoboxRequiredFieldValidator2.setValueStack(stack);



        final List<Validator> validatorsForMockAction = new ArrayList<Validator>() {
            {
                add(referenceNumberRequiredStringValidator);
                add(orderRequiredValidator);
                add(customerRequiredValidator);
                add(customerVisitorValidator);
            }
        };

        final List<Validator> validatorsForCustomer = new ArrayList<Validator>() {
            {
                add(customerNameRequiredStringValidator);
                add(customerAgeRequiredValidator);
                add(customerAddressRequiredFieldValidator);
                add(customerAddressVisitorFieldValidator);
            }
        };

        final List<Validator> validatorsForAddress = new ArrayList<Validator>() {
            {
                add(customerAddressStreetRequiredFieldValidator);
                add(customerAddressStreetRequiredFieldValidator2);
                add(customerAddressPoboxRequiredFieldValidator);
                add(customerAddressPoboxRequiredFieldValidator2);
            }
        };


        DefaultActionValidatorManager validatorManager = new DefaultActionValidatorManager() {
            @Override
            public List<Validator> getValidators(Class clazz, String context, String method) {
                if (clazz.isAssignableFrom(MockAction.class)) {
                    return validatorsForMockAction;
                }
                else if (clazz.isAssignableFrom(Customer.class)) {
                    return validatorsForCustomer;
                }
                else if (clazz.isAssignableFrom(Address.class)) {
                    return validatorsForAddress;
                }
                return Collections.emptyList();
            }
        };
        customerVisitorValidator.setActionValidatorManager(validatorManager);
        customerAddressVisitorFieldValidator.setActionValidatorManager(validatorManager);

        MockAction action = new MockAction();
        stack.push(action);
        validatorManager.validate(action, "ctx");

View Full Code Here

        for (Validator validator : validatorList) {
            if (validator instanceof FieldValidator) {
                FieldValidator fieldValidator = (FieldValidator) validator;

                if (validator instanceof VisitorFieldValidator) {
                    VisitorFieldValidator vfValidator = (VisitorFieldValidator) fieldValidator;
                    Class clazz = getVisitorReturnType(actionClass, vfValidator.getFieldName());
                    if (clazz == null) {
                        continue;
                    }

                    List<Validator> visitorValidators = actionValidatorManager.getValidators(clazz, actionName);
                    String vPrefix = prefix + (vfValidator.isAppendPrefix() ? vfValidator.getFieldName() + "." : "");
                    findFieldValidators(name, clazz, actionName, visitorValidators, retultValidators, vPrefix);
                } else if ((prefix + fieldValidator.getFieldName()).equals(name)) {
                    if (StringUtils.isNotBlank(prefix)) {
                        //fixing field name for js side
                        FieldVisitorValidatorWrapper wrap = new FieldVisitorValidatorWrapper(fieldValidator, prefix);
View Full Code Here

        for (Validator validator : validatorList) {
            if (validator instanceof FieldValidator) {
                FieldValidator fieldValidator = (FieldValidator) validator;

                if (validator instanceof VisitorFieldValidator) {
                    VisitorFieldValidator vfValidator = (VisitorFieldValidator) fieldValidator;
                    Class clazz = getVisitorReturnType(actionClass, vfValidator.getFieldName());
                    if (clazz == null) {
                        continue;
                    }

                    List<Validator> visitorValidators = actionValidatorManager.getValidators(clazz, actionName);
                    String vPrefix = prefix + (vfValidator.isAppendPrefix() ? vfValidator.getFieldName() + "." : "");
                    findFieldValidators(name, clazz, actionName, visitorValidators, retultValidators, vPrefix);
                } else if ((prefix + fieldValidator.getFieldName()).equals(name)) {
                    if (StringUtils.isNotBlank(prefix)) {
                        //fixing field name for js side
                        FieldVisitorValidatorWrapper wrap = new FieldVisitorValidatorWrapper(fieldValidator, prefix);
View Full Code Here

        // customer
        final RequiredFieldValidator customerRequiredValidator = new RequiredFieldValidator();
        customerRequiredValidator.setFieldName("customer");
        customerRequiredValidator.setDefaultMessage("Customer is required");
        customerRequiredValidator.setValueStack(stack);
        final VisitorFieldValidator customerVisitorValidator = new VisitorFieldValidator();
        customerVisitorValidator.setAppendPrefix(true);
        customerVisitorValidator.setFieldName("customer");
        customerVisitorValidator.setValueStack(stack);

        /* Customer.class */
        // customer -> name
        final RequiredStringValidator customerNameRequiredStringValidator = new RequiredStringValidator();
        customerNameRequiredStringValidator.setFieldName("name");
        customerNameRequiredStringValidator.setDefaultMessage("Name is required");
        customerNameRequiredStringValidator.setValueStack(stack);

        // customer -> age
        final RequiredFieldValidator customerAgeRequiredValidator = new RequiredFieldValidator();
        customerAgeRequiredValidator.setFieldName("age");
        customerAgeRequiredValidator.setDefaultMessage("Age is required");
        customerAgeRequiredValidator.setValueStack(stack);

        // customer -> Address
        final RequiredFieldValidator customerAddressRequiredFieldValidator = new RequiredFieldValidator();
        customerAddressRequiredFieldValidator.setFieldName("address");
        customerAddressRequiredFieldValidator.setDefaultMessage("Address is required");
        customerAddressRequiredFieldValidator.setValueStack(stack);

        final VisitorFieldValidator customerAddressVisitorFieldValidator = new VisitorFieldValidator();
        customerAddressVisitorFieldValidator.setFieldName("address");
        customerAddressVisitorFieldValidator.setAppendPrefix(true);
        //customerAddressVisitorFieldValidator.setDefaultMessage("");
        customerAddressVisitorFieldValidator.setValueStack(stack);



        /* Address.class */
        // customer -> Address -> street
        final RequiredStringValidator customerAddressStreetRequiredFieldValidator = new RequiredStringValidator();
        customerAddressStreetRequiredFieldValidator.setFieldName("street");
        customerAddressStreetRequiredFieldValidator.setDefaultMessage("Street is required");
        customerAddressStreetRequiredFieldValidator.setShortCircuit(true);
        customerAddressStreetRequiredFieldValidator.setValueStack(stack);

        final RequiredStringValidator customerAddressStreetRequiredFieldValidator2 = new RequiredStringValidator();
        customerAddressStreetRequiredFieldValidator2.setFieldName("street");
        customerAddressStreetRequiredFieldValidator2.setDefaultMessage("Street is required 2");
        customerAddressStreetRequiredFieldValidator2.setShortCircuit(true);
        customerAddressStreetRequiredFieldValidator2.setValueStack(stack);

        // customer -> Address -> pobox
        final RequiredStringValidator customerAddressPoboxRequiredFieldValidator = new RequiredStringValidator();
        customerAddressPoboxRequiredFieldValidator.setFieldName("pobox");
        customerAddressPoboxRequiredFieldValidator.setDefaultMessage("PO Box is required");
        customerAddressPoboxRequiredFieldValidator.setShortCircuit(false);
        customerAddressPoboxRequiredFieldValidator.setValueStack(stack);

        final RequiredStringValidator customerAddressPoboxRequiredFieldValidator2 = new RequiredStringValidator();
        customerAddressPoboxRequiredFieldValidator2.setFieldName("pobox");
        customerAddressPoboxRequiredFieldValidator2.setDefaultMessage("PO Box is required 2");
        customerAddressPoboxRequiredFieldValidator2.setShortCircuit(false);
        customerAddressPoboxRequiredFieldValidator2.setValueStack(stack);



        final List<Validator> validatorsForMockAction = new ArrayList<Validator>() {
            {
                add(referenceNumberRequiredStringValidator);
                add(orderRequiredValidator);
                add(customerRequiredValidator);
                add(customerVisitorValidator);
            }
        };

        final List<Validator> validatorsForCustomer = new ArrayList<Validator>() {
            {
                add(customerNameRequiredStringValidator);
                add(customerAgeRequiredValidator);
                add(customerAddressRequiredFieldValidator);
                add(customerAddressVisitorFieldValidator);
            }
        };

        final List<Validator> validatorsForAddress = new ArrayList<Validator>() {
            {
                add(customerAddressStreetRequiredFieldValidator);
                add(customerAddressStreetRequiredFieldValidator2);
                add(customerAddressPoboxRequiredFieldValidator);
                add(customerAddressPoboxRequiredFieldValidator2);
            }
        };


        DefaultActionValidatorManager validatorManager = new DefaultActionValidatorManager() {
            @Override
            public List<Validator> getValidators(Class clazz, String context, String method) {
                if (clazz.isAssignableFrom(MockAction.class)) {
                    return validatorsForMockAction;
                }
                else if (clazz.isAssignableFrom(Customer.class)) {
                    return validatorsForCustomer;
                }
                else if (clazz.isAssignableFrom(Address.class)) {
                    return validatorsForAddress;
                }
                return Collections.emptyList();
            }
        };
        customerVisitorValidator.setActionValidatorManager(validatorManager);
        customerAddressVisitorFieldValidator.setActionValidatorManager(validatorManager);

        MockAction action = new MockAction();
        stack.push(action);
        validatorManager.validate(action, "ctx");

View Full Code Here

        // customer
        final RequiredFieldValidator customerRequiredValidator = new RequiredFieldValidator();
        customerRequiredValidator.setFieldName("customer");
        customerRequiredValidator.setDefaultMessage("Customer is required");
        customerRequiredValidator.setValueStack(stack);
        final VisitorFieldValidator customerVisitorValidator = new VisitorFieldValidator();
        customerVisitorValidator.setAppendPrefix(true);
        customerVisitorValidator.setFieldName("customer");
        customerVisitorValidator.setValueStack(stack);

        /* Customer.class */
        // customer -> name
        final RequiredStringValidator customerNameRequiredStringValidator = new RequiredStringValidator();
        customerNameRequiredStringValidator.setFieldName("name");
        customerNameRequiredStringValidator.setDefaultMessage("Name is required");
        customerNameRequiredStringValidator.setValueStack(stack);

        // customer -> age
        final RequiredFieldValidator customerAgeRequiredValidator = new RequiredFieldValidator();
        customerAgeRequiredValidator.setFieldName("age");
        customerAgeRequiredValidator.setDefaultMessage("Age is required");
        customerAgeRequiredValidator.setValueStack(stack);

        // customer -> Address
        final RequiredFieldValidator customerAddressRequiredFieldValidator = new RequiredFieldValidator();
        customerAddressRequiredFieldValidator.setFieldName("address");
        customerAddressRequiredFieldValidator.setDefaultMessage("Address is required");
        customerAddressRequiredFieldValidator.setValueStack(stack);

        final VisitorFieldValidator customerAddressVisitorFieldValidator = new VisitorFieldValidator();
        customerAddressVisitorFieldValidator.setFieldName("address");
        customerAddressVisitorFieldValidator.setAppendPrefix(true);
        //customerAddressVisitorFieldValidator.setDefaultMessage("");
        customerAddressVisitorFieldValidator.setValueStack(stack);



        /* Address.class */
        // customer -> Address -> street
        final RequiredStringValidator customerAddressStreetRequiredFieldValidator = new RequiredStringValidator();
        customerAddressStreetRequiredFieldValidator.setFieldName("street");
        customerAddressStreetRequiredFieldValidator.setDefaultMessage("Street is required");
        customerAddressStreetRequiredFieldValidator.setShortCircuit(true);
        customerAddressStreetRequiredFieldValidator.setValueStack(stack);

        final RequiredStringValidator customerAddressStreetRequiredFieldValidator2 = new RequiredStringValidator();
        customerAddressStreetRequiredFieldValidator2.setFieldName("street");
        customerAddressStreetRequiredFieldValidator2.setDefaultMessage("Street is required 2");
        customerAddressStreetRequiredFieldValidator2.setShortCircuit(true);
        customerAddressStreetRequiredFieldValidator2.setValueStack(stack);

        // customer -> Address -> pobox
        final RequiredStringValidator customerAddressPoboxRequiredFieldValidator = new RequiredStringValidator();
        customerAddressPoboxRequiredFieldValidator.setFieldName("pobox");
        customerAddressPoboxRequiredFieldValidator.setDefaultMessage("PO Box is required");
        customerAddressPoboxRequiredFieldValidator.setShortCircuit(false);
        customerAddressPoboxRequiredFieldValidator.setValueStack(stack);

        final RequiredStringValidator customerAddressPoboxRequiredFieldValidator2 = new RequiredStringValidator();
        customerAddressPoboxRequiredFieldValidator2.setFieldName("pobox");
        customerAddressPoboxRequiredFieldValidator2.setDefaultMessage("PO Box is required 2");
        customerAddressPoboxRequiredFieldValidator2.setShortCircuit(false);
        customerAddressPoboxRequiredFieldValidator2.setValueStack(stack);



        final List<Validator> validatorsForMockAction = new ArrayList<Validator>() {
            {
                add(referenceNumberRequiredStringValidator);
                add(orderRequiredValidator);
                add(customerRequiredValidator);
                add(customerVisitorValidator);
            }
        };

        final List<Validator> validatorsForCustomer = new ArrayList<Validator>() {
            {
                add(customerNameRequiredStringValidator);
                add(customerAgeRequiredValidator);
                add(customerAddressRequiredFieldValidator);
                add(customerAddressVisitorFieldValidator);
            }
        };

        final List<Validator> validatorsForAddress = new ArrayList<Validator>() {
            {
                add(customerAddressStreetRequiredFieldValidator);
                add(customerAddressStreetRequiredFieldValidator2);
                add(customerAddressPoboxRequiredFieldValidator);
                add(customerAddressPoboxRequiredFieldValidator2);
            }
        };


        DefaultActionValidatorManager validatorManager = new DefaultActionValidatorManager() {
            @Override
            public List<Validator> getValidators(Class clazz, String context, String method) {
                if (clazz.isAssignableFrom(MockAction.class)) {
                    return validatorsForMockAction;
                }
                else if (clazz.isAssignableFrom(Customer.class)) {
                    return validatorsForCustomer;
                }
                else if (clazz.isAssignableFrom(Address.class)) {
                    return validatorsForAddress;
                }
                return Collections.emptyList();
            }
        };
        customerVisitorValidator.setActionValidatorManager(validatorManager);
        customerAddressVisitorFieldValidator.setActionValidatorManager(validatorManager);

        MockAction action = new MockAction();
        stack.push(action);
        validatorManager.validate(action, "ctx");

View Full Code Here

        for (Validator validator : validatorList) {
            if (validator instanceof FieldValidator) {
                FieldValidator fieldValidator = (FieldValidator) validator;

                if (validator instanceof VisitorFieldValidator) {
                    VisitorFieldValidator vfValidator = (VisitorFieldValidator) fieldValidator;
                    Class clazz = getVisitorReturnType(actionClass, vfValidator.getFieldName());
                    if (clazz == null) {
                        continue;
                    }

                    List<Validator> visitorValidators = actionValidatorManager.getValidators(clazz, actionName);
                    String vPrefix = prefix + (vfValidator.isAppendPrefix() ? vfValidator.getFieldName() + "." : "");
                    findFieldValidators(name, clazz, actionName, visitorValidators, retultValidators, vPrefix);
                } else if ((prefix + fieldValidator.getFieldName()).equals(name)) {
                    if (StringUtils.isNotBlank(prefix)) {
                        //fixing field name for js side
                        FieldVisitorValidatorWrapper wrap = new FieldVisitorValidatorWrapper(fieldValidator, prefix);
View Full Code Here

TOP

Related Classes of com.opensymphony.xwork2.validator.validators.VisitorFieldValidator

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.