Chapter 7. Extending and Customizing Facelets

7.1 Extensibility: JSF and Facelets

Extensibility is one of JSF's greatest strengths. JSF achieves its extensibility by using default implementations of pluggable classes to deliver its core functionality. These classes include implementations of ActionListener, NavigationHandler, VariableResolver, PropertyResolver, ViewHandler, and StateManager. They are surprisingly simple to extend because JSF allows you to decorate the default implementation. If the custom pluggable class contains a constructor that takes an argument of the class that it extends, JSF uses that constructor and passes in the previously registered implementation. You can decorate the behavior of the default implementation with custom logic and delegate to the default implementation. Additionally, all components delegate generating client output to a Renderer class, which also is easily replaced by a custom implementation. If none of the existing components meet your application needs, you can either extend an existing one or develop a custom component. In short, just about everything in JSF can be extended or replaced with a modest effort.

Facelets itself is an example of the extensibility of JSF. As previously mentioned in Chapter 1. Introducing Facelets: A Better JSF ViewHandler, it is integrated into JSF as a custom ViewHandler. Quite naturally, Facelets is true to its roots—like JSF, it also is easily extended. Chapter 6. Developing and Using Composition Components ...

Get Facelets now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.