A custom component library contains new and modified JSF
components that you can use in your Web applications and distribute
the libraries to your development team.
About this task
To create and add a custom component to a custom component
library.
Procedure
- Click . Click Next.
The New Web Page wizard opens.
- In the File Name field, type a file
name for your custom component. In the Template list, click Faces
Custom Component. Then click Finish.
The JSP opens.
This JSP is a page fragment that wraps
custom component tags within the <jsfc:component> tags:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@taglib uri="http://www.ibm.com/jsf/customcomponent" prefix="jsfc"%>
<jsfc:component>
</jsfc:component>
The custom component tag, <jsfc:component>,
contains the other JSF components that you will add to your custom
component.
- Define the attributes
for the custom component tag.
- Add your custom component tags to the JSP. You
can add the tags using different methods:
- Type the tags into the Source view of Page Designer.
- Drop an existing tag or group of tags from the Palette onto the
page.
- Drop the component from the Page Data View onto the page.
Save the file. The JSF component, tag class, and associated configuration
files are created in the component library project. The new JSF component
class, custom tag class for each custom component page, faces-config.xml,
and tag library definition (JLD) file is added to the tag library
JAR file.Tip: A test page is automatically generated when
you save the component. To test your component, right-click the test
page in Enterprise Explorer and select .
Follow the instructions in the Run On Server wizard.
What to do next
Once you have added your custom component to your custom
library, you can use your custom components to
create page content. To add the custom
components to the palette, refer to
Creating a JSF Library Definition
(JLD). To distribute the components to other users, refer to
Distributing a component library.