Jump to content
Changes to the Jaspersoft community edition download ×

How print a array in jasper ?


gabriel.nadoroski
Go to solution Solved by reportdev,

Recommended Posts

Hi, I need help, I am sending the parameter in array, to printed in the report the problem is:

It is printed like this:
"[ex]"

And I need to print like this, like a table:

ex1
-----
ex2

I don't use a query to send the parameters, I sending for a array using a framework in php, is just a test to implement in a real report, I just need know how I can do that, someone can help ?

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

  • Solution

you need to convert the List to JRBeanCollectionDataSource in order for it to iterate and use a List element

<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.4.2.final using JasperReports Library version 6.4.1  --><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="Iterator" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="20f55d6a-1496-430d-8dde-cdb41d7b53ac">    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>    <subDataset name="Dataset1" uuid="a32a36ba-2e14-4071-9649-c5738d43e63a">        <queryString>            <![CDATA[]]>        </queryString>        <field name="_THIS" class="java.lang.String"/>    </subDataset>    <parameter name="arrayAccepter" class="java.util.List">        <defaultValueExpression><![CDATA[Arrays.asList("Hello1", "Hello2", "Hello3", "Hello4")]]></defaultValueExpression>    </parameter>    <queryString>        <![CDATA[]]>    </queryString>    <background>        <band splitType="Stretch"/>    </background>    <detail>        <band height="90">            <textField>                <reportElement x="0" y="0" width="290" height="30" uuid="5208b9c8-6128-4f52-90de-7d93bbd0294e"/>                <textFieldExpression><![CDATA[$P{arrayAccepter}.toString()]]></textFieldExpression>            </textField>            <componentElement>                <reportElement x="0" y="60" width="100" height="30" uuid="b014b59d-186c-42cd-b975-a7a1ca18ca9f"/>                <jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">                    <datasetRun subDataset="Dataset1" uuid="b3c55d8f-90d9-4ddc-9fa1-66da2cb48783">                        <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{arrayAccepter})]]></dataSourceExpression>                    </datasetRun>                    <jr:listContents height="30" width="100">                        <textField>                            <reportElement x="0" y="0" width="100" height="30" uuid="c6bd4e2a-e756-4089-bdf7-9b06b5575201"/>                            <textFieldExpression><![CDATA[$F{_THIS}]]></textFieldExpression>                        </textField>                    </jr:listContents>                </jr:list>            </componentElement>        </band>    </detail></jasperReport>[/code]

 

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...