ホームページ >Java >&#&チュートリアル >JasperReports の詳細バンドに JavaBean のリストを表示するにはどうすればよいですか?
A JavaBean には、 java.util.List。このリストのデータを JasperReports ドキュメントの Detail
バンドに表示するにはどうすればよいですか?解決策// Java source to generate the report ... // DataSource using JRBeanCollectionDataSource private static JRDataSource getDataSource() { Collection<beanwithlist> coll = ...; return new JRBeanCollectionDataSource(coll); } // JavaBean public class BeanWithList { private List<string> cities; // ... // Ensure a public getter for field extraction public List<string> getCities() { return this.cities; } } // jrxml file ... // Subdataset for iterating through the list <subdataset name="dataset1"> <field name="city" class="java.lang.String"> <fielddescription></fielddescription> </field> </subdataset> // Detail band with jr:list component <detail> ... <componentelement> <!-- jr:list component --> <list ...> <datasetrun subdataset="dataset1"> <!-- DataSource expression using JRBeanCollectionDataSource --> <datasourceexpression></datasourceexpression> </datasetrun> <listcontents ...> <textfield ...> <textfieldexpression></textfieldexpression> </textfield> </listcontents> </list> </componentelement> ... </detail> ...</string></string></beanwithlist>結果
この構成は、詳細
バンド内のリストのデータを表示するレポートを生成します。追加情報以上がJasperReports の詳細バンドに JavaBean のリストを表示するにはどうすればよいですか?の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。