hi,erveryone.

 in a DWR RemoteMethod,dwr cant get injected bean automatical.
like this:
--------------
import javax.inject.Inject;
import javax.inject.Named;
import org.apache.deltaspike.core.api.provider.BeanProvider;
import org.directwebremoting.annotations.RemoteMethod;
import org.directwebremoting.annotations.RemoteProxy;
@Named("Test")
@RemoteProxy //for dwr
public class Test
{
    @Inject private User user;
    @RemoteMethod //for dwr
    public String test(){
        //i find dwr cant get @Inject bean
        System.out.println("user is null ? "+(user == null));
       
        //fortunately , i can get it in a manual way. but i dont wanna this way
        user=BeanProvider.getContextualReference(User.class,false);
        System.out.println("user name is: "+user.getUsername());
        return user.getUsername();
    }
}

import java.io.Serializable;
import javax.enterprise.context.SessionScoped;
import javax.inject.Named;
@SessionScoped
@Named
public class User implements Serializable{
    private static final long serialVersionUID = -559381017984772756L;
    private String username="wuhenge";
    public String getUsername(){
        return this.username;
    }
    public void setUsername(String s){
        this.username=s;
    }
}
--------
after run this demo,i find dwr can get inject bean in a manual way.but i dont 
wanna this way

i try to add deltaspike servlet module,but that didnt work.

the edition of dwr is latest on 
http://ci.directwebremoting.org/bamboo/browse/DWRTRUNK-ALL-521/artifact.

thanks erveryone!!!!

Reply via email to