How to Create a JavaScript File for a Peer

30-24 Web User Interface Developers Guide for Oracle Application Development Framework For example, the tagPane component has the properties shown in Table 30–4 . ADF Faces and MyFaces Trinidad component libraries are defined differently from other libraries. A JSF component has a collection called attributes that provides access to component properties using the Java simple beans specification through a MAP interface. The collection also holds value pairs that do not correspond to a components properties. This concept is called attribute transparency. The JSF runtimes both MyFaces Trinidad and the JSF reference implementation implement this concept using the Java reflection API. My Faces Trinidad defines its own internal collection, which does not use the Java reflection API. This difference means that it is more efficient than the base implementation. The solution in MyFaces Trinidad collects more metadata about the component properties. This metadata declares state properties, which allows the base class to fully implement the StateHolder interface in a base class. Table 30–4 Component Properties for the tagPane Custom Component Origin Property Data Type Description Inherited id String.class The identifier for a component. rendererType String.class The logical identifier registered as a component renderer. rendered Boolean.class True or false flag that determines if the component is rendered. binding ValueExpression.cl ass A binding value expression to store a component instance in a managed bean. Rich Client Framework clientCompone nt Boolean.class True or false flag that determines whether a client-side component will be generated. clientListene rs ClientListenerSet. class A binding expression that registers a client listener on a component. clientAttribu tes Set.class A client attribute on a component. The attribute is added both to the server-side JSF component as well as the client-side equivalent. Best Practice inlineStyle String.class A CSS style applied to the root component’s class attribute. styleClass String.class A CSS style added to the component’s class attribute. visible Boolean.class True or false flag that returns the visibility of the component. The visible property is not the same as the rendered property. The visible attribute affects the CSS style on the CSS root of the component. partialTrigge rs String[].class The IDs of the components that should trigger a partial page update. Specific to tagPane tags Map.class The map of weighted tags. The key represents the tag name and the value as a number. MapString.Number. orderBy String.class The order that the tags are rendered. The valid enumerations are alpha and weight. tagSelectList ener MethodExpression.c lass The newselectListener method binding expression that expects a single parameter of type oracle.adfdemo.acme.faces.event.TagSelec tEvent. This binding will be when the client-side oracle.adfdemo.acme.js.event.AcmeTagSele ctEvent.js event is queued from clicking one of the tags. 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.