Examples of LengthValidator


Examples of javax.faces.validator.LengthValidator

    public boolean configureTrinidadComponent(FacesContext facesContext, UIComponent uiComponent,
                                              Map<String, Object> metaData)
    {
        boolean informationAdded = false;
        //TODO
        LengthValidator lengthValidator = (LengthValidator)facesContext.getApplication()
                                            .createValidator("org.apache.myfaces.trinidad.Length");

        if(metaData.containsKey(CommonMetaDataKeys.MIN_LENGTH))
        {
            Object min = metaData.get(CommonMetaDataKeys.MIN_LENGTH);

            if(min instanceof Integer)
            {
                lengthValidator.setMinimum((Integer)min);
                informationAdded = true;
            }
        }

        if(metaData.containsKey(CommonMetaDataKeys.MAX_LENGTH))
        {
            Object maxLength = metaData.get(CommonMetaDataKeys.MAX_LENGTH);

            if(maxLength instanceof Integer)
            {
                if(processComponent(uiComponent))
                {
                    ReflectionUtils.tryToInvokeMethod(
                            uiComponent,
                            ReflectionUtils.tryToGetMethod(
                                    uiComponent.getClass(),
                                    "setMaximumLength",
                                    int.class),
                            maxLength);
                }
                lengthValidator.setMaximum((Integer)maxLength);
                informationAdded = true;
            }
        }

        //reInitValidators((EditableValueHolder)uiComponent, metaData); //search wrappers and call .deactivate

        if(informationAdded && lengthValidator instanceof ClientValidator)
        {
            if(uiComponent instanceof EditableValueHolder)
            {
                ((EditableValueHolder)uiComponent).addValidator(
                        new ExtValTrinidadClientValidatorWrapper((ClientValidator)lengthValidator));
            }
            else if (uiComponent instanceof CoreOutputLabel)
            {
                if(lengthValidator.getMinimum() > 0)
                {
                    ((CoreOutputLabel)uiComponent).setShowRequired(true);
                }

                if(Boolean.TRUE.equals(metaData.get(CommonMetaDataKeys.SKIP_VALIDATION)))
View Full Code Here

Examples of javax.faces.validator.LengthValidator

    }
    int maxLength = 0;
    String pattern = null;
    for (Validator validator : input.getValidators()) {
      if (validator instanceof LengthValidator) {
        LengthValidator lengthValidator = (LengthValidator) validator;
        maxLength = lengthValidator.getMaximum();
      }
        /*if (validator instanceof RegexValidator) {
          RegexValidator regexValidator = (RegexValidator) validator;
          pattern = regexValidator.getPattern();
        }*/
 
View Full Code Here

Examples of javax.faces.validator.LengthValidator

    }
    int maxLength = -1;
    final String pattern = null;
    for (Validator validator : input.getValidators()) {
      if (validator instanceof LengthValidator) {
        LengthValidator lengthValidator = (LengthValidator) validator;
        maxLength = lengthValidator.getMaximum();
      }
      /*if (validator instanceof RegexValidator) {
        RegexValidator regexValidator = (RegexValidator) validator;
        pattern = regexValidator.getPattern();
      }*/
 
View Full Code Here

Examples of javax.faces.validator.LengthValidator

    protected Validator createValidator()
        throws JspException
    {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        setValidatorId(VALIDATOR_ID);
        LengthValidator validator = (LengthValidator)super.createValidator();
        if (_minimum != null)
        {
            if (UIComponentTag.isValueReference(_minimum))
            {
                ValueBinding vb = facesContext.getApplication().createValueBinding(_minimum);
                validator.setMinimum(ConverterUtils.convertToInt(vb.getValue(facesContext)));
            }
            else
            {
                validator.setMinimum(ConverterUtils.convertToInt(_minimum));
            }
        }
        if (_maximum != null)
        {
            if (UIComponentTag.isValueReference(_maximum))
            {
                ValueBinding vb = facesContext.getApplication().createValueBinding(_maximum);
                validator.setMaximum(ConverterUtils.convertToInt(vb.getValue(facesContext)));
            }
            else
            {
                validator.setMaximum(ConverterUtils.convertToInt(_maximum));
            }
        }
        return validator;
    }
View Full Code Here

Examples of javax.faces.validator.LengthValidator

        controller.release();
    }

    @Test
    public void getConverterClass() throws Exception {
        validator = new LengthValidator();
        controller.replay();
        ValidatorDescriptor validatorDescription = serviceImpl.getValidatorDescription(environment.getFacesContext(), input,
                validator, null);
        assertEquals(validator.getClass(), validatorDescription.getImplementationClass());
    }
View Full Code Here

Examples of javax.faces.validator.LengthValidator

        UIInput text = (UIInput)facesContext.getViewRoot().findComponent("form2:text");
        validators = text.getValidators();
        if (validators == null || validators.length == 0)
        {
            text.addValidator(new LengthValidator(7, 3));
        }

        return "ok";
    }
View Full Code Here

Examples of javax.faces.validator.LengthValidator

    @Override
    protected Validator createValidator() throws JspException
    {
        setValidatorIdString(VALIDATOR_ID);
        LengthValidator validator = (LengthValidator)super.createValidator();
        if (null != _min)
        {
            validator.setMinimum(_min);
        }
        if (null != _max)
        {
            validator.setMaximum(_max);
        }
        return validator;
    }
View Full Code Here

Examples of javax.faces.validator.LengthValidator

        UIInput text = (UIInput)facesContext.getViewRoot().findComponent("form2:text");
        validators = text.getValidators();
        if (validators == null || validators.length == 0)
        {
            text.addValidator(new LengthValidator(7, 3));
        }

        return "ok";
    }
View Full Code Here

Examples of javax.faces.validator.LengthValidator

        }
    }

    private List<Validator> createSubValidators() {
        List<Validator> subValidators = new ArrayList<Validator>();
        subValidators.add(new LengthValidator(PropertySimple.MAX_VALUE_LENGTH));
        if (this.propertyDefinition != null) {
            switch (this.propertyDefinition.getType()) {
            case INTEGER: {
                subValidators.add(new LongRangeValidator(Integer.MAX_VALUE, Integer.MIN_VALUE));
                break;
View Full Code Here

Examples of javax.faces.validator.LengthValidator

    protected Validator createValidator()
        throws JspException
    {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        setValidatorId(VALIDATOR_ID);
        LengthValidator validator = (LengthValidator)super.createValidator();
        if (_minimum != null)
        {
            if (UIComponentTag.isValueReference(_minimum))
            {
                ValueBinding vb = facesContext.getApplication().createValueBinding(_minimum);
                validator.setMinimum(ConverterUtils.convertToInt(vb.getValue(facesContext)));
            }
            else
            {
                validator.setMinimum(ConverterUtils.convertToInt(_minimum));
            }
        }
        if (_maximum != null)
        {
            if (UIComponentTag.isValueReference(_maximum))
            {
                ValueBinding vb = facesContext.getApplication().createValueBinding(_maximum);
                validator.setMaximum(ConverterUtils.convertToInt(vb.getValue(facesContext)));
            }
            else
            {
                validator.setMaximum(ConverterUtils.convertToInt(_maximum));
            }
        }
        return validator;
    }
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.