Java Reference
In-Depth Information
<reportElement x="280" y="0" width="69" height="24"/>
<textFieldExpression class="java.lang.String">
<reportElement x="420" y="0" width="69" height="24"/>
<textFieldExpression class="java.lang.String">
There are a few JRXML elements in this example we haven't seen before.
As we mentioned, the <queryString> element is used to embed a database query into
the report template. As we can see in the example, the <queryString> element contains
the query to be executed, wrapped in a CDATA block. The <queryString> element has no
attributes or sub-elements other than the CDATA block containing the query.
Text wrapped inside an XML CDATA block is ignored by the
XML parser. As we can see in the example, our query contains
the > character, which would invalidate the XML if it wasn't
inside a CDATA block. A CDATA block is optional, if the data
inside it does not break the XML structure. However, for
consistency and maintainability, we have used it wherever it
is allowed, in the given example.
The <field> element defines fields that are populated at run time when the report
is filled. Field names must match the column name or alias of the corresponding
column in the SQL query. The class attribute of the <field> element is optional. Its
default value is java.lang.String . Even though all of our fields are Strings, we still
added the class attribute for clarity. As can be seen in the example above, the syntax
to obtain the value of a report field is $F{field_name} , where field_name is the
name of the field as defined in its definition.
The next attribute that we haven't discussed before is the <textField> attribute. Text
fields are used to display dynamic textual data in reports. In this case, we are using
them to display the value of the fields. Like all sub-elements of <band> , <textField>
must contain a <reportElement> sub-element indicating the text field's height ,
width , and x , y coordinates within the band. The data that is displayed in text fields
is defined by the <textFieldExpression> sub-element of <textField> . The
Search WWH ::

Custom Search