{title:'@HtmlDocConfig', updated:'8.1.0,9.0.0'}

The {@link oaj.html.annotation.HtmlDocConfig @HtmlDocConfig} annotation is used to customize the HTML view of POJOs serialized by {@link oaj.html.HtmlDocSerializer}.

It's used in the following locations:

For example, the following shows setting the title on a page:

| @Rest | @HtmlDocConfig( | title="My Resource Page" | )

The purpose of this annotation is to populate the HTML document view which by default consists of the following structure:

| <html> | <head> | <style type='text/css'> | CSS styles and links to stylesheets | </style> | </head> | <body> | <header> | Page header | </header> | <nav> | Navigation links | </nav> | <aside> | Side-bar text | </aside> | <article> | Contents of serialized object | </article> | <footer> | Footer message | </footer> | </body> | </html>

The outline above is controlled by the {@link oaj.html.HtmlDocTemplate} interface which can be overridden via the {@link oaj.html.annotation.HtmlDocConfig#template() @HtmlDocConfig(template)} annotation.

The HelloWorldResource class was an example of the @HtmlDocConfig annotation in use:

| /** | * Sample REST resource that prints out a simple "Hello world!" message. | */ | @Rest( | path="/helloWorld" | ) | @HtmlDocConfig( | navlinks={ | "up: request:/..", | "options: servlet:/?method=OPTIONS" | }, | aside={ | "<div style='max-width:400px' class='text'>", | " <p>This page shows a resource that simply response with a 'Hello world!' message</p>", | " <p>The POJO serialized is a simple String.</p>", | "</div>" | } | ) | public class HelloWorldResource extends BasicRestServlet {...}

SVL variables can be used in any of these annotations:

| @Rest( | path="/helloWorld", | // Register a config file. | config="MyConfig.cfg" | ) | @HtmlDocConfig( | navlinks={ | "up: request:/..", | "options: servlet:/?method=OPTIONS", | // Add a nav link to view the source code for this class. | "source: $C{Source/gitHub}/org/apache/juneau/examples/rest/$R{servletClassSimple}.java" | }, | aside={ | // Localize our messages. | "<div style='max-width:400px' class='text'>", | " <p>$L{localizedMessage1}</p>", | " <p>$L{localizedMessage2}</p>", | "</div>" | } | ) | public class HelloWorldResource extends BasicRestServlet {...}