Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
371 views
in Technique[技术] by (71.8m points)

java - Passing the List of primitive type objects as datasource for subreport

I need to pass to my subreport a dataSource with help of master report's List<String> parameter. I don't know what is a type of dataSource is correct and how to get value in subreport.

The snippet from my master report:

<parameter name="seznamPriloh" class="java.util.List" isForPrompting="false"/>
....
<subreport>
    <reportElement x="0" y="56" width="555" height="76"/>
    <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{seznamPriloh})]]></dataSourceExpression>
            <subreportExpression><![CDATA[cz.alis.keong.jasjdr.reporting.ReportCompiler.compile("R79_SeznamPriloh")]]></subreportExpression>
</subreport>

The snippet from my subreport:

<detail>
    <band height="23">
        <textField>
            <reportElement x="56" y="3" width="100" height="20"/>
            <textElement/>
            <textFieldExpression><![CDATA[$F{}]]></textFieldExpression>
        </textField>
    </band>
</detail>

Please advise me how to pass the datasource to subreport via master report's parameter of java.util.List<String> type.

Edit: 08.14 14:20 Add Tags to Java

Edit: 08.14 15:30 relates with How do I print a list of strings contained within another list in iReport? and works for 4.5.0 And List<String>

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You have to specify what field you're using in your sub report. You are passing $F{} and as you are passing a List<String> as a DataSource you should put $F{_THIS}. Of course you have to add a field with that name too, only doing that you can use the expression $F{somefield}.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...