如何根据条件创建不同的页脚?

How to create different page footer depending on a condition?

我需要根据条件显示不同的页脚。

我的页脚由许多静态标签组成,理论上我可以为每个标签定义一个 'Print When Expression'。但是很不方便。

问: 是否可以根据条件 select 使用不同的页脚?

如果不是,我还能如何处理这种情况而不必在很多地方指定条件?

xsd allows none or maximum one pageFooter tag with a maximum of one乐队。

但是

这是一个典型示例,您可以在其中使用 frame component 对数据进行分组并决定是否显示它。

示例 根据页码显示带有文本字段的不同框架

<pageFooter>
    <band height="60" splitType="Stretch">
        <frame>
            <reportElement x="0" y="0" width="540" height="60" uuid="d0198e94-8325-4909-9804-a8d393600ec5">
                <printWhenExpression><![CDATA[$V{PAGE_NUMBER}%2!=0]]></printWhenExpression>
            </reportElement>
            <textField>
                <reportElement x="0" y="0" width="100" height="30" uuid="379e2ac0-63ea-4493-bd38-1b7ca7b35d8c"/>
                <textFieldExpression><![CDATA["Text Field 1"]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="0" y="30" width="100" height="30" uuid="6598ba79-08b6-4997-953d-70b64f159e3b"/>
                <textFieldExpression><![CDATA["Text Field 2"]]></textFieldExpression>
            </textField>
        </frame>
        <frame>
            <reportElement x="0" y="0" width="540" height="60" uuid="d0198e94-8325-4909-9804-a8d393600ec5">
                <printWhenExpression><![CDATA[$V{PAGE_NUMBER}%2==0]]></printWhenExpression>
            </reportElement>
            <textField>
                <reportElement x="0" y="0" width="100" height="30" uuid="379e2ac0-63ea-4493-bd38-1b7ca7b35d8c"/>
                <textFieldExpression><![CDATA["Text Field 3"]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="0" y="30" width="100" height="30" uuid="6598ba79-08b6-4997-953d-70b64f159e3b"/>
                <textFieldExpression><![CDATA["Text Field 4"]]></textFieldExpression>
            </textField>
        </frame>
    </band>
</pageFooter>

将不同pageFooter的不同文本添加到不同的frame,然后在frame组件上设置printWhenExpression。