Show TOC

Using CRUD Application TemplateLocate this document in the navigation structure

Use

You can use the four basic functions - create, read, update, and delete (CRUD), to work with the database. This template enhances the Session Bean CRUD Facade template and generates not only a CRUD facade using stateless session beans, but also user interface (UI) components. These components are Java Server Faces (JSF)-based UI components with an SAP look and feel. After generating the template for a particular entity, you can implement the business logic of your application.

Prerequisites

You have an EJB project created with Java Persistence facet with at least one entity to which you want to apply the CRUD Application template. This entity needs to have a primary key. If it has additional attributes, you can create named queries for these attributes and use them for searching.

Procedure

You can create a CRUD facade and a user interface in the Project Explorer of the Java EE perspective, or in the JPA diagram editor.

  1. In the Project Explorer , expand the ejbModule node of your EJB project, and select an entity.

  2. In the context menu, choose Apply Template .

  3. Select CRUD Application , then choose Next .

  4. (Optional) Specify the following settings:

    • In the EJB project field, specify the project to store the stateless session beans.

    • In the Web project field, specify the project to store the JSF page.

    • In the EAR project field, specify the EAR project to be deployed.

    You can use an existing EJB, Web, and EAR projects, or create new ones. At this point, you can also specify another entity to apply this template to by choosing another persistence unit from a different project in the Persistence Unit field, and selecting the appropriate checkbox in the Entities field. Choose Next .

  5. (Optional) Specify the bean class, name, and package for the session bean, then choose Next .

  6. (Optional) Specify additional information about the session bean such as the mapped name and transaction type, then choose Next .

  7. (Optional) Select the appropriate fields for the name queries and choose Finish .

    A stateless session bean together with its local interface and a JSF page are created.

    Note

    You use these named queries if you want to search by some of the attributes of the entity. They appear as search fields in the generated UI.

  8. In the context menu of the EAR project, choose Start of the navigation path Run As Next navigation step Run on Server End of the navigation path. After deploying the application, the JSF page appears in a Web browser integrated in the Developer Studio.