I have web flow with this view:
<var name="newRecipe" class="springapp.service.NewRecipe" />
<view-state id="displayNameView" view="/WEB-INF/jsp/add_name.jsp" model="newRecipe">
<transition on="nameEntered" to="displayDescriptionView" />
</view-state>
and validator:
@Component("newRecipeValidator")
public class NewRecipeValidator implements Validator {
@Override
public boolean supports(@SuppressWarnings("rawtypes") final Class clazz) {
return NewRecipe.class.isAssignableFrom(clazz);
}
@Override
public void validate(final Object obj, final Errors errors) {
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "error.not-specified-name", "Pole wymagane.");
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "description", "error.not-specified-description", "Pole wymagane.");
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "category", "error.not-specified-category", "Pole wymagane.");
}
public void validateDisplayNameView(final NewRecipe obj, final ValidationContext context) {
System.out.println("okej");
}
}
My problem is that when web flows tries to validate view displayNameView it calls validateDisplayNameView() and after that validate().
In validate() (for view displayNameView) newRecipe always will have null fields description and category.