Step 3: Adding a Field to the Session Bean

Previous topic
Previous
Next topic
Next

Now that your session bean has been created, you will add a new field, company.

To create a new field:

  1. On the UML diagram, click into the first empty compartment on the session bean to create a new attribute. Type company : String to create a field called company of type String.

  2. Click outside of the session bean to remove the focus.

The field you added in the UML diagram is synchronized with the other tools. To see this, take a look at the EJB Module Editor.

To open the EJB Module Editor:

  1. In the UML diagram, double click anywhere on the session bean to open the EJB Module Editor. Alternatively, in the Navigator, right-click on your session bean (hrApp) and chose Edit EJB.
  2. Expand the node for your session bean (hrApp) and click the Fields node.
    Notice that the field you added in the UML diagram appears in the Fields page of the EJB Module Editor. The EJB Module Editor is used to edit the EJB module or any of the EJBs contained within.
  3. Close the EJB Module Editor.

To view the Java code that this step added, take a look at the Code Editor.

To view the generated code in the Code Editor:

  1. In the Navigator, expand the folders for you project (EJB-Tier.jpr), the EJB module (ejb-jar.xml), and your session bean (hrApp).
  2. Double click on your bean class (hrAppBean.java).
    The file opens in the Code Editor.
  3. In the Structure pane of the Navigator, double click getCompany() to jump to that method in the code.
    Notice that the framework generated getter and setter methods for the field you added in the UML diagram.