com.plumtree.xpshared.htmlelements
Class HTMLPage

java.lang.Object
  extended by com.plumtree.xpshared.htmlelements.HTMLElement
      extended by com.plumtree.xpshared.htmlelements.HTMLPage
All Implemented Interfaces:
java.lang.Cloneable

public class HTMLPage
extends HTMLElement

This object can display an entire page of HTML, consisting of one <html> element, one <head> element and one <body> element.

Use the SetHead() and SetBody() methods to define the contents of this HTML page.

Use the validateHTML() method to determine whether or not the html generated by this object complies to the HTML 4 specification. This method requires that CSE HTML Validator 5.0 be installed on the client computer.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.plumtree.xpshared.htmlelements.HTMLElement
HTMLElement.ValidationLevel
 
Field Summary
static boolean bAlwaysValidateHTMLOnDisplay
          Set this member true to cause the page to validate every time GetDisplayString() is called.
static java.lang.String DOCTYPE_3_2
           
static java.lang.String DOCTYPE_4_0_FRAMESET
           
static java.lang.String DOCTYPE_4_0_STRICT
           
static java.lang.String DOCTYPE_4_0_TRANSITIONAL
           
static java.lang.String DOCTYPE_RENDERED
           
 
Fields inherited from class com.plumtree.xpshared.htmlelements.HTMLElement
aNewLine, bAllowEvents, bAllowSetStyleClassWithString, bCheckNestedStringForHTML, bDisplayDidPause, bEnforceMaxTableDepth, bForceFormattingOff, bForceFormattingOn, bPauseAfterDisplay, bPrintComments, bResumingAndChildFinished, bResumingAndChildInMidRender, bShowLang, iMaxTableDepth, sLangLocal, sNewLine, sTab
 
Constructor Summary
HTMLPage()
          Creates a new HTMLPage object.
 
Method Summary
 void AddInnerHTMLElement(HTMLElement e)
          Do not call this method.
protected  void AppendBeginningOfOpeningTag(boolean bFormat, XPStringBuilder sb, IXPResponse response)
          This method generates the beginning of the opening tag.
protected  void AppendClosingTag(boolean bFormat, XPStringBuilder sb, IXPResponse response)
          This method generates the closing tag of this html element.
 void ClearBody()
          Call this method to remove the HTMLBody object associated with this HTMLPage.
 HTMLBody GetBody()
          Call this method to obtain the HTMLBody object describing the body of this html page.
 java.lang.String GetDisplayString()
          HTMLElement.GetDisplayString rewritten.
 HTMLFrameSet GetFrameSet()
          Call this method to get the HTMLFrameSet of this page.
 HTMLHead GetHead()
          Call this method to obtain the HTMLHead object describing the head of this html page.
protected  XPStringBuilder GetStringBuilder()
          This method is used to get a reasonable sized String Builder.
protected  boolean ProvidesClosingTag()
          Indicates whether or not this HTML element provides a closing tag.
 void SetBody(HTMLBody b)
          Call this method to set the body of this page.
 void SetFrameSet(HTMLFrameSet fs)
          Call this method to set the frameset of this page.
 void SetHead(HTMLHead h)
          Call this method to set the head of this html page.
 void ValidateHTML()
          Call this method to determine whether or not the HTML generated by this HTMLPage object is valid HTML.

CSE HTML Validator version 5.0 must be installed on the computer running this code.
 void ValidateHTML(boolean bSaveResults, boolean bSaveOnlyErrors, java.lang.String sFileName, java.lang.String sPathName)
          Call this method to have greater control over validation.
 
Methods inherited from class com.plumtree.xpshared.htmlelements.HTMLElement
AddInnerHTMLEncodedString, AddInnerHTMLString, AppendClosingLineBreak, CleanupHTMLSubtreeAfterRendering, ClearInnerHTMLElements, clone, Display, Display, ForceFormattingOff, GetChildInMidRender, GetClone, GetDisabled, GetDisplayDidPause, GetDisplayOptions, GetDisplayString, GetDisplayString, GetDo508Checking, GetDoFormat, GetElementName, GetForceLineBreaksAfterSafeElements, GetHTMLElementReadOnly, GetID, GetImgBaseUrl, GetInnerHTML, GetInnerHTML, GetInnerHTMLDisplayString, GetInnerHTMLElements, GetInnerHTMLElementsAsArrayList, GetIsNetscape, GetLang, GetLastChildFullyRendered, GetName, GetOnClick, GetOnKeyDown, GetOnKeyPress, GetOnKeyUp, GetOnMouseOut, GetOnMouseOver, GetPauseAfterDisplay, GetPostComment, GetPreComment, GetStyle, GetStyleClass, GetStyleClassPrefix, GetTitle, GetValidationLevel, InsertInnerHTMLElement, InternalWrite, SaveToTempFile, SaveToTempFile, SetChildInMidRender, SetDisabled, SetDisplayOptions, SetDo508Checking, SetDoFormat, SetElementName, SetFlushAfterDisplay, SetForceLineBreaksAfterSafeElements, SetHTMLElementReadOnly, SetID, SetImgBaseUrl, SetInner, SetIsNetscape, SetLangGlobal, SetLangLocal, SetLastChildFullyRendered, SetName, SetOnClick, SetOnKeyDown, SetOnKeyPress, SetOnKeyUp, SetOnMouseOut, SetOnMouseOver, SetPauseAfterDisplay, SetPostComment, SetPreComment, SetStyle, SetStyleClass, SetStyleClass, SetStyleClassPrefix, SetTitle, SetValidationLevel, ToByteArray, VerifyWritability, WriteNugget, WriteNugget
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DOCTYPE_4_0_STRICT

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

