Creating Managed Beans
See Also
You can create JSF managed beans for your application using the IDE's Managed Bean wizard.
In JSF 2.0, any metadata that you specify in the wizard is translated into annotations
that are applied to the managed bean once it is generated. If you prefer to register the
managed bean with the application using a Faces configuration file (faces-config.xml
)
instead, the wizard provides the option of doing so.
To create a new JSF managed bean:
- In the Projects window, right-click your project node and choose New >
JSF Managed Bean. The JSF Managed Bean wizard opens.
(If JSF Managed Bean is not listed, choose Other. Then select the JavaServer
Faces category and JSF Managed Bean file type. Click Next.)
- In the Class Name field, type in a name for the managed bean.
- In Location, specify the top-level location for the file.
('Source Packages' is the default option, and places the file in the project's
src/java
folder.
- In Package, specify a package name for the new class. If you
specify the name of a package that does not exist, it will be created upon
completing the wizard. The Created File field provides a read-only
path to the new location for the file.
- (Optional.) If you want to to register the managed bean with the application using
a Faces configuration file, select the 'Add data to configuration file' option.
Doing so will prevent the wizard from generating annotations in the new class. If
a
faces-config.xml
does not yet exist for the application, one will be
created upon completing the wizard.
- (Optional.) Specify configuration details:
- Name: Specifies the name which the managed bean can be
invoked by. If left blank, the managed bean can be accessed using the name
of the managed bean class, but with the first letter in lowercase.
- Scope: Specifies the scope into which a newly created
instance of the specified managed bean will be stored. (Default is
request
; choose none
if you want to refrain
from placing bean instances in any scope).
- Description: A textual description of the element, which
can be flagged with a language code using the
xml:lang
attribute.
- Click Finish. The new managed bean is generated and opens in the editor.
- See Also
- Creating JSF Pages
- Editing JSF Pages
- Creating a New Application with JSF Support
- About JavaServer Faces Framework Support
Legal Notices