Developing the Model Layer for a Web-based EJB Application

The most efficient way to develop a web-based EJB application is to use the Oracle Application Development Framework (ADF). This framework automatically implements the MVC design pattern.

The steps below are intended to quickly get you started creating the model for a web-based EJB application. For more detailed information, see the topics in Working With the Oracle Application Development Framework.

To create the model layer for a web-based EJB application:

  1. Create a web-based application workspace:
    1. In the Navigator, right-click Applications and choose New Application Workspace from the context menu.
      The Create Application Workspace dialog opens.
    2. In the dialog, click the Application Templates list and choose Web Application [JSP, Struts, EJB] . Click OK. (You can also opt to have no controller.)
      Two new projects appear, Model and ViewController
  2. Create entity beans:
    1. Right-click the Model project and choose New.
      The New Gallery opens.
    2. In the Business Tier category, choose Enterprise JavaBeans and in the Items list choose EJB Diagram. Click OK.
    3. Provide details in the Create EJB dialog and click OK.
    4. Drag and drop database tables onto the diagram to create CMP entity beans. If you need help creating a database connection, see Defining Database Connections. If you do not have a database connection you can use the Component Palette to create entity beans on the EJB diagram.
  3. Implement a session facade:
    1. In the Component Palette, click Session Bean and then click in the diagram.
      The Create Enterprise JavaBean Wizard opens.
    2. Follow the steps in the wizard, making sure to select a stateless session bean and generating local interfaces.
    3. In the Component Palette, select EJB Local Reference and draw a line between the session bean and the entity beans it will access.
  4. Create data transfer objects (DTO):
    1. In the Navigator, right-click each entity bean and choose Generate | Data Transfer Object from the context menu.
      A new file, <entity>LocalDTO.java appears in the Navigator.
    2. Double click the <entity>LocalDTO.java file to open it in the code editor.
    3. Uncomment the _load method.
  5. Add business methods:
    1. Create attributes and methods on the session bean that access the entity bean(s).
    2. If you want to populate an attribute with a collection, see Specifying the Type for a Collection.

The model layer for your web-based EJB application is far from complete, but functional. Your next step is to register the business services with the data control. For more information, see Creating Oracle ADF Data Controls for EJB Components. For additional help creating and testing your application, see the topics in Working With the Oracle Application Development Framework.


Related topics

Creating a Diagram of Enterprise JavaBeans
Developing Enterprise JavaBeans
What are Enterprise JavaBeans?

 

 

 

Copyright © 1997, 2004, Oracle. All rights reserved.