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:
    
    
      - 
        Create a web-based application workspace:
        
          - 
            In the Navigator, right-click Applications
 and choose New Application Workspace from the 
            context menu.
 The Create Application Workspace dialog opens.
- 
            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
 
- 
        Create entity beans:
        
          - 
            Right-click the Model project and 
            choose New.
 The New Gallery opens.
- 
            In the Business Tier category, choose 
Enterprise JavaBeans and in the Items list 
            choose EJB Diagram. Click 
OK.
          
- 
            Provide details in the Create EJB dialog and click 
OK.
          
- 
            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.
          
 
- 
        Implement a session facade:
        
          - 
            In the Component Palette, click Session Bean
 and then click in the diagram.
 The Create Enterprise JavaBean Wizard opens.
- 
            Follow the steps in the wizard, making sure to select a stateless 
            session bean and generating local interfaces.
          
- 
            In the Component Palette, select EJB Local 
            Reference and draw a line between the session bean and the 
            entity beans it will access.
          
 
- 
        Create data transfer objects (DTO):
        
          - 
            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.
- 
            Double click the <entity>LocalDTO.java
 file to open it in the code editor.
          
- 
            Uncomment the _loadmethod.
 
- 
        Add business methods:
        
          - 
            Create attributes and methods on the session bean that access the 
            entity bean(s).
          
- 
            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.