8wbj1w
Last Updated: February 25, 2016
·
2.023K
· steviebraga

JSF 2.2 Composite Components

Writing a composite component in JSF 2.2, I found myself facing with this ServletException:

Tag Library supports namespace: http://xmlns.jcp.org/jsf/composite, but no tag was defined for name: myComponent

I wrote composite components before, but using JSF 2.1. In 2.2 there is small difference:


Namespaces

In 2.1 we just declared the regular namespace:

xmlns:custom="http://java.sun.com/jsf/composite"

But in 2.2 we need to add the tag name to the url

xmlns:custom="http://xmlns.jcp.org/jsf/composite/custom"


Directory Structure

In 2.1 components need to be on this folder

webaap > resources > components > myComponent.xhtml

Now in 2.2 the components must be inside a folder named with the tag name

webaap > resources > custom > myComponent.xhtml


With this little changes the component started working alright:

<custom:myComponent> ... </custom:myComponent>