DWR passing String

拟墨画扇 提交于 2019-12-13 05:44:41

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!