How to Add a JavaScript Library Feature Configuration File

Creating Custom ADF Faces Components 30-19

30.3.3 How to Create a JavaScript File for a Peer

Use JDeveloper to create a JavaScript file for the peer. Add code to register the peer and bind it to the component. To create the peer JavaScript file: 1. In the Application Navigator, right-click the project and select New. 2. In the New Gallery, expand Web Tier and select HTML. 3. Select JavaScript File and click OK. 4. In the Create JavaScript File dialog, do the following: ■ File Name : Enter the name of the client-side peer. For example, for the tagPane component, you might enter AcmeTagPanePeer.js. ■ Directory : Enter the directory path of the event in a subdirectory under the src directory. For example, for the tagPane component, you might enter adf-richclient-demo-acme\src\oracle\adfdemo\acme\js\compon ent.

5. Open the JavaScript file in the editor and add code for the peer. In this code, you

must create the peer, add event handling with respect to the DOM, and register the peer with the component. Example 30–7 shows the code that might be added for the tagPane component. Example 30–7 tagPane JavaScript Peer AdfRichUIPeer.createPeerClassAdfRichUIPeer, AcmeTagPanePeer, true; AcmeTagPanePeer.InitSubclass = function { AdfLogger.LOGGER.logMessageAdfLogger.FINEST, AcmeTagPanePeer.InitSubclass; AdfRichUIPeer.addComponentEventHandlersthis, AdfUIInputEvent.CLICK_EVENT_TYPE; } AcmeTagPanePeer.prototype.HandleComponentClick = functioncomponentEvent { AdfLogger.LOGGER.logMessageAdfLogger.FINEST, AcmeTagPanePeer.HandleComponentClickcomponentEvent; if the left mouse button was pressed if componentEvent.isLeftButtonPressed { find component for the peer var component = this.getComponent; AdfAssert.assertPrototypecomponent, AcmeTagPane; find the native dom element for the click event var target = componentEvent.getNativeEventTarget; if target target.tagName == A { AdfLogger.LOGGER.logMessageAdfLogger.FINEST, File type element A found: + componentEvent.toString; var tag = target.firstChild.nodeValue; AdfAssert.assertStringtag; Tip: To prevent naming collisions, start the name with the component prefix.