Calling an EJB from JSF
Java Server Faces (JSF) and Facelets have largely supplemented JSP and permit the use of DI. This simplifies access to the EJB but JNDI can be used if desired. JSF uses the concept of a managed bean to hold business logic. In EJB 3.1 it is not necessary to actually use a managed bean. However, both using an EJB directly and using a managed bean to access an EJB will be presented. Knowing how to use the managed bean approach can be useful especially when reviewing older code.
To access an EJB from a JSF page:
- Create a supporting EJB
- Annotate the EJB with the @Named annotation
In this example we will also package the beans in the
.warfile to demonstrate this new feature of EJB 3.1. Packaging in
.warfile makes ...