O'Reilly logo

JavaServer Faces by Hans Bergsten

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using Other Custom Classes

In the next chapter, we’ll look at how to develop custom components in addition to custom renderers. Custom renderers and components are, however, not the only types of classes that you can plug into JSF. As I’ve mentioned before, pretty much everything in JSF is pluggable. You can replace the default ActionListener, NavigationHandler, VariableResolver, PropertyResolver, ViewHandler, and StateManager implementation classes. If a custom version of any of these classes has a constructor that takes an argument of the same type, JSF uses that constructor and passes in the previously registered instance as the argument. This makes it easy to provide a custom class that implements only some of the methods and delegates the rest to the previous instance. I’ll show you an example of how to do this for a custom ViewHandler in Chapter 15.

A custom VariableResolver can be used to add implicit EL variables, such as an implicit variable named now that holds a java.util.Date instance for the current time. A custom PropertyResolver can add support for custom properties or data types not supported out of the box, such as a pseudo-property named ids for objects of type UIComponent to hold a java.util.Map with all children keyed by their IDs. This would make it easy to access components by their ID in a JSF EL expression, e.g., #{view.ids.form.ids.input} would access a component with the ID input nested within a component with the ID form.

Custom ActionListener and NavigationHandler ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required