Registering the Component

All custom components must be registered in the faces-config.xml file. Here’s how you register the UITabLabel component:

<faces-config>
  ...
  <component>
    <component-type>
      com.mycompany.TabLabel
    </component-type>
    <component-class>
      com.mycompany.jsf.component.UITabLabel
    </component-class>
  </component>
  ...
</faces-config>

The <component> element contains two mandatory nested elements. The <component-type> element assigns the component a unique identifier and the <component-class> holds the fully qualified component class name. As you may recall from Chapter 6, the code that creates components does so by calling the Application createComponent() method. It takes the component type identifier as the argument and returns an instance of the class mapped to the identifier.

Get JavaServer Faces 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.