简体   繁体   中英

DWR passing String

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM