Creating a property template for JSF library components

Property templates determine how a component will access and display data on a page. These templates establish the options that display in the data wizards that you use when you drag data from the Page Data View onto a Web page. Use the templates to remove or add options to the wizard lists or change the tags that are generated when the components are added to the page.

  1. Create a JSF enabled dynamic Web project.

  2. Create a JSF page.

To create a property template:

  1. Click

    Window | Preferences | Web | JavaServer Faces Tools | Generation Templates. Select one of the three types of templates:

    • Data Templates

    • Iterative Templates

    • Method Templates
    The template preferences window opens and displays all of the currently defined templates.

  2. Click

    New. The New Template dialog opens.

  3. In the Name field, enter the name of the template that you are creating. This is the name that will display in the data wizards. Click

    Use for input if the template will be used for input controls. In the Class field, enter the Java™ class of the template. Click

    Default template for this class to set this template as the default data type selection in the data wizard. In the Description field, enter a description for your template.

  4. Use the Pattern text box to determine how the control will display. You can paste tags from another template or JSP file into the text box, or you type the tags. For example:

    <${h}:outputText styleClass="outputText" id="${id}" value="#{${value}}">
    </${h}:outputText>
    The pattern will include variables that are dynamically computed based on the Web page where the template is used and the data to which the component is bound. To see a list of available variables, click

    Insert Variable. The available variables include taglib prefixes, for example the core JSF taglib http://java.sun.com/jsf/core, and attributes, for example value. When a variable is inserted into a pattern, it displays as ${variable_name}. For example ${action}.

  5. Click OK. The New Template dialog closes.

  6. Click OK. The Properties dialog closes.

Once you have created a property template for the JSF library components, you can create Web pages that access data by dropping data onto a Web page from the Page Data View. This will launch the data wizard that enables you to select control types for the property templates that you have edited and created. For more information on adding data to a Web page, refer to Adding data to a JSF page using data viewing components.