How to return a DataTable from a Java class to a JSP (Javascript code)?

84 views
Skip to first unread message

Rui Maia

unread,
Oct 10, 2013, 7:43:23 AM10/10/13
to google-visua...@googlegroups.com
On a Java class:

public DataTable GetDT(...) {
// Create a data table.
   DataTable result = new DataTable();
   ArrayList<ColumnDescription> cd = new ArrayList<ColumnDescription>();
    cd.add(...);
    cd.add(...);
   cd.add(...);
   result.addColumns(cd);  
            ....
           return result;
}


....on JSP

<script type='text/javascript' src='https://www.google.com/jsapi'></script>

<script>
// Load the Visualization API and the piechart package.
google.load('visualization', '1', {packages:['corechart', 'table']});
google.setOnLoadCallback(drawTable);
function drawTable() {
var dataD = <%=myDBUtils.GetTransfersByDateRangeDailyDT(null, null, startDate, endDate)%>;
var optionsExtD = {
    title: 'xxxxxx',
    hAxis: {title: 'xxxx', titleTextStyle: {color: 'red'}}
   };
var chartD = new google.visualization.Table(document.getElementById('table_div-D'));
       chartD.draw(dataD, optionsExtD);
}
</script>


NOT WORKING. Any HELP?

TKX


Rui Maia

unread,
Oct 10, 2013, 8:11:08 AM10/10/13
to google-visua...@googlegroups.com
More info... the Google Chrome developper tools identify this problem:

(syntax error: unexpected number)...
var dataD = 2013-10-07,1.0,000001
2013-10-07,1.0,000003
2013-10-07,1.0,000005
2013-10-07,1.0,000007
2013-10-07,1.0,000009;

asgallant

unread,
Oct 10, 2013, 10:36:39 AM10/10/13
to google-visua...@googlegroups.com
Your function myDBUtils.GetTransfersByDateRangeDailyDT is not returning a DataTable object.
Reply all
Reply to author
Forward
0 new messages