Examples of ConstraintViolation


Examples of javax.validation.ConstraintViolation

      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

Examples of javax.validation.ConstraintViolation

      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

Examples of javax.validation.ConstraintViolation

      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

Examples of javax.validation.ConstraintViolation

        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

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

Examples of javax.validation.ConstraintViolation

    {
        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

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

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

Examples of javax.validation.ConstraintViolation

            }

            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

Examples of javax.validation.ConstraintViolation

        constraintsBox.setAlignment(Pos.CENTER_LEFT);
        controller.getConstraintViolations().addListener(new ListChangeListener() {
            public void onChanged(Change change) {
                constraintsBox.getChildren().clear();
                for (Object o : controller.getConstraintViolations()) {
                    ConstraintViolation constraintViolation = (ConstraintViolation) o;
                    Label errorLabel = new Label(constraintViolation.getMessage());
                    ImageView warningView = new ImageView(WARNING);
                    warningView.setFitHeight(15);
                    warningView.setPreserveRatio(true);
                    warningView.setSmooth(true);
                    errorLabel.setGraphic(warningView);
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.