[
https://hibernate.onjira.com/browse/BVAL-267?page=com.atlassian.jira.plug...
]
Antonio Goncalves commented on BVAL-267:
----------------------------------------
After a quick Tweet about facilitating the creation of {{ConstraintViolationException}},
Emmanuel suggested that I explain myself a bit longer
(
https://twitter.com/emmanuelbernard/status/173884950544777217). So here I go.
Not all the constraints can be expressed with annotations. Some business constraints
follow complex workflows that BV cannot help with. In such cases, we end up using our own
exception :
{code}
if (complexBusinessConstraint)
throw new ComplexBusinessException("A complex business constraint has been
violated");
{code}
In a typical EJB/JSF world we then have to catch this exception and use the
{{FacesContext}} to add a {{FacesMessage}} so it can be displayed to the user. It would be
nice if we could use the BV/JSF integration and do something like that so a simple message
is automatically displayed (or resource bundle) :
{code}
if (complexBusinessConstraint)
throw new ConstraintViolationException("A complex business constraint has been
violated");
{code}
This way we don't have to try to tweek a {{Set<ConstraintViolation<?>>}}
(which is the constructor of {{ConstraintViolationException}}) or play with the
{{ConstraintValidatorContext}} to build a constraint violation.
So really the title of this JIRA should be _Provide a ConstraintViolationException
constructor to facilitate JSF integration_ (or something like that).
Provide a ConstraintViolationException builder to facilitate consumer
code
--------------------------------------------------------------------------
Key: BVAL-267
URL:
https://hibernate.onjira.com/browse/BVAL-267
Project: Bean Validation
Issue Type: Improvement
Components: spec-general
Reporter: Emmanuel Bernard
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira