Search code examples
javajavascriptajaxdwr

Handling java List in dwr addRows function


I am calling ajaxcontroller to get data from server. ajaxController.fetchCounts(callFetchcounts);

callFetchcounts, this function will be called once i got the data. I am handling it like this:

var callFetchcounts = function(data) {
if( data.length > 0){
    dwr.util.addRows("rounded-corner",[data] , cellFuncs, { escapeHtml:false });
}}

var cellFuncs = [
 function(data) {return data.category},
 function(data) {return data.count},
 function(data) {return "<a href=''>Edit</a>"}
];

From the ajaxController i will get List of objects. (I can even get array of objects.) I want to populate a table where number of rows = number of elements in the result List/array. Number of columns = number of elements in each list object. I want to populate columns with List object's data.

How to do this? I am struck here. Can any one please help me with an example.

Thanks, Tiru


Solution

  • This should help - http://www.packtpub.com/article/dwr-java-ajax-user-interface-basic-elements-part2 :)