dwr-jsf integration cant call a CDI managedbean

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

dwr-jsf integration cant call a CDI managedbean

mihaisheng
 hi,
i use dwr to call a CDI managedbean(jboss7.1.1.final,jdk1.7).like this:
------------------------
@RemoteProxy
@Named("Test")
@SessionScoped
public class Test implements Serializable
{
    private static final long serialVersionUID = -1231439157655757940L;
    @Inject private CurrentUser currentUser;

    @Named
    @RemoteMethod
    public String test1(){
        return currentUser.getUsername();
    }

    @Named
    @RemoteMethod
    public String test2(){
        return "hellow from managedbean";
    }
}
--------------------------
@SessionScoped
@Named
public class CurrentUser implements Serializable{
 & nbsp;  private static final long serialVersionUID = 1401288096425725460L;
    private String username="user1";
    public String getUsername(){
        return this.username;
    }
}
------------------------

in a jsf page,i put two button to call two remotemethod.
---------------------------------
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets">
      <head>
  <script type='text/javascript' src='dwr/engine.js'></script>
  <script type='text/javascript' src='dwr/util.js'></script>
   <script type='text/javascript' src='dwr/interface/Test.js'></script> & nbsp;
</head>

<h:form id="loginForm" rendered="#{not identity.loggedIn}">
         <input type="button" value="method simple" onclick="Test.test2(function(i){alert(i);});"/>
         <input type="button" value="method(cdi)" onclick="Test.test1(function(i){alert(i);});"/>
</h:form>
</html>
------------------------------

i find remote method [test2] run correct in browser.
but remote method [test1] run to error(NullPointerException).im sure this code run well in jsf maner.


can someone tell me if dwr(jsf integration) support a CDI managedBean ????




Reply | Threaded
Open this post in threaded view
|

Re: dwr-jsf integration cant call a CDI managedbean

david@butterdev.com
Please follow the directions on our support page and send questions to the correct list:
http://directwebremoting.org/dwr/support/#mailing_lists

Also, it would be helpful if you would tell us what version of DWR you are using.

You may be running into this:
http://directwebremoting.org/jira/browse/DWR-526
http://dwr.2114559.n2.nabble.com/Problem-upgrading-to-DWR3-0-RC2-with-JSF-td6641119.html

If so you can grab a recent development build on our Bamboo server, or wait for our next release:
http://ci.directwebremoting.org/bamboo/browse/DWRTRUNK-ALL-521/artifact

On 10/01/2013 03:08 AM, εδΈ‰ιƒŽ wrote:
 hi,
i use dwr to call a CDI managedbean(jboss7.1.1.final,jdk1.7).like this:
------------------------
@RemoteProxy
@Named("Test")
@SessionScoped
public class Test implements Serializable
{
    private static final long serialVersionUID = -1231439157655757940L;
    @Inject private CurrentUser currentUser;

    @Named
    @RemoteMethod
    public String test1(){
        return currentUser.getUsername();
    }

    @Named
    @RemoteMethod
    public String test2(){
        return "hellow from managedbean";
    }
}
--------------------------
@SessionScoped
@Named
public class CurrentUser implements Serializable{
 & nbsp;  private static final long serialVersionUID = 1401288096425725460L;
    private String username="user1";
    public String getUsername(){
        return this.username;
    }
}
------------------------

in a jsf page,i put two button to call two remotemethod.
---------------------------------
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets">
      <head>
  <script type='text/javascript' src='dwr/engine.js'></script>
  <script type='text/javascript' src='dwr/util.js'></script>
   <script type='text/javascript' src='dwr/interface/Test.js'></script> & nbsp;
</head>

<h:form id="loginForm" rendered="#{not identity.loggedIn}">
         <input type="button" value="method simple" onclick="Test.test2(function(i){alert(i);});"/>
         <input type="button" value="method(cdi)" onclick="Test.test1(function(i){alert(i);});"/>
</h:form>
</html>
------------------------------

i find remote method [test2] run correct in browser.
but remote method [test1] run to error(NullPointerException).im sure this code run well in jsf maner.


can someone tell me if dwr(jsf integration) support a CDI managedBean ????