DOCTYPE_4_0_TRANSITIONAL

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

DOCTYPE_4_0_FRAMESET

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

DOCTYPE_3_2

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

DOCTYPE_RENDERED

public static java.lang.String DOCTYPE_RENDERED

bAlwaysValidateHTMLOnDisplay

public static boolean bAlwaysValidateHTMLOnDisplay
Set this member true to cause the page to validate every time GetDisplayString() is called.

Constructor Detail

HTMLPage

public HTMLPage()
Creates a new HTMLPage object.

Method Detail

GetStringBuilder

protected XPStringBuilder GetStringBuilder()
This method is used to get a reasonable sized String Builder. It should be overridden by larger HTMLElements such as HTMLPage.

Overrides:
GetStringBuilder in class HTMLElement
Returns:
XPStringBuilder

GetDisplayString

public java.lang.String GetDisplayString()
HTMLElement.GetDisplayString rewritten.

Overrides:
GetDisplayString in class HTMLElement
Returns:
String display string.
Throws:
HTMLException - Throws an exception if the html isn't valid or cannot be generated.

AppendBeginningOfOpeningTag

protected void AppendBeginningOfOpeningTag(boolean bFormat,
                                           XPStringBuilder sb,
                                           IXPResponse response)
This method generates the beginning of the opening tag. The abstract HTMLElement superclass will provide the remainder of the opening tag, repleate with attributes common to all html elements, such as name, and id, and class.

Specified by:
AppendBeginningOfOpeningTag in class HTMLElement
Parameters:
bFormat - boolean indicating whether or not to format.
sb - XPStringBuilder
response - IXPResponse

AppendClosingTag

protected void AppendClosingTag(boolean bFormat,
                                XPStringBuilder sb,
                                IXPResponse response)
This method generates the closing tag of this html element. If the providesClosingTag method returns false, then this method will never be called.

Specified by:
AppendClosingTag in class HTMLElement
Parameters:
bFormat - boolean indicating whether or not to format.
sb - XPStringBuilder
response - IXPResponse

ProvidesClosingTag

protected boolean ProvidesClosingTag()
Indicates whether or not this HTML element provides a closing tag. Some elements only provide opening tags, such as the <br> element.

Specified by:
ProvidesClosingTag in class HTMLElement
Returns:
boolean true.

ValidateHTML

public void ValidateHTML(boolean bSaveResults,
                         boolean bSaveOnlyErrors,
                         java.lang.String sFileName,
                         java.lang.String sPathName)
                  throws java.lang.Exception
Call this method to have greater control over validation. You can decide whether to save the results file, and if so, what the name and path of the file is.

Parameters:
bSaveResults - save our results?
bSaveOnlyErrors - save only on errors?
sFileName - name of results file.
sPathName - path to results file.
Throws:
java.lang.Exception

ValidateHTML

public void ValidateHTML()
                  throws java.lang.Exception
Call this method to determine whether or not the HTML generated by this HTMLPage object is valid HTML.

CSE HTML Validator version 5.0 must be installed on the computer running this code. The path to the main folder for the HTML Validator must be included in the "PATH" environment variable.

CSE HTML Validator must be configured in the following way:

  1. Lauch the Validator.
  2. Choose Options | Validator Engine Options.
  3. Go to the Classic tab.
  4. CHECK "Don't use output file; use .val files." option.
  5. UNCHECK "If no errors/warnings, don't view." option.
  6. CHECK "Never open viewer with .val files." option.
  7. Click OK, and exit the HTML Validator.


This method will throw an HTMLException if the HTML generated is not valid. This exception will present the location of the HTML Validator output file. There will be no output file for valid HTML.

The client of this method will probably wish to catch this Exception and display it to the console. In this way, the invalid HTML can still be generated and debugged.

Like: try
{
  myPage.validateHTML();
}
catch( HTMLException he )
{
  System.out.println( he );
}
myPage.display( myResponse );


Throws:
HTMLException - This Exception will describe the location of a file giving a complete rundown of all errors in the HTML.
java.lang.Exception

ClearBody

public void ClearBody()
Call this method to remove the HTMLBody object associated with this HTMLPage.


AddInnerHTMLElement

public void AddInnerHTMLElement(HTMLElement e)
Do not call this method. Use the SetHeadh() and SetBody() methods to define the HTML displayed by this html page.

Overrides:
AddInnerHTMLElement in class HTMLElement

SetHead

public void SetHead(HTMLHead h)
Call this method to set the head of this html page. If this head is not set, this page will display with an empty head.


GetHead

public HTMLHead GetHead()
Call this method to obtain the HTMLHead object describing the head of this html page.


GetFrameSet

public HTMLFrameSet GetFrameSet()
Call this method to get the HTMLFrameSet of this page.

Returns:
HTMLFrameSet object.

SetFrameSet

public void SetFrameSet(HTMLFrameSet fs)
Call this method to set the frameset of this page. This object will not display until this method is called with a valid HTMLFrameSet object, or SetBody() is called with valid HTMLBody object.

A valid HTMLPage can have either an HTMLFrameSet or an HTMLBody, it can neither have both nor neither.


SetBody

public void SetBody(HTMLBody b)
Call this method to set the body of this page. This object will not display until this method is called with a valid HTMLBody object or a valid HTMLFrameSet object.

A valid HTMLPage can have either an HTMLFrameSet or an HTMLBody, it can neither have both nor neither.


GetBody

public HTMLBody GetBody()
Call this method to obtain the HTMLBody object describing the body of this html page.




Copyright © 2002,2003,2004,2005 Plumtree Software, Inc., All Rights Reserved.