showtime Posted June 14, 2010 Share Posted June 14, 2010 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 More sharing options...
showtime Posted June 14, 2010 Author Share Posted June 14, 2010 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.xmlCan 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 More sharing options...
showtime Posted June 21, 2010 Author Share Posted June 21, 2010 Can anyone help me...? Link to comment Share on other sites More sharing options...
bestwick Posted June 23, 2010 Share Posted June 23, 2010 May be as report parameter? 1 declare a parameter in jrxml ... name: paramId2 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¶mId=3 Link to comment Share on other sites More sharing options...
kavita.negi Posted October 16, 2013 Share Posted October 16, 2013 Very Helpful Answer Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now