开发者

Jasper report syntax reportelement and frame

I'm trying to understand how jasper reports work but i find the syntax a little difficult to get to grips with.

what exactly does reportelement- key refer to? also is frame a purely visual component?

<frame>
    <reportElement 开发者_如何学Ckey="frame-6" mode="Opaque" x="0" y="36" width="534" height="36" backcolor="#CCCCCC"/>
    <box>
        <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
        <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
        <bottomPen lineWidth="0.0" lineColor="#000000"/>
        <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
    </box>
</frame>

Also in the following what do the F and v indicate, and more importantly where are they defined?

<textFieldExpression class="java.math.BigDecimal"><![CDATA[$V{amountTotal}]]></textFieldExpression>
<variableExpression><![CDATA[new BigDecimal($F{amount percentage})</variableExpression>


About the frame:

The quotes from IReport Ultimate Guide:

A frame is an element that can contain other elements and optionally draw a border around them.
..
Since a frame is a container of other elements, in the document outline view the frame is represented as a node containing other elements.
..
A frame can contain other frames, and so on recursively. To add an element to a frame, just drag the new element from the palette inside the frame. Alternatively you can use the outline view and drag elements from a band into the frame and so on. The position of an element is always relative to the container position. If the container is a band, the element position will be relative to the top of the band and the left margin. If the container (or element parent) is a frame, the element coordinates will be relative to the top left corner of the frame. Since an element dragged from a container to another does not change its top/left properties, when moving an element from a container to another its position is recalculated based on the new container location. The advantages of using a frame to draw a border around a set of elements, with respect to using a simple rectangle element, are:
* When you move a frame, all the elements contained in the frame will move in concert.
* While using a rectangle to overlap some elements, the elements inside the rectangle will not treated as overlapped (respect to the frame), so you will not have problems when exporting in HTML (which does not support overlapped elements).
* Finally, the frame will automatically stretch accordingly to its content, and the element position type property of its elements will refer to the frame itself, not to the band, making the design a bit easier to manage. in HTML (which does not support overlapped elements).

About the reportElement

The quotes from JasperReports Ultimate Guide:

REPORT ELEMENT PROPERTIES
When you add a report element to one of your report sections, you must specify the relative position of this element in that particular section and its size, along with other general report element properties like color, transparency, stretch behavior, and so forth.
The properties that are common to all types of report elements are grouped in the tag, which appears in the declaration of all report elements.
..
ELEMENT KEY
Unlike variables and parameters, report elements are not required to have a name, because normally you do not need to obtain any individual element inside a report template. However, in some cases it is useful to be able to locate an element to alter one of its properties before using the report template. This could be the case in an application for which the color of some elements in the report template needs to change based on user input. To locate the report elements that need to have their colors altered, the caller program could use the getElementByKey(String) method available at band level. A key value must be associated with the report element and it must be unique within the overall band for the lookup to work. The key attribute is used as an example in the provided /demo/samples/alterdesign sample.

About the fields ($F) and variables ($V):

  • $F{fieldName} is a reference to the field with name fieldName. The fields contains data from a data source.
  • $V{variableName} is a reference to the report's variable with name variableName. The variable have expression and can be used for different calculations.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