问题
I'm a newbie of DWR World and I have some problems to understand the right behaviour of my application.
I have this situation:
File dwr.xml
<dwr>
<allow>
<create creator="new" javascript="Starred">
<param name="class" value="it.mypackage.entity.Starred" />
</create>
<convert converter="bean" match="it.mypackage.beans.ActivityBean"/>
</allow>
</dwr>
Within my html page I have:
<% String name = "myname"; %>
<li><input type="checkbox" name="a" class="styled" /><a href="#" onclick="Products.addProducts(name, 1,myjs)">Monitor</a></li>
and in my Products.java I have:
public void addProducts(String name, String id) {
System.out.println(name + "_" + id);
}
but when I click on this checkbox nothing happears. If I change String name with integer value System.out works correctly.
Can you help me please?
回答1:
You will need to add in your dwr.xml
<create creator="new" javascript="Product">
<param name="class" value="fully qualified name of your Product class" />
<include method="addProducts" />
Then in your JSP, you will need to include the following java script files.
engine.js
util.js
interface/Product.js
来源:https://stackoverflow.com/questions/5219636/dwr-passing-string