In the example, you will create a method and attach it to the command button component on the
Start.jsp page. The method will capture the value entered by the user in the input text field, then display the value in the output text field below the input field.
To implement the behavior described, you will use a backing bean for the page. A backing bean is a JSF managed bean that contains logic and properties for UI components on a page. Backing beans can act as the state holder of user input and the UI components' data. Backing beans are useful for implementing validation methods and event handler methods that invoke back end application code with component values.
To create a backing bean, you will do the following:
A JSF managed bean is a JavaBean whose instantiation and scope you declaratively set up in the
faces-config.xml file. The JavaBean can be any existing class (such as a data transfer class), or it can be a class specific to a page only (hence it is called a backing bean). A backing bean contains the properties that hold the page's data, along with the corresponding accessor methods and/or any other methods (such as navigation or validation) used by the bean. JDeveloper can automatically create a backing bean for a page, or you can elect to create your own backing bean that contains all the properties and logic for the page.
In the example, before you create the managed bean, you will enable the Auto Bind option to turn on automatic component binding for the page, so that JDeveloper can automatically create a backing bean for the page you're working with.
To begin enabling automatic component binding for the page, you will open the page in the visual editor, then you will choose Desi gn Page Properties from the main menu.
In the Page Properties dialog, you will select the Component Binding tab, then select the Auto Bind checkbox.
To create a backing bean for the page, you will click
to use the Create Managed Bean dialog to create and configure a managed bean in
In the Create Managed Bean dialog, you will specify a bean name, a class name, a package name, and select the Generate Class If It Does Not Exist checkbox to generate the backing bean file.
To create and attach an action method to the command button on the page, you will use the Bind Action Property dialog to generate a starter action method in the backing bean. Then you will use the source editor to edit the backing bean by adding code to the action method.
Copyright © 1997, 2009, Oracle. All rights reserved.