Page tree
Skip to end of metadata
Go to start of metadata

The default template of PocketQuery produces a simple Confluence table, enriched by a few gimmicks. The result looks like this:

The table has two columns Name and Population, according to the SELECT clause of the query. This table now already has a few features:

  • The table is sortable by clicking the column headers.
  • If your string results are very long, they are cut by an ellipsis (…) to avoid bluttering the table.
  • Double-clicking the values opens the (complete) strings in a dialog.

Templates for PocketQuery are written in Velocity, a Java templating language used in Confluence. Let’s have a look at the code of the default PocketQuery template that is selected by default for all queries.

<table class="aui confluenceTable pocketquery-table">
    <thead>
        <tr>
        	#foreach ($column in $columns)
            <th>$!column</th>
        	#end
        </tr>
    </thead>

    <tbody>
        #foreach ($row in $result)
        <tr>
          	#foreach ($column in $row)
           	<td>$!column</td>
           	#end
        </tr>
        #end
    </tbody>
</table>

 

Nothing fancy here: there is one loop for the header that runs through the column names and one loop (with another nested loop) running through the result. Note that the variables $columns and $result are passed to any PocketQuery template, so you can use them as you please. For a more formal specification of what kind of objects are available in PocketQuery templates, see the PocketQuery documentation on templates.

  • No labels