{8.1.0-updated} @HtmlDocConfig

The {@link oaj.html.annotation.HtmlDocConfig @HtmlDocConfig} annotation is used to customize the HTML view of your serialized POJOs. It's used in the following locations:

- {@link oajr.annotation.Rest @Rest}-annotated classes.
- {@link oajr.annotation.RestMethod @RestMethod}-annotated methods.

The annotation itself is just a convenience for setting configuration properties set on the {@link oaj.html.HtmlDocSerializer} class. For example, the following two pieces of code are equivalent:

// Title defined via property. @Rest( properties={ @Property(name=HTMLDOC_title, value="My Resource Page") } ) // Title defined via @HtmlDoc annotation. @Rest() @HtmlDocConfig( title="My Resource Page" )

The purpose of these 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 oajr.annotation.HtmlDoc#template @HtmlDoc(template)} annotation.

The HelloWorldResource class was an example of the @HtmlDoc 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 {...}