theonix | 1 Aug 2011 16:01

[dwr-users] Problem upgrading to DWR3.0-RC2 with JSF

Hi,

I'm trying to upgrade from DWR 2.0.3 to DWR 3.0 RC2 version.
I've been used  DWR 2.0.3 with JSF (myfaces 1.1.3) without any problem but
with DWR 3.0RC2 I got this error:

16:55:48,569 INFO  [startup] Starting: DwrServlet v3.0.0-RC2-final-312 on
Apache Tomcat/5.0.30 / JDK 1.5.0_14 from Sun Microsystems Inc.
16:55:49,343 ERROR [JsfCreator] Object postCodeValueChangeListener cannot be
created since the faces context is null
16:55:49,343 ERROR [startup] Failed to add creator: type=jsf,
javascript=VirginPostCodeValueChangeListener
java.lang.NullPointerException
        at
org.directwebremoting.faces.AbstractJsfCreator.getType(AbstractJsfCreator.java:41)
        at
org.directwebremoting.extend.AbstractCreator.getJavascript(AbstractCreator.java:45)
        at
org.directwebremoting.impl.DefaultCreatorManager.addCreator(DefaultCreatorManager.java:87)
        at
org.directwebremoting.impl.DefaultCreatorManager.addCreator(DefaultCreatorManager.java:78)
        at
org.directwebremoting.impl.DwrXmlConfigurator.loadCreate(DwrXmlConfigurator.java:269)
        at
org.directwebremoting.impl.DwrXmlConfigurator.loadAllows(DwrXmlConfigurator.java:219)
        at
org.directwebremoting.impl.DwrXmlConfigurator.configure(DwrXmlConfigurator.java:165)
        at
org.directwebremoting.impl.StartupUtil.configureFromDefaultDwrXml(StartupUtil.java:612)
        at
(Continue reading)

David Marginian | 1 Aug 2011 17:27

[dwr-users] Re: Problem upgrading to DWR3.0-RC2 with JSF

You haven't changed anything else or upgraded your JSF version?  I made some changes here but the getInstance() method on JsfCreator has not changed (which appears to be returning null now).  I can't really tell what the problem is.  Could you place a breakpoint in JsfCreator and provide more information?

On Mon, Aug 1, 2011 at 8:01 AM, theonix <jesus-2vIOKR2aDXpBDgjK7y7TUQ@public.gmane.org> wrote:
Hi,

I'm trying to upgrade from DWR 2.0.3 to DWR 3.0 RC2 version.
I've been used  DWR 2.0.3 with JSF (myfaces 1.1.3) without any problem but
with DWR 3.0RC2 I got this error:

16:55:48,569 INFO  [startup] Starting: DwrServlet v3.0.0-RC2-final-312 on
Apache Tomcat/5.0.30 / JDK 1.5.0_14 from Sun Microsystems Inc.
16:55:49,343 ERROR [JsfCreator] Object postCodeValueChangeListener cannot be
created since the faces context is null
16:55:49,343 ERROR [startup] Failed to add creator: type=jsf,
javascript=VirginPostCodeValueChangeListener
java.lang.NullPointerException
       at
org.directwebremoting.faces.AbstractJsfCreator.getType(AbstractJsfCreator.java:41)
       at
org.directwebremoting.extend.AbstractCreator.getJavascript(AbstractCreator.java:45)
       at
org.directwebremoting.impl.DefaultCreatorManager.addCreator(DefaultCreatorManager.java:87)
       at
org.directwebremoting.impl.DefaultCreatorManager.addCreator(DefaultCreatorManager.java:78)
       at
org.directwebremoting.impl.DwrXmlConfigurator.loadCreate(DwrXmlConfigurator.java:269)
       at
org.directwebremoting.impl.DwrXmlConfigurator.loadAllows(DwrXmlConfigurator.java:219)
       at
