hi gerald, please also describe the use-case for this feature.
regards, gerhard http://www.irian.at Your JSF/JavaEE powerhouse - JavaEE Consulting, Development and Courses in English and German Professional Support for Apache MyFaces 2012/3/7 Gerald Turner <[email protected]> > Hi myfaces-users, I sent the following email directly to Gerhard > Petracek and he pointed me to the mailing list, mentioned that there is > usually a short discussion before opening a JIRA ticket. > > Gerald Turner <[email protected]> writes: > > > Hello Gerhard, I apologize in advance if this is inappropriate to > > email you a question directly — I'm having a hard time deciphering > > what sort of support is available to the MyFaces project. > > > > I have a quick question: Should the ExtVal BV framework be able to > > inspect javax.validation.ConstraintViolation<T> getPropertyPath and > > getRootBean methods and affix the resulting FacesMessage to the > > appropriate clientID? > > > > I've looked thru the ExtVal source and it seems that this bit if > > detail in ConstraintViolation is discarded. Should I report this in > > JIRA as a feature request? > > > > Here's a terse example in case that question didn't make sense: > > > > Using JSR303 I have a multi-field ConstraintValidator on the > > type/class level of a JPA entity. The ConstraintValidator emits two > > ConstraintViolations with propertyPath set, one for each field. The > > JSF page has a globalOnly h:messages and a h:message for each field. > > The violation messages are rendered in the globalOnly component > > (twice) and not rendered to the specific fields. > > > > § Entity: > > > > @WidgetMutuallyExclusiveOptions > > @Entity > > class Widget { > > > > private boolean option1; > > private boolean option2; > > > > } > > > > § ConstraintValidator: > > > > class WidgetMutuallyExclusiveOptionsValidator > > implements > ConstraintValidator<WidgetMutuallyExclusiveOptions,Widget> { > > > > private WidgetMutuallyExclusiveOptions anno; > > > > public void initialize(WidgetMutuallyExclusiveOptions anno) { > > this.anno = anno; > > } > > > > public isValid(Widget widget, ConstraintValidatorContext ctx) { > > if (widget.isOption1() && widget.isOption2()) { > > ctx.disableDefaultConstraintViolation(); > > ctx.buildConstraintViolationWithTemplate(anno.message()) > > .setNode("option1"); > > .addConstraintViolation(); > > ctx.buildConstraintViolationWithTemplate(anno.message()) > > .setNode("option2"); > > .addConstraintViolation(); > > return false; > > } > > return true; > > } > > > > } > > > > § Controller Bean: > > > > @Named("edit") > > public WidgetEdit { > > > > @BeanValidation(modelValidation=@ModelValidation(isActive=true)) > > private Widget widget; > > > > public Widget getWidget() { > > return widget; > > } > > > > public void save() { > > … > > } > > > > } > > > > § Partial JSF: > > > > <h:form> > > <h:messages globalOnly="true"/> > > <h:panelGrid columns="3"> > > <h:outputLabel value="Option #1" for="opt1"/> > > <h:selectBooleanCheckbox id="opt1" value="#{edit.widget.option1}"/> > > <h:message for="opt1"/> > > <h:outputLabel value="Option #2" for="opt2"/> > > <h:selectBooleanCheckbox id="opt2" value="#{edit.widget.option2}"/> > > <h:message for="opt2"/> > > </h:panelGrid> > > <h:commandButton value="Submit" actionListener="#{edit.save}"/> > > </h:form> > > > > Sorry, can't help myself, one more question: it seems that > > field/method level validations are check in one pass, then type/class > > level validations in a second pass only if the first pass succeeded. > > For instance if I add @Size and @NotNull sorts of validations to the > > Entity in addition to the multi-field @WidgetMutuallyExclusiveOptions, > > I cannot get all the error messages rendered in one response, I have > > to pass the @Size/@NotNull/etc. validations before seeing the > > multi-field validation. Is there a way of changing that behavior? It > > could be that ExtVal isn't handling my field validations, perhaps it's > > the native JSF stack getting a crack at JSR303 before ExtVal's turn. > > > > BTW, I really appreciate ExtVal BV, I've spent the last several days > > trying to debug why JSR303 isn't fully supported by JSF, considered > > writing some glue that clones model objects but my project is getting > > increasingly uglier! ExtVal does the trick in one maven dependency + > > one annotation on the JSF bean, nice! > > -- > Gerald Turner Email: [email protected] JID: [email protected] > GPG: 0xFA8CD6D5 21D9 B2E8 7FE7 F19E 5F7D 4D0C 3FA0 810F FA8C D6D5 >

