Java Reference
In-Depth Information
As we can see from the screenshot, the aircraft model is only displayed when the
model number changes. This layout makes it a lot easier to see which aircraft are of
the same model.
When setting isPrintRepeatedValues="false" in a
<reportElement> element inside an <image> element,
the image will not be displayed repeatedly, unless its
isUsingCache attribute is set to true and its corresponding
image expression is the same for each row. Adding images to a
report is discussed in detail in the next chapter.
One nice feature of JasperReports is that it allows incorporating a report within
another report, that is, one report can be a subreport of another. Subreports allow
us to keep report designs simple, since we can create many simple reports and
encapsulate them into a master report.
Let us create a more detailed version of the report discussed in the previous section.
This new version divides the report on the number of aircraft in the city they are
registered to. We will create one report that displays the aircraft registered in each
city for a particular state, and use that report as a subreport for a master report that
divides the aircraft by state. The JRXML template for the subreport is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN"
<jasperReport name="AircraftCityReport">
<parameter name="state" class="java.lang.String"/>
<parameter name="city" class="java.lang.String"/>
<![CDATA[select a.tail_num, a.aircraft_serial, am.model, a.state
from aircraft a, aircraft_models am
where a.aircraft_model_code = am.aircraft_model_code
and = 'US' and a.state = $P{state}
and = $P{city}
order by model]]>
<field name="tail_num" class="java.lang.String"/>
<field name="aircraft_serial" class="java.lang.String"/>
<field name="model" class="java.lang.String"/>
Search WWH ::

Custom Search