Package javax.faces.validator

Examples of javax.faces.validator.ValidatorException


    public void validateCar(FacesContext context, UIComponent component, Object value) throws ValidatorException
    {
        if (value instanceof String && value.equals("c6"))
        {
            throw new ValidatorException(new FacesMessage("Are you kidding?", "You cannot buy a James Blond car!"));
        }
    }
View Full Code Here


            {
                _tree.setNodeId(nodeId);
            }
            catch (Exception e)
            {
                throw new ValidatorException(message, e);
            }

            if (_tree.getNode().isLeaf())
            {
                message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Invalid node path (cannot expand a leaf): "
                        + nodeId, "Invalid node path (cannot expand a leaf): " + nodeId);
                throw new ValidatorException(message);
            }
        }
    }
View Full Code Here

      {
        return;
      }
      if (!GenericValidator.isUrl(value.toString())) {
        Object[] args = {value.toString()};
        throw new ValidatorException(MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR,URL_MESSAGE_ID, args));

      }

  }
View Full Code Here

      FileItem file = (FileItem) value;
      if (maxSize != null && file.getSize() > maxSize) {
        Object[] args = {maxSize,  component.getId()};
        FacesMessage facesMessage = MessageFactory.createFacesMessage(context,
            SIZE_LIMIT_MESSAGE_ID, FacesMessage.SEVERITY_ERROR, args);
        throw new ValidatorException(facesMessage);
      }
      // Check only a valid file
      if (file.getSize() > 0 && contentType != null
          && !ContentType.valueOf(contentType).match(ContentType.valueOf(file.getContentType()))) {
        ContentType expectedContentType = ContentType.valueOf(contentType);
        Object [] args = {expectedContentType, component.getId()};
        FacesMessage facesMessage = MessageFactory.createFacesMessage(context,
            CONTENT_TYPE_MESSAGE_ID, FacesMessage.SEVERITY_ERROR, args);
        throw new ValidatorException(facesMessage);
      }
    }
  }
View Full Code Here

        for (String expression : annotation.value())
        {
            if (!java.util.regex.Pattern.compile(expression).matcher(convertedObject.toString()).matches())
            {
                throw new ValidatorException(new FacesMessage(
                        FacesMessage.SEVERITY_ERROR,
                        getErrorMessageSummary(annotation),
                        getErrorMessageDetail(annotation).replace("{0}", expression)));
            }
        }
View Full Code Here

        if (convertedObject instanceof String
                && column.length() < ((String) convertedObject).length())
        {
            this.violation = VALIDATE_LENGTH;
            this.maxLength = column.length();
            throw new ValidatorException(getValidationErrorFacesMessage(null));
        }
    }
View Full Code Here

      Date min = getMinimum();
      if (max != null && (converted.after(max)))
      {
        if (min != null)
        {
           throw new ValidatorException
                      (_getNotInRangeMessage(context, component, value, min, max));
        }
        else
        {
           throw new ValidatorException
                      (_getMaximumMessage(context, component, value, max));
        }
      }

      if (min != null && (converted.before(min)))
      {
        if (max != null)
        {
          throw new ValidatorException
                      (_getNotInRangeMessage(context, component, value, min, max));
        }
        else
        {
          FacesMessage msg = _getMinimumMessage(context, component, value, min);
          throw new ValidatorException(msg);
        }
      }
    }
  }
View Full Code Here

      if(isMaximumSet() && isMinimumSet())
      {
        if(doubleValue < min || doubleValue > max)
        {
          throw new ValidatorException(
            _getNotInRangeMessage(context, component, value, min, max));
        }
      }
     
      if(isMaximumSet())
      {
        if (doubleValue > max)
        {
          throw new ValidatorException(
            _getMaximumMessage(context, component, value, max));
        }
      }
     
      if(isMinimumSet())
      {
        if (doubleValue < min)
        {
          throw new ValidatorException(
            _getMinimumMessage(context, component, value, min));
        }
      }
    }
    catch (NumberFormatException nfe)
    {
      FacesMessage msg = _getNotCorrectType(context);
      throw new ValidatorException(msg);
    }
  }
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

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.