Hi,
I’m experiencing a strange problem with a method that uses the PieChart bean.
If I launch the method clicking on a button in the form, I get an error (but the chart is updated anyway) telling me that “Cannot convert null to an object.”
But if I execute the method from the editor, the error doesn’t show up.
The method is:
globals.resocontopiani = ""
var query_anno = ""
var query_anno = "select distinct yearnr from piani order by yearnr"// era "select yearnr from ordini order by yearnr"
var dataset_anniOrd = databaseManager.getDataSetByQuery(controller.getServerName(), query_anno, null, 100000);
var anni_ordini = dataset_anniOrd.getColumnAsArray(1)
var sceltannata = ""
var sceltannata = plugins.dialogs.showSelectDialog("Attenzione","Scegli l'anno",anni_ordini)
if(elements['pieChart'] != null)
{
var maxReturedRows = 10000;
var query = "SELECT"+
" ri.categoria, COUNT(*) as TotPrestazioni, SUM(ri.prezuni)"+
" from rigpiani ri"+
" where ri.annoprest =" + sceltannata +
" and ri.categoria <> 'NULL'" +
" group by ri.categoria" +
" order by 1 asc"
//clear pieChart
for(var i = 1 ; i <= 25 ; i++) //
{
elements.pieChart.setLegends(i-1,"")// set legends of chart
elements.pieChart.setValues(i-1, 0, 0)
}
var dataset = databaseManager.getDataSetByQuery(controller.getServerName(), query, null, maxReturedRows);
for( var i = 1 ; i <= 25 ; i++ ) //
{
dataset.rowIndex = i;
elements.pieChart.setLegends(i-1,dataset[1]+" ("+ dataset[2]+") "+ dataset[3].toFixed(2) )// set legends of chart
elements.pieChart.setValues(i-1, 0, dataset[3])
}
}
else
{
HTML = HTML+'<tr class="normal"><td nowrap colspan=2>JavaBean non riconosciuto.</td></tr>';
}
globals.resocontopiani = HTML
controller.show();
OSX.2.8, Servoy 2RC3