org.mortbay.html

Class Page

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 StringBack
static StringBaseUrl
static StringBgColour
static StringContent
static StringContentSize
static StringFgColour
static StringFooter
static StringFooterSize
static StringHeader
static StringHeaderSize
static StringHeading
static StringHelp
static StringHighlightColour
static StringHome
static StringLeftMargin
static StringLeftMarginSize
static StringMargin
static StringMarginSize
static StringNext
static StringNoTitle
protected Hashtableproperties
static StringPageType
static StringPrev
static StringRequest
static StringResponse
static StringRightMargin
static StringRightMarginSize
static StringSection
static StringTarget
static StringTitle
static StringUp
Constructor Summary
Page()
Page(String title)
Page(String title, String attributes)
Method Summary
PageaddHeader(Object o)
Add element or object to the page header.
voidaddSection(String section, Composite composite)
Set a composite as a named section and add it to the. contents of the page
voidaddTo(String section, Object element)
Add content to a named sections.
protected voidcompleteSections()
This call back is called just before writeHeaders() actually writes the HTML page headers.
voidflush(Writer out)
FrameSetframeSet()
Return the preferred FrameSet to be used with a specialized Page.
CompositegetSection(String section)
Get a composite as a named section.
Dictionaryproperties()
Access the page properties.
voidrewind()
PagesetBackGroundColor(String color)
Set page background color.
PagesetBackGroundImage(String bg)
Set page background image.
PagesetBase(String target, String href)
Set the URL Base for the Page.
voidsetSection(String section, Composite composite)
Set a composite as a named section.
Pagetitle(String title)
Set page title.
voidwrite(Writer out)
Write the entire page by calling:
writeHtmlHead(out)
writeBodyTag(out)
writeElements(out)
writeHtmlEnd(out)
voidwrite(Writer out, String section, boolean endHtml)
Write page section.
voidwriteBodyTag(Writer out)
Write HTML page body tag.
voidwriteElements(Writer out)
Write any body elements of the page.
voidwriteHtmlEnd(Writer out)
Write end BODY and end HTML tags.
voidwriteHtmlHead(Writer out)
Write HTML page head tags.

Field Detail

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

public static final String Next

NoTitle

public static final String NoTitle

properties

protected Hashtable properties

PageType

public static final String PageType

public static final String Prev

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

Constructor Detail

Page

public Page()

Page

public Page(String title)

Page

public Page(String title, String attributes)

Method Detail

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)

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)
Write the entire page by calling:
writeHtmlHead(out)
writeBodyTag(out)
writeElements(out)
writeHtmlEnd(out)

write

public void write(Writer out, String section, boolean endHtml)
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)
Write HTML page body tag. Write tags <BODY page attributes>.

writeElements

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

writeHtmlEnd

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

writeHtmlHead

public void writeHtmlHead(Writer out)
Write HTML page head tags. Write tags <HTML><head> .... </head>
Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.