I've been playing around with JSF 2.0 composite components but I'm a bit confused as to what the require attribute in the composite:attribute
tag is meant to do. The documentation says that the required attribute is true if the page author must supply a value for this attribute.
I've interpreted that as meaning that a value must be supplied for all composite:attributes that have required=true
. I also assumed that an empty string is a valid value. And this is how it worked in Mojarra 2.0.2.
Using this simple managed bean:
@ManagedBean(name = "simpleMB")
@ViewScoped
public class SimpleManagedBean implements Serializable {
private static final long serialVersionUID = -1;
private String whatever;
... setter and getter
}
And the composite component:
<composite:interface>
<composite:attribute name="value" required="true" />
</composite:interface>
<composite:implementation>
<h:outputText value="Value: '#{cc.attrs.value}'" />
</composite:implementation>
These tags worked in Mojarra 2.0.2:
<foo:bar value="" />
<foo:bar value="#{simpleMB.whatever}" />
However, when I upgraded to 2.0.3, only the first tag works. The second tag causes this error message:
/requiredAttribute.xhtml @20,42 <foo:bar> The following attribute(s) are
required, but no values have been supplied for them: value.
It works fine when I set required to false.
Have I misinterpreted what the required attribute means? Can somebody clarify what behaviour I should expect?
Thanks.