1

I have to generate a report, that displays info about one object ( so the input is only one bean ).

The first problem is - this bean should contain lists of sub-beans( for example, comments, with comment type and comment date ). So I can pass them to a sub-report.

The second problem is - there is an array of 4 sub-beans, that contains few fields. I can create a separate field for each sub-bean's property ( firstSubBeanName, secondSubBeanName... ) , but it's ugly :(. Ideally, there should be a way to access these beans in a such way :

$F{test}[0].name

Please help.

2
  • I don't see why this wouldn't work, provided that the field is declared with the appropriate type (i.e. com.foo.bar.SomeBean[]). Have you tried it? Do you have any error? Commented Oct 23, 2011 at 9:49
  • Well, I didn't know how to specify the type 'array of something', at least with generics it doesn't work. But it works well with lists, so the problem is resolved. Commented Oct 23, 2011 at 15:30

1 Answer 1

2

If your list have a name (ie is a property of the object), you have just to pass as Data Source Expression for the subreport this property

$F{subBeansList}

The subreport should be ready to receive such kind of data. If you are using struts, it is possible you should use this class:

org.apache.struts2.views.jasperreports.ValueStackDataSource

as intermediary on your list field to be passed to the subreport.

The second question, the easy way is to use a list, so you can use this expression:

$F{test}.thelist.get(0)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.