First page Back Continue Last page Graphics

Using JSF Managed Beans


Using JSF Managed Beans

JSF components are a type of JavaBean, and they are also designed to work with another type of JavaBean called a managed bean. Often managed beans handle events or some manipulation of data that is best handled at the front end rather than placing the logic in a business component. However, all application data and processing should be handled by logic in the business layer of the application.

Some typical uses for managed beans are:

To hold values that can be used by multiple pages

To execute a method in response to user interaction, such as a button click

To execute a method when a UI event, such as a value change, takes place

Backing beans are a specialized type of managed bean that exposes some or all of the UI components on the page by defining accessors for them. When you create a JSF page, the Page Implementation section of the Create JSF Page dialog box enables you to choose whether to expose the UI components, which you would need to do only if the page requires special code to manipulate its components programmatically. For example, you may set a condition to determine whether to render the component. If you choose to expose components in a managed bean, JDeveloper automatically adds stubs for accessors as you add components to the page. Backing beans are directly related to pages, whereas other types of managed beans can be made available to multiple pages.