org.mortbay.html
Class Page

java.lang.Object
  |
  +--org.mortbay.html.Element
        |
        +--org.mortbay.html.Composite
              |
              +--org.mortbay.html.Page
Direct Known Subclasses:
FrameSet

public class Page
extends Composite

HTML Page. A HTML Page extends composite with the addition of the HTML Header tags, fields and elements. Furthermore, individual parts of the page may be written or the progressive page be output with flush.

Pages contain parameters and named sections. These are used by derived Page classes that implement a Look and Feel. Page users may add to name sections such as "Margin" or "Footer" and set parameters such as "HelpUrl" without knowledge of how the look and feel will arrange these. To assist with standard look and feel creation Page defines a set of standard names for many common parameters and sections.

If named sections are used, the page constructor or completeSections must add the named section to the page in the appropriate places. If named sections are not added to the page, then they can only be written with an explicit call to write(out,"section",end); Changes in behaviour to section creation and adding, should be controlled via page properties.

Version:
$Id: Page.java,v 1.3 2001/11/08 03:49:03 gregwilkins Exp $
Author:
Greg Wilkins
See Also:
Composite

Field Summary
static java.lang.String Back
           
static java.lang.String BaseUrl
           
static java.lang.String BgColour
           
static java.lang.String Content
           
static java.lang.String ContentSize
           
static java.lang.String FgColour
           
static java.lang.String Footer
           
static java.lang.String FooterSize
           
static java.lang.String Header
           
static java.lang.String HeaderSize
           
static java.lang.String Heading
           
static java.lang.String Help
           
static java.lang.String HighlightColour
           
static java.lang.String Home
           
static java.lang.String LeftMargin
           
static java.lang.String LeftMarginSize
           
static java.lang.String Margin
           
static java.lang.String MarginSize
           
static java.lang.String Next
           
static java.lang.String NoTitle
           
static java.lang.String PageType
           
static java.lang.String Prev
           
static java.lang.String Request
           
static java.lang.String Response
           
static java.lang.String RightMargin
           
static java.lang.String RightMarginSize
           
static java.lang.String Section
           
static java.lang.String Target
           
static java.lang.String Title
           
static java.lang.String Up
           
 
Fields inherited from class org.mortbay.html.Element
ALIGN, BGCOLOR, BOTTOM, CENTER, CLASS, COLOR, HEIGHT, ID, LEFT, MIDDLE, noAttributes, RIGHT, SIZE, STYLE, TOP, VALIGN, WIDTH
 
Constructor Summary
Page()
           
Page(java.lang.String title)
           
Page(java.lang.String title, java.lang.String attributes)
           
 
Method Summary
 Page addHeader(java.lang.Object o)
          Add element or object to the page header.
 void addSection(java.lang.String section, Composite composite)
          Set a composite as a named section and add it to the.
 void addTo(java.lang.String section, java.lang.Object element)
          Add content to a named sections.
 void flush(java.io.Writer out)
           
 FrameSet frameSet()
          Return the preferred FrameSet to be used with a specialized Page.
 Composite getSection(java.lang.String section)
          Get a composite as a named section.
 java.util.Dictionary properties()
          Access the page properties.
 void rewind()
           
 Page setBackGroundColor(java.lang.String color)
          Set page background color.
 Page setBackGroundImage(java.lang.String bg)
          Set page background image.
 Page setBase(java.lang.String target, java.lang.String href)
          Set the URL Base for the Page.
 void setSection(java.lang.String section, Composite composite)
          Set a composite as a named section.
 Page title(java.lang.String title)
          Set page title.
 void write(java.io.Writer out)
          Write the entire page by calling:
writeHtmlHead(out)
writeBodyTag(out)
writeElements(out)
writeHtmlEnd(out)
 void write(java.io.Writer out, java.lang.String section, boolean endHtml)
          Write page section.
 void writeBodyTag(java.io.Writer out)
          Write HTML page body tag.
 void writeElements(java.io.Writer out)
          Write any body elements of the page.
 void writeHtmlEnd(java.io.Writer out)
          Write end BODY and end HTML tags.
 void writeHtmlHead(java.io.Writer out)
          Write HTML page head tags.
 
Methods inherited from class org.mortbay.html.Composite
add, contents, nest, replace, reset, setNest, size, unnest
 
Methods inherited from class org.mortbay.html.Element
attribute, attribute, attribute, attributes, attributes, bgColor, bottom, center, color, cssClass, cssID, height, height, height, left, middle, right, setAttributesFrom, size, size, style, top, toString, width, width, width, write, write
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

Request

public static final java.lang.String Request
See Also:
Constant Field Values

Response

public static final java.lang.String Response
See Also:
Constant Field Values

Header

public static final java.lang.String Header
See Also:
Constant Field Values

Title

public static final java.lang.String Title
See Also:
Constant Field Values

Section

public static final java.lang.String Section
See Also:
Constant Field Values

HeaderSize

public static final java.lang.String HeaderSize
See Also:
Constant Field Values

Footer

public static final java.lang.String Footer
See Also:
Constant Field Values

FooterSize

public static final java.lang.String FooterSize
See Also:
Constant Field Values

Content

