HTML and CSS Reference
(CDI Managed Beans)
CRUD using JPA
Figure 10-6. Weather application structure
As shown in the previous figure, the application has the following structure:
XHTML pages: These represent the weather application pages. It uses both the backing
beans and managed beans using the JSF expression language (EL).
Backing beans: These are normal managed beans that are conceptually related to the UI
pages and are not part of the application model. Backing beans are ideal for centralizing
the handling of the page actions. In the weather application, backing beans mainly get
the instances of the managed beans which carry the user's entered data and then call the
UserManager EJB in order to perform the required operation.
User Manager EJB: In order to perform the different business operations, backing beans
call UserManager EJB. UserManager EJB is a stateless session EJB* which uses the JPA
entities and the JPA EntityManager in order to perform the required database operations.
JPA entities (CDI managed beans): JPA entities represent the data classes that map to the
database tables. In the weather application, the JPA entities are used as the application's
CDI managed beans which are binded with the XHTML pages using EL.
Notice that for simplicity the application uses Oracle Java DB. Java DB is Oracle's supported distribution of the
Apache Derby open-source database. It supports standard ANSI/ISO SQL through the JDBC and Java EE APIs and is
included in the JDK.
■ it is important to know that Jpa can be used without eJBs; however, using eJBs in Jpa applications has a
great advantage, which is handling application transactions implicitly through the eJB container (container-managed
transaction). although the weather application is a basic JsF 2.2 application, we insisted on introducing eJBs with Jpa in
it in order to show you how these technologies can work together inside a JsF 2.2 application.
In the next sections, we will go into the details of the application components.
■ it is important to note that going into the details of eJB and Jpa is outside the scope of this topic.
in order to know learn the capabilities of them, we recommend you to read the oracle Java ee tutorial: