Binding a Managed Bean to a Control

After you create a managed bean, you must bind the managed bean, or a method or property of the managed bean, to a component on a JavaServer Faces (JSF) Web page. A managed bean property provides data for the Web page and a managed bean method binds logic to a component.

You can drag the following items from the Data Bindings view and drop them onto the Web Page editor.

The following procedure is specific to binding a managed bean property to a control. Binding the managed bean method, managed bean, or an existing bound managed bean name is similar, but wizards will be specific to the item you are working with and, therefore, steps will vary.

To bind a managed bean property to a control:

  1. Select the .jsp Web page file that you want to work with in the WorkSpace Navigator.

    The Web page opens in the Web Page editor.

  2. In the Data Bindings view, select the managed bean property or method that you want to use and drag and drop it onto the Web page.

    The Create JSF components wizard opens.

  3. To map the JSF components to the managed bean attributes:

    1. Deselect attributes that you do not want to map.

    2. Edit a JSF component by clicking in its cell, clicking the down arrow that appears, and selecting a new component.

    3. Edit the text in the Label column to the appropriate name for each class member.

    4. To move an attribute up or down in the list, select the attribute and click Move up or Move down.

    5. Do one of the following:

      • Click Next to configure a container to hold the new components.

      • Click Finish to accept the defaults and skip the rest of this procedure.

  4. On the Create JSF component for the ManagedBean member page, do one of the following:

    • To use a table-type container:

      1. Select Use table-typed container to hold components.

      2. Select either a JSF panelGrid or an HTML table.

      3. Type the number of component pairs that you want to appear in each row in the text box.

    • To use a non-table typed container, unselect Use table-typed container to hold components.

    The generated code from your selections is displayed.

  5. Click Finish.

    The Web page with your selections is generated.

  6. Select File|Save from the main menu bar to save the Web page.

Building a Web Page Using a Managed Bean

Configuring a Managed Bean

Developing a Web Application

WorkSpace Navigator

Web Application Development Views

JavaServer Faces

Send your feedback on this help topic to Sybase Tech Pubs: pubs@sybase.com