Developer Tools
JDeveloper
In addition to JSF navigation rules, other resources that your application needs are also specified in the JSF configuration file,
faces-config.xml. The resources an application might need include files that contain the text to be displayed by the application pages, and JavaBeans that define the data for the application to work with.
In the example, you will create a JSF managed bean for holding and processing input data. Then you will create a method that handles an event to provide the navigation between pages following the rules already defined in the
faces-config.xml file.
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.
To begin creating a managed bean, 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
N
ew
to use the Create Managed Bean dialog to create and configure a managed bean in
faces-config.xml.
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 that will determine which page to display when the Login command button is clicked, 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 add the action method code.
Copyright © 1997, 2009, Oracle. All rights reserved.