3

I am using spring and DWR combination,When i do ajax request from DWR.I want to access entire form values bind to the bean in my DAO layer.

I didn't find any examples for Spring form controller with DWR.

Any suggestions or help appreciated.

Thanks in Advance.

Regards,

Raj

skaffman
  • 398,947
  • 96
  • 818
  • 769
user581805
  • 77
  • 1
  • 3
  • 11

1 Answers1

2

Considering your problem is how to create Spring-DWR integration, so that you can simulate Spring controller calls from Java, try it like this:

Your Spring XML config:

<bean id="myController" class="pkg.MyController">

    <property name="service1" ref="service1Bean"/>
    <property name="service2" ref="service2Bean"/>

    <dwr:remote javascript="MyControllerInJavascript">
        <dwr:include method="method1"/>
        <dwr:include method="method2"/>
    </dwr:remote>

</bean>

Your controller:

package pkg;

public class MyController {

    public SomeObject method1(String argument1, Long argument2) {
        ...
    }

    public OtherObject method2(YetAnotherObject argument1) {
        ...
    }

}

In your Javascript:

<script type="text/javascript"
        src="/your_dwr_path/interface/MyControllerInJavascript.js"/>

MyControllerInJavacript.method1('argument',123,callbackMethod);

Further integration steps you can find at the docs.

mdrg
  • 3,242
  • 2
  • 22
  • 44
  • Thanks,I am getting hope now. I am new to this,If possible can you post some code. – user581805 Feb 11 '11 at 14:23
  • @user581805 I already gave you most of the code you need to get started on this. I cannot guess your requirements and start coding for you... and I won't neither anyone in this community, even if you tell us what you need. It's your assignment, and you should learn from it and the hurdles you face. We are here only to help with specific problems, like "how make A communicate with B", not "code this app for me". – mdrg Feb 13 '11 at 11:42
  • @medr:Thanks,in Above snippets no where mentioned how to bind my spring command object in controller area,That is the reason i am asking code,rest of the things i am fine. – user581805 Feb 14 '11 at 10:26
  • @user581805 You mean, how do you send data from JS so that it becomes `YetAnotherObject` and how do you return some `OtherObject` from Java to JS? If that's the case, you need to do nothing. The conversion between DOM and Java objects will be performed through reflection. You just need to send from JS an object with the same field names as the attributes with setters and getters in that class. – mdrg Feb 14 '11 at 11:17