public static final java.lang.String Content
See Also:
Constant Field Values

ContentSize

public static final java.lang.String ContentSize
See Also:
Constant Field Values

Margin

public static final java.lang.String Margin
See Also:
Constant Field Values

MarginSize

public static final java.lang.String MarginSize
See Also:
Constant Field Values

LeftMargin

public static final java.lang.String LeftMargin
See Also:
Constant Field Values

LeftMarginSize

public static final java.lang.String LeftMarginSize
See Also:
Constant Field Values

RightMargin

public static final java.lang.String RightMargin
See Also:
Constant Field Values

RightMarginSize

public static final java.lang.String RightMarginSize
See Also:
Constant Field Values

Help

public static final java.lang.String Help
See Also:
Constant Field Values

Home

public static final java.lang.String Home
See Also:
Constant Field Values

Heading

public static final java.lang.String Heading
See Also:
Constant Field Values

Up

public static final java.lang.String Up
See Also:
Constant Field Values

Prev

public static final java.lang.String Prev
See Also:
Constant Field Values

Next

public static final java.lang.String Next
See Also:
Constant Field Values

Back

public static final java.lang.String Back
See Also:
Constant Field Values

Target

public static final java.lang.String Target
See Also:
Constant Field Values

BaseUrl

public static final java.lang.String BaseUrl
See Also:
Constant Field Values

FgColour

public static final java.lang.String FgColour
See Also:
Constant Field Values

BgColour

public static final java.lang.String BgColour
See Also:
Constant Field Values

HighlightColour

public static final java.lang.String HighlightColour
See Also:
Constant Field Values

PageType

public static final java.lang.String PageType
See Also:
Constant Field Values

NoTitle

public static final java.lang.String NoTitle
See Also:
Constant Field Values
Constructor Detail

Page

public Page()

Page

public Page(java.lang.String title)

Page

public Page(java.lang.String title,
            java.lang.String attributes)
Method Detail

title

public Page title(java.lang.String title)
Set page title.

Returns:
This Page (for chained commands)

addHeader

public Page addHeader(java.lang.Object o)
Add element or object to the page header.

Parameters:
o - The Object to add. If it is a String or Element, it is added directly, otherwise toString() is called.
Returns:
This Page (for chained commands)

setBackGroundImage

public final Page setBackGroundImage(java.lang.String bg)
Set page background image.

Returns:
This Page (for chained commands)

setBackGroundColor

public final Page setBackGroundColor(java.lang.String color)
Set page background color.

Returns:
This Page (for chained commands)

setBase

public final Page setBase(java.lang.String target,
                          java.lang.String href)
Set the URL Base for the Page.

Parameters:
target - Default link target, null if none.
href - Default absolute href, null if none.
Returns:
This Page (for chained commands)

write

public void write(java.io.Writer out)
           throws java.io.IOException
Write the entire page by calling:
writeHtmlHead(out)
writeBodyTag(out)
writeElements(out)
writeHtmlEnd(out)

Overrides:
write in class Composite
Parameters:
out - Writer to write the element to.
java.io.IOException

writeHtmlHead

public void writeHtmlHead(java.io.Writer out)
                   throws java.io.IOException
Write HTML page head tags. Write tags <HTML><head> .... </head>

java.io.IOException

writeBodyTag

public void writeBodyTag(java.io.Writer out)
                  throws java.io.IOException
Write HTML page body tag. Write tags <BODY page attributes>.

java.io.IOException

writeHtmlEnd

public void writeHtmlEnd(java.io.Writer out)
                  throws java.io.IOException
Write end BODY and end HTML tags.

java.io.IOException

writeElements

public void writeElements(java.io.Writer out)
                   throws java.io.IOException
Write any body elements of the page.

java.io.IOException

write

public void write(java.io.Writer out,
                  java.lang.String section,
                  boolean endHtml)
           throws java.io.IOException
Write page section. The page is written containing only the named section. If a head and bodyTag have not been written, then they are written before the section. If endHtml is true, the end HTML tag is also written. If the named section is Content and it cannot be found, then the normal page contents are written.

java.io.IOException

flush

public void flush(java.io.Writer out)
           throws java.io.IOException
Overrides:
flush in class Composite
java.io.IOException

rewind

public void rewind()

properties

public java.util.Dictionary properties()
Access the page properties. It is up to a derived Page class to interpret these properties.


frameSet

public FrameSet frameSet()
Return the preferred FrameSet to be used with a specialized Page. The Frames will be named after the sections they are to contain. The default implementation returns null


setSection

public void setSection(java.lang.String section,
                       Composite composite)
Set a composite as a named section. Other Page users may. add to the section by calling addTo(). It is up to the section creator to add the section to the page in it appropriate position.


addSection

public void addSection(java.lang.String section,
                       Composite composite)
Set a composite as a named section and add it to the. contents of the page


getSection

public Composite getSection(java.lang.String section)
Get a composite as a named section.


addTo

public void addTo(java.lang.String section,
                  java.lang.Object element)
Add content to a named sections. If the named section cannot. be found, the content is added to the page.



Copyright ? 2000 Mortbay Consulting Pty. Ltd. All Rights Reserved.