JPA Layer:
1. Make project
2. Make DB connection
3. Convert project to JPA project — use connection from step 2
4. Make JPA entities – give them properties
4a List them as “managed” in persistence.xml
5. Make tables
EJB (business logic) Layer:
1. Make EJB classes that manipulate JPA entities in JPA layer.
2. Annotate EJB classes as:
@Stateless
@LocalBean
and:
@PersistenceContext
EntityManager em;
3. Give the EJB classes methods to be called from the View layer
View Layer (Web, specifically)
0. If faces-config.xml doesn’t exist, do Project Properties->JPA
->Project Facets
1. In faces-config.xml, make new Managed Bean classes. Give them
Session scope.
2. Annotate them with:
@EJB
BookEJB bookEJB; // for example
3. Put properties in the managed bean classes that will be
bound to the fields in the web pages.
4. Make methods in the managed bean classes that will be bound to
the buttons/links etc. in the web pages. The methods should return
strings that tell the JSF engine which page to load next.
5. Make xhtml file(s). Be sure to put the following before the
header:
xmlns:ui=”http://java.sun.com/jsf/facelets”
xmlns:h=”http://java.sun.com/jsf/html”
xmlns:f=”http://java.sun.com/jsf/core”
Order matters.
6. Make a form. Put components in the form that are bound to the
managed bean class properties.