myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rene O (JIRA)" <...@myfaces.apache.org>
Subject [jira] [Commented] (MYFACES-3892) Create a option to execute BeanValidation before JSF-Validation
Date Fri, 16 May 2014 11:24:26 GMT

    [ https://issues.apache.org/jira/browse/MYFACES-3892?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13998672#comment-13998672
] 

Rene O commented on MYFACES-3892:
---------------------------------

A workaround is to call BeanValidation manually within JSF-Validator before JSF-validation
is done:
{code:title=MyJsfValidatorClass.java}
//...
public void validateMyData(FacesContext context, UIComponent component, Object value) throws
ValidatorException {
	//call beanvalidation manually
	Set<ConstraintViolation<MyDataModel>> violationsSet = validator.validateValue(MyDataModel.class,
"myFieldName", value, Default.class);

	//if beanvalidation error exists do not validate my own jsf-validation rules
	if(!violationsSet.isEmpty()){
		return;
	}

	//...my own jsf-validation rules...
	//...throw new ValidatorException(new FacesMessage("validation error",null));
}
{code}

> Create a option to execute BeanValidation before JSF-Validation
> ---------------------------------------------------------------
>
>                 Key: MYFACES-3892
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3892
>             Project: MyFaces Core
>          Issue Type: Improvement
>    Affects Versions: 2.2.3
>            Reporter: Rene O
>
> As stated in this answer: http://stackoverflow.com/a/19835645 BeanValidation is executed
after JSF-Validation.
> But it would be very useful to have a way to change this behaviour.
> Now you can't decide within jsf-validator wether a component is valid or not in terms
of BeanValidation
> {code}
> //My JSF-Validator
> //...
> UIInput input = (UIInput) component;
> if (!input.isValid()) {
>     return;
> }
> //...my own jsf-validation rules...
> //...
> {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message