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

30-32 Web User Interface Developers Guide for Oracle Application Development Framework In JSF 1.2, the target for Java EE 5 Servlet 2.5, JSP 2.1, most of the JSP problems were fixed. The JSFJSP component acts as a component factory that is responsible only for creating components. This means that the rendering response phase is divided into two steps. First the component tree is created, and then the tree is rendered, instead of rendering the components as the component tree was being built. This functionality was made possible by insisting that the entire view be represented by JSF components. The non-JSFJSP generates markup that implicitly becomes a JSF verbatim component. As a result of changing these mechanics, in JSF 1.2, custom JSP tags extend the javax.faces.webapp.UIComponentELTag class. The encodeBegin, encodeChildren, and encodeEnd methods in the JSP tag have been deprecated. These methods once made corresponding calls to the component. Because the view root in JSF 1.2 does the rendering, all the work can be done in the doStartTag and doEndTag methods. MyFaces Trinidad has its own version of this base class that you will use. The org.apache.myfaces.Trinidad.webapp.UIComponentELTag hooks into the components property bag and makes coding JSPs simpler. The tag class includes the creation of the component’s properties. You must choose tag properties carefully. There are some properties that you can ignore for tag implementation, but they may be required as TLD attributes. The following three attributes are implemented by superclasses and shared by many components through Java inheritance: ■ id ■ binding ■ rendered Do not implement the id attribute because the id attribute is implemented by the superclass javax.faces.webapp.UIComponentTagBase. The superclass javax.faces.webapp.UIComponentELTag implements the other two attributes, binding and rendered. Therefore, you do not need to add these to your tag class. To add a JSP tag: 1. In the Application Navigator, right-click the project and select New. 2. In the New Gallery, expand General then select Java. 3. Select Java Class and click OK. 4. In the Create Java Class File dialog, do the following: ■ Name : Enter a tag name. For example, for the tagPane component, you might enter TagPaneTag. ■ Package : Enter a name for the package. For example, for the tagPane component, you might enter oracle.adfdemo.acme.faces.taglib. ■ Class : Enter org.apache.myfaces.trinidad.webapp.UIXComponentELTag. ■ In the Optional Attributes section, select the following:. – In the Access Modifiers section, select public. Note: An application that uses Facelets uses a handler to instantiate the component. For more information, see Section 30.2.8, How to Add a Facelets Tag Library Configuration File Creating Custom ADF Faces Components 30-33 – At the bottom, select Constructors from Superclass and Implement Abstract Methods . 5. In the source editor, add all the attributes to the file. Example 30–19 shows the code for the attributes for the TagPaneTag class. Example 30–19 Attributes in the TagPaneTag Class public class TagPaneTag extends UIXComponentELTag { private ValueExpression _partialTriggers = null; private ValueExpression _visible = null; private ValueExpression _inlineStyle = null; private ValueExpression _styleClass = null; private ValueExpression _tags = null; private ValueExpression _orderBy = null; private MethodExpression _tagSelectListener = null; 6. To declaratively generate the accessor methods for the attributes, right-click the file in the source editor and choose Generate Accessors.

7. In the Generate Accessors dialog, click Select All, set the Scope to public and

click OK. 8. Add the render type and component type to the class. The component type will be used by the superclass to instantiate the component using the applications factory method, createComponentcomponentType. Example 30–20 shows the code for the TagPaneTag class, where both the component type and render type are oracle.adfdemo.acme.TagPane. Example 30–20 Component Type and Render Type for the TagPaneTag Class public String getComponentType { return COMPONENT_TYPE; } public String getRendererType { return RENDERER_TYPE; } pThis components type, codeoracle.adfdemo.acme.TagPanecodep static public final String COMPONENT_TYPE = oracle.adfdemo.acme.TagPane; pLogical name given to the registered renderer for this component.p static public final String RENDERER_TYPE = oracle.adfdemo.acme.TagPane; 9. Override the setProperties method from the superclass that has a single formal parameter of type FacesBean. This is a MyFaces Trinidad version on the base UIComponentELTag, but it is passed the components state holder instead of the component reference. The job of the setProperties method is to push the JSP tag attribute values to the component. Example 30–21 shows the overridden method for the tagPaneTag class.