Class HtmlDocSerializer.Builder<SELF extends HtmlDocSerializer.Builder<SELF>>

Direct Known Subclasses:
HtmlDocSerializer.DefaultBuilder, HtmlSchemaDocSerializer.Builder
Enclosing class:
HtmlDocSerializer

public abstract static class HtmlDocSerializer.Builder<SELF extends HtmlDocSerializer.Builder<SELF>> extends HtmlStrippedDocSerializer.Builder<SELF>
Builder class.
  • Constructor Details

    • Builder

      protected Builder()
      Constructor, default settings.
    • Builder

      protected Builder(HtmlDocSerializer.Builder<?> copyFrom)
      Copy constructor.
      Parameters:
      copyFrom - The builder to copy from.
    • Builder

      protected Builder(HtmlDocSerializer copyFrom)
      Copy constructor.
      Parameters:
      copyFrom - The bean to copy from.
  • Method Details

    • aside

      public List<String> aside()
      Returns the list of aside section contents.

      Gives access to the inner list if you need to make more than simple additions via aside(String...).

      Returns:
      The list of aside section contents.
      See Also:
    • aside

      public SELF aside(String... value)
      Aside section contents.

      Allows you to specify the contents of the aside section on the HTML page. The aside section floats on the right of the page for providing content supporting the serialized content of the page.

      By default, the aside section is empty.

      Example:

      WriterSerializer serializer = HtmlDocSerializer .create() .aside( "<ul>", " <li>Item 1", " <li>Item 2", " <li>Item 3", "</ul>" ) .build();

      Notes:
      • Format: HTML
      • Supports REST Server SVL Variables (e.g. "$L{my.localized.variable}").
      • A value of "NONE" can be used to force no value.
      • The parent value can be included by adding the literal "INHERIT" as a value.
      • Multiple values are combined with newlines into a single string.
      • On methods, this value is inherited from the @HtmlDocConfig annotation on the servlet/resource class.
      • On servlet/resource classes, this value is inherited from the @HtmlDocConfig annotation on the parent class.
      Parameters:
      value - The new value for this property.
      Returns:
      This object.
    • asideFloat

      public SELF asideFloat(AsideFloat value)
      Float aside section contents.

      Allows you to position the aside contents of the page around the main contents.

      By default, the aside section is floated to the right.

      Example:

      WriterSerializer serializer = HtmlDocSerializer .create() .aside( "<ul>", " <li>Item 1", " <li>Item 2", " <li>Item 3", "</ul>" ) .asideFloat(RIGHT) .build();

      Parameters:
      value - The new value for this property.
      Returns:
      This object.
    • build

      Description copied from class: Context.Builder
      Build the object.
      Overrides:
      build in class HtmlStrippedDocSerializer.Builder<SELF extends HtmlDocSerializer.Builder<SELF>>
      Returns:
      The built object.
    • copy

      public abstract SELF copy()
      Description copied from class: Context.Builder
      Copy creator.
      Specified by:
      copy in class HtmlStrippedDocSerializer.Builder<SELF extends HtmlDocSerializer.Builder<SELF>>
      Returns:
      A new mutable copy of this builder.
    • footer

      public List<String> footer()
      Returns the list of footer section contents.

      Gives access to the inner list if you need to make more than simple additions via footer(String...).

      Returns:
      The list of footer section contents.
      See Also:
    • footer

      public SELF footer(String... value)
      Footer section contents.

      Allows you to specify the contents of the footer section on the HTML page.

      By default, the footer section is empty.

      Example:

      WriterSerializer serializer = HtmlDocSerializer .create() .footer( "<b>This interface is great!</b>" ) .build();

      Parameters:
      value - The new value for this property.
      Returns:
      This object.
    • hashKey

      public HashKey hashKey()
      Description copied from class: Context.Builder
      Returns the hashkey of this builder.

      Used to return previously instantiated context beans that have matching hashkeys. The HashKey object is suitable for use as a hashmap key of a map of context beans. A context bean is considered equivalent if the HashKey.equals(Object) method is the same.

      Overrides:
      hashKey in class HtmlSerializer.Builder<SELF extends HtmlDocSerializer.Builder<SELF>>
      Returns:
      The hashkey of this builder.
    • head

      public List<String> head()
      Returns the list of head section contents.

      Gives access to the inner list if you need to make more than simple additions via head(String...).

      Returns:
      The list of head section contents.
      See Also:
    • head

      public SELF head(String... value)
      Additional head section content.

      Adds the specified HTML content to the head section of the page.

      Example:

      WriterSerializer serializer = HtmlDocSerializer .create() .head( "<link rel='icon' href='$U{servlet:/htdocs/mypageicon.ico}'>" ) .build();

      Parameters:
      value - The new value for this property.
      Returns:
      This object.
    • header

      public List<String> header()
      Returns the list of header section contents.

      Gives access to the inner list if you need to make more than simple additions via header(String...).

      Returns:
      The list of header section contents.
      See Also:
    • header

      public SELF header(String... value)
      Header section contents.

      Allows you to override the contents of the header section on the HTML page. The header section normally contains the title and description at the top of the page.

      Example:

      WriterSerializer serializer = HtmlDocSerializer .create() .header( "<h1>My own header</h1>" ) .build()

      Parameters:
      value - The new value for this property.
      Returns:
      This object.
    • noResultsMessage

      public SELF noResultsMessage(String value)
      No-results message.

      Allows you to specify the string message used when trying to serialize an empty array or empty list.

      Example:

      WriterSerializer serializer = HtmlDocSerializer .create() .noResultsMessage("<b>This interface is great!</b>") .build();

      A value of "NONE" can be used to represent no value to differentiate it from an empty string.

      Parameters:
      value - The new value for this property.
      Returns:
      This object.
    • nowrap

      public SELF nowrap()
      Prevent word wrap on page.

      Adds "* {white-space:nowrap}" to the CSS instructions on the page to prevent word wrapping.

      Returns:
      This object.
    • nowrap

      public SELF nowrap(boolean value)
      Same as nowrap() but allows you to explicitly specify the boolean value.
      Parameters:
      value - The new value for this property.
      Returns:
      This object.
      See Also:
    • resolveBodyVars

      Resolve $ variables in serialized POJO.
      Returns:
      This object.
    • resolveBodyVars

      public SELF resolveBodyVars(boolean value)
      Same as resolveBodyVars() but allows you to explicitly specify the boolean value.
      Parameters:
      value - The new value for this property.
      Returns:
      This object.
      See Also:
    • script

      public List<String> script()
      Returns the list of page script contents.

      Gives access to the inner list if you need to make more than simple additions via script(String...).

      Returns:
      The list of page script contents.
      See Also:
    • script

      public SELF script(String... value)
      Adds the specified Javascript code to the HTML page.

      A shortcut on @Rest is also provided for this setting:

      WriterSerializer serializer = HtmlDocSerializer .create() .script("alert('hello!');") .build();

      Parameters:
      value - The value to add to this property.
      Returns:
      This object.
    • style

      public List<String> style()
      Returns the list of page style contents.

      Gives access to the inner list if you need to make more than simple additions via style(String...).

      Returns:
      The list of page style contents.
      See Also:
    • style

      public SELF style(String... value)
      Adds the specified CSS instructions to the HTML page.

      WriterSerializer serializer = HtmlDocSerializer .create() .style( "h3 { color: red; }", "h5 { font-weight: bold; }" ) .build();

      Parameters:
      value - The value to add to this property.
      Returns:
      This object.
    • stylesheet

      public List<String> stylesheet()
      Returns the list of stylesheet URLs.

      Gives access to the inner list if you need to make more than simple additions via stylesheet(String...).

      Returns:
      The list of stylesheet URLs.
      See Also:
    • stylesheet

      public SELF stylesheet(String... value)
      Adds to the list of stylesheet URLs.

      Note that this stylesheet is controlled by the @Rest.stylesheet() annotation.

      Parameters:
      value - The value to add to this property.
      Returns:
      This object.
    • template

      public SELF template(Class<? extends HtmlDocTemplate> value)
      HTML document template.

      Specifies the template to use for serializing the page.

      By default, the BasicHtmlDocTemplate class is used to construct the contents of the HTML page, but can be overridden with your own custom implementation class.

      Example:

      WriterSerializer serializer = HtmlDocSerializer .create() .template(MySpecialDocTemplate.class) .build();

      Parameters:
      value - The new value for this property.
      Returns:
      This object.
    • widgets

      public List<Class<? extends HtmlWidget>> widgets()
      Returns the list of page widgets.

      Gives access to the inner list if you need to make more than simple additions via widgets(Class...).

      Returns:
      The list of page widgets.
      See Also:
    • widgets

      public SELF widgets(Class<? extends HtmlWidget>... values)
      HTML Widgets.

      Defines widgets that can be used in conjunction with string variables of the form "$W{name}"to quickly generate arbitrary replacement text. Widgets resolve the following variables:

      The following examples shows how to associate a widget with a REST method and then have it rendered in the links and aside section of the page:

      WriterSerializer serializer = HtmlDocSerializer .create() .widgets( MyWidget.class ) .navlinks( "$W{MyWidget}" ) .aside( "Check out this widget: $W{MyWidget}" ) .build();

      Notes:
      • Widgets are inherited from super classes, but can be overridden by reusing the widget name.
      See Also:
      Parameters:
      values - The values to add to this setting.
      Returns:
      This object.