I played with JSF 2.0 composite components, but I'm a bit confused about having to use the require attribute in the composite:attribute tag. The documentation states that the required attribute is true if the page author must specify a value for this attribute.
I interpreted this as meaning that a value should be provided for all composite attributes that have required=true . I also suggested that an empty string is a valid value. And so he 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 component 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 to false.
I misinterpreted what the required attribute means? Can someone clarify what behavior I should expect?
Thanks.
source share