Jump to content
We've recently updated our Privacy Statement, available here ×

Question on REPORT_MAX_COUNT


bbergquist

Recommended Posts

Is there anyway to set a default value for REPORT_MAX_COUNT either from a Scriptlet or some other mechanism.

 

I'm using JasperServer and have a report with a large dataset and would like to enforce a maximum record count for the report. If I were driving the report filling myself, I would pass in this parameter but since JasperServer is running the report, I don't know how to set this parameter.

 

Actually I do know of a way but I don't like how it is done. In JasperServer I can create an input control called "REPORT_MAX_COUNT" and then provide a value there when the report is run. The problem is that this input control must be available and must be entered by the user and I don't know how to give a default value.

 

So is there anyway to set this built in parameter via a Scriptlet?

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

This is something that's not currently possible in JasperReports. The first scriptlet event is fired after the data source has been initialized, and at that moment changing REPORT_MAX_COUNT would have no effect. You could post a feature request for such a provision in JasperReports here.

 

In the meantime, you would have to do a little customization to JasperServer in order to avoid a REPORT_MAX_COUNT input control. What you could do is to create a JRXML property which JS would recognize and use as REPORT_MAX_COUNT when running the report. This would be done by extending the built-in com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl:

Code:

public class MyEngineServiceImpl extends EngineServiceImpl {
public static final String REPORT_PROPERTY_MAX_COUNT = "max.count";
protected ReportUnitResult fillReport(ExecutionContext context,
JasperReport report, Map reportParameters,
ReportDataSource datasource, Query query) {
if (!reportParameters.containsKey(JRParameter.REPORT_MAX_COUNT)) {
int maxCount = JRProperties.getIntegerProperty(report, REPORT_PROPERTY_MAX_COUNT, 0);
if (maxCount > 0) {
reportParameters.put(JRParameter.REPORT_MAX_COUNT, Integer.valueOf(maxCount));
}
}
return super.fillReport(context, report, reportParameters, datasource, query);
}
}

and change the "engineService" bean from applicationContext.xml to your extended class:

Code:
[code]
<bean id="engineService" class="com.me.MyEngineServiceImpl" destroy-method="release">
...

 

Then, the JRXML would contain the max count value as a property:

Code:
[code]
<jasperReport ...>
<property name="max.count" value="1000"/>
...

 

Regards,

Lucian

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...