# Creating a Managed Bean

Now you create a Managed bean to interact with two JSP Pages that you will define later.

To create a managed bean:

1. 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.

   Create Managed Bean

2. 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.

   New Managed Bean Wizard

3. 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.

   Java Class Page of New Managed Bean Wizard

   Click Next.

4. 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.

   Managed Bean Configuration Page of New Managed Bean Wizard

   Click Next.

5. 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.

   Summary Page of New Managed Bean Wizard

   Click Finish.

6. 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.

   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.

   faces-config.xml in Editor

7. In the editor, click the Managed Bean tab as shown in Figure: Managed Beans in faces-config.xml.

   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.

   Managed Bean Tab of faces-config.xml in Editor

8. The `LoginBean.java` class opens in the java editor, as shown in Figure: LoginBean Class in Editor.

   LoginBean Class in Editor

9. 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.

   LoginBean Class in Explorer

10. 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;

    LoginBean Class with New Variables

11. Open the Source menu by pressing Alt+Shift+S. Select Generate Getters and Setters from the menu, as shown in Figure: Source Menu.

    Source Menu

    Alternatively, right-click in the editor and choose Source > Generate Getters and Setters.

12. 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.

    Generate Getters and Setters Dialog

    Ensure that After 'password' is selected for Insertion Point. This is the location of the method code. Click OK.

13. The generated code appears in the editor, as shown in Figure: LoginBean Class in Editor.

    LoginBean Class in Editor

14. Click Save All to save your work.