Jump to content
Changes to the Jaspersoft community edition download ×

How to print list parameters in jrxml


vishnukumar

Recommended Posts

Hi,

 

I am new to jasper reports. I am passing parameters as following.

 

List<String> courseModules = new ArrayList<String>();

      List<String> marks = new ArrayList<String>();

     

      courseModules.add("Medical Billing");

      courseModules.add("Medical Transcription");

      marks.add("20");

      marks.add("30");

           

      Map model = new HashMap();

      model.put("courseModules", courseModules);

      model.put(“marks”, marks);

      model.put("BaseDir", "reports");

      model.put("JRDataSource", new JREmptyDataSource());

     

      ModelAndView returnModelAndView = new ModelAndView("marksheet", model);

 

I use ResourceBundleViewResolver. In .jrxml, I map parameters as

 

<parameter name="courseModules" class="java.util.List"/>

 

<parameter name="marks" class="java.util.List"/>

 

 

I got printed as

 

[Medical Billing, Medical Transcription]

[20, 30]

 

But, my requirement is, I have to print like

 

   Courses              Mark

Medica Billing          30

Medical Transcription   40

 

I don’t know how to iterate the elements in the list in jrxml.

Please, guide me.

 

Thanks

Vishnu

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Hi,

 

You could iterate though lists using a list component or a subreport.

In JasperReports, iterating through something always implies a subdataset or a data source.

 

I suggest you go with a list. Check the /demo/samples/list sample provided with the JR project package. You'll have to create a dataset that iterates though your list, probably using a build-in data source such as JRBeanCollectionDataSource or even a custom made data source implementation. Check the /demo/samples/datasource sample for details about custom data sources.

 

I hope this helps.
Teodor

 

Link to comment
Share on other sites

  • 1 year later...

 Dear Vishnu,

 

Could you achieve it ? I am also facing the exact problem but not able to solve it. Can you please share with me a sample jrxml file where you are iterating through a List (java.util.List) and printing the java bean attributes?

A quick reply would be a great help.

Regards

Pavitra

 

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