JasperReports: does positionType = '' Float '' really work for staticText?

I need a staticText to staticText under another variable-height element. I take a sample from the book JasperReports for Java Programmers . It says it is possible. The difference with my example is that I use a string encoded string in textFieldExpression , they use the $ F {} field.

 <textField isStretchWithOverflow="true" hyperlinkType="None"> <reportElement x="0" y="0" width="100" height="24"/> <box> <pen lineWidth="0.5" lineStyle="Solid"/> </box> <textElement/> <textFieldExpression class="java.lang.String"><![CDATA["jjjjjjjjjjj oooooooooo uuuuuuuuuu aaaaaaaaaa xxxxxxxxx u ttttt"]]></textFieldExpression> </textField> <staticText> <reportElement positionType="Float" x="0" y="25" width="500" height="30"/> <box> <pen lineWidth="0.5" lineStyle="Solid"/> </box> <textElement/> <text><![CDATA[ This staticText element has a positionType of "Float" ppp ]]></text> </staticText> 

It says that when using positionType="Float" the y attribute is ignored because the staticText is located below the textField . It seems to work, BUT ... maybe they're BS'ing me? textField has y = 0 and height = 24. staticText has y = 25. Match? If I change staticText y, it is obvious that it is not ignored: the element is positioned wherever I tell it. There is no swimming !!! Quote from the book:

As we can see, setting the positionType attribute of <reportElement> to Float made JasperReports ignore the y position of the <staticText> element, which was pushed down by the stretched <textField> element.

No, we donโ€™t see how they ignore him, because y = 25 is the place where we expected it! Does positionType="Float" for staticText in general? Thanks!

+6
jasper-reports
source share
2 answers

My understanding of floating nature is that a floating object will move down if necessary, but if the previous object is less than expected, it will not move up.

I donโ€™t remember any problems with floating objects that do not actually float when necessary, whether they are static text or text fields.

In another note, if you find that the text field is working, you can use it to display static text by putting your text in quotation marks in the value of the text field (making it a Java object).

+5
source share

This answer applies (different elements, same situation).

One thing that I have not selected from the sample book is that textField declared that the height (24) is less than the actual height when the element is stretched. Thus, y = "25" on a staticText will be displayed above its actual position; the item actually floats down!

+2
source share

All Articles