title: Gridlock with textfields with dynamic content
body: <p>I really hope someone has a clue on this layout issue, because I am already out of ideas.</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>The report that I am having trouble with has the following structure shown in code snippet #1</p>
  
  <p>The data for it comes from a SQL query that works perfectly, so it's only the layout that is bugging me.</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <hr>
  
  <h3>Code:</h3>
  
  <pre><code>&lt;band height="245" isSplitAllowed="false"&gt;&lt;!-- 245 --&gt;
    &lt;frame&gt;
      &lt;reportElement isRemoveLineWhenBlank="true"
        positionType="Float" width="545" y="0" x="0" height="75"
        stretchType="RelativeToBandHeight"&gt;
      &lt;/reportElement&gt;
  
      &lt;box&gt;
        &lt;pen lineColor="black" lineStyle="Solid"
          lineWidth="1" /&gt;
      &lt;/box&gt;
  
      &lt;frame&gt;
        &lt;reportElement isRemoveLineWhenBlank="true"
          positionType="FixRelativeToTop" width="200" y="0" x="55"
          height="75" stretchType="RelativeToTallestObject"/&gt;
  
        &lt;box&gt;
          &lt;pen lineColor="green" lineStyle="Solid"
            lineWidth="3" /&gt;
        &lt;/box&gt;
  
        &lt;textField isStretchWithOverflow="true" pattern=""
          isBlankWhenNull="true" evaluationGroup="Ebene2"&gt;
          &lt;reportElement x="0" y="0" width="200"
            height="13" positionType="Float" isRemoveLineWhenBlank="true"
            isPrintInFirstWholeBand="true"&gt;
            &lt;printWhenExpression&gt;&lt;![CDATA[new Boolean(  ($F{AnlagenEbeneOfSchaden}).intValue()==1 )]]&gt;&lt;/printWhenExpression&gt;
          &lt;/reportElement&gt;
  
          &lt;textElement&gt;
            &lt;font fontName="Arial" size="10"
              isBold="true" isItalic="false" isUnderline="false"
              isStrikeThrough="false" pdfFontName="Helvetica-Bold"
              pdfEncoding="CP1252" isPdfEmbedded="false" /&gt;
          &lt;/textElement&gt;
          &lt;textFieldExpression class="java.lang.String"&gt;&lt;![CDATA[((alwin2Scriptlet)$P{REPORT_SCRIPTLET}).getStrukturBezMitStandOrtEbeneDB($F{Strukturcode1}, 1)]]&gt;&lt;/textFieldExpression&gt;
        &lt;/textField&gt;
  
        &lt;textField isStretchWithOverflow="true" pattern=""
          isBlankWhenNull="true" evaluationGroup="Ebene2"&gt;
          &lt;reportElement x="15" y="0" width="185"
            height="13" mode="Opaque" positionType="Float"
            isRemoveLineWhenBlank="true" isPrintInFirstWholeBand="true" /&gt;
          &lt;textElement&gt;
            &lt;font fontName="Arial" size="10"
              isBold="true" isItalic="false" isUnderline="false"
              isStrikeThrough="false" pdfFontName="Helvetica-Bold"
              pdfEncoding="CP1252" isPdfEmbedded="false" /&gt;
          &lt;/textElement&gt;
          &lt;textFieldExpression class="java.lang.String"&gt;&lt;![CDATA[((alwin2Scriptlet)$P{REPORT_SCRIPTLET}).getStrukturBezMitStandOrtEbeneDB($F{Strukturcode1}, 2)]]&gt;&lt;/textFieldExpression&gt;
        &lt;/textField&gt;
        &lt;textField isStretchWithOverflow="true" pattern=""
          isBlankWhenNull="true" evaluationGroup="Ebene3"&gt;
          &lt;reportElement mode="Opaque" x="30" y="15"
            width="170" height="13" positionType="Float"
            isRemoveLineWhenBlank="true" /&gt;
          &lt;textElement&gt;
            &lt;font fontName="Arial" size="10"
              isBold="false" isItalic="false" isUnderline="false"
              isStrikeThrough="false" pdfFontName="Helvetica"
              pdfEncoding="CP1252" isPdfEmbedded="false" /&gt;
          &lt;/textElement&gt;
          &lt;textFieldExpression class="java.lang.String"&gt;&lt;![CDATA[((alwin2Scriptlet)$P{REPORT_SCRIPTLET}).getStrukturBezMitStandOrtEbeneDB($F{Strukturcode1}, 3)]]&gt;&lt;/textFieldExpression&gt;
        &lt;/textField&gt;
  
        &lt;textField isStretchWithOverflow="true" pattern=""
          isBlankWhenNull="true"&gt;
          &lt;reportElement mode="Opaque" x="45" y="30"
            width="155" height="13" positionType="Float"
            isRemoveLineWhenBlank="true" /&gt;
          &lt;textElement&gt;
            &lt;font fontName="Arial" size="10"
              isBold="false" isItalic="false" isUnderline="false"
              isStrikeThrough="false" pdfFontName="Helvetica"
              pdfEncoding="CP1252" isPdfEmbedded="false" /&gt;
          &lt;/textElement&gt;
          &lt;textFieldExpression class="java.lang.String"&gt;&lt;![CDATA[((alwin2Scriptlet)$P{REPORT_SCRIPTLET}).getStrukturBezMitStandOrtEbeneDB($F{Strukturcode1}, 4)]]&gt;&lt;/textFieldExpression&gt;
        &lt;/textField&gt;
        &lt;textField isStretchWithOverflow="true" pattern=""
          isBlankWhenNull="true"&gt;
          &lt;reportElement mode="Opaque" x="60" y="45"
            width="140" height="13" positionType="Float"
            isRemoveLineWhenBlank="true" /&gt;
          &lt;textElement&gt;
            &lt;font fontName="Arial" size="10"
              isBold="false" isItalic="false" isUnderline="false"
              isStrikeThrough="false" pdfFontName="Helvetica"
              pdfEncoding="CP1252" isPdfEmbedded="false" /&gt;
          &lt;/textElement&gt;
          &lt;textFieldExpression class="java.lang.String"&gt;&lt;![CDATA[((alwin2Scriptlet)$P{REPORT_SCRIPTLET}).getStrukturBezMitStandOrtEbeneDB($F{Strukturcode1}, 5)]]&gt;&lt;/textFieldExpression&gt;
        &lt;/textField&gt;
        &lt;textField isStretchWithOverflow="true" pattern=""
          isBlankWhenNull="true"&gt;
          &lt;reportElement mode="Opaque" x="75" y="60"
            width="125" height="13" positionType="Float"
            isRemoveLineWhenBlank="true" /&gt;
          &lt;textElement&gt;
            &lt;font fontName="Arial" size="10"
              isBold="false" isItalic="false" isUnderline="false"
              isStrikeThrough="false" pdfFontName="Helvetica"
              pdfEncoding="CP1252" isPdfEmbedded="false" /&gt;
          &lt;/textElement&gt;
          &lt;textFieldExpression class="java.lang.String"&gt;&lt;![CDATA[((alwin2Scriptlet)$P{REPORT_SCRIPTLET}).getStrukturBezMitStandOrtEbeneDB($F{Strukturcode1}, 6)]]&gt;&lt;/textFieldExpression&gt;
        &lt;/textField&gt;
      &lt;/frame&gt;
  
      &lt;textField isStretchWithOverflow="true" pattern=""
        isBlankWhenNull="true"&gt;
        &lt;reportElement mode="Opaque" x="30" y="1" width="20"
          height="13" isRemoveLineWhenBlank="true" /&gt;
        &lt;textElement&gt;
          &lt;font fontName="Arial" size="10" isBold="true"
            isItalic="false" isUnderline="false" isStrikeThrough="false"
            pdfFontName="Helvetica" pdfEncoding="CP1252"
            isPdfEmbedded="false" /&gt;
        &lt;/textElement&gt;
        &lt;textFieldExpression class="java.lang.Integer"&gt;&lt;![CDATA[$V{REPORT_COUNT}]]&gt;&lt;/textFieldExpression&gt;
      &lt;/textField&gt;
      &lt;textField isStretchWithOverflow="true" pattern=""
        isBlankWhenNull="true"&gt;
        &lt;reportElement mode="Opaque" x="515" y="1"
          width="20" height="13" isRemoveLineWhenBlank="true" /&gt;
        &lt;textElement textAlignment="Right"&gt;
          &lt;font fontName="Arial" size="11" isBold="true"
            isItalic="false" isUnderline="false" isStrikeThrough="false"
            pdfFontName="Helvetica-Bold" pdfEncoding="CP1252"
            isPdfEmbedded="false" /&gt;
        &lt;/textElement&gt;
        &lt;textFieldExpression class="java.lang.String"&gt;&lt;![CDATA[$F{Bewertung}]]&gt;&lt;/textFieldExpression&gt;
      &lt;/textField&gt;
      &lt;frame&gt;
        &lt;reportElement isRemoveLineWhenBlank="true"
          positionType="FixRelativeToTop" width="240" y="0" x="255"
          height="15" stretchType="RelativeToTallestObject" /&gt;
  
        &lt;box&gt;
          &lt;pen lineColor="red" lineStyle="Solid"
            lineWidth="3" /&gt;
        &lt;/box&gt;
  
        &lt;textField isStretchWithOverflow="true"
          isBlankWhenNull="true"&gt;
          &lt;reportElement mode="Opaque" x="0" y="1"
            width="240" height="13" isRemoveLineWhenBlank="true"
            isPrintWhenDetailOverflows="true"  /&gt;
          &lt;textElement verticalAlignment="Top"&gt;
            &lt;font fontName="Arial" size="10"
              isBold="false" isItalic="false" isUnderline="false"
              isStrikeThrough="false" pdfFontName="Helvetica"
              pdfEncoding="CP1252" isPdfEmbedded="false" /&gt;
          &lt;/textElement&gt;
          &lt;textFieldExpression class="java.lang.String"&gt;&lt;![CDATA[$F{SCHADENGRUPPE} + ($F{SCHADENBESCHREIBUNG}!=null?$F{SCHADENBESCHREIBUNG}:"")+" ["+$F{SCHADENNR}+"]"]]&gt;&lt;/textFieldExpression&gt;
        &lt;/textField&gt;
      &lt;/frame&gt;
    &lt;/frame&gt;
    &lt;frame&gt;
      &lt;reportElement isRemoveLineWhenBlank="true"
        positionType="Float" width="545" y="76" x="0" height="155"&gt;
        &lt;printWhenExpression&gt;&lt;![CDATA[new Boolean( (!($F{BILD1_FILE} == null) ) || (!($F{BILD2_FILE} == null)) )]]&gt;&lt;/printWhenExpression&gt;
      &lt;/reportElement&gt;
      &lt;!--        &lt;box padding="5"&gt;
        &lt;pen lineColor="black" lineStyle="Solid"
        lineWidth="3" /&gt;
        &lt;/box&gt;
      --&gt;
      &lt;image vAlign="Top" hAlign="Center"&gt;
        &lt;reportElement positionType="Float" x="303" y="0"
          width="212" height="145" isPrintWhenDetailOverflows="true"
          isRemoveLineWhenBlank="true"&gt;
          &lt;printWhenExpression&gt;&lt;![CDATA[new Boolean( (!($F{BILD1_FILE} == null) ) &amp;&amp; ($F{BILD2_FILE} == null) )]]&gt;&lt;/printWhenExpression&gt;
        &lt;/reportElement&gt;
        &lt;graphicElement /&gt;
        &lt;imageExpression class="java.awt.Image"&gt;&lt;![CDATA[$F{BILD1_FILE}]]&gt;&lt;/imageExpression&gt;
      &lt;/image&gt;
      &lt;image vAlign="Top" hAlign="Center"&gt;
        &lt;reportElement positionType="Float" x="303" y="0"
          width="212" height="145" isPrintWhenDetailOverflows="true"
          isRemoveLineWhenBlank="true"&gt;
          &lt;printWhenExpression&gt;&lt;![CDATA[new Boolean( (!($F{BILD2_FILE} == null)) &amp;&amp; ($F{BILD1_FILE} == null) )]]&gt;&lt;/printWhenExpression&gt;
        &lt;/reportElement&gt;
        &lt;graphicElement /&gt;
        &lt;imageExpression class="java.awt.Image"&gt;&lt;![CDATA[$F{BILD2_FILE}]]&gt;&lt;/imageExpression&gt;
      &lt;/image&gt;
      &lt;image vAlign="Top" hAlign="Center"&gt;
        &lt;reportElement positionType="Float" x="70" y="0"
          width="212" height="145" isPrintWhenDetailOverflows="true"
          isRemoveLineWhenBlank="true"&gt;
          &lt;printWhenExpression&gt;&lt;![CDATA[new Boolean( (!($F{BILD1_FILE} == null) ) &amp;&amp; (!($F{BILD2_FILE} == null)) )]]&gt;&lt;/printWhenExpression&gt;
        &lt;/reportElement&gt;
        &lt;graphicElement /&gt;
        &lt;imageExpression class="java.awt.Image"&gt;&lt;![CDATA[$F{BILD1_FILE}]]&gt;&lt;/imageExpression&gt;
      &lt;/image&gt;
      &lt;image vAlign="Top" hAlign="Center"&gt;
        &lt;reportElement positionType="Float" x="303" y="0"
          width="212" height="145" isPrintWhenDetailOverflows="true"
          isRemoveLineWhenBlank="true"&gt;
          &lt;printWhenExpression&gt;&lt;![CDATA[new Boolean( (!($F{BILD2_FILE} == null)) &amp;&amp; (!($F{BILD1_FILE} == null)) )]]&gt;&lt;/printWhenExpression&gt;
        &lt;/reportElement&gt;
        &lt;graphicElement /&gt;
        &lt;imageExpression class="java.awt.Image"&gt;&lt;![CDATA[$F{BILD2_FILE}]]&gt;&lt;/imageExpression&gt;
      &lt;/image&gt;
    &lt;/frame&gt;
  
    &lt;line&gt;
      &lt;reportElement positionType="Float" mode="Opaque" x="0"
        y="240" width="525" height="1" /&gt;
      &lt;graphicElement pen="Thin" /&gt;
    &lt;/line&gt;
  
    &lt;!--
      &lt;frame&gt;
      &lt;reportElement isRemoveLineWhenBlank="true"
      positionType="Float" width="545" y="86" x="0" height="170"&gt;
      &lt;printWhenExpression&gt;&lt;![CDATA[new Boolean( (!($F{BILD1_FILE} == null) ) || (!($F{BILD2_FILE} == null)) )]]&gt;&lt;/printWhenExpression&gt;
      &lt;/reportElement&gt;
      &lt;box&gt;
      &lt;pen lineColor="black" lineStyle="Solid"
      lineWidth="1" /&gt;
      &lt;/box&gt;
      &lt;/frame&gt;
    --&gt;
  &lt;/band&gt;
  </code></pre>
  
  <h3>Code:</h3>
  
  <pre><code>&lt;textField isStretchWithOverflow="true"
    isBlankWhenNull="true"&gt;
    &lt;reportElement mode="Opaque" x="0" y="1"
      width="240" height="13" isRemoveLineWhenBlank="true"
      isPrintWhenDetailOverflows="true"  /&gt;
    &lt;textElement verticalAlignment="Top"&gt;
      &lt;font fontName="Arial" size="10"
        isBold="false" isItalic="false" isUnderline="false"
        isStrikeThrough="false" pdfFontName="Helvetica"
        pdfEncoding="CP1252" isPdfEmbedded="false" /&gt;
    &lt;/textElement&gt;
    &lt;textFieldExpression class="java.lang.String"&gt;&lt;![CDATA[$F{SCHADENGRUPPE} + ($F{SCHADENBESCHREIBUNG}!=null?$F{SCHADENBESCHREIBUNG}:"")+" ["+$F{SCHADENNR}+"]"]]&gt;&lt;/textFieldExpression&gt;
  &lt;/textField&gt;
  </code></pre>
  
  <hr>
  
  <h3>Screenshots:</h3>
  
  <p><a href="http://www.imagechicken.com/uploads/1240937692037795400.jpg" rel="nofollow noreferrer">screenshot 1</a></p>
  
  <p><a href="http://www.imagechicken.com/uploads/1240937425007514300.jpg" rel="nofollow noreferrer">screenshot 2</a></p>