erwanletutour.elt Posted February 24, 2022 Share Posted February 24, 2022 Hello,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>[/code]In jaspersoft studio when i tried to visualize my report and add more value it work well and my report is generatedBut 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>[/code]I got an error HTTP 400, 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.EDITIn 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>[/code]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>[/code]but still got the same error at the generation Link to comment Share on other sites More sharing options...
yama818 Posted February 24, 2022 Share Posted February 24, 2022 I haven't tried it, but the following article may be helpful.https://community.jaspersoft.com/wiki/how-pass-report-parameter-values-url-multi-select-list-input-control <reportParameter name="skillList"> <value>java</value> <value>maven</value> </reportParameter>[/code]↓ <reportParameter name="skillList"> <value>java</value> </reportParameter> <reportParameter name="skillList"> <value>maven</value> </reportParameter>[/code] Link to comment Share on other sites More sharing options...
erwanletutour.elt Posted February 25, 2022 Author Share Posted February 25, 2022 Thank for your answer, i tried it, but it only take the last value in the report, it seem like it overwrite the first value passed Link to comment Share on other sites More sharing options...
Solution erwanletutour.elt Posted May 19, 2022 Author Solution Share Posted May 19, 2022 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. Link to comment Share on other sites More sharing options...
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