I have some trouble generating jasper report when i try to pass more than on value to a collection type parameter in my request body. In my rapport my parameter is decribed like this
<parameter name="skillList" class="java.util.Collection" nestedType="java.lang.String">
<parameterDescription><![CDATA[list of skill]]></parameterDescription>
</parameter>
In jaspersoft studio when i tried to visualize my report and add more value it work well and my report is generated
But when i try to use the execution service of the server using HTTP POST with a request body like this one :
<reportExecutionRequest>
<reportUnitUri>MyReportURI</reportUnitUri>
<async>false</async>
<outputFormat>pdf</outputFormat>
<parameters>
<reportParameter name="title">
<value>--- titre test ---</value>
</reportParameter>
<reportParameter name="header">
<value>@@@ header test @@@</value>
</reportParameter>
<reportParameter name="name">
<value>LE TUTOUR</value>
</reportParameter>
<reportParameter name="surname">
<value>Erwan</value>
</reportParameter>
<reportParameter name="skillList">
<value>java</value>
<value>maven</value>
</reportParameter>
</parameters>
</reportExecutionRequest>
If I have only one value in the skillList parameter my rapport is well generated, but when I add another one I have a HTTP 400 bad request.
In the documentation of the service there is many exemple with more than one value so i don't understand why my repport is not generated.
If someone have a solution or have encountered the same issue and solved it i woul not say no to some help.
edit In a new attempt I changed my parameter, it's now a subdataset
<subDataset name="listSkill" uuid="8027f62e-3b29-4faf-b11a-185b4db46d6f">
<field name="skill" class="java.lang.String">
<fieldDescription><![CDATA[_THIS]]></fieldDescription>
</field>
</subDataset>
and the way to use it
<componentElement>
<reportElement x="0" y="200" width="100" height="30" uuid="26b52f0f-e1e0-451e-9183-2df0f1f1ce65"/>
<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="listSkill" uuid="593d4d96-cbaf-46ba-94ef-97344e0cb4f2">
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{skills}) ]]></dataSourceExpression>
</datasetRun>
<jr:listContents height="30" width="100">
<textField>
<reportElement x="0" y="0" width="100" height="30" uuid="061f84d9-205a-4f49-a711-1f657b1fa5fd"/>
<textFieldExpression><![CDATA[$F{skill}]]></textFieldExpression>
</textField>
</jr:listContents>
</jr:list>
</componentElement>
still work in jaspersoft studio when I generate my report, but not when in try to execute it, using the REST API of the server.
Solved this:
Now I only pass 1 parameter to my rapport, a json string with all my parameters as fields.
I use a data adapter that match that string and replaced all the $P{xxxx} by $F{xxxx}.
Then I use the JSON_INPUT_STREAM
parameter of the report to cast that string to byte array input stream.
In this json string, my lists object are described like this
"LIST_SKILL": [
["skill one", "value 1"],
["skill two", "value 2"],
["skill three", "value 3"]
]
Then on my list object, in the dataSet properties::JRDatasource expression
((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("LIST_SKILL")
After that, my report is correctly generated in jaspersoft studio / server and with rest service call.