Package javax.faces.validator

Examples of javax.faces.validator.Validator


            final Validator[] validators = valueHolder.getValidators();
            if (validators != null)
            {
                for (int ctr = 0; ctr < validators.length; ctr++)
                {
                    final Validator test = validators[ctr];
                    if (test instanceof JSFValidator)
                    {
                        present = test.toString().equals(validator.toString());
                        if (present)
                        {
                            break;
                        }
                    }
View Full Code Here


    }

    @Override
    public Validator createValidator(final String validatorId) {
        log.debugf("Creating validator for validatorId %s", validatorId);
        Validator result = parent.createValidator(validatorId);
        result = attemptExtension(result);
        return result;
    }
View Full Code Here

    public void validate(final FacesContext context) {
        context.getApplication().publishEvent(context, PreValidateEvent.class, UIValidateForm.class, this);
        BeanManager manager = new BeanManagerLocator().getBeanManager();
        manager.fireEvent(this, BEFORE);

        Validator validator = null;
        try {
            validator = context.getApplication().createValidator(getValidatorId());
            if (validator == null) {
                throw new IllegalArgumentException("Seam UIValidateForm - Could not create Validator with id: ["
                        + getValidatorId() + "]");
            }
        } catch (Exception e) {
            throw new IllegalStateException("Seam UIValidateForm - Could not create validator with id [" + getValidatorId()
                    + "] because: nested exception is:" + e.getMessage(), e);
        }

        Map<String, UIInput> components = getComponents();
        try {
            UIComponent parent = this.getParent();
            validator.validate(context, parent, components);
        } catch (ValidatorException e) {
            setValid(false);
            for (UIInput comp : components.values()) {
                comp.setValid(false);
                if (isShowFieldMessages()) {
View Full Code Here

        super(criteria);
    }

    @Test
    public void testValidator() throws Exception {
        Validator validator = createValidator();
        try {
            validator.validate(facesEnvironment.getFacesContext(), input, criteria.getValue());
            validateOnClient(validator);
        } catch (ValidatorException e) {
            // client-side script has to throw exception too.
            try {
                validateOnClient(validator);
View Full Code Here

    * validator specified in pages.xml, and using Hibernate Validator
    * annotations specified on the model.
    */
   public void validateConvertedValue(FacesContext facesContext, Object value)
   {
      Validator validator = getValidator();
      if (validator!=null)
      {
         validator.validate( facesContext, facesContext.getViewRoot(), value );
      }
     
      if (valueExpression!=null)
      {
         //TODO: note that this code is duplicated from ModelValidator!!
View Full Code Here

               {
                  currentPathValidator = pv;
                  for (String id : pv.getValidatorIdList())
                  {
                     currentValidatorId = id;
                     Validator validator = context.getApplication().createValidator(id);
                     validator.validate(context, new NullComponent(), coerced);
                  }
                  if (pv.getValidatorExpression() != null)
                  {
                     elUtils.invokeMethod(context, pv.getValidatorExpression().getELExpression(),
                              new Class<?>[] { FacesContext.class, UIComponent.class, Object.class },
View Full Code Here

                  {
                     Object coerced = elUtils.coerceToType(context, el, values);
                     for (String id : param.getValidatorIdList())
                     {
                        currentValidatorId = id;
                        Validator validator = context.getApplication().createValidator(id);
                        validator.validate(context, new NullComponent(), coerced);
                     }
                     if (param.getValidatorExpression() != null)
                     {
                        elUtils.invokeMethod(context, param.getValidatorExpression().getELExpression(),
                                 new Class<?>[] { FacesContext.class, UIComponent.class, Object.class },
                                 new Object[] { context, new NullComponent(), coerced });
                     }
                  }
               }
               else
               {
                  String value = context.getExternalContext().getRequestParameterMap().get(name);
                  if (value != null)
                  {
                     Object coerced = elUtils.coerceToType(context, el, value);
                     for (String id : param.getValidatorIdList())
                     {
                        currentValidatorId = id;
                        Validator validator = context.getApplication().createValidator(id);
                        validator.validate(context, new NullComponent(), coerced);
                     }
                     if (param.getValidatorExpression() != null)
                     {
                        elUtils.invokeMethod(context, param.getValidatorExpression().getELExpression(),
                                 new Class<?>[] { FacesContext.class, UIComponent.class, Object.class },
View Full Code Here

        super(config);
    }

    private Class<? extends Validator> getBuiltInBeanValidatorClass(FacesContext context) {
        try {
            Validator beanValidator = context.getApplication().createValidator(BeanValidator.VALIDATOR_ID);
            return beanValidator.getClass();
        } catch(FacesException e){
            return null;
        }
    }
View Full Code Here

     * @param input
     * @param defaultValidatorClass TODO
     */
    private void setupValidator(SetupValidatorsParameter parameterObject, EditableValueHolder input) {
        boolean addBeanValidator = true;
        Validator defaultValidator = null;
        Validator beanValidator = parameterObject.getValidator();
        Validator[] validators = input.getValidators();
        for (int i = 0; i < validators.length; i++) {
            Validator nextValidator = validators[i];
            if (nextValidator.getClass().equals(beanValidator.getClass())) {
                addBeanValidator = false;
            } else if (nextValidator.getClass().equals(parameterObject.getDefaultValidatorClass())) {
                defaultValidator = nextValidator;
            }
        }

        if (defaultValidator != null && defaultValidator instanceof BeanValidator) {
View Full Code Here

       
        assertNotNull("input", input);
       
        assertEquals("input validator", 1, input.getValidators().length);
       
        Validator v = input.getValidators()[0];
       
        v.validate(faces, input, "4333");
    }
View Full Code Here

TOP

Related Classes of javax.faces.validator.Validator

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.