Package javax.validation

Examples of javax.validation.ConstraintViolation


        if (!constraintViolations.isEmpty())
        {
            Set<FacesMessage> messages = new LinkedHashSet<FacesMessage>(constraintViolations.size());
            for (Object violation: constraintViolations)
            {
                ConstraintViolation constraintViolation = (ConstraintViolation) violation;
                String message = constraintViolation.getMessage();
                Object[] args = new Object[]{ message, _MessageUtils.getLabel(context, component) };
                FacesMessage msg = _MessageUtils.getErrorMessage(context, MESSAGE_ID, args);
                messages.add(msg);
            }
            throw new ValidatorException(messages);
View Full Code Here


      s.flush();
      fail( "Associated objects should not be validated" );
    }
    catch ( ConstraintViolationException e ) {
      assertEquals( 1, e.getConstraintViolations().size() );
      final ConstraintViolation constraintViolation = e.getConstraintViolations().iterator().next();
      assertEquals( Color.class, constraintViolation.getRootBeanClass() );
    }

    tx.rollback();
    s.close();
  }
View Full Code Here

      s.flush();
      fail( "Collection of embedded objects should be validated" );
    }
    catch ( ConstraintViolationException e ) {
      assertEquals( 1, e.getConstraintViolations().size() );
      final ConstraintViolation constraintViolation = e.getConstraintViolations().iterator().next();
      assertEquals( Screen.class, constraintViolation.getRootBeanClass() );
      // toString works since hibernate validator's Path implementation works accordingly. Should do a Path comparison though
      assertEquals( "connectors[].number", constraintViolation.getPropertyPath().toString() );
    }

    tx.rollback();
    s.close();
  }
View Full Code Here

      s.flush();
      fail( "Collection of embedded objects should be validated" );
    }
    catch ( ConstraintViolationException e ) {
      assertEquals( 1, e.getConstraintViolations().size() );
      final ConstraintViolation constraintViolation = e.getConstraintViolations().iterator().next();
      assertEquals( Display.class, constraintViolation.getRootBeanClass() );
    }

    tx.rollback();
    s.close();
  }
View Full Code Here

        if (!constraintViolations.isEmpty())
        {
            final Set<FacesMessage> messages = new LinkedHashSet<FacesMessage>(constraintViolations.size());
            for (Object violation: constraintViolations)
            {
                final ConstraintViolation constraintViolation = (ConstraintViolation) violation;
                final String message = constraintViolation.getMessage();
                final Object[] args = new Object[]{ message, _MessageUtils.getLabel(context, component) };
                final FacesMessage msg = _MessageUtils.getErrorMessage(context, MESSAGE_ID, args);
                messages.add(msg);
            }
            throw new ValidatorException(messages);
View Full Code Here

        if (!constraintViolations.isEmpty())
        {
            Set<FacesMessage> messages = new LinkedHashSet<FacesMessage>(constraintViolations.size());
            for (Object violation: constraintViolations)
            {
                ConstraintViolation constraintViolation = (ConstraintViolation) violation;
                String message = constraintViolation.getMessage();
                Object[] args = new Object[]{ message, _MessageUtils.getLabel(context, component) };
                FacesMessage msg = _MessageUtils.getErrorMessage(context, MESSAGE_ID, args);
                messages.add(msg);
            }
            throw new ValidatorException(messages);
View Full Code Here

    {
        Set<ConstraintViolation<BeanValidationDemoBean>> violations = this.validator.validate(this, groups);

        if (!violations.isEmpty())
        {
            ConstraintViolation violation = violations.iterator().next();
            String message = "property: " + violation.getPropertyPath().toString()
                    + " - message: " + violation.getMessage();
            this.facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, message, message));
        }
    }
View Full Code Here

        if (!constraintViolations.isEmpty())
        {
            Set<FacesMessage> messages = new LinkedHashSet<FacesMessage>(constraintViolations.size());
            for (Object violation: constraintViolations)
            {
                ConstraintViolation constraintViolation = (ConstraintViolation) violation;
                String message = constraintViolation.getMessage();
                Object[] args = new Object[]{ message, _MessageUtils.getLabel(context, component) };
                FacesMessage msg = _MessageUtils.getErrorMessage(context, MESSAGE_ID, args);
                messages.add(msg);
            }
            throw new ValidatorException(messages);
View Full Code Here

        if (!constraintViolations.isEmpty())
        {
            Set<FacesMessage> messages = new LinkedHashSet<FacesMessage>(constraintViolations.size());
            for (Object violation: constraintViolations)
            {
                ConstraintViolation constraintViolation = (ConstraintViolation) violation;
                String message = constraintViolation.getMessage();
                Object[] args = new Object[]{ message, _MessageUtils.getLabel(context, component) };
                FacesMessage msg = _MessageUtils.getErrorMessage(context, MESSAGE_ID, args);
                messages.add(msg);
            }
            throw new ValidatorException(messages);
View Full Code Here

            }

            if (violations != null && !violations.isEmpty()) {
                ValidatorException toThrow;
                if (1 == violations.size()) {
                    ConstraintViolation violation = violations.iterator().next();
                    toThrow = new ValidatorException(MessageFactory.getMessage(
                          context,
                          MESSAGE_ID,
                          violation.getMessage(),
                          MessageFactory.getLabel(context, component)));
                } else {
                    Set<FacesMessage> messages = new LinkedHashSet<FacesMessage>(
                          violations.size());
                    for (ConstraintViolation violation : violations) {
                        messages.add(MessageFactory.getMessage(context,
                                                               MESSAGE_ID,
                                                               violation.getMessage(),
                                                               MessageFactory.getLabel(
                                                                     context,
                                                                     component)));
                    }
                    toThrow = new ValidatorException(messages);
View Full Code Here

TOP

Related Classes of javax.validation.ConstraintViolation

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.