json data from code
Posted: Fri Feb 07, 2025 11:15 am
Hello
I have prepared a report with data from Api in json format. It works. Now I would like to feed the report with this data, but I want to provide the path from the code.
I tried the following:
String reportPath = context.getRealPath("/reports/report.mrt");
StiReport report = StiSerializeManager.deserializeReport(new File(reportPath));
report.getDictionary().clear();
StiJsonDatabase db = new StiJsonDatabase();
db.setPathData("https://abc.pl:1091/api/printdata");
report.getDictionary().getDatabases().add(db);
report.getDictionary().connect();
System.out.println(report.getDictionary());
report.render();
StiWebViewerOptions options = new StiWebViewerOptions();
options.getToolbar().setZoom(97);
options.getToolbar().setViewMode(StiWebViewMode.SinglePage);
return new ReportViewerOptions(report, options);
It doesn't work.
what's wrong?
I have prepared a report with data from Api in json format. It works. Now I would like to feed the report with this data, but I want to provide the path from the code.
I tried the following:
String reportPath = context.getRealPath("/reports/report.mrt");
StiReport report = StiSerializeManager.deserializeReport(new File(reportPath));
report.getDictionary().clear();
StiJsonDatabase db = new StiJsonDatabase();
db.setPathData("https://abc.pl:1091/api/printdata");
report.getDictionary().getDatabases().add(db);
report.getDictionary().connect();
System.out.println(report.getDictionary());
report.render();
StiWebViewerOptions options = new StiWebViewerOptions();
options.getToolbar().setZoom(97);
options.getToolbar().setViewMode(StiWebViewMode.SinglePage);
return new ReportViewerOptions(report, options);
It doesn't work.
what's wrong?