Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in iReport3.7.1 ,Struts2

 
Manali Mainkar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I am developing report in struts2 using jasper report.For report design I am using iReport3.7.1.
All VO class fiels are accessible with iReport along with the java.util.Arraylist contained in VO,but I am unable to access the fields of List.
Has anyone used the iReport with Sturts2 .
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to Javaranch!

Have you tried converting the List to an Object[]?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Isn't iReport just a jasperReports report designer? You don't really use it "with" Struts 2, you use the reports you designed.

In any case, yes, I created a bunch of reports using iReport and then used the JasperReports plugin to render them. I only did some of the work in iReport, though; too clunky to use. I never had any issues passing lists in (or arrays), if I remember correctly.
 
Manali Mainkar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ya...thats right ...its just the designer for jasper report . but while creating report ,it gives me fields,arraylist from my struts 2 vo class ,but I am not getting the solution for accesing the fields contain in my list .
 
Manali Mainkar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
My Object structure is like this...

StudentVO.java
int studentID;
String name;
Arraylist<SubjectVO> subjects;

& SubjectVO.java:
int subjectID;
String subjectName;
int marks;

I'm passing arraylist of StudentVO to report through Struts.xml
& I've attached object of StudentVO to dataset1 in ireport.
& then added all fields from that to report Fields.
After drag-dropping StudentID & name to page, I'm able to print ID & Name of student on page.
But just failing to populate arraylist of SubjectVO associated with that object on my page.

Thanks.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're not really providing enough information to help. In any case, this sounds more like a JasperReports issue than a Struts 2 issue.

Without any info regarding the action config for the "jasper" result, or any info about the report, it's impossible to help.
 
Manali Mainkar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
Actually I am passing DataSource,Location and Format as result params from struts.xml
<result name="success" type="jasper">
<param name="location">foo.jasper</param>
<param name="dataSource">mySource</param>
<param name="format">PDF</param>
</result>
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And "mySource" is...?
 
Manali Mainkar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mySource : Arraylist in my action class
location : location of jasper
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And the report looks like...?

Please don't make me ask everything. TellTheDetails. ItDoesntWorkIsUseless.
 
Manali Mainkar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My action
StudentVO studentVO = new StudentVO();
ArrayList<StudentVO> studentList= null;
SubjectVO vo = new SubjectVO ():
vo .setSubjectID(1);
vo.subjectName("English");
vo.setMarks(86) ;
Arraylist<SubjectVO> subjects = new Arraylist<SubjectVO>();
subjects .add(vo);
//StudentVo contais ArrayList<subjectVO>
studentVO .setStudentID(1);
studentVO .setName("StudentA");
studentVO.setSubjects (subjects) ;

//setting subjects ArrayList to StudentVO
studentList = new ArrayList<StudentVO>();

studentList .add(studentVO );
Passing studentList as dataSource from struts.xml
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please UseCodeTags when posting code or configuration. Unformatted code and configuration is unnecessarily difficult to read.

You can edit your post by using the button.

So show me the getter, and show me how you're accessing the data inside the report.
 
Manali Mainkar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry.actually I am new to this site....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic