views:

521

answers:

0

I really hope someone has a clue on this layout issue, because I am already out of ideas.

Although I think that my problem has something to do with the designs i.e. with way Jasper treats them (layout), here's some general information abou the application.

Basically we have a JAVA client-server application and we use Jasper to generate a bunch of reports. The Jasper designs are processed by a servlet on the server-side and sent to the client as jrprint files, where they are being presented to the user. We also have a scriptlet that does some stuff - concatenating data etc.

The report that I am having trouble with has the following structure shown in code snippet #1

The data for it comes from a SQL query that works perfectly, so it's only the layout that is bugging me.

In the detail I have a bunch of textfields that visualise some hierarchy and another textfield that can contain relatively large amount of text. I've packed each of them in a frame, both of them building up another frame.

Beneath them I have another frame which can contain 0,1 or 2 images (ideally). I end up with a report containing pages like the one in attachment 1.

My goal is to have report pages where there is no space between the above frame and the image frame - like the one in attachment 2, and of course with the text within the upper frame. At the moment this is only possible if I get rid of the lengthy text.

In my opinion, the problem lies in the definition of the field for the lengthy text. As I don't know how long the string would be, i define it with a height of 13 (code snippet #2 ), that is one line only. Because of the stretching properties of the fields it accommodates accordingly, but by doing so it pushes the images down by variable number of lines. So, is there any way to avoid that "pushing", which ruins the design.


Code:

