java example exception in viewer.jsp
-
- Posts: 34
- Joined: Mon Sep 18, 2017 6:07 am
Re: java example exception in viewer.jsp
Thanks for your replay.
I've got two questions here:
1, Do we have some internationalization solution with the stimulsoft report?
2, For the designer page, is there an option to set for auto-resizing the whole page?
I've got two questions here:
1, Do we have some internationalization solution with the stimulsoft report?
2, For the designer page, is there an option to set for auto-resizing the whole page?
Re: java example exception in viewer.jsp
Hello.
1. Yes, you could use the Globalization Strings feature to add multi-language support.
https://www.stimulsoft.com/en/documenta ... editor.htm
2. No, you should change the position for all components of the report.
Thank you.
1. Yes, you could use the Globalization Strings feature to add multi-language support.
https://www.stimulsoft.com/en/documenta ... editor.htm
2. No, you should change the position for all components of the report.
Thank you.
-
- Posts: 34
- Joined: Mon Sep 18, 2017 6:07 am
Re: java example exception in viewer.jsp
I've created a .mrt template which has a JSON data source, a normal formatted JSON file and everything is OK. And I tried to replace the json data source value at the running time just like replacing the SQL statement. I used the following code but new JSON data is not displayed OK in the viewer page.
The "queryStr" is a JSON String. And I tried to remove the former data source and add a new created data source with the "queryStr", still not work.
Please help, thanks a lot. If possible, show some code. Huge thanks.
Code: Select all
if (!queryStr.isEmpty()) {
StiJsonDatabase stiJsonDatabase = ((StiJsonDatabase) stiDatabaseCollection.get(0));
stiJsonDatabase.setEmbeddedData(queryStr);
stiJsonDatabase.setJsonData(queryStr);
}
Please help, thanks a lot. If possible, show some code. Huge thanks.
Re: java example exception in viewer.jsp
Hello.
Please set path to null
Please set path to null
Code: Select all
if (!queryStr.isEmpty()) {
StiJsonDatabase stiJsonDatabase = ((StiJsonDatabase) stiDatabaseCollection.get(0));
stiJsonDatabase.setPathData(null);
stiJsonDatabase.setEmbeddedData(queryStr);
}
-
- Posts: 34
- Joined: Mon Sep 18, 2017 6:07 am
Re: java example exception in viewer.jsp
I've successfully replaced the json data of the data source in the viewer page, but things are little different in the designer page.
The data source seems to be added, but there are no data in it.
I found out that the dataSources is null and databases has value. So, after the database is added, any action should be proceeded for loading the dataSources?
Code: Select all
StiWebDesigerHandler handler = new StiWebDesigerHandler() {
//Occurred on loading webdesinger. Must return edited StiReport
public StiReport getEditedReport(HttpServletRequest request) {
try {
// StiReport report = StiSerializeManager.deserializeReport(new FileInputStream(reportPath));
StiReport report = reportPath == "" ? StiReport.newInstance() : StiSerializeManager.deserializeReport(new FileInputStream(reportPath));
if (reportName == "") {
report.setReportName( request.getParameter("report").replace(".mrt",""));
RequestContext requestContext = new RequestContext(request, response);
//json format data
String qryStr = JsonUtils.objectToJson(request.getAttribute("reportJsonReturn"), requestContext.getMessage("date_format"));
StiJsonDatabase jsonDatabase = new StiJsonDatabase("json");
//set json data source
jsonDatabase.setEmbeddedData(qryStr);
report.getDictionary().getDatabases().add(jsonDatabase);
}
return report;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
//Occurred on opening StiReport. Method intended for populate report data.
public void onOpenReportTemplate(StiReport report, HttpServletRequest request) {
}
//Occurred on new StiReport. Method intended for populate report data.
public void onNewReportTemplate(StiReport report, HttpServletRequest request) {
}
//Occurred on save StiReport. Method must implement saving StiReport
public void onSaveReportTemplate(StiReport report, StiRequestParams requestParams, HttpServletRequest request) {
try {
FileOutputStream fos = new FileOutputStream(savePath + requestParams.designer.fileName);
if (requestParams.designer.password != null) {
StiSerializeManager.serializeReport(report, fos, requestParams.designer.password);
} else {
StiSerializeManager.serializeReport(report, fos, true);
}
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
}
};
I found out that the dataSources is null and databases has value. So, after the database is added, any action should be proceeded for loading the dataSources?
- Attachments
-
- no_data.png (14.56 KiB) Viewed 5563 times
Re: java example exception in viewer.jsp
Hello.
You should parse database & add fileds, like in example
You should parse database & add fileds, like in example
Code: Select all
public StiReport getEditedReport(HttpServletRequest request) {
try {
StiReport report = StiReport.newInstance();
StiJsonDatabase jsonDatabase = new StiJsonDatabase("json");
String jsonData = StiIOUtil.toString(new FileInputStream("c:/2.json"));
jsonDatabase.setEmbeddedData(jsonData);
report.getDictionary().getDatabases().add(jsonDatabase);
DataSet dataSet = StiJsonToDataSetConverterV2.getDataSet(((StiJsonDatabase) jsonDatabase).getJSONObject());
for (DataTable table : dataSet.getTables()) {
StiJsonSource source = new StiJsonSource("json." + table.getName(), "json." + table.getName());
source.setDictionary(report.getDictionary());
report.getDictionary().getDataSources().add(source);
source.setColumns(new StiDataColumnsCollection());
for (StiDataColumn col : table.getColumns()){
source.getColumns().add(col);
}
}
return report;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
-
- Posts: 34
- Joined: Mon Sep 18, 2017 6:07 am
Re: java example exception in viewer.jsp
Thank you for your quick reply so much.
I've got the dataSources now, but the data list is different from loading the Json file by creating data source manually.
By which I mean, can we show the data-list selection page as soon as the designer page is loaded?
I've got the dataSources now, but the data list is different from loading the Json file by creating data source manually.
By which I mean, can we show the data-list selection page as soon as the designer page is loaded?
- Attachments
-
- data_select.png (45.24 KiB) Viewed 5548 times
Re: java example exception in viewer.jsp
Hello.
You can add only StiJsonDatabase in code, than user right-click "New Data Source" on Dictionary and select databse in "Report Connectios" - data-list selection page will appear.
You can add only StiJsonDatabase in code, than user right-click "New Data Source" on Dictionary and select databse in "Report Connectios" - data-list selection page will appear.
-
- Posts: 34
- Joined: Mon Sep 18, 2017 6:07 am
Re: java example exception in viewer.jsp
You're my hero.Vadim wrote:Hello.
You can add only StiJsonDatabase in code, than user right-click "New Data Source" on Dictionary and select databse in "Report Connectios" - data-list selection page will appear.
Re: java example exception in viewer.jsp
Hello
We are always glad to help you!
Please let us know if you need any additional help.
Thank you.
We are always glad to help you!
Please let us know if you need any additional help.
Thank you.