Search code examples
javajavascriptdwr

using Vector and Hashtable as a bean for dwr



I want to write a DWR function that prepares a Vector of Hashtable's and returns to the javascript and there in javascript i need to iterate a Vector and print the content of Hashtable.

My DWR function is:

public Vector getEmployeeData() {
   Vector employeeData = new Vector();
   // some other content to prepare vector

   return employeeData;
}

And i have configured dwr-servlet in web.xml properly and content in dwr.xml is:

<create creator="new" javascript="Employee" scope="script">
  <param name="class" value="com.test.DWREmployeeManager"/>
</create>
<convert match="java.util.Hashtable" converter="bean"/>
<convert match="java.util.Vector" converter="bean"/>  

But my problem is when i called this dwr method from javascrit i am getting empty array as a result to the dwr call-back function.

Can anybody suggest the solution for this problem..


Solution

  • Instead of using the two tags,

    <convert match="java.util.Hashtable" converter="bean"/>
    <convert match="java.util.Vector" converter="bean"/>  
    

    I used the below convert tag:

    <convert converter="collection" match="java.util.Collection"/>
    

    Now its working fine.

    Thanx