yaragalla Posted August 10, 2012 Share Posted August 10, 2012 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 More sharing options...
yaragalla Posted August 17, 2012 Author Share Posted August 17, 2012 please kindly help me with this situation? what to do in this situation? Link to comment Share on other sites More sharing options...
ankushchhabra Posted August 18, 2012 Share Posted August 18, 2012 Hi , Lets suppose if your java Bean , Accounts.java , contain the following propertiesPrivate String fName;Private String lName;Private List <BankAccount> bAccounts ; And BankAccount.java looks like followingprivate String bankId;private String branch ; ==================== iReport ==================== 1) Create a Master Report , Supply the query2 ) 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 reportHopefully , this will solve your purpose.' Regards,Ankush9988812479 Link to comment Share on other sites More sharing options...
yaragalla Posted August 19, 2012 Author Share Posted August 19, 2012 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 More sharing options...
yaragalla Posted August 21, 2012 Author Share Posted August 21, 2012 Thank you so much. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now