Java Reference
In-Depth Information
we just have to change the class HelloWorld . We will complete our code by spe-
cifying the scope of the POJO with @RequestScoped annotation.
public class HelloWorld implements IHelloWorld{
Example 2 - accessing an EJB from a JSF page
Suppose we have a JSF page where we want to access a method of an EJB com-
ponent. The typical scenario requires you to first access an instance of the EJB from
the managed bean associated with the JSF page and then call the EJB method in a
managed bean method that will be called in the JSF page. In terms of code that can
be translated as shown in the following code.
The following code is an example of an EJB component:
public class MyEJB implements IMyEJB{
public String getHelloWorld(){
return "Hello world By EJB";
The following code is an example of a JSF-managed bean:
public class MyManagedBean {
IMyEJB ejb;
public String getMyEjbHelloWorld(){
return ejb.getHelloWorld();
Search WWH ::

Custom Search