0

当我将方法 isNullOrEmpty(String) 放入报告中时,我的报告出现问题。
我不知道是什么问题。
有人知道是什么问题吗?

这是我的 jrxml 文件:

 <jasperReport ....>
    <parameter name="TRUE" isForPrompting="false" class="java.lang.Boolean">
        <defaultValueExpression ><![CDATA[new Boolean(true)]]>
        </defaultValueExpression>
    </parameter>
    <parameter name="date_start" isForPrompting="true" class="java.sql.Timestamp">
        <parameterDescription><![CDATA[reports.helpdesk.startDate]]>
        </parameterDescription>
        <defaultValueExpression ><![CDATA[new java.sql.Timestamp(System.currentTimeMillis()-262800000)]]>
        </defaultValueExpression>
    </parameter>
    <parameter name="date_end" isForPrompting="true" class="java.sql.Timestamp">
        <parameterDescription><![CDATA[reports.helpdesk.endDate]]>
        </parameterDescription>
        <defaultValueExpression ><![CDATA[new java.sql.Timestamp(System.currentTimeMillis())]]>
        </defaultValueExpression>
    </parameter>
    <parameter name="CENTRIC_DICTIONARY" isForPrompting="false" class="java.util.Map"/>
    <parameter name="SCRIPT_DB_CONNECTION" isForPrompting="false" class="java.sql.Connection"/>
    <field name="enteredby" class="java.lang.Integer"/>
    <field name="description" class="java.lang.String"/>
    <field name="assigned_date" class="java.sql.Timestamp"/>
    <field name="max_score" class="java.lang.Integer"/>
    <field name="totalAnswer" class="java.lang.Integer"/>
    <field name="totalticketcreated" class="java.lang.Integer"/>
    <field name="totalfeedbackreceived" class="java.lang.Integer"/>
    <field name="score" class="java.lang.Integer"/>
    <background>
        <band height="0"  isSplitAllowed="true" >
        </band>
    </background>
    <title>
        <band height="0"  isSplitAllowed="true" >
        </band>
    </title>
    <pageHeader>
        <band height="108"  isSplitAllowed="true" >
            <staticText>
                <reportElement
                    x="0"
                    y="0"
                    width="802"
                    height="20"
                    key="staticText"/>
                <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
                <textElement textAlignment="Center" verticalAlignment="Top" rotation="None" lineSpacing="Single">
                    <font fontName="SansSerif" size="12" isBold="true"/>
                </textElement>
                <text><![CDATA[Customer Feedback by Counter]]>
                </text>
            </staticText>
            <textField isStretchWithOverflow="true" isBlankWhenNull="true" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
                <reportElement
                    x="0"
                    y="20"
                    width="802"
                    height="35"
                    key="textField"
                    isRemoveLineWhenBlank="true"/>
                <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
                <textElement textAlignment="Center" verticalAlignment="Top" rotation="None" lineSpacing="Single">
                    <font size="12" isBold="true"/>
                </textElement>
                <textFieldExpression   class="java.lang.String"><![CDATA[" From ( " + $P{date_start} + " - " + $P{date_start} + " )"]]>
                </textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="true" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
                <reportElement
                    x="0"
                    y="54"
                    width="802"
                    height="41"
                    key="textField"
                    isRemoveLineWhenBlank="true"/>
                <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
                <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" isStyledText="true" lineSpacing="1_1_2">
                    <font size="11" isBold="true"/>
                </textElement>
                <textFieldExpression   class="java.lang.String"><![CDATA[(!Strings.isNullOrEmpty($P{date_start})) ? "Date Ticket Created From : " + $P{date_start} +"\n" + "Date Ticket Created to : " + $P{date_end}
     : "Date Ticket Created From : " + $P{date_start} +"\n" + "Date Ticket Created to : " + $P{date_end}]]>
                </textFieldExpression>
            </textField>
        </band>
    </pageHeader>
</jasperReport>

更新: - 为什么当我使用这个公式时结果不能显示:

new SimpleDateFormat("dd/MM/yyyy").format($P{date_start})!= null   &&  new SimpleDateFormat("dd/MM/yyyy").format($P{date_end})!=null  && ($P{lookup_department}==null) && ($P{lookup_assignedOfficer}==null) ? "Date Ticket Created From : " + new SimpleDateFormat("dd/MM/yyyy").format($P{date_start}) +"\n" + "Date Ticket Created to : " + new SimpleDateFormat("dd/MM/yyyy").format($P{date_end})
:new SimpleDateFormat("dd/MM/yyyy").format($P{date_start})!=null   &&  new SimpleDateFormat("dd/MM/yyyy").format($P{date_end})!=null  && ($P{lookup_department}!=null) && ($P{lookup_assignedOfficer}==null) ? "Division :"+$F{division} 
:new SimpleDateFormat("dd/MM/yyyy").format($P{date_start})!=null   &&  new SimpleDateFormat("dd/MM/yyyy").format($P{date_end})!=null  && ($P{lookup_department}==null) && ($P{lookup_assignedOfficer}!=null) ? "Ticket Created :"+$F{tickedcreted}
: $F{division}
4

1 回答 1

0

您的 date_start 参数是一个时间戳, isNullOrEmpty() 方法显然需要一个字符串。试试这个:

$P{date_start} != null

整个文本字段表达式变为:

<textFieldExpression   class="java.lang.String"><![CDATA[($P{date_start} != null) ? "Date Ticket Created From : " + $P{date_start} +"\n" + "Date Ticket Created to : " + $P{date_end}
 : "Date Ticket Created From : " + $P{date_start} +"\n" + "Date Ticket Created to : " + $P{date_end}]]></textFieldExpression>
于 2012-07-12T15:36:36.420 回答