Displaying, creating, and updating JPA data on Web pages

  1. Create a dynamic Web project and activate the Java™ Persistence facet.

  2. Create JPA entity beans or Import JPA entity beans into a project.

  3. Configure JPA entity beans.

  4. Create JPA manager beans.

  5. Configure JPA manager beans.

  6. Create a Web page.

To display a JPA data on a Web page in order to view a list of data, view a data record, create new data, or update existing data:

  1. Expand the Data and Services drawer in the Palette.

  2. Drag the JPA Data component onto the Web page. The Add JPA data to page wizard opens.

  3. Select the JPA Manager that you want to use in your page.

  4. Select a method for displaying the data:

    • If you want to display a list of data, click

      Retrieve a list of data.

    • If you want to display a single record, click

      Retrieve a single record.

    • If you want to create a form that can create a new record, click

      Create a new record.

    • If you want to create a form that enables you to update an existing record, click

      Update an existing record.

  5. Click Next.

  6. Select the query that will retrieve the data that you want to display.

    Important: This step only applies to displaying a list of data, displaying a single record, and updating an existing record.

    If you selected Retrieve a single record or Update an existing record, you have the option of querying the data based on primary key or selecting a query for the list.

  7. If you select a query that requires user input, you need to set the filter parameters for the query on the Set filter values page of the wizard.

  8. Click Next until you get to the Configure data controls page of the wizard.

  9. Specify how you want to display the data on your Web page. You can add and remove data, reorder the fields, change the labels, and change some of the control types. Click Finish.

    Note: It is also possible to display JPA data on a Web page by dragging JPA manager beans or JPA page data from the Page data view onto the Web page.