JBoss.orgCommunity Documentation
JSF Tools provides a number of useful features when working with managed beans, such as:
Adding and generating code for new managed beans
Generating code for attributes and getter/setter methods
Adding existing managed beans to a JSF configuration file
This guide will look at each of these features in more detail.
To begin, create a new managed bean in JSF configuration file editor using the Tree view.
When you define a new managed bean, make sure that Generate Source Code option is checked as shown in the figure below.
After the Java class has been generated you can open it for additional editing. There are two ways to open a Java class:
Click on the Managed-Bean-Class link in the editor.
Right click the managed bean and select the option.
The generated Java source should look as follows:
You can also generate source code for properties, also includes getter and setter methods. Right click on the bean and select Add Property dialog.
→ . You will then see theWhen the form is open make sure that all the check boxes are selected:
Add Java property
Generate Getter
Generate Setter
Once the generation is complete, you can open the file and see the newly added property with accompanying "get" and "set" methods:
This covers the options available when creating a new Managed Bean. The next section will show you how to add an existing Bean into a JSF configuration file.
If you already have a Java bean you can easily add it to a JSF configuration file.
You should start the same way you create a new managed bean. Use the
button to add your existing Java class.Once the class is set, its Name will be set as well. But you can easily substitute it for the other one. Notice that Generate Source Code option is not available as the Java class already exists.
After adding your class the Managed Properties dialog where all corresponding properties are displayed. Checking the appropriate ones will add them into your JSF Configuration File.
button will be activated. When you click it you will be presented with theIf you don't want to add any, just click the
button.
The steps above have demonstrated how you can add an existing Bean to the JSF configuration file, i.e. faces-config.xml
. The next chapter will demonstrate how to organize and register other kinds of artifacts.