what is the right way to use a jsf xhtml page to access an ejb which is also a managed bean for JSF ?
in the javaee6tutorial trunk download at
https://svn.java.net/svn/javaeetutorial~svn/trunk/examples
in example jaxrs/Customer they have 2 beans.
a CustomerManager bean annotated @Stateful @Named
and a CustomerBean annotated @Named @Stateless.
The index.xhtml jsf page accesses #{customerManager.customer.firstname} and other fields.
But each time the #{customerManager.customer.xxxx} expression is evaluated a new Customer is created in the
@PostConstruct
private void init() {
logger.info("new customer created");
customer = new Customer();
}
of the CustomerManager.java class.
-- instead of creating 1 time and then accessing the same bean for the other expression language statements in the file.
It seems as if the Scoping is messed up.
All the examples i have seen previously use a managed bean(JSF or JavaEE) that then accesses an EJB located in another class.
What is the proper way to use a single class as an ejb and a jsf managed bean with scoping in the same class.
Is there documentation that can help explain ?
Also when to use javax.enterprise.context.RequestScoped vs javax.faces.bean.RequestScoped , ... etc.
Thanks
-Gary