Jump to content

doubt on java bean data source


yaragalla

Recommended Posts

 i have a bean and it contains some  properties and it also contain a collection. in my report in the column header section i have to use these properties and in the detail section i have to use the collection so i have to use the properties in the column header and the collection in the detail section. for example "registration number" should be in the column header and the products list should be in the detail section. how to achieve this? kindly help me? thanks in advance

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

 Hi , 

Lets suppose if your java Bean , Accounts.java , contain the following properties

Private String fName;

Private String lName;

Private List <BankAccount> bAccounts ;  

 

And BankAccount.java looks like following

private String bankId;

private String branch ; 

 

==================== iReport ====================

 

1) Create a Master Report , Supply the query

2 ) Declare fNname(String) , lName (String) , bAccounts (Object)

3) Drag fName and lName in the Header of the report 

4) In Detail band , create another subreport and pass bAccounts  as a datasource using the following expression

<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{bAccounts})]]></dataSourceExpression>

 5) Now , in the sub report , declare the fields  ie bankId(String) and branch(String)

6) Drag Drop the fields in detail bank of  Sub report

Hopefully , this will solve your purpose.'

 

 

Regards,

Ankush

9988812479

 

Link to comment
Share on other sites

Thank you so much Ankushchhabra. this is what i am looking for. Really thanks. But still I have some doubt. in your explanation you said  "1) Create a Master Report , Supply the query"      I cannot pass a query to the main report. All the data that my main report needs will be coming from a bean like "Accounts.java" I have to pass this bean to the main report in order to fill it. How can i pass this bean to the main report. which data source is suitable. when i check the API i found 2 data sources and both of them take collection and array. I am little confused. I am also new. kindly bear with me. Thanks in advance



Post Edited by yaragalla at 08/19/2012 18:58
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...