How to Add a Custom Component to a JavaScript Library Feature Configuration File

Creating Custom ADF Faces Components 30-25 My Faces Trinidad extends the javax.faces.component.UIComponent class with the org.apache.trinidad.component.UIXComponent class, followed by a complete component hierarchy. To ease code maintenance, the framework has a strategy for generating code based on configuration files and templates. This component strategy is a trade-off in terms of development. It requires more coding for defining properties, but you will not have to code the two methods saveState, restoreState for the StateHolder interface for each component.

30.4.4 How to Create a Class for a Component

Use JDeveloper to create a Java file for the component. Create a Type bean to hold property information and define a PropertyKey for each property. Then, generate accessors for the private attributes. To create the component class: 1. In the Application Navigator, right-click the project and select New. 2. In the New Gallery, expand General and select Java. 3. Select Java Class. Click OK. 4. In the Create Java Class File dialog, do the following: ■ Name : Enter a component name. For example, for the tagPane component, you might enter TagPane. ■ Package : Enter a name for the package. For example, for the tagPane component, you might enter oracle.adfdemo.acme.faces.component. ■ Extends : Enter a name for the class the component class extends. For example, for the tagPane component, you would enter org.apache.myfaces.trinidad.component.UIXObject. ■ In the Optional Attributes section, select the following:. – In the Access Modifiers section, select public. – At the bottom, select Constructors from Superclass, and Implement Abstract Methods .

5. In the source editor, create a Type bean that contains component property

information. This static class attribute shadows an attribute with the same name in the superclass. The type attribute is defined once per component class. Through the Type constructor, you pass a reference to the superclass’s Type bean, which copies property information. For example, the tagPane class would contain the following constructor: static public final FacesBean.Type TYPE = new FacesBean.TypeUIXObject.TYPE;

6. For each property, define a static PropertyKey that is used to access the

properties state. Use the TYPE reference to register a new attribute. Specify the property type using the class reference. The component data type should correspond to the component property. There is another overload of the registerKey method that allows you to specify state information. The default Note: Do not have your custom component extend from any ADF Faces implementation packages. These implementations are private and might change.