org.directwebremoting.impl.DwrXmlConfigurator.configure(DwrXmlConfigurator.java:165)
       at
org.directwebremoting.impl.StartupUtil.configureFromDefaultDwrXml(StartupUtil.java:612)
       at
org.directwebremoting.impl.StartupUtil.configureContainerFully(StartupUtil.java:726)
       at
org.directwebremoting.servlet.DwrServlet.configureContainer(DwrServlet.java:109)
       at org.directwebremoting.servlet.DwrServlet.init(DwrServlet.java:68)


I have dwr.jar and dwr-noncla.jar in the classpath.

web.xml


 ...
 <filter>
       <filter-name>DwrFacesFilter</filter-name>

<filter-class>org.directwebremoting.faces.FacesExtensionFilter</filter-class>
 </filter>

 <filter-mapping>
       <filter-name>DwrFacesFilter</filter-name>
       <url-pattern>/dwr/*</url-pattern>
 </filter-mapping>

  ...


 <servlet>
   <servlet-name>dwr-invoker</servlet-name>
   <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
   <init-param>
     <param-name>debug</param-name>
     <param-value>true</param-value>
   </init-param>
 </servlet>

 <servlet-mapping>
   <servlet-name>dwr-invoker</servlet-name>
   <url-pattern>/dwr/*</url-pattern>
 </servlet-mapping>
 ...



dwr.xml


<?xml version="1.0" encoding="UTF-8"?>
&lt;!DOCTYPE dwr PUBLIC &quot;-//GetAhead Limited//DTD Direct Web Remoting
3.0//EN&quot; &quot;http://directwebremoting.org/schema/dwr30.dtd&quot;&gt;
<dwr>

 <init>
   <creator id="jsf" class="org.directwebremoting.faces.JsfCreator"/>
 </init>

 <allow>
   <filter class="com.tsys.gpp.virgin.web.servlet.VirginSessionFilter" />
   <create creator="jsf" javascript="VirginPostCodeValueChangeListener">


     <include method="enterAddressManually" />
     <include method="findAddressByPostCode" />
     <include method="findAddressByAddressId" />
     <include method="needPreviousAddress" />
   </create>
   ...


Do I miss anything?


Thanks in advance


--
View this message in context: http://dwr.2114559.n2.nabble.com/Problem-upgrading-to-DWR3-0-RC2-with-JSF-tp6641119p6641119.html
Sent from the DWR - Users mailing list archive at Nabble.com.

theonix | 2 Aug 2011 17:18

[dwr-users] Re: Problem upgrading to DWR3.0-RC2 with JSF

Hi, thanks for your quick response.

I've only changed the DWR libraries.

I placed a breakpoint as you suggested and I have found some differences
between version 2 and 3.

In the DefaultCreatorManager.addCreator method 

        Creator creator = (Creator) clazz.newInstance();

        LocalUtil.setParams(creator, params, ignore);
        creator.setProperties(params);

Params include 

HashMap$Entry	"class =>
com.tsys.gpp.virgin.web.listeners.VirginRecipientPostCodeValueChangeListener"	

But this param is never set because setClass method have been removed from
JsfCreator in version 3.

From JsfCreator v2.0.3

    /**
     * What sort of class do we create?
     *  <at> param classname The name of the class
     */
    public void setClass(String classname)
    {
        try
        {
            this.instanceType = LocalUtil.classForName(classname);
        }
        catch (ClassNotFoundException ex)
        {
            throw new IllegalArgumentException("Creator.ClassNotFound");
        }
    }

So, if instanceType is null it uses JsfCreator.getInstance() to resolve the
jsf bean class using the FacesContext, but the problem here is that
FacesContext does not exist for this request.

Thanks

--
View this message in context: http://dwr.2114559.n2.nabble.com/Problem-upgrading-to-DWR3-0-RC2-with-JSF-tp6641119p6645204.html
Sent from the DWR - Users mailing list archive at Nabble.com.

