dhairyashil.bhosale584 Posted January 12, 2016 Posted January 12, 2016 Hi all I am new to Jasper report, I am trying to generate tabular report in Jasper.I am trying iterate List in Table like this:JAVA Code:List<String> severity = (List<String>)session.getAttribute("severity"); List<String> messages = (List<String>)session.getAttribute("messages"); LinkedHashMap parameters = new LinkedHashMap(); parameters.put("severity", severity); parameters.put("messages", messages); jPrint = JasperFillManager.fillReport(jasperreport,parameters,new JREmptyDataSource()); JasperExportManager.exportReportToPdfStream(jPrint,baos);[/code] JRXML:<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="jasper_report_template" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="a3d5ea75-61fe-4bd0-a2ef-43652ca82bb5"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/> <queryString> <![CDATA[]]> </queryString> <field name="severity" class="java.util.List"> <fieldDescription><![CDATA[severity]]></fieldDescription> </field> <field name="messages" class="java.util.List"> <fieldDescription><![CDATA[messages]]></fieldDescription> </field> <columnHeader> <band height="23" splitType="Stretch"> <staticText> <reportElement mode="Opaque" x="0" y="-180" width="535" height="15" backcolor="#70A9A9" uuid="9b5b79e0-e146-41d9-b665-6cf9441c44f7"/> <box> <bottomPen lineWidth="1.0" lineColor="#CCCCCC"/> </box> <text><![CDATA[ ]]></text> </staticText> <staticText> <reportElement x="290" y="0" width="121" height="15" uuid="427a0dc3-acc5-445d-afdf-325f56220d5b"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font isBold="true"/> </textElement> <text><![CDATA[Error Severity]]></text> </staticText> <staticText> <reportElement x="0" y="3" width="136" height="15" uuid="9d05c15b-478c-49d3-a334-c5d6bfc62e53"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font isBold="true"/> </textElement> <text><![CDATA[Erorr Messages]]></text> </staticText> </band> </columnHeader> <detail> <band height="16" splitType="Stretch"> <staticText> <reportElement mode="Opaque" x="0" y="0" width="535" height="14" backcolor="#E5ECF9" uuid="b0ac6c6e-6d86-44de-801c-fcb85f1c5cb7"/> <box> <bottomPen lineWidth="0.25" lineColor="#CCCCCC"/> </box> <text><![CDATA[ ]]></text> </staticText> <textField> <reportElement x="290" y="0" width="121" height="15" uuid="d106ecf9-2dc8-49fb-b63c-e348b96f871d"/> <textElement textAlignment="Center" verticalAlignment="Middle"/> <textFieldExpression><![CDATA[$F{severity}]]></textFieldExpression> </textField> <textField> <reportElement x="0" y="0" width="136" height="15" uuid="d106ecf9-2dc8-49fb-b63c-e348b96f871d"/> <textElement textAlignment="Center" verticalAlignment="Middle"/> <textFieldExpression><![CDATA[$F{messages}]]></textFieldExpression> </textField> </band> </detail></jasperReport> So My question is,1) How to print these list in Jrxml?2) Is that right way to iterate List in jrxml?3) How to right perfect Jrxml code to iterate List? (is subreport is useful in this scenario?)
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