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

Jasperserver Custom Data Source Parameters


showtime

Recommended Posts

Hi all,

I have created a custom data source successfully.  I have a parameter in the custom data source, which is a sql statement.

In my custom data source, I will execute this sql statement and pass the ResultSet to the Jasper report.

 

After I finished the coding, I found that I don't know how to define the parameter of the Custom Data Source dynamically.  Anyone could give me some hits how I can pass a parameter to a Custom Data Source?  

 

I would use Jasper Web Service + JSP to run the report.

 

Your help is much appreciated.  Thanks.

Gary

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

May be I put it in this way, please refer to the following code.  This is example from the custom bean data source:

C:\Jasper\jasperserver-ce-3.7.0\samples\customDataSource\webapp\WEB-INF\applicationContext-sampleCDS.xml

Can I pass the parameter value, say "bar", to the JasperServer externally from a Web Service or JSP ?

Code:
<bean id="myCustomDataSource"class="com.jaspersoft.jasperserver.api.engine.jasperreports.util.CustomDataSourceDefinition">	<property name="factory" ref="customDataSourceServiceFactory"/>	<property name="name" value="myCustomDataSource"/>	<property name="serviceClassName" value="example.cds.CustomSimplifiedDataSourceService"/>	<property name="validator">		<bean class="example.cds.CustomTestValidator"/>	</property>	<property name="propertyDefinitions">		<list>			<map>				<entry key="name" value="foo"/>			</map>			<map>				<entry key="name" value="bar"/>				<entry key="default" value="b"/>			</map>			<map>				<entry key="name" value="repository"/>				<entry key="hidden" value="true"/>				<entry key="default" value-ref="repositoryService"/>			</map>		</list>	</property></bean>
Link to comment
Share on other sites

May be as report parameter?

 

1 declare a parameter in jrxml ... name: paramId

2 In custom datasource:

public void setReportParameterValues(Map parameterValues) {

 

String id = "3";

 

if (parameterValues.get("paramId") != null) {

id = (String)parameterValues.get("paramId") ;

}

 

parameterValues.put(JRParameter.REPORT_DATA_SOURCE, ds);

}

3 edit your report in jasperserver:

add input control ... name: paramId

 

then it is usable ex. URL parameter : reporturl&paramId=3

Link to comment
Share on other sites

  • 3 years later...

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...