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

Is there a way to pass list<String> object to datasource instead of custom class object


nikith.g23005

Recommended Posts

Hi im working on jasper reports and using dynamic jasper .im getting this error Error retrieving field value from bean: when i pass list object holding string values and it works if i pass a custom objects .my requirement is that im getting data as vector object holding string type and i dont want to create custom object or map object as i have more than 100 rows in my vector object.Is there any way i can pass list object to data source to make it work 
JRDataSource ds=new JRBeanCollectionDataSource(vec);

Link to comment
Share on other sites

Hi.

I am working with a lot of List of String in my project.
I pass that List into jasper as a parameter.

HashMap<String, Object> parameters = new HashMap<>();// List string parameterparameters.put("myList", listString);[/code]

Then I define a subDataset

				]]>	</queryString>	<field name="_THIS" class="java.lang.String"/></subDataset>[/code]<p>And use it in template:</p><pre language="xml">	<jr:list printOrder="Vertical">	<datasetRun subDataset="stringArray" uuid="97f0b91c-e67f-436b-bdd3-8e064de6f366">		<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{myList})																				$F{_THIS}			[/code]

Hope this can help you

  • Like 1
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...