Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
A table-row conditional block is a conditional block which body occupies single or multiple rows of a single document table. The body of such a block (as well as the body of its every template option) starts at the beginning of the first occupied row and ends at the end of the last occupied row as follows.
Note – Table rows occupied by different template options in the following template are highlighted with different colors.
| <<if ...>> ... | ... | ... |
| ... | ... | ... |
| <<elseif ...>> ... | ... | ... |
| ... | ... | ... |
| <<else>> ... | ... | ... |
| ... | ... | ... |
| ... | ... | ...<</if>> |
The following examples in this section are given using client, an instance of the Client class, and clients, an enumeration of instances of the Client class that is defined as follows.
public class Client
{
public String getName() { ... }
public String getCountry() { ... }
public String getLocalAddress() { ... }
...
}
Using table-row conditional blocks, you can pick to output a single row among several rows of a single document table depending on a condition like in the following example.
| ... | ... | ... |
| <<if [client.getCountry() == “New Zealand”]>><<[client.getName()]>> | <<[client.getLocalAddress()]>> | |
| <<else>><<[client.getName()]>> | <<[client.getCountry()]>> | <<[client.getLocalAddress()]>><</if>> |
| ... | ... | ... |
You can normally use table-row conditional blocks within data bands to make elements of an enumeration look differently depending on a condition. Consider the following template.
| <<foreach [in clients]>><<if [getCountry() == “New Zealand”]>><<[getName()]>> | <<[getLocalAddress()]>> | |
| <<else>><<[getName()]>> | <<[getCountry()]>> | <<[getLocalAddress()]>><</if>><</foreach>> |
In this case, the engine produces a report as follows.
| A Company | Australia | 219-241 Cleveland St STRAWBERRY HILLS NSW 1427 |
| B Ltd. | Brazil | Avenida João Jorge, 112, ap. 31 Vila Industrial Campinas - SP 13035-680 |
| C & D | Canada | 101-3485 RUE DE LA MONTAGNE MONTRÉAL (QUÉBEC) H3G 2A6 |
| E Corp. | 445 Mount Eden Road Mount Eden Auckland 1024 | |
| F & Partners | 20 Greens Road Tuahiwi Kaiapoi 7691 | |
| G & Co. | Greece | Karkisias 6 GR-111 42 ATHINA GRÉCE |
| H Group | Hungary | Budapest Fiktív utca 82., IV. em./28. 2806 |
| I & Sons | 43 Vogel Street Roslyn Palmerston North 4414 | |
| J Ent. | Japan | Hakusan 4-Chōme 3-2 Bunkyō-ku, TŌKYŌ 112-0001 Japan |
Note – You can use common conditional blocks within table-row data bands as well.
Also, you can use data bands inside table-row conditional blocks. For example, you can provide an alternate content for an empty table-row data band using the following template.
| Client | Country | Local Address |
| <<if [!clients.any()]>>No data | ||
| <<else>><<foreach [in clients]>><<[getName()]>> | <<[getCountry()]>> | <<[getLocalAddress()]>><</foreach>><</if>> |
In case when the corresponding enumeration is empty, the engine produces a report as follows.
| Client | Country | Local Address |
| No data | ||
Note – Table-column data bands and conditional blocks can also be nested to table-row conditional blocks, but not conversely: Nesting of table-row conditional blocks into table-column data bands and conditional blocks is forbidden.
A special case is a template option inside a single-column table row. In such a case, if you put an opening if, elseif, or else tag and a closing if tag in the same cell, the engine treats a template option formed by these tags as a common one rather than a table-row one by default. The following template illustrates such a scenario.
| Header |
| <<if [false]>>Content to remove<</if>> |
| Footer |
In this case, the engine produces a report as follows.
| Header |
|---|
| Footer |
However, if needed, you can override this behavior making the engine to treat such a template option as a table-row one by specifying a greedy switch like in the following template.
| Header |
| <<if [false]>>Content to remove<</if -greedy>> |
| Footer |
In this case, the engine produces a report as follows.
| Header |
|---|
| Footer |
Note – In the previous examples, tag <<if [false]>> is used for the sake of simplicity; you can use any other Boolean expression instead of just false.
Q: How do I define a table‑row conditional block in a template?
A: Enclose the rows that belong to the block with <<if [condition]>> … <<else>> … <<endif>> (or <<elseif>>). The opening tag must be placed in the first cell of the first row, and the closing tag in the last cell of the last row of the block.
Q: Can I nest table‑row conditional blocks inside data bands?
A: Yes. Table‑row conditional blocks can be placed inside foreach or other data‑band tags, allowing each row to be rendered conditionally per item. The opposite—nesting a table‑row block inside a table‑column block—is not allowed.
Q: What does the -greedy switch do for a single‑cell conditional block?
A: By default, if the opening and closing if/elseif/else tags are in the same cell, the engine treats the block as a common (non‑row) conditional block. Adding -greedy forces the engine to treat it as a table‑row conditional block, so the whole row participates in the condition.
Q: How can I show a “No data” message when a data band enumeration is empty?
A: Use a conditional block that checks the enumeration with !enumeration.any(). Example: <<if [!clients.any()]>>No data<<else>>…<<endif>>. Place this block in a row that spans the required columns.
Q: Are there any nesting restrictions for table‑row conditional blocks?
A: Table‑row conditional blocks can be nested inside table‑column data bands and conditional blocks, but you cannot nest a table‑row block inside another table‑row block or inside a table‑column block. Attempting to do so will cause the engine to ignore the inner block.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.