BeanValidator cannot resolve composite component values

From: Lincoln Baxter, III <>
Date: Mon, 12 Oct 2009 13:52:57 -0400

I've logged an issue for this:

When baseClass is:
    class com.sun.faces.el.CompositeComponentAttributesELResolver

BeanValidator.isResolvable(...) returns false because ExpressionEvalMap
is a Map -- and never attempts to traverse the composite component.

This is a big problem with Bean Validation support, since probably the
most attractive feature of JSF2 is composite components, and this means
BeanValidation will not function at all within any composite components.

            // case 1, base classes of Map, List, or Array are not
            if (null != baseClass) {
                if (Map.class.isAssignableFrom(baseClass) ||
                        Collection.class.isAssignableFrom(baseClass) ||
                        Array.class.isAssignableFrom(baseClass)) {
                    failureMessage = "Unable to validate expression " +
valueExpression.getExpressionString() +
                            " using Bean Validation. Expression
evaluates to a Map, List or array.";
                    result = false;

This can be reproduced by using the following component, and an Object
annotated with JSR303 annos.
Consuming page: (I've also tried "value" as the for="..." attribute
value with no success)

                <a:comp id="test" value="${bean.test.text}">
                        <f:validateBean for="#{bean.test}"/>

Example component:

        <html xmlns=""
                <composite:attribute name="value" required="true"
        type="Object" />
                <composite:editableValueHolder name="value" targets="value" />
                <h:message id="inputErr" for="input"/><br/>
                <h:inputText id="input" value="#{cc.attrs.value}" >
                        <f:ajax execute="@this" render="@this inputErr" />

Example Object:

        public class ValidationCriteria
            @Size(min=4, max=255)
            private String text;
            public String getText()
                return text;
            public void setText(final String validation)
                this.text = validation;


public class Bean
    private ValidationCriteria test = new ValidationCriteria();

    public ValidationCriteria getTest()
        return test;

Lincoln Baxter, III
Co-Founder of OcpSoft
Creator of:
PrettyFaces: URL rewriting for JSF
PrettyTime: Java elapsed timestamp formatting