Once you create a java bean, you will need to set up the management of the bean. While JSF allows you to bind a component in the user interface directly to any java bean, the best choice is to use JSF managed beans.
Managed beans are any java beans used by the application that are
registered in the JSF faces-config.xml
file. When the JSF
application starts up, it parses this configuration file 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 binding), 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.
Managed beans are registered using the <managed-bean>
element of the faces-config.xml
file.
To define a managed bean, you add an entry to the JSF 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.
You can add managed beans to your JSF configuration file either by editing the XML in the file manually, or using the JSF Configuration Editor, which provides dialogs and browse features for finding class file references for your beans. If you have not already created the bean, you can use the dialog to ask for a bean file to be created for you.
Copyright © 1997, 2006, Oracle. All rights reserved.