SimpleServlets v5.5.0

com.simpleservlets.htmlobjects
Class HTMLPage

java.lang.Object
  extended by com.simpleservlets.htmlobjects.GenericHTMLElement
      extended by com.simpleservlets.htmlobjects.HTMLPage
All Implemented Interfaces:
HTMLElement

public class HTMLPage
extends GenericHTMLElement
implements HTMLElement

Root tag for the entire HTML page, <html> tag.

An HTMLPage should contain exactly two children: an HTMLHead and an HTMLBody. The page can be traversed and sent to a browser with the send(HTMLPage, HttpServletResponse) method on HTMLUtil.

For example, this code:

 protected void doGet(HttpServletRequest req, HttpServletResponse res)
         throws ServletException, IOException {
 
     HTMLBody body = new HTMLBody(HTMLColor.LIGHT_YELLOW);
     body.addParagraph("This is from HTMLObjects!");
 
     HTMLPage page = new HTMLPage(new HTMLHead("HTMLObjects Demo"), body);
     HTMLUtil.send(page, res);
 }
 
produces this HTML:
 <html>
  <head>
   <title>HTMLObjects Demo</title>
  </head>
  <body bgcolor="#FFFFE0">
   <p>This is from HTMLObjects!</p>
  </body>
 </html>
 

Author:
Paul Hyde

Field Summary
 
Fields inherited from interface com.simpleservlets.htmlobjects.HTMLElement
ZERO_LEN_ARRAY
 
Constructor Summary
HTMLPage()
           
HTMLPage(HTMLHead head, HTMLBody body)
           
 
Method Summary
 HTMLElement addSibling(HTMLElement element)
          Always throws HTMLException as HTMLPage is the root tag and does not permit siblings.
 HTMLString addSibling(String text)
          Always throws HTMLException as HTMLPage is the root tag and does not permit siblings.
 
Methods inherited from class com.simpleservlets.htmlobjects.GenericHTMLElement
add, add, getAttributes, getChildren, getName, getParent, hasAttributes, hasChildren, isSafeToWrapWithWhitespace, removeAllAttributes, removeAllChildren, removeAttribute, removeChild, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttributeGroup, setParent, setSafeToWrapWithWhitespace, setStyle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.simpleservlets.htmlobjects.HTMLElement
add, add, getAttributes, getChildren, getName, getParent, hasAttributes, hasChildren, isSafeToWrapWithWhitespace, removeAllAttributes, removeAllChildren, removeAttribute, removeChild, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttributeGroup, setParent, setStyle
 

Constructor Detail

HTMLPage

public HTMLPage(HTMLHead head,
                HTMLBody body)

HTMLPage

public HTMLPage()
Method Detail

addSibling

public HTMLElement addSibling(HTMLElement element)
                       throws HTMLException
Always throws HTMLException as HTMLPage is the root tag and does not permit siblings.

Specified by:
addSibling in interface HTMLElement
Overrides:
addSibling in class GenericHTMLElement
Parameters:
element - the element to add. null is ignored (and returned).
Returns:
the element added (same as what is passed in).
Throws:
HTMLException - if there is no parent container at the moment (if getParent() returns null). This is a RuntimeException, so callers are not required to use a try/catch block.

addSibling

public HTMLString addSibling(String text)
                      throws HTMLException
Always throws HTMLException as HTMLPage is the root tag and does not permit siblings.

Specified by:
addSibling in interface HTMLElement
Overrides:
addSibling in class GenericHTMLElement
Throws:
HTMLException - if there is no parent container at the moment (if getParent() returns null). This is a RuntimeException, so callers are not required to use a try/catch block.

SimpleServlets v5.5.0

Copyright © 2001-2007 Programix Incorporated. All rights reserved. SimpleServlets is free and is OSI Certified Open Source Software under the BSD license.