In this section, you will learn how to obtain a HTML content from a panel. The examples are in Java but they are applicable to Groovy
You will need to use the PanelRenderingService:
Expected HTML structure
The panel HTML generation has the following dom structure:
The presence of the header (thead) and footer (tfoot) is configurable.
Basic HTML generation
This code snipplet will output a HTML table structure (like described above), with header, footers (if defined in panel attributes) and one line per panel item.
Every attribute content will be output mostly as in the panel view.
Adding own class names
By default, the generated table has an AUI class name. This can be changed with the RenderOptions :
This code will output the same thing as the basic generation would, except for the table :
You can check the API javadoc for the full set of methods available. Most of the HTML elements classes can be overriden
Changing the content formatting
The render options allows you to change the way attribute content are formatted.
In the case when default formatting does not fit your needs, you can specify alternate content formatters.
If you want to display the issue summary instead of issue type and key :
When the panel rendering service encounters an issue attribute, it will use your formatter instead of the default one.
When implementing a formatter, you can return a HTML fragment. This is your responsibility to escape user text.
You can add one content formatter by type.
Render options allows you to control the behaviour of the renderPanel method:
- renderOptions.overrideSecurity(). When using this option, you can disable permission checking and access the panel even if current logged in user does not have the permission
- renderOptions.withUser(anotherUser). Use anotherUser permissions to access the panel.
renderOptions.withCssClassProvider(new CssClassProvider(...)). This option let you override the default class names in the generated HTML elements.
- renderOptions.withContentFormatter(new XXXFormatter()). This option let you change the way contents are formatted in the HTML
- renderOptions.withHeader(true/false). Enables/disables header generation (true by default).
- renderOptions.withFooter(true/false). Enables/disables footer generation.
Using renderOptions.withFooter(true) only has effect if at least one attribute has a footer defined.