David Marginian | 2 Aug 2011 17:57

[dwr-users] Re: Problem upgrading to DWR3.0-RC2 with JSF

Thank you.  Removing that method was a mistake on my part.  I have made a fix and it is available on Bamboo - give it a shot and let me know:
http://ci.directwebremoting.org/bamboo/browse/DWRTRUNK-ALL-331/artifact


On Tue, Aug 2, 2011 at 9:18 AM, theonix <jesus-2vIOKR2aDXqIwRZHo2/mJg@public.gmane.orgm> wrote:
Hi, thanks for your quick response.

I've only changed the DWR libraries.

I placed a breakpoint as you suggested and I have found some differences
between version 2 and 3.

In the DefaultCreatorManager.addCreator method

       Creator creator = (Creator) clazz.newInstance();

       LocalUtil.setParams(creator, params, ignore);
       creator.setProperties(params);

Params include

HashMap$Entry   "class =>
com.tsys.gpp.virgin.web.listeners.VirginRecipientPostCodeValueChangeListener"

But this param is never set because setClass method have been removed from
JsfCreator in version 3.

From JsfCreator v2.0.3

   /**
    * What sort of class do we create?
    * <at> param classname The name of the class
    */
   public void setClass(String classname)
   {
       try
       {
           this.instanceType = LocalUtil.classForName(classname);
       }
       catch (ClassNotFoundException ex)
       {
           throw new IllegalArgumentException("Creator.ClassNotFound");
       }
   }

So, if instanceType is null it uses JsfCreator.getInstance() to resolve the
jsf bean class using the FacesContext, but the problem here is that
FacesContext does not exist for this request.

Thanks


--
View this message in context: http://dwr.2114559.n2.nabble.com/Problem-upgrading-to-DWR3-0-RC2-with-JSF-tp6641119p6645204.html
Sent from the DWR - Users mailing list archive at Nabble.com.

theonix | 3 Aug 2011 13:05

[dwr-users] Re: Problem upgrading to DWR3.0-RC2 with JSF

It looks to be working now, thank you

--
View this message in context: http://dwr.2114559.n2.nabble.com/Problem-upgrading-to-DWR3-0-RC2-with-JSF-tp6641119p6648301.html
Sent from the DWR - Users mailing list archive at Nabble.com.

proudjun | 3 Aug 2011 07:34

[dwr-users] How can I resend a request?

Hi, I am very new to DWR, our instructor had briefly went over it.

Currently I have something like
public User getProfileByUserKey(long user_key);
declared as remove method.

