Creating Composite Components

See Also

JSF 2.0 has simplified the process of creating composite user interface (UI) components, which can be reused in web pages. You can use the IDE's Composite Component wizard to generate a Facelets template for a JSF composite component.

You can access the Composite Component wizard from the JavaServer Faces category in the IDE's File wizard (Ctrl-N). However, a more intuitive way to prompt the wizard is by highlighting the code snippet from a Facelets page in the editor, then choosing Convert to Composite Component from the right-click menu.

To create a new composite component:

  1. Open a Facelets page contained in your project. (In the Projects window, double-click any Facelets Page node to open it in the editor.)
  2. In the editor, highlight the snippet you want to create a component from.
  3. Right-click the highlighted snippet and choose Convert to Composite Component. The Composite Component wizard opens, containing the selected snippet in its Implementation Section panel.
  4. In the File Name field, type in a name for the composite component.
  5. In Location, specify the top-level location for the file. ('Web Pages' is the default option, and places the file in the project's web root.
  6. In Folder, specify a folder that will contain the composite component. The resources/ezcomp folder is provided by default. If the folder does not already exist, the wizard creates it.

    The Created File field provides a read-only path to the new location for the component.
  7. Click Finish. The new composite component source file is generated in the specified location, and a new component tag is inserted into the location in the editor where you highlighted the snippet. The namespace for the component is also automatically added to the page's <html> tag.
See Also
Creating JSF Pages
Editing JSF Pages
Creating Managed Beans
About JavaServer Faces Framework Support

Legal Notices