Now you create a Managed bean to interact with two JSP Pages that you will define later.
To create a managed bean:
In the Project Explorer, expand ADFFacesTutorialWeb project and then the Faces Configuration node. Right-click Managed Beans and choose New Managed Bean, as shown in Figure: Create Managed Bean.
In the New Managed Bean wizard, select the Create a new Java class option, as shown in Figure: New Managed Bean Wizard and click Next.
In the Java Class page of the New Managed Bean Wizard, change the default package name to tutorial and enter LoginBean as the name, as shown in Figure: Java Class Page of New Managed Bean Wizard. Leave other options to default values.
Click Next.
On the Managed Bean Configuration page of the New Managed Bean Wizard, check that the Scope is set to session, as shown in Figure: Managed Bean Configuration Page of New Managed Bean Wizard.
Click Next.
The Summary page of the New Managed Bean Wizard displays the properties for the bean, as shown in Figure: Summary Page of New Managed Bean Wizard.
Click Finish.
Creating the managed bean added several entries in the Project Explorer, one is the new loginBean in the Managed Beans node, as shown in Figure: loginBean in Project Explorer.
Double-click loginBean to open the faces-config.xml file where the bean is referenced, as shown in Figure: faces-config.xml in Editor.
In the editor, click the Managed Bean tab as shown in Figure: Managed Beans in faces-config.xml.
Select loginBean and click the Managed Bean class link, as shown in Figure: Managed Bean Tab of faces-config.xml in Editor.
The LoginBean.java class opens in the java editor, as shown in Figure: LoginBean Class in Editor.
Notice that in the Project Explorer, the LoginBean Java class is under the Java Resources, src nodes in the tutorial package, as shown in Figure: LoginBean Class in Explorer.
In the LoginBean class in the editor, add two String type variables for userName and password, as shown in Figure: LoginBean Class with New Variables.
private String userName;private String password;
Open the Source menu by pressing Alt+Shift+S. Select Generate Getters and Setters from the menu, as shown in Figure: Source Menu.
Alternatively, right-click in the editor and choose Source > Generate Getters and Setters.
In the Generate Getters and Setters dialog select the two variables you want to create getters and setters for, as shown in Figure: Generate Getters and Setters Dialog.
Ensure that After 'password' is selected for Insertion Point. This is the location of the method code. Click OK.
The generated code appears in the editor, as shown in Figure: LoginBean Class in Editor.
Click Save All
to save your work.