Print Properties
Inclusions

Letter Fragments

The Inclusion handler types allows to dynamically include letter fragments into Open Office letters. This facility makes it easier to manage document layouts and provides a way to reuse existing fragments. The handler should be used in the following form:

 $fragment{[fragment_name]} 
where the fragment_name specifies the name of "Letter Fragment" type.

The section below describes few possible ways of using the fragment handler. All examples are available in the attached sample project.

Examples

staffLetter -This letter includes a single fragment - staffDetails (screenshot below).

Sample usage of a $fragment handler
The fragment shows details of a Sakila DVD rental store's staff member. The required data are provided by the staff data set defined as follows:

 select
    store_id, first_name, last_name, picture, email, address, address2, district, city, country, postal_code, phone, country
from
    staff, address, city, country
where
    staff.staff_id='$P{staffId}'
and
    staff.address_id=address.address_id
and
    address.city_id=city.city_id
and
    city.country_id=country.country_id;

In order to generate the letter the $P{staffId} parameter, specifying a staff member, must be provided.

The sample outcome of the letter generation is shown below

storeCustomersLetter - This letter is a simple example of how letter fragments (specified by a user provided parameter) can be used to generate different versions of the result document. The example lists all customers of the store specifiedy by the storeId parameter.

storeCustomersLetter
The second parameter, customerFullDetails, defines a letter fragment that should be included in order to show customer details. Its value should be set to either true - to show full details of a customer, or false - to show only customer names.

The screenshots below show two versions of the result document.

customerFullDetails set to true

customerFullDetails set to false

The data set, storeCustomers, providing customer details is defined as shown below.

select 
    first_name, last_name, email, active, count(rental.rental_id) as num_rentals 
from 
    customer, rental 
where 
    customer.store_id=$P{storeId} and customer.customer_id=rental.customer_id 
group by 
    customer.customer_id
1185 Views, 1 Attachments 1 Attachments

  • Comments
Copyright © 2008 - 2010