How to Create a JavaScript File for a Component

Creating Custom ADF Faces Components 30-21 ■ Component: This class holds the properties that define behavior for the component. ■ Resource bundle: This class holds text strings for the component. ■ Renderer: This class determines how the component will be displayed in the client. ■ Resource loader: This class is required only if your component contains images needed for skinning. After you have created the classes, add the component class and the renderer class to the faces-config.xml file. Then, complete the configuration files started in Section 30.2, Setting Up the Workspace and Starter Files.

30.4.1 How to Create a Class for an Event Listener

The ADF Faces event API requires an event listener interface to process the event. The custom component has a dependency with the event and the event has a dependency with an event listener interface. The Java import statements must reflect these dependencies. You also must define the componentType for the component. To create the EventListener 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 Interface and click OK. 4. In the Create Java Interface File dialog, do the following: ■ Name : Enter a listener name. For example, for the tagPane component, you might enter TagSelectListener. ■ Package : Enter a name for the package. For example, for the tagPane component, you might enter oracle.adfdemo.acme.faces.event.

5. Open the Java file in the editor and add the following:

■ Have the listener extend the javax.faces.event.FacesListener interface. ■ Add an import statement, and import the FacesListener class and any other classes on which your event is dependent. ■ Add a method signature that will process the new event. Even though you have not created the actual event, you can enter it now so that you will not have to enter it later. Example 30–9 shows the code for the tagPane event listener. Example 30–9 tagPane Event Listener Java Code package oracle.adfdemo.acme.faces.event; import javax.faces.event.AbortProcessingException; import javax.faces.event.FacesListener; public interface TagSelectListener extends FacesListener { pProcess the {link TagSelectEvent}.p 30-22 Web User Interface Developers Guide for Oracle Application Development Framework param event fired on click of a tag link throws AbortProcessingException error processing {link TagSelectEvent} public void processTagSelectTagSelectEvent event throws AbortProcessingException; }

30.4.2 How to Create a Class for an Event

You must create a server-side event that will be the counter representation of the JavaScript event created in Section 30.3.2, How to Create a Javascript File for an Event.