While JSF allows you to bind a component in the user interface directly to any JavaBean, the best choice is to use JSF managed beans.
Managed beans are any JavaBeans used by the application that are registered in the JSF configuration file
faces-config.xml. In an application that uses ADF data bindings and ADF task flows, managed beans should be registered in either the configuration file
adfc-config.xml or a task flow definition file.
When the application starts up, it parses the configuration file (or files) and the beans are made available. Whenever a managed bean is referenced (for example in an EL expression as a value for a component's tag attribute - called a value expression), the Managed Bean Creation Facility instantiates the bean by calling the default constructor method on the bean. If any properties are also declared, they are populated with the declared default values.
To define a managed bean, you add an entry to the configuration file, giving a symbolic name that you will use to refer to the bean and identifying the class to be used to instantiate the bean. You use the symbolic name to identify the bean when you need to refer to the bean's properties and methods. Because you are using a symbolic name rather than referring to the bean directly, the presentation is kept separate from the application logic, which means that you can change the model without affecting the view.
A managed bean is registered using the
<managed-bean> element in the configuration file. You can add managed beans to your configuration file either by editing the XML in the file manually, or by using the overview editor for
In the example, from the overview editor for
faces-config.xml you will use the Create Managed Bean dialog to register and create a new managed bean. The Create Managed Bean dialog has an option that lets you create the bean class if it does not already exist:
When viewed in the XML editor, the managed bean registration in the configuration file looks like this:
<managed-bean> <managed-bean-name>dnd</managed-bean-name> <managed-bean-class>MyPage</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean>
The scope of a managed bean determines the scope within which the bean is stored. The following are the valid scopes for a bean:
application: The bean is available for the duration of the web application. This is helpful for global beans such as LDAP directories.
session: The bean is available to the client throughout the client's session.
request: The bean is available from the time it is instantiated until a response is sent back to the client. This is usually the life of the current page.
none: The bean is instantiated each time it is referenced. This is helpful if the bean is referenced within another bean.
The following scopes are available only in an ADF application:
backingBean: To be used by any backing bean for a region or declarative component as the same region or declarative component on a page needs to have its own separate scope.
pageFlow: Memory scope for passing data between activities within the ADF bounded task flow.
pageFlowscope defines a unique storage area for each instance of an ADF bounded task flow. Its lifespan is the ADF bounded task flow, which is longer than
requestscope and shorter than
view: If specified, JDeveloper retains objects used on a page as long as the user continues to interact with the page. The objects are automatically released when the user leaves the page.
Copyright © 1997, 2009, Oracle. All rights reserved.false ,,,,,,,,,,,,,,,