I am trying to get a comma separated string from a parameter I am passing into my jaspersoft report. This is what I have tried but jasper studio says the expression is invalid. Please assist.
IntStream.range(0, $P{cities}.size()).mapToObj(index -> $P{cities}.get(index).get("label")).collect(Collectors.joining(", "))
I modiefied a little example I made with a variable, it should work the same with a parameter:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.21.0.final using JasperReports Library version 6.21.0-4f56c4f36cd19e17675219a9ac4692d5f0f13b06 -->
<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="Führungskräftegespräch" pageWidth="602" pageHeight="3000" columnWidth="602" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" isFloatColumnFooter="true" uuid="80afabe3-2d3d-4c26-8c41-8e3b10a62a77">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<queryString>
<![CDATA[]]>
</queryString>
<variable name="cities" class="java.util.List">
<variableExpression><![CDATA[java.util.stream.LongStream.range(0,3).mapToObj(i -> java.util.Collections.singletonMap("label", String.valueOf(i))).collect(java.util.stream.Collectors.toList())]]></variableExpression>
</variable>
<background>
<band splitType="Stretch"/>
</background>
<summary>
<band height="842">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<staticText>
<reportElement x="210" y="10" width="100" height="30" uuid="0ac46265-4524-42a2-a14a-220ee44b165d"/>
<text><![CDATA[Main Report]]></text>
</staticText>
<textField>
<reportElement x="60" y="120" width="371" height="81" uuid="02bbcdb4-3ad4-4043-b257-11ec5c378e15"/>
<textFieldExpression><![CDATA[$V{cities}.stream().map(o -> ((Map<String,Object>)o).get("label").toString()).collect(java.util.stream.Collectors.joining(","))]]></textFieldExpression>
</textField>
</band>
</summary>
</jasperReport>