org.mortbay.html

Class Page

Known Direct 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.5 2004/09/23 02:15:15 gregwilkins Exp $
Author:
Greg Wilkins
See Also:
Composite

Field Summary

static String
Back
static String
BaseUrl
static String
BgColour
static String
Content
static String
ContentSize
static String
FgColour
static String
Footer
static String
FooterSize
static String
Header
static String
HeaderSize
static String
Heading
static String
Help
static String
HighlightColour
static String
Home
static String
LeftMargin
static String
LeftMarginSize
static String
Margin
static String
MarginSize
static String
Next
static String
NoTitle
static String
PageType
static String
Prev
static String
Request
static String
Response
static String
RightMargin
static String
RightMarginSize
static String
Section
static String
Target
static String
Title
static String
Up
protected Hashtable
properties

Fields inherited from class org.mortbay.html.Composite

elements, nest

Fields inherited from class org.mortbay.html.Element

ALIGN, BGCOLOR, BOTTOM, CENTER, CLASS, COLOR, HEIGHT, ID, LEFT, MIDDLE, RIGHT, SIZE, STYLE, TOP, VALIGN, WIDTH, attributeMap, noAttributes

Constructor Summary

Page()
Page(String title)
Page(String title, String attributes)

Method Summary

Page
addHeader(Object o)
Add element or object to the page header.
void
addSection(String section, Composite composite)
Set a composite as a named section and add it to the.
void
addTo(String section, Object element)
Add content to a named sections.
protected void
completeSections()
This call back is called just before writeHeaders() actually writes the HTML page headers.
void
flush(Writer out)
FrameSet
frameSet()
Return the preferred FrameSet to be used with a specialized Page.
Composite
getSection(String section)
Get a composite as a named section.
Dictionary
properties()
Access the page properties.
void
rewind()
Page
setBackGroundColor(String color)
Set page background color.
Page
setBackGroundImage(String bg)
Set page background image.
Page
setBase(String target, String href)
Set the URL Base for the Page.
void
setSection(String section, Composite composite)
Set a composite as a named section.
Page
title(String title)
Set page title.
void
write(Writer out)
Write the entire page by calling:
writeHtmlHead(out)
writeBodyTag(out)
writeElements(out)
writeHtmlEnd(out)
void
write(Writer out, String section, boolean endHtml)
Write page section.
void
writeBodyTag(Writer out)
Write HTML page body tag.
void
writeElements(Writer out)
Write any body elements of the page.
void
writeHtmlEnd(Writer out)
Write end BODY and end HTML tags.
void
writeHtmlHead(Writer out)
Write HTML page head tags.

Methods inherited from class org.mortbay.html.Composite

add, contents, nest, replace, reset, setNest, size, unnest, write

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, size, style, toString, top, width, width, width, write, write, write

Field Details

Back

public static final String Back

BaseUrl

public static final String BaseUrl

BgColour

public static final String BgColour

Content

public static final String Content

ContentSize

public static final String ContentSize

FgColour

public static final String FgColour

Footer

public static final String Footer

FooterSize

public static final String FooterSize

Header

public static final String Header

HeaderSize

public static final String HeaderSize

Heading

public static final String Heading

Help

public static final String Help

HighlightColour

public static final String HighlightColour

Home

public static final String Home

LeftMargin

public static final String LeftMargin

LeftMarginSize

public static final String LeftMarginSize

Margin

public static final String Margin

MarginSize

public static final String MarginSize

NoTitle

public static final String NoTitle

PageType

public static final String PageType

Request

public static final String Request

Response

public static final String Response

RightMargin

public static final String RightMargin

RightMarginSize

public static final String RightMarginSize

Section

public static final String Section

Target

public static final String Target

Title

public static final String Title

Up

public static final String Up

properties

protected Hashtable properties

Constructor Details

Page

public Page()

Page

public Page(String title)

Page

public Page(String title,
            String attributes)

Method Details

addHeader

public Page addHeader(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)

addSection

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

addTo

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

completeSections

protected void completeSections()
This call back is called just before writeHeaders() actually writes the HTML page headers. It can be implemented by a derived Page class to complete a named section after the rest of the Page has been created and appropriate properties set.

flush

public void flush(Writer out)
            throws IOException

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

getSection

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

properties

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

rewind

public void rewind()

setBackGroundColor

public final Page setBackGroundColor(String color)
Set page background color.
Returns:
This Page (for chained commands)

setBackGroundImage

public final Page setBackGroundImage(String bg)
Set page background image.
Returns:
This Page (for chained commands)

setBase

public final Page setBase(String target,
                          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)

setSection

public void setSection(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.

title

public Page title(String title)
Set page title.
Returns:
This Page (for chained commands)

write

public void write(Writer out)
            throws IOException
Write the entire page by calling:
writeHtmlHead(out)
writeBodyTag(out)
writeElements(out)
writeHtmlEnd(out)
Overrides:
write in interface Composite

write

public void write(Writer out,
                  String section,
                  boolean endHtml)
            throws 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.

writeBodyTag

public void writeBodyTag(Writer out)
            throws IOException
Write HTML page body tag. Write tags &ltBODY page attributes&gt.

writeElements

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

writeHtmlEnd

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

writeHtmlHead

public void writeHtmlHead(Writer out)
            throws IOException
Write HTML page head tags. Write tags &ltHTML&gt&lthead&gt .... &lt/head&gt

Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.