Hi,
We are using the ReportClientDocument class in jrcerom.jar to read the report and parse it contents. The parameters to the report will be passed from the application. Also the application will reset the report data source with the application data source. It works fine but the parameters passed to the report is not displayed in the report. It display null values instead of the parameters, but the results are filtered with the parameter value. It would be great if some one helps for resetting the parameter value after changing the data source.
P.S: If we remove the code to change the data source, the parameter values are displayed in the report. But it is connected to the data source configured in the report which we don't want.
Code:
public void print(CrystalReportParams parms) {
ReportClientDocument reportClientDocument = new ReportClientDocument();
Fields parameterFields = new Fields();
reportClientDocument.open(REPORT_NAME, 0);
Tables tables = reportClientDocument.getDatabaseController().
getDatabase().getTables();
ITable table = tables.getTable(0);
reportClientDocument.getDatabaseController().setDataSource
(resultSet0, "tableName0" , "tableName0_ResultSet");
tables = reportClientDocument.getDatabaseController().getDatabase().getTables();
table = tables.getTable(0);
if(table instanceof com.crystaldecisions.sdk.occa.report.data.CommandTable) {
setParameterFields((ITable)table, parameterFields, parms, "");
}
// Code to export the report to pdf...
}
private void setParameterFields(ITable table, Fields parameterFields,
CrystalReportParams parms, String reportName){
IProcedure command = (IProcedure)table;
for (int i=0; i< command.getParameters().size(); i++) {
ParameterField commandParam = (ParameterField)
command.getParameters().get(i);
if(reportName.length() > 0)
commandParam.setReportName(reportName);
Values values = new Values();
ParameterFieldDiscreteValue pfdv = new ParameterFieldDiscreteValue();
pfdv.setValue(CrystalReportUtility.getParmeterValues
(commandParam.getName(), parms));
values.add(pfdv);
commandParam.setCurrentValues(values);
parameterFields.add(commandParam);
}
}
}