Package javax.faces.validator

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


    HtmlRendererUtils.checkForCommandFacet(input, facesContext, writer);
    int maxLength = -1;
    for (Validator validator : input.getValidators()) {
      if (validator instanceof LengthValidator) {
        LengthValidator lengthValidator = (LengthValidator) validator;
        maxLength = lengthValidator.getMaximum();
      }
    }
    boolean required = ComponentUtils.getBooleanAttribute(input, Attributes.REQUIRED);
    if (required || maxLength > 0) {
      final String[] cmds = {
View Full Code Here

    @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

    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");

        Object minLength = null;
        if(metaData.containsKey(CommonMetaDataKeys.MIN_LENGTH))
        {
            minLength = metaData.get(CommonMetaDataKeys.MIN_LENGTH);
        }
        else if(metaData.containsKey(CommonMetaDataKeys.MIN_LENGTH_DEFAULT))
        {
            minLength = metaData.get(CommonMetaDataKeys.MIN_LENGTH_DEFAULT);
        }

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

        Object maxLength = null;
        if(metaData.containsKey(CommonMetaDataKeys.MAX_LENGTH))
        {
            maxLength = metaData.get(CommonMetaDataKeys.MAX_LENGTH);
        }
        else if(metaData.containsKey(CommonMetaDataKeys.MAX_LENGTH_DEFAULT))
        {
            maxLength = metaData.get(CommonMetaDataKeys.MAX_LENGTH_DEFAULT);
        }

        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

    protected void processValidation(FacesContext facesContext,
            UIComponent uiComponent, MetaDataEntry metaDataEntry,
            Object convertedObject) throws ValidatorException
    {
        Length annotation = metaDataEntry.getValue(Length.class);
        LengthValidator lengthValidator = (LengthValidator)facesContext.getApplication()
                                            .createValidator("javax.faces.Length");

        lengthValidator.setMinimum(annotation.minimum());
        lengthValidator.setMaximum(annotation.maximum());

        lengthValidator.validate(facesContext, uiComponent, convertedObject);
    }
View Full Code Here

      writer.writeAttribute(HtmlAttributes.TITLE, title, true);
    }
    int maxLength = 0;
    for (Validator validator : input.getValidators()) {
      if (validator instanceof LengthValidator) {
        LengthValidator lengthValidator = (LengthValidator) validator;
        maxLength = lengthValidator.getMaximum();
      }
    }
    if (maxLength > 0) {
      writer.writeAttribute(HtmlAttributes.MAXLENGTH, maxLength);
    }
View Full Code Here

    checkForCommandFacet(input, facesContext, writer);
    int maxLength = -1;
    for (Validator validator : input.getValidators()) {
      if (validator instanceof LengthValidator) {
        LengthValidator lengthValidator = (LengthValidator) validator;
        maxLength = lengthValidator.getMaximum();
      }
    }
    boolean required = ComponentUtil.getBooleanAttribute(input, TobagoConstants.ATTR_REQUIRED);
    if (required || maxLength > 0) {
      String rendererName = HtmlRendererUtil.getRendererName(facesContext, input);
View Full Code Here

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

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

    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

Related Classes of javax.faces.validator.LengthValidator

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.