Pass a field from a subreport to a subreport

0

Main report 

<subreport>
                <reportElement stretchType="RelativeToTallestObject" x="24" y="10" width="548" height="623" uuid="198e6ba0-fa45-47af-8d87-2325efd48899"/>
                <subreportParameter name="p_s_hostname">
                    <subreportParameterExpression><![CDATA[$P{p_s_hostname}]]></subreportParameterExpression>
                </subreportParameter>
                <dataSourceExpression><![CDATA[$P{p_l_resultTypeTwo}]]></dataSourceExpression>
                <subreportExpression><![CDATA["report/result_sub.jasper"]]></subreportExpression>
 </subreport>

 

 

Subreport 

  <subreport>
                    <reportElement x="20" y="10" width="509" height="70" uuid="440f2f73-a20a-4738-860e-b4078f7edeab"/>
                    <subreportParameter name="p_s_hostname">
                        <subreportParameterExpression><![CDATA[$F{commentList}]]></subreportParameterExpression>
                    </subreportParameter>
                    <subreportExpression><![CDATA["report/comment.jasper"]]></subreportExpression>
</subreport>

JAVA

List <DataMap> list = isptResultService.selectResultTypeOneForReport(param);

        for (int i = 0; i < list.size(); i++) {
            DataMap map = list.get(i);

            List<DataMap> itemResultList = isptResultService.selectIsptItemResultList(map);
            map.put("itemResultList", itemResultList);
          
            List<DataMap> commentList = isptResultService.selectIsptCommentListForReport(map);
            for(int j = 0; j<commentList.size(); j++) {
            commentList.get(j).put("P_S_HOSTNAME", ConfigUtils.getString("SYSTEM.SITE.ADDR"));
            }
            map.put("commentList", new JRBeanCollectionDataSource(commentList));
        }
        model.addAttribute("p_l_resultTypeTwo", new JRBeanCollectionDataSource(list));

<span style="font-size:12px">In the main report, I used a field variable declaration to pass a parameter to a subreport.</span>

I want to send a commentList from a subreport to a subreport.

but net.sf.jasperreports.engine.fill.JRFillSubreport - Fill 2: exception

<span style="font-size:12px">In the main report, there is a value of p_l_resultTypeTwo.</span> <span style="font-size:12px">In the main report, there is no value for commentList.</span> What is the problem?

wkwjsrjehenr's picture
Joined: May 1 2019 - 9:04pm
Last seen: 5 months 5 days ago

1 Answer:

0

You only show the first row of the error stack trace, show a bit more to see maybe what error actually is about

rodrigo_43's picture
Joined: Apr 26 2019 - 4:15pm
Last seen: 1 week 5 days ago
Feedback