How to Create a Javascript File for an Event

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. Server-side JSF events are queued by the component during the Apply Request Values lifecycle phase. Events propagate up to the UIViewRoot class after all the phases but the Render Response phase. Queued events are broadcast to the associated component. The server-side Java component must raise the server-side event, so you must create the event source file first to resolve the compilation dependency. To create the server-side event 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 and click OK. 4. In the Create Java Class File dialog, do the following: ■ Name : Enter an event name. For example, for the tagPane component, you might enter TagSelectEvent. ■ Package : Enter the package name. For example, for the tagPane component, you might enter oracle.adfdemo.acme.faces.event. ■ Extends : Enter a name for the class that the event class extends. This is usually javax.faces.event.FacesEvent. ■ 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 . Example 30–10 shows the code for the event class. Example 30–10 tagPane Event Java Code package oracle.adfdemo.acme.faces.event; import javax.faces.component.UIComponent; import javax.faces.event.FacesEvent; import javax.faces.event.FacesListener; public class TagSelectEvent extends FacesEvent { pTag selected on the client.p private String tag = null; Creating Custom ADF Faces Components 30-23 pOverloade constructor passing the codesourcecode {link oracle.adfdemo.acme.faces.component.TagPane} component and the selected codetagcode. p param source component firing the event param tag selected tag link type public TagSelectEventUIComponent source, String tag { supersource; this.tag = tag; } pReturns codetruecode if the codefacesListenercode is a {link TagSelectListener}.p param facesListener listener to be evaluated return codetruecode if codefacesListenercode instancof {link TagSelectListener} public boolean isAppropriateListenerFacesListener facesListener { return facesListener instanceof TagSelectListener; } pDelegates to the codeprocessTagSelectcode method of a codeFacesListenercode implementing the {link TagSelectListener} interface. param facesListener target listener realizing {link TagSelectListener} public void processListenerFacesListener facesListener { TagSelectListener facesListener.processTagSelectthis; } return the tag that was selected triggering this event public String getTag { return tag; } }

30.4.3 Creating the Component

A JSF component can be described as a state holder of properties. These properties define behavior for rendering and how a component responds to user interface actions. When you are developing the component class, you identify the types of the needed properties. You also define the base component that it will extend from the MyFaces Trinidad Framework. For example, the tagPane component extends the UIXObject in MyFaces Trinidad. Most components will have several properties that should be implemented. Some of the properties are inherited from the base class, and some are required for the rich client framework. Other properties are required because they are best practice. And finally, some properties are specific to the functionality of the custom component. 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.