Show TOC

Procedure documentationUsing CRUD Application Template Locate this document in the navigation structure

 

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

  1. Select an entity. In its context menu, choose Apply Template...

  2. Expand the Java EE node and choose CRUD Application. Choose Next.

  3. (Optional) Specify the following settings:

    • In the EJB project field, specify the project where the stateless session beans will be created.

    • In the Web Project field, specify the project where the JSF page will be created.

    • In the EAR project field, specify the EAR project that will be deployed.

    You can use an existing EJB, Web, and EAR projects or create new ones. At this point you can 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.

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

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

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

    End of the note.
  7. In the context menu of the EAR Project, choose   Run As   Run on Server  . After deploying the application, the JSF page appears in a Web browser integrated in the Developer Studio.