If at all possible, I recommend creating your custom components using just the xhtml.
You can create custom
JSF components in Java code, but there are a number of reasons to avoid this:
1. It's a lot more complicated than setting up xhtml.
2. Good documentation on how to do so is harder to find.
3. Java code is dependent on JSF internals, which can - and have already - changed radically between JSF versions, raising the cost of maintenance.
4. Thanks to #3, #2 is even harder, since Internet searches have a maddening tendency to bring up old, outdated docs ahead of newer stuff. In fact, I think that's the prime reason why so many JSF newbies are coding action listeners and bindings when they should be doing neither.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.