[jboss-user] [EJB 3.0] - Re: @EJB Injection in JSF Managed Bean
sisepago
do-not-reply at jboss.com
Tue Oct 31 06:37:28 EST 2006
Now i know that this scenario can not work, because jbossas 4 does not support @EJB Injection in a JSF Managed Bean class. In JSF Managed Bean you can now only use JNDI ENC javax.naming.InitialContext Inteface to look up session's interface compenents.
-- EJB 3 Codes
|
| @javax.ejb,Remote
| public Interface Service{
| public String meth1(Object o);
| }
|
| @javax.ejb.Stateful
| public class ServiceImpl implements Service{
| @PersistenceContext
| private EntityManager em;
| public String meth1(Test t){
| em.persist(t);
| return "success";
| }
| }
|
| the String "success" is for the redirection
|
|
| --- JSF Managed Bean class
|
| public class ManagedBean{
| private String field1="";
| private Service s1 = null;
|
| public ManagedBean(){
| InitialContext ctx = new InitialContext(); //JNDI ENC
| s1 = (Service)ctx.lookup("ServiceImpl/remote");
| }
|
| public String getField1(){return field1;}
| public void setFied1(String f){field1 = f;}
|
| public String controller(){
| if(field1==null){
| return null;
| }else{
|
| return (s1.meth1(new Test(getField1()));
|
| }
| }
| }
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3982024#3982024
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3982024
More information about the jboss-user
mailing list