Is a managed bean property accessible from an ejb? I would like to get few values from a managed bean into my ejb. The managed bean properties are created by jsf, which works fine, but in my ejb I always get null for the managed bean properties.
Here are some parts of me code:
Managed Bean: BeanCredentials
@ManagedBean
@RequestScoped
public class BeanCredentials implements Serializable {
private String eMail;
public String geteMail() {
return eMail;
}
public void seteMail(String eMail) {
this.eMail = eMail;
}
}
EJB: ServiceUser
@Stateful
public class ServiceUser {
@PersistenceContext(unitName = "...")
private EntityManager em;
@Inject
private BeanCredentials credentials;
...
@Transactional
public void login() {
if(this.credentials.geteMail() == null) { /* Always true */
System.out.println(true);
}
}
}
public void login();
is called from an additional managed bean which provides user services to the front end (i.e. login, logout, create new users, display user information). This managed bean delegte the ejb (ServiceUser
) to process all necessary user takss
Managed Bean: BeanUser
@ManagedBean
@SessionScoped
public class BeanUser implements Serializable {
@EJB
private ServiceUser serviceUser;
...
public void login() {
this.serviceUser.login();
}
}
In the jsf from the value eMail
from BeanCredentials
is filled, but I am not able to acces the value inside the ejb ServiceUser
. Does I misunderstood some annotations or the concept?
How could I access the managed bean properties inside an ejb? What is the common solution?