Class HtmlTemplatePage


public class HtmlTemplatePage extends HtmlPage
An HtmlPage that builds its content by parsing an HTML template file.

This class reads an HTML file from the servlet context, parses it using the Oorian HtmlParser, and uses the parsed <head> and <body> elements as the page content. Attributes on the <html> element are applied to the page.

Subclasses can override createHead(Head) and createBody(Body) to further modify the parsed content after the template has been loaded.

See Also:
  • Constructor Details

    • HtmlTemplatePage

      public HtmlTemplatePage(String htmlFile)
      Creates a new template page that will load the specified HTML file.
      Parameters:
      htmlFile - The path to the HTML template file, relative to the servlet context root.
  • Method Details

    • setCharset

      public void setCharset(String charset)
      Sets the character encoding used when reading the template file.
      Parameters:
      charset - The character encoding name (default is UTF-8).
    • initializePage

      protected boolean initializePage()
      Initializes the page by parsing the HTML template file.

      Reads the template file from the servlet context, parses it with the Oorian HtmlParser, and extracts the head and body elements. Attributes from the <html> element are applied to this page.

      Overrides:
      initializePage in class HtmlPage
      Returns:
      true if initialization was successful.
      Throws:
      HttpFileException - If the template file cannot be read or parsed.
    • createHead

      protected void createHead(Head head)
      Description copied from class: HtmlPage
      Creates the head section of this page.

      Subclasses must implement this method to add stylesheets, scripts, meta tags, and other head content.

      Specified by:
      createHead in class HtmlPage
      Parameters:
      head - The Head element to populate.
    • createBody

      protected void createBody(Body body)
      Description copied from class: HtmlPage
      Creates the body section of this page.

      Subclasses must implement this method to build the page layout and content.

      Specified by:
      createBody in class HtmlPage
      Parameters:
      body - The Body element to populate.