How to Create a Class for an Event Listener

30-26 Web User Interface Developers Guide for Oracle Application Development Framework assumes the property is persistent. Example 30–11 shows the PropertyKey methods for the tagPane component. Example 30–11 PropertyKey Definition pCustom CSS applied to the style attribute of the root markup node.p static public final PropertyKey INLINE_STYLE_KEY = TYPE.registerKeyinlineStyle, String.class; pCustom CSS class to the class attribute of the root markup node.p static public final PropertyKey STYLE_CLASS_KEY = TYPE.registerKeystyleClass, String.class;

7. Right-click in the editor and choose Generate Accessors. In the Generate

Accessors dialog, click Select All, ensure the Scope is set to Public, and click OK. This allows JDeveloper to generate get and set methods for the private attributes. Then, remove the private attribute and replace with calls to getPropertyPropertyKey and getPropertyPropertyKey. Example 30–12 shows the code after replacing the private attribute. Example 30–12 Component Properties public void setInlineStyleString newinlineStyle { inlineStyle = newinlineStyle; setPropertyINLINE_STYLE_KEY, newinlineStyle; } pCSS value applied to the root components style attribute.p return newinlineStyle CSS custom style text public String getInlineStyle { return inlineStyle; return String getPropertyINLINE_STYLE_KEY; } 8. You may need to override any methods to perform specific functions in the component. For example, to allow your component to participate in partial page rendering PPR, you must override the getBeanType method, as shown in Example 30–13 . Example 30–13 pExposes the codeFacesBean.Typecode for this class through a protected method. This method is called but the codeUIComponentBasecode superclass to setup the components codeValueMapcode which is the container for the codeattributescode collection.p return codeTagPane.TYPEcode static property Override protected FacesBean.Type getBeanType Creating Custom ADF Faces Components 30-27 { return TYPE; } Refer to the ADF Faces JavaDoc for more information about the class your component extends, and the methods you may need to override. For the tagPane component, the component must act on the event fired from the client component. A reference to the source component is passed as a parameter to the event’s constructor. For the tagPane component, the broadcast method checks if the event passed in using the formal parameter is a TagSelectEvent. If it is, the broadcast method invokes the method expression held by the tagSelectListener attribute. Most events have an immediate boolean property that specifies the lifecycle phase in which the event should be invoked. If the immediate attribute is true, the event is processed in the Apply Values phase; otherwise, the event is processed in the Invoke Application phase. For more information, see Chapter 4, Using the JSF Lifecycle with ADF Faces. Example 30–14 shows the overwritten broadcast method for the tagPane component. Example 30–14 The broadcast Method in the tagPane Component param facesEvent faces event throws AbortProcessingException exception during processing Override public void broadcastFacesEvent facesEvent throws AbortProcessingException { notify the bound TagSelectListener if facesEvent instanceof TagSelectEvent { TagSelectEvent event = TagSelectEvent facesEvent; utility method found in UIXComponentBase for invoking method event expressions broadcastToMethodExpressionevent, getTagSelectListener; } super.broadcastfacesEvent; }

30.4.5 How to Add the Component to the faces-config.xml File

After creating the component class, register the component by adding it to the META-INFfaces-config.xml file. By defining the component in the faces configuration file packaged with the JAR project, you ensure that component is automatically recognized by the JSF runtime during web application startup. To register the component, enter the component type, which is a logical name used by the applications factory to instantiate an instance of the component. For example, the tagPane component’s type is oracle.adfdemo.acme.TagPane. You also need to add the fully qualified class path for the component, for example oracle.adfdemo.acme.faces.component.TagPane.