<band height="245" isSplitAllowed="false"><!-- 245 -->
  <frame>
    <reportElement isRemoveLineWhenBlank="true"
      positionType="Float" width="545" y="0" x="0" height="75"
      stretchType="RelativeToBandHeight">
    </reportElement>

    <box>
      <pen lineColor="black" lineStyle="Solid"
        lineWidth="1" />
    </box>

    <frame>
      <reportElement isRemoveLineWhenBlank="true"
        positionType="FixRelativeToTop" width="200" y="0" x="55"
        height="75" stretchType="RelativeToTallestObject"/>

      <box>
        <pen lineColor="green" lineStyle="Solid"
          lineWidth="3" />
      </box>

      <textField isStretchWithOverflow="true" pattern=""
        isBlankWhenNull="true" evaluationGroup="Ebene2">
        <reportElement x="0" y="0" width="200"
          height="13" positionType="Float" isRemoveLineWhenBlank="true"
          isPrintInFirstWholeBand="true">
          <printWhenExpression><![CDATA[new Boolean(  ($F{AnlagenEbeneOfSchaden}).intValue()==1 )]]></printWhenExpression>
        </reportElement>

        <textElement>
          <font fontName="Arial" size="10"
            isBold="true" isItalic="false" isUnderline="false"
            isStrikeThrough="false" pdfFontName="Helvetica-Bold"
            pdfEncoding="CP1252" isPdfEmbedded="false" />
        </textElement>
        <textFieldExpression class="java.lang.String"><![CDATA[((alwin2Scriptlet)$P{REPORT_SCRIPTLET}).getStrukturBezMitStandOrtEbeneDB($F{Strukturcode1}, 1)]]></textFieldExpression>
      </textField>

      <textField isStretchWithOverflow="true" pattern=""
        isBlankWhenNull="true" evaluationGroup="Ebene2">
        <reportElement x="15" y="0" width="185"
          height="13" mode="Opaque" positionType="Float"
          isRemoveLineWhenBlank="true" isPrintInFirstWholeBand="true" />
        <textElement>
          <font fontName="Arial" size="10"
            isBold="true" isItalic="false" isUnderline="false"
            isStrikeThrough="false" pdfFontName="Helvetica-Bold"
            pdfEncoding="CP1252" isPdfEmbedded="false" />
        </textElement>
        <textFieldExpression class="java.lang.String"><![CDATA[((alwin2Scriptlet)$P{REPORT_SCRIPTLET}).getStrukturBezMitStandOrtEbeneDB($F{Strukturcode1}, 2)]]></textFieldExpression>
      </textField>
      <textField isStretchWithOverflow="true" pattern=""
        isBlankWhenNull="true" evaluationGroup="Ebene3">
        <reportElement mode="Opaque" x="30" y="15"
          width="170" height="13" positionType="Float"
          isRemoveLineWhenBlank="true" />
        <textElement>
          <font fontName="Arial" size="10"
            isBold="false" isItalic="false" isUnderline="false"
            isStrikeThrough="false" pdfFontName="Helvetica"
            pdfEncoding="CP1252" isPdfEmbedded="false" />
        </textElement>
        <textFieldExpression class="java.lang.String"><![CDATA[((alwin2Scriptlet)$P{REPORT_SCRIPTLET}).getStrukturBezMitStandOrtEbeneDB($F{Strukturcode1}, 3)]]></textFieldExpression>
      </textField>

      <textField isStretchWithOverflow="true" pattern=""
        isBlankWhenNull="true">
        <reportElement mode="Opaque" x="45" y="30"
          width="155" height="13" positionType="Float"
          isRemoveLineWhenBlank="true" />
        <textElement>
          <font fontName="Arial" size="10"
            isBold="false" isItalic="false" isUnderline="false"
            isStrikeThrough="false" pdfFontName="Helvetica"
            pdfEncoding="CP1252" isPdfEmbedded="false" />
        </textElement>
        <textFieldExpression class="java.lang.String"><![CDATA[((alwin2Scriptlet)$P{REPORT_SCRIPTLET}).getStrukturBezMitStandOrtEbeneDB($F{Strukturcode1}, 4)]]></textFieldExpression>
      </textField>
      <textField isStretchWithOverflow="true" pattern=""
        isBlankWhenNull="true">
        <reportElement mode="Opaque" x="60" y="45"
          width="140" height="13" positionType="Float"
          isRemoveLineWhenBlank="true" />
        <textElement>
          <font fontName="Arial" size="10"
            isBold="false" isItalic="false" isUnderline="false"
            isStrikeThrough="false" pdfFontName="Helvetica"
            pdfEncoding="CP1252" isPdfEmbedded="false" />
        </textElement>
        <textFieldExpression class="java.lang.String"><![CDATA[((alwin2Scriptlet)$P{REPORT_SCRIPTLET}).getStrukturBezMitStandOrtEbeneDB($F{Strukturcode1}, 5)]]></textFieldExpression>
      </textField>
      <textField isStretchWithOverflow="true" pattern=""
        isBlankWhenNull="true">
        <reportElement mode="Opaque" x="75" y="60"
          width="125" height="13" positionType="Float"
          isRemoveLineWhenBlank="true" />
        <textElement>
          <font fontName="Arial" size="10"
            isBold="false" isItalic="false" isUnderline="false"
            isStrikeThrough="false" pdfFontName="Helvetica"
            pdfEncoding="CP1252" isPdfEmbedded="false" />
        </textElement>
        <textFieldExpression class="java.lang.String"><![CDATA[((alwin2Scriptlet)$P{REPORT_SCRIPTLET}).getStrukturBezMitStandOrtEbeneDB($F{Strukturcode1}, 6)]]></textFieldExpression>
      </textField>
    </frame>

    <textField isStretchWithOverflow="true" pattern=""
      isBlankWhenNull="true">
      <reportElement mode="Opaque" x="30" y="1" width="20"
        height="13" isRemoveLineWhenBlank="true" />
      <textElement>
        <font fontName="Arial" size="10" isBold="true"
          isItalic="false" isUnderline="false" isStrikeThrough="false"
          pdfFontName="Helvetica" pdfEncoding="CP1252"
          isPdfEmbedded="false" />
      </textElement>
      <textFieldExpression class="java.lang.Integer"><![CDATA[$V{REPORT_COUNT}]]></textFieldExpression>
    </textField>
    <textField isStretchWithOverflow="true" pattern=""
      isBlankWhenNull="true">
      <reportElement mode="Opaque" x="515" y="1"
        width="20" height="13" isRemoveLineWhenBlank="true" />
      <textElement textAlignment="Right">
        <font fontName="Arial" size="11" isBold="true"
          isItalic="false" isUnderline="false" isStrikeThrough="false"
          pdfFontName="Helvetica-Bold" pdfEncoding="CP1252"
          isPdfEmbedded="false" />
      </textElement>
      <textFieldExpression class="java.lang.String"><![CDATA[$F{Bewertung}]]></textFieldExpression>
    </textField>
    <frame>
      <reportElement isRemoveLineWhenBlank="true"
        positionType="FixRelativeToTop" width="240" y="0" x="255"
        height="15" stretchType="RelativeToTallestObject" />

      <box>
        <pen lineColor="red" lineStyle="Solid"
          lineWidth="3" />
      </box>

      <textField isStretchWithOverflow="true"
        isBlankWhenNull="true">
        <reportElement mode="Opaque" x="0" y="1"
          width="240" height="13" isRemoveLineWhenBlank="true"
          isPrintWhenDetailOverflows="true"  />
        <textElement verticalAlignment="Top">
          <font fontName="Arial" size="10"
            isBold="false" isItalic="false" isUnderline="false"
            isStrikeThrough="false" pdfFontName="Helvetica"
            pdfEncoding="CP1252" isPdfEmbedded="false" />
        </textElement>
        <textFieldExpression class="java.lang.String"><![CDATA[$F{SCHADENGRUPPE} + ($F{SCHADENBESCHREIBUNG}!=null?$F{SCHADENBESCHREIBUNG}:"")+" ["+$F{SCHADENNR}+"]"]]></textFieldExpression>
      </textField>
    </frame>
  </frame>
  <frame>
    <reportElement isRemoveLineWhenBlank="true"
      positionType="Float" width="545" y="76" x="0" height="155">
      <printWhenExpression><![CDATA[new Boolean( (!($F{BILD1_FILE} == null) ) || (!($F{BILD2_FILE} == null)) )]]></printWhenExpression>
    </reportElement>
    <!--        <box padding="5">
      <pen lineColor="black" lineStyle="Solid"
      lineWidth="3" />
      </box>
    -->
    <image vAlign="Top" hAlign="Center">
      <reportElement positionType="Float" x="303" y="0"
        width="212" height="145" isPrintWhenDetailOverflows="true"
        isRemoveLineWhenBlank="true">
        <printWhenExpression><![CDATA[new Boolean( (!($F{BILD1_FILE} == null) ) && ($F{BILD2_FILE} == null) )]]></printWhenExpression>
      </reportElement>
      <graphicElement />
      <imageExpression class="java.awt.Image"><![CDATA[$F{BILD1_FILE}]]></imageExpression>
    </image>
    <image vAlign="Top" hAlign="Center">
      <reportElement positionType="Float" x="303" y="0"
        width="212" height="145" isPrintWhenDetailOverflows="true"
        isRemoveLineWhenBlank="true">
        <printWhenExpression><![CDATA[new Boolean( (!($F{BILD2_FILE} == null)) && ($F{BILD1_FILE} == null) )]]></printWhenExpression>
      </reportElement>
      <graphicElement />
      <imageExpression class="java.awt.Image"><![CDATA[$F{BILD2_FILE}]]></imageExpression>
    </image>
    <image vAlign="Top" hAlign="Center">
      <reportElement positionType="Float" x="70" y="0"
        width="212" height="145" isPrintWhenDetailOverflows="true"
        isRemoveLineWhenBlank="true">
        <printWhenExpression><![CDATA[new Boolean( (!($F{BILD1_FILE} == null) ) && (!($F{BILD2_FILE} == null)) )]]></printWhenExpression>
      </reportElement>
      <graphicElement />
      <imageExpression class="java.awt.Image"><![CDATA[$F{BILD1_FILE}]]></imageExpression>
    </image>
    <image vAlign="Top" hAlign="Center">
      <reportElement positionType="Float" x="303" y="0"
        width="212" height="145" isPrintWhenDetailOverflows="true"
        isRemoveLineWhenBlank="true">
        <printWhenExpression><![CDATA[new Boolean( (!($F{BILD2_FILE} == null)) && (!($F{BILD1_FILE} == null)) )]]></printWhenExpression>
      </reportElement>
      <graphicElement />
      <imageExpression class="java.awt.Image"><![CDATA[$F{BILD2_FILE}]]></imageExpression>
    </image>
  </frame>

  <line>
    <reportElement positionType="Float" mode="Opaque" x="0"
      y="240" width="525" height="1" />
    <graphicElement pen="Thin" />
  </line>

  <!--
    <frame>
    <reportElement isRemoveLineWhenBlank="true"
    positionType="Float" width="545" y="86" x="0" height="170">
    <printWhenExpression><![CDATA[new Boolean( (!($F{BILD1_FILE} == null) ) || (!($F{BILD2_FILE} == null)) )]]></printWhenExpression>
    </reportElement>
    <box>
    <pen lineColor="black" lineStyle="Solid"
    lineWidth="1" />
    </box>
    </frame>
  -->
</band>

Code:

<textField isStretchWithOverflow="true"
  isBlankWhenNull="true">
  <reportElement mode="Opaque" x="0" y="1"
    width="240" height="13" isRemoveLineWhenBlank="true"
    isPrintWhenDetailOverflows="true"  />
  <textElement verticalAlignment="Top">
    <font fontName="Arial" size="10"
      isBold="false" isItalic="false" isUnderline="false"
      isStrikeThrough="false" pdfFontName="Helvetica"
      pdfEncoding="CP1252" isPdfEmbedded="false" />
  </textElement>
  <textFieldExpression class="java.lang.String"><![CDATA[$F{SCHADENGRUPPE} + ($F{SCHADENBESCHREIBUNG}!=null?$F{SCHADENBESCHREIBUNG}:"")+" ["+$F{SCHADENNR}+"]"]]></textFieldExpression>
</textField>


Screenshots:

screenshot 1

screenshot 2