PDA

View Full Version : DWR Spring setup?



nvmurali
Apr 4th, 2007, 06:58 AM
So, with the help of this link:
http://bram.jteam.nl/index.php/2007/01/31/spring-dwr-ajax-made-easy/
I kind of got DWR list page to show up. However, anytime I try to execute any of the functions shown on the page, it throws an error.

This is what I first put in


<bean id="myManager" class="llr.service.impl.MyManagerImpl">
<dwr:remote javascript="MyAjaxManagerService">
<dwr:include method="loadById"/>
<dwr:include method="loadByUserId"/>
</dwr:remote>
<property name="myDao" ref="myDao"/>
</bean>
[code]
The logs show
[code]
007-04-04 01:32:53,437 WARN [org.directwebremoting.impl.DefaultRemoter] - Method execution failed:
java.lang.IllegalArgumentException: object is not an instance of declaring class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.directwebremoting.impl.ExecuteAjaxFilter.doFil ter(ExecuteAjaxFilter.java:34)


I looked a little further and found a <dwr:configuration> tag which I thought would be the correct way to do it.

So, here's what I have now



<bean id="myManager" class="com.service.impl.MyManagerImpl">
<dwr:remote javascript="MyAjaxManagerService">
<dwr:include method="loadById"/>
<dwr:include method="loadByUserId"/>
</dwr:remote>
<property name="myDao" ref="myDao"/>
</bean>

<dwr:configuration>
<dwr:create type="new"
class="com.service.impl.MyManagerImpl""
javascript="MyAjaxService"/>
<dwr:convert type="bean" class="com.model.TestObject" />
</dwr:configuration>



This now gives me Null Pointer exceptions on Loading (in the tomcat logs)
http://getahead.org/blog/joe/2006/06/14/spring_2_namespaces_and_dwr.html
is the link I was trying to base my code off.
Please help!

nvmurali
Apr 5th, 2007, 08:24 AM
In case anybody else needs it, it turned out, I was doing it wrong!!! It is actually very simple

Here's how to do it with DWR & Spring using the spring config file instead of the dwr.xml file




<bean id="myManagerBean" class="myManager.class">
<dwr:remote javascript="myAjaxManager">
<dwr:include method="loadById"/>
</dwr:remote>
<property name="myDao" ref="myDao"/>
</bean>
<dwr:configuration>
<dwr:convert type="bean" class="com.example.model.*"/>
</dwr:configuration>



You can obviously substitute the model.* with just one bean if you wish to convert only a particular one.

This will solve the "object is not an instance of the calling class" problem.

Obviously, you still have to map the /dwr/* to your controller
as well as in your web.xml (servlet name and mapping)

astonishingone
May 22nd, 2007, 09:16 AM
Hi ,
I am new to dwr
I am using with spring and hibernate.
Well everything was ok just that the list i retrieve by my dwr remote method got the data in the form of list first time and if i refresh or call the JavaScript function of fillTable again it displays the same data even i manually edit the data in mysql db .
i am using dwr-sping i.e not using dwr.xml
I am using both dwr controller and spring MVC controller
i have debugged that the data at DAO layer (i.e hibernate) is retrieving the correctly but the list object which i get via dwr remote method is getting the same data which it received first time , is this object scoping problem , just guessing .

My main intention is to auto refresh the page using dwr as the data contains more then 15000 plus rows and not to delete and populate as it will give same conventional refresh page effect , i want to first load and then replace / edit the existing data in html table so that if use scroll down after refesh he is not again at first record and also show that data change effect (like changing border color of cell )


I hope i am able to explain the problem

Thanks in advance for your valuable suggestion