Package javax.faces.validator

Examples of javax.faces.validator.ValidatorException


       
        if (longValue > max)
        {
          if (min == Long.MIN_VALUE)//the default...
          {
             throw new ValidatorException
                        (_getNotInRangeMessage(context, component, value, IntegerUtils.getString(min), IntegerUtils.getString(max)));
          }
          else
          {
             throw new ValidatorException
                        (_getMaximumMessage(context, component, value, IntegerUtils.getString(max)));
          }
        }

        if (longValue < min)
        {
          if (max == Long.MAX_VALUE)//the default...
          {
            throw new ValidatorException
                        (_getNotInRangeMessage(context, component, value, IntegerUtils.getString(min), IntegerUtils.getString(max)));
          }
          else
          {
            FacesMessage msg = _getMinimumMessage(context, component, value, IntegerUtils.getString(min));
            throw new ValidatorException(msg);
          }
        }
      }
      else
      {
View Full Code Here


      int maxBytes = getMaximum();
      try
      {
        byte[] bytes = theValue.getBytes(getEncoding());
        if (bytes.length > maxBytes)
          throw new ValidatorException(
            getLengthValidationFailureMessage(context, component, theValue));

      }
      catch (UnsupportedEncodingException uee)
      {
View Full Code Here

      String theValue = (String)value;
      Matcher matcher = _compiled.matcher(theValue);
      // the matched string has to be the same as the input
      if (! matcher.matches())
      {
        throw new ValidatorException(_getNoMatchFoundMessage(context,
                                                             component,
                                                             theValue));
      }
    }
  }
View Full Code Here

    }

    ValidatorException createValidatorException(
            String violationSummaryMessage, String violationDetailMessage, FacesMessage.Severity severity)
    {
        return new ValidatorException(
                ExtValUtils.createFacesMessage(severity, violationSummaryMessage, violationDetailMessage));
    }
View Full Code Here

        String labeledMessageSummary = bvmi.createLabeledMessage(violationMessage, false);
        String labeledMessageDetail = bvmi.createLabeledMessage(violationMessage, true);

        FacesMessage.Severity severity = bvmi.calcSeverity(violation);

        ValidatorException validatorException = bvmi
                .createValidatorException(labeledMessageSummary, labeledMessageDetail, severity);

        if (!bvmi.executeAfterThrowingInterceptors(uiComponent, convertedObject, validatorException))
        {
            return null;
        }

        if (bvmi.isMessageTextUnchanged(validatorException, labeledMessageSummary, labeledMessageDetail))
        {
            return ExtValUtils.createFacesMessage(severity, violationMessage, violationMessage);
        }
        else
        {
            return ExtValUtils.createFacesMessage(severity,
                    validatorException.getFacesMessage().getSummary(),
                    validatorException.getFacesMessage().getDetail());
        }
    }
View Full Code Here

            try {
                int converted = intValue(value);
                if (maximumSet &&
                    (converted > maximum)) {
        if (minimumSet) {
                        throw new ValidatorException(MessageFactory.getMessage
             (context,
              Validator.NOT_IN_RANGE_MESSAGE_ID,
              new Object[] {
            new Integer(minimum),
            new Integer(maximum) }));
     
        }
        else {
                        throw new ValidatorException(MessageFactory.getMessage
             (context,
              LongRangeValidator.MAXIMUM_MESSAGE_ID,
              new Object[] {
            new Integer(maximum) }));
        }
                }
                if (minimumSet &&
                    (converted < minimum)) {
        if (maximumSet) {
                        throw new ValidatorException(MessageFactory.getMessage
             (context,
              Validator.NOT_IN_RANGE_MESSAGE_ID,
              new Object[] {
            new Double(minimum),
            new Double(maximum) }));
     
        }
        else {
                        throw new ValidatorException(MessageFactory.getMessage
             (context,
              LongRangeValidator.MINIMUM_MESSAGE_ID,
              new Object[] {
            new Integer(minimum) }));
        }
                }
            } catch (NumberFormatException e) {
                throw new ValidatorException(MessageFactory.getMessage
                                     (context, LongRangeValidator.TYPE_MESSAGE_ID));
            }
        }

    }
View Full Code Here

            {
                return;
        }
        Object[] args = {value.toString()};
        if(!GenericValidator.matchRegexp(value.toString(),"^"+getPattern()+"$")){
            throw new ValidatorException(getFacesMessage(REGEXPR_MESSAGE_ID, args));
        }
    }
View Full Code Here

        if (null != comparator)
        {
            if (false == validateOperatorOnComparisonResult(operator, comparator.compare(value, foreignValue)))
            {
                throw new ValidatorException(MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR, message, args));
            }
        }
        else if ( (value instanceof Comparable) && (foreignValue instanceof Comparable) )
        {
            try
            {
                if (false == validateOperatorOnComparisonResult(operator, ((Comparable)value).compareTo(foreignValue)))
                {
                    throw new ValidatorException(MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR, message, args));
                }
            }
            catch (RuntimeException exception)
            {
                if (exception instanceof ValidatorException)
                {
                    throw exception;
                }
                else
                {
                    throw new ValidatorException(MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR, message + ": " + exception.getLocalizedMessage(), args));
                }
            }
        }
        else if (value instanceof Comparable)
        {
View Full Code Here

            if (!isbnValidator.isValid( value.toString())) {
                Object[] args = {value.toString()};
                String message = getMessage();
                if (null == messagemessage = ISBN_MESSAGE_ID;

                throw new ValidatorException(MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR, message, args));
            }
           

    }
View Full Code Here

            suffixMessageKey = CSV_SUFFIX_MESSAGE_ID;
        FacesMessage facesMsg = null;
        // value must be a String
        if (!(value instanceof String)) {
            Object[] args = { value };
            throw new ValidatorException(MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR, CSV_NOT_STRING_MESSAGE_ID, args));
        }
        Validator validator = facesContext.getApplication().createValidator(getSubvalidatorId());
        if (getSeparator() == null)
            setSeparator(DEFAULT_SEPARATOR);
        String[] values = null;
        try {
            values = ((String)value).split(getSeparator());
        }
        catch (PatternSyntaxException e) {
            Object[] args = { getSeparator() };
            throw new ValidatorException(MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR, CSV_INVALID_SEPARATOR_MESSAGE_ID, args));
        }
       
        // loop through the separated values and validate each one
        for (int i = 0; i < values.length; i++) {
            if (values[i].trim().length() == 0) {
                continue;
            }
            else try {
                validator.validate(facesContext, uiComponent, values[i]);
            }
            catch (ValidatorException e) {
                facesMsg = addMessage(facesMsg, e.getFacesMessage(), i, suffixMessageKey);
            }
        }
        if (facesMsg != null)
            throw new ValidatorException(facesMsg);
    }
View Full Code Here

TOP

Related Classes of javax.faces.validator.ValidatorException

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.