In my javascript, I called it via
userService.getProfileByUserKey(id,{callback:function(profile){
//do something...
}, timeout: 5000, errorHandler:function(msg){
 document.write(msg);
}

Everything works when there are no error. But, sometimes when the connection
are broken, it doesn't return the profile object and invoke the callback
function. My problem is: I HAVE TO GET THE PROFILE OBJECT! Can anyone please
kindly tell me how to ensure I obtain the profile object? or Can anyone tell
me how can I retry sending making a call? Are there any configurations in
DWR for it?

- Jun

--
View this message in context: http://dwr.2114559.n2.nabble.com/How-can-I-resend-a-request-tp6647594p6647594.html
Sent from the DWR - Users mailing list archive at Nabble.com.

David Marginian | 3 Aug 2011 13:14

[dwr-users] Re: How can I resend a request?

If the connection is down and you cannot reach the server you cannot get 
a profile object.  If you want to retry it is possible to call your 
remote function again in the errorHandler you have specified.

On 8/2/2011 11:34 PM, proudjun wrote:
> Hi, I am very new to DWR, our instructor had briefly went over it.
>
> Currently I have something like
> public User getProfileByUserKey(long user_key);
> declared as remove method.
>
> In my javascript, I called it via
> userService.getProfileByUserKey(id,{callback:function(profile){
> //do something...
> }, timeout: 5000, errorHandler:function(msg){
>   document.write(msg);
> }
>
> Everything works when there are no error. But, sometimes when the connection
> are broken, it doesn't return the profile object and invoke the callback
> function. My problem is: I HAVE TO GET THE PROFILE OBJECT! Can anyone please
> kindly tell me how to ensure I obtain the profile object? or Can anyone tell
> me how can I retry sending making a call? Are there any configurations in
> DWR for it?
>
> - Jun
>
> --
> View this message in context: http://dwr.2114559.n2.nabble.com/How-can-I-resend-a-request-tp6647594p6647594.html
> Sent from the DWR - Users mailing list archive at Nabble.com.
>

David Marginian | 3 Aug 2011 13:20

[dwr-users] Re: Problem upgrading to DWR3.0-RC2 with JSF

Great!  Thanks for the help.  I created a JIRA for release purposes - 
http://directwebremoting.org/jira/browse/DWR-526.

On 8/3/2011 5:05 AM, theonix wrote:
> It looks to be working now, thank you
>
> --
> View this message in context: http://dwr.2114559.n2.nabble.com/Problem-upgrading-to-DWR3-0-RC2-with-JSF-tp6641119p6648301.html
> Sent from the DWR - Users mailing list archive at Nabble.com.
>

proudjun | 3 Aug 2011 20:21

[dwr-users] Re: How can I resend a request?


david@... wrote:
> 
> If the connection is down and you cannot reach the server you cannot get 
> a profile object.  If you want to retry it is possible to call your 
> remote function again in the errorHandler you have specified.
> 

What is bugging me is that how can I implement that function?
If I do...
service.method(param,{callback:function(r){},errorHandler:function(msg){
 service.method(param,{callback:function(r){},errorHandler:function(msg){
 //again...
}
})
and if I want to ensure that a connection is obtained, this is NOT possible. 
So shall I do something like this?

function callbackFunc(r){}
function errorHandlerFunc(msg,service,methodname){
service[methodname].apply(service,Array.protocol.slice(2,arguments))
}
service.method(param,callback:callbackFunc,errorHandler:errorHandlerFunc(msg,service,'method'));

Is this even legal as js?

--
View this message in context: http://dwr.2114559.n2.nabble.com/How-can-I-resend-a-request-tp6647594p6649715.html
Sent from the DWR - Users mailing list archive at Nabble.com.

David Marginian | 3 Aug 2011 21:02

[dwr-users] Re: How can I resend a request?

You would need to use a closure.  See the bottom of this page for an example:
http://directwebremoting.org/dwr/documentation/browser/extra-data.html

The same principal can be applied to the error handler.

On Wed, Aug 3, 2011 at 12:21 PM, proudjun <jouyang3-Hoa+k3RbWgPFRk3jFJgznQ@public.gmane.org> wrote:

david-H55tQ8LTKd1xxXtqJ93Y6g@public.gmane.org wrote:
>
> If the connection is down and you cannot reach the server you cannot get
> a profile object.  If you want to retry it is possible to call your
> remote function again in the errorHandler you have specified.
>

What is bugging me is that how can I implement that function?
If I do...
service.method(param,{callback:function(r){},errorHandler:function(msg){
 service.method(param,{callback:function(r){},errorHandler:function(msg){
 //again...
}
})
and if I want to ensure that a connection is obtained, this is NOT possible.
So shall I do something like this?

function callbackFunc(r){}
function errorHandlerFunc(msg,service,methodname){
service[methodname].apply(service,Array.protocol.slice(2,arguments))
}
service.method(param,callback:callbackFunc,errorHandler:errorHandlerFunc(msg,service,'method'));

Is this even legal as js?


--
View this message in context: http://dwr.2114559.n2.nabble.com/How-can-I-resend-a-request-tp6647594p6649715.html
Sent from the DWR - Users mailing list archive at Nabble.com.


Gmane