i want to build a custom JSF Component. Now i read some docs from oracle and saw a few code Examples. The problem is i am a bit confused:
It seems there are two ways to
A composite component is useful if you want to represent a bunch of closely related existing tags/components/HTML as a single and reuseable component by pure XML means.
A custom component would be the only way when there are no standard JSF tags/components available to achieve the requirement. E.g. <input type="file">
, <input type="range">
, etc. Note that such a custom component can in turn be used in a composite, whenever desireable.
Makes totally sense, right?
You can create a so-called "backing component" class extending UINamingContainer
(or at least implementing NamingContainer
) and bind it to the composite by <cc:interface componentType>
. You can find several examples in my answers here.
Do however note that sometimes a composite component isn't suitable, you'd need to create a tag file instead. For example when you want to have a custom and reuseable <h:column>
.