BEA Systems, Inc.

WebLogic Server 5.1.0 API Reference

weblogic.html
Class HtmlPage

java.lang.Object
  |
  +--weblogic.html.WebPage
        |
        +--weblogic.html.HtmlPage
Direct Known Subclasses:
ServletPage

public class HtmlPage
extends WebPage

Class for HtmlPage objects. The starting point for the generation of HTML with htmlKona is the creation of an HtmlPage object. Set the HEAD portion of the page by calling the getHead() method. Then set attributes of the page, such as background, background color, name, etc., after calling the getBodyElement() method, with methods from the BodyElement class. Finally, call the getBody() method to add htmlKona elements to the body portion of the page. For example:

  HtmlPage hp = new HtmlPage();
  hp.getHead()
    .addElement(new TitleElement("Hello World"))
    .addElement(new LinkHeadElement(LinkHeadElement.relTag,
                                    LinkHeadElement.relCopyright,
                                    "http://www.weblogic.com/copyright.html"));
  hp.getBodyElement()
    .setAttribute(BodyElement.bgColor, HtmlColor.white)
    .setAttribute(BodyElement.textColor, HtmlColor.navy);
  hp.getBody()
    .addElement(MarkupElement.HorizontalRule)
    .addElement(new StringElement("Hello World!").asBoldElement())
    .addElement(MarkupElement.HorizontalRule);
  hp.output();
 

The various output() methods in this class are called to generate HTML to an output stream. If the htmlKona program is executed in a batch mode, the output is directed to a given filename. In the case of a CGI invocation, the output occurs to stdout. If the htmlKona page is used for server-side Java, the argument to the output() method will depend upon the output stream specified by the vendor for the server.

Author:
Copyright (c) 1995-97, WebLogic, Inc.
Copyright © 2000 BEA Systems, Inc. All Rights Reserved.
See Also:
HtmlContainer, HtmlElement, ServletPage

Field Summary
static int HTML_2
           
static int HTML_3
           
static int HTML_4
           
protected  java.lang.String htmlLevel
           
 
Fields inherited from class weblogic.html.WebPage
allow, codeset, contentbuf, contentencoding, contentlength, contents, contenttype, expires, lastmodified, location, pragma, referer, server
 
Constructor Summary
HtmlPage()
          Constructs an HtmlPage object and sets its content type to "text/html".
HtmlPage(Codeset codeset)
          Constructs an HtmlPage object of type "text/html" and sets its codeset.
HtmlPage(java.lang.String title)
          Deprecated. Use HtmlPage.getHead().addElement()
 
Method Summary
 HtmlPage addScript(java.lang.String script)
          Deprecated. Use HtmlPage.getHead().addElement()
 HtmlContainer getBody()
          Returns the HtmlContainer that is the body portion of an HtmlPage.
 BodyElement getBodyElement()
          Returns the (HtmlContainer) BodyElement for an HtmlPage, which allows you to set attributes for the BODY tag with the BodyElement.setAttribute() method.
 HtmlContainer getHead()
          Returns the HtmlContainer that is the head portion of an HtmlPage.
 java.lang.String getHtmlLevel()
           
 java.lang.String getTitle()
          Gets the title of an HtmlPage.
 void output(java.io.OutputStream out)
           
 void output(java.io.OutputStream out, int outputbuffersize)
          Outputs HTML for an HtmlPage to the specified OutputStream.
 void output(java.io.OutputStream out, int outputbuffersize, java.lang.String codeset)
           
 void output(java.io.OutputStream out, java.lang.String codeset)
          Outputs HTML for an HtmlPage to the specified OutputStream.
 void outputBody()
          Outputs HTML for the body of an HtmlPage to stout.
 void outputBody(java.io.OutputStream out)
          Outputs HTML for the body of an HtmlPage to the specified DataOutputStream.
 void outputHeader()
          Outputs HTML for the header of an HtmlPage to stout.
 void outputHeader(java.io.OutputStream out)
          Outputs HTML for the header of an HtmlPage to the specified DataOutputStream.
 void outputTrailer()
          Outputs HTML for the trailer of an HtmlPage to stout.
 void outputTrailer(java.io.OutputStream out)
          Outputs HTML for the trailer of an HtmlPage to the specified DataOutputStream.
 HtmlPage resetBody()
          Returns a new HtmlContainer that is the body portion of an HtmlPage.
 HtmlPage resetHead()
          Returns a new HtmlContainer that is the head portion of an HtmlPage.
 HtmlPage setALinkColor(java.lang.String color)
          Deprecated. Use HtmlPage.getBodyElement().setAttribute()
 HtmlPage setBackground(java.lang.String url)
          Deprecated. Use HtmlPage.getBodyElement().setAttribute()
 HtmlPage setBackgroundColor(java.lang.String color)
          Deprecated. Use HtmlPage.getBodyElement().setAttribute()
static int setDefaultBufferSize(int toBe)
          Deprecated.  
 HtmlPage setFrameSetElement(FrameSetElement fs)
          Adds a FrameSetElement to an HtmlPage.
 void setHtmlLevel(int version)
          Sets the HTML version for a page.
 HtmlPage setLinkColor(java.lang.String color)
          Deprecated. Use HtmlPage.getBodyElement().setAttribute()
 HtmlPage setOnLoad(java.lang.String str)
          Deprecated. Use HtmlPage.getBodyElement().setAttribute()
 HtmlPage setOnUnload(java.lang.String str)
          Deprecated. Use HtmlPage.getBodyElement().setAttribute()
 HtmlPage setTitle(java.lang.String title)
          Deprecated. Use HtmlPage.getHead().addElement()
 HtmlPage setVLinkColor(java.lang.String color)
          Deprecated. Use HtmlPage.getBodyElement().setAttribute()
 java.lang.String toString()
          Returns a string representation of an HtmlPage.
 
Methods inherited from class weblogic.html.WebPage
allow, allow, contentBuf, contentBuf, contentEncoding, contentEncoding, contentLength, contentLength, contents, contents, contentType, contentType, expires, expires, includeHeader, lastModified, lastModified, location, location, output, output, pragma, pragma, referer, referer, server, server, setClientPull, setClientPull, setCodeset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

HTML_2

public static final int HTML_2

HTML_3

public static final int HTML_3

HTML_4

public static final int HTML_4

htmlLevel

protected java.lang.String htmlLevel
Constructor Detail

HtmlPage

public HtmlPage()
Constructs an HtmlPage object and sets its content type to "text/html".

HtmlPage

public HtmlPage(Codeset codeset)
Constructs an HtmlPage object of type "text/html" and sets its codeset. For example:
HtmlPage hp = new HtmlPage(new Codeset("SJIS"));

Parameters:
codeset - A Codeset object

HtmlPage

public HtmlPage(java.lang.String title)
Deprecated. Use HtmlPage.getHead().addElement()
Deprecated. Instead, use:
  HtmlPage.getHead().addElement(new TitleElement(title);
Method Detail

setDefaultBufferSize

public static int setDefaultBufferSize(int toBe)
Deprecated.  
Sets the default buffer size for output. Returns the previous default.

Parameters:
toBe - Size buffer should be
Returns:
Size buffer was

setHtmlLevel

public void setHtmlLevel(int version)
Sets the HTML version for a page. Use a final static int from this class. If this method is not called, the default (HTML 4.0) is used.

Parameters:
doctype - HTML_2, HTML_3, or HTML_4 (default)

getHtmlLevel

public java.lang.String getHtmlLevel()

getTitle

public java.lang.String getTitle()
Gets the title of an HtmlPage.

Returns:
Page title

setFrameSetElement

public HtmlPage setFrameSetElement(FrameSetElement fs)
Adds a FrameSetElement to an HtmlPage.

Parameters:
fs - FrameSetElement
Returns:
HtmlPage object

getBody

public HtmlContainer getBody()
Returns the HtmlContainer that is the body portion of an HtmlPage. After the getBody() method is called, use addElement() methods to add the htmlKona objects for lists, divisions, tables, etc., to the body portion of the HTML page.

Returns:
HtmlContainer object

getBodyElement

public BodyElement getBodyElement()
Returns the (HtmlContainer) BodyElement for an HtmlPage, which allows you to set attributes for the BODY tag with the BodyElement.setAttribute() method.

Returns:
BodyElement

resetBody

public HtmlPage resetBody()
Returns a new HtmlContainer that is the body portion of an HtmlPage.

Returns:
HtmlPage with a new HtmlContainer object

getHead

public HtmlContainer getHead()
Returns the HtmlContainer that is the head portion of an HtmlPage. After the getHead() method is called, use addElement() methods to add the htmlKona objects TitleElement, IsIndexElement, LinkHeadElement, MetaElement, BaseElement, BaseFontElement, StyleElement and ScriptElement to the head portion of the page.

Returns:
HtmlContainer object

resetHead

public HtmlPage resetHead()
Returns a new HtmlContainer that is the head portion of an HtmlPage.

Returns:
HtmlContainer object

outputHeader

public void outputHeader()
                  throws java.io.IOException
Outputs HTML for the header of an HtmlPage to stout.

Throws:
java.io.IOException - if there is an IO error

outputBody

public void outputBody()
                throws java.io.IOException
Outputs HTML for the body of an HtmlPage to stout.

Throws:
java.io.IOException - if there is an IO error

outputTrailer

public void outputTrailer()
                   throws java.io.IOException
Outputs HTML for the trailer of an HtmlPage to stout.

Throws:
java.io.IOException - if there is an IO error

outputHeader

public void outputHeader(java.io.OutputStream out)
                  throws java.io.IOException
Outputs HTML for the header of an HtmlPage to the specified DataOutputStream.

Parameters:
ostr - Output stream
Throws:
java.io.IOException - if there is an IO error

outputBody

public void outputBody(java.io.OutputStream out)
                throws java.io.IOException
Outputs HTML for the body of an HtmlPage to the specified DataOutputStream.

Parameters:
ostr - Output stream
Throws:
java.io.IOException - if there is an IO error

outputTrailer

public void outputTrailer(java.io.OutputStream out)
                   throws java.io.IOException
Outputs HTML for the trailer of an HtmlPage to the specified DataOutputStream.

Parameters:
ostr - Output stream
Throws:
java.io.IOException - if there is an IO error

output

public void output(java.io.OutputStream out,
                   java.lang.String codeset)
            throws java.io.IOException
Outputs HTML for an HtmlPage to the specified OutputStream.

Parameters:
ostr - Output stream
Throws:
java.io.IOException - if there is an IO error
Overrides:
output in class WebPage

output

public void output(java.io.OutputStream out)
            throws java.io.IOException

Overrides:
output in class WebPage

output

public void output(java.io.OutputStream out,
                   int outputbuffersize)
            throws java.io.IOException
Outputs HTML for an HtmlPage to the specified OutputStream.

Parameters:
ostr - Output stream
outputbuffersize - Buffered output stream buffer size
Throws:
java.io.IOException - if there is an IO error

output

public void output(java.io.OutputStream out,
                   int outputbuffersize,
                   java.lang.String codeset)
            throws java.io.IOException

toString

public java.lang.String toString()
Returns a string representation of an HtmlPage.

Returns:
String
Overrides:
toString in class java.lang.Object

setTitle

public HtmlPage setTitle(java.lang.String title)
Deprecated. Use HtmlPage.getHead().addElement()
Deprecated. Use:
  getHead().addElement(new TitleElement(title));

addScript

public HtmlPage addScript(java.lang.String script)
Deprecated. Use HtmlPage.getHead().addElement()
Deprecated. Instead, use:
   HtmlPage.getHead().addElement(new ScriptElement());

setOnLoad

public HtmlPage setOnLoad(java.lang.String str)
Deprecated. Use HtmlPage.getBodyElement().setAttribute()
Deprecated. Instead, use:
  HtmlPage.getBodyElement().setAttribute(BodyElement.onLoadScript, string);

setOnUnload

public HtmlPage setOnUnload(java.lang.String str)
Deprecated. Use HtmlPage.getBodyElement().setAttribute()
Deprecated. Instead, use:
  HtmlPage.getBodyElement().setAttribute(BodyElement.onUnload, string);

setBackground

public HtmlPage setBackground(java.lang.String url)
Deprecated. Use HtmlPage.getBodyElement().setAttribute()
Deprecated. Instead, use:
  HtmlPage.getBodyElement().setAttribute(BodyElement.backgroundImg, url);

setLinkColor

public HtmlPage setLinkColor(java.lang.String color)
Deprecated. Use HtmlPage.getBodyElement().setAttribute()
Deprecated. Instead, use:
  HtmlPage.getBodyElement().setAttribute(BodyElement.linkColor, color);

setALinkColor

public HtmlPage setALinkColor(java.lang.String color)
Deprecated. Use HtmlPage.getBodyElement().setAttribute()
Deprecated. Instead, use:
  HtmlPage.getBodyElement().setAttribute(BodyElement.aLinkColor, color);

setVLinkColor

public HtmlPage setVLinkColor(java.lang.String color)
Deprecated. Use HtmlPage.getBodyElement().setAttribute()
Deprecated. Instead, use:
  HtmlPage.getBodyElement().setAttribute(BodyElement.vLinkColor, color);

setBackgroundColor

public HtmlPage setBackgroundColor(java.lang.String color)
Deprecated. Use HtmlPage.getBodyElement().setAttribute()
Deprecated. Instead, use:
  HtmlPage.getBodyElement().setAttribute(BodyElement.bgColor, color);

Documentation is available at
http://www.weblogic.com/docs51