JSF Composite Components Where You Want Them
As Ryan Lubke commented in the Facelets Tags vs Composite Components thread, JSF composite components must be kept in the /resources directory in your webapp. This grates against my "package-by-feature" style of programming. I want all my related code together thanks.
Fortunately there are two ways to work around this problem.
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets" template="/apps/webcore/tags/selectUser.xhtml"/>JSF Composite Components Where You Want Them
That's not perfect, but it lets me keep all my related code together. To make things a little neater, you can actually use the same namespace for composite components and regular components. Just declare the location of your composite resources directory in the taglib.xml like this:
<facelet-taglib> <namespace>https://rogerkeays.com/webcore</namespace> <composite-library-name>webcore</composite-library-name> </facelet-taglib>
I don't see any reason why composite components should not be able to be added to taglib.xml. If I had it my way, the existing Facelets <tag> feature would just look in the tag file for <cc:implementation> and handle it as a composite component if one is found.
In fact, composite components and tag files should be the same thing.
Roger Keays is an artist, an engineer, and a student of life. Since he left Australia in 2009, he has been living as a digital nomad in over 40 different countries around the world. Roger is addicted to surfing. His other interests are music, psychology, languages, and finding good food. Click here to subscribe to his weekly blog, or stalk him on Facebook and Twitter.