PAJES 3.0.21

org.pajes.html
Class Paje

java.lang.Object
  extended by org.pajes.html.Tag
      extended by org.pajes.html.TraversableElement
          extended by org.pajes.html.Container
              extended by org.pajes.html.Paje
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, HTML, Traversable
Direct Known Subclasses:
TreePaje

public class Paje
extends Container

Container to hold all the objects within the <HTML> and </HTML> tags.

See Also:
PajeFactory, Serialized Form

Field Summary
 
Fields inherited from class org.pajes.html.Tag
ON_CLICK_ATTRIBUTE, TAG_CLOSE, TAG_LEFT, TAG_RIGHT
 
Constructor Summary
Paje()
          Create an empty document.
Paje(PajeParser parser)
          Create a document from an HTML source document.
 
Method Summary
 Traversable add(HTML htmlObject)
          Adds an HTML element to the document.
 Container add(java.lang.String code, boolean suppressNewLine)
          Adds a line of text to the document.
 java.lang.Object clone()
          Allows a tag to be cloned.
 void destroy()
          Loops through the container and retrieves each object contained within it and then invokes that objects destroy method.
 Body getBody()
          Returns the instance of PajeBody in this document.
 DocType getDocType()
          Returns the Document Type Declaration.
 java.lang.String getDocTypeHeader()
          Returns the Document Type Declaration string.
 Head getHead()
          Returns the instance of Head in this document.
 java.lang.String getXMLEncoding()
          Returns the XML encoding.
 java.lang.String getXMLVersion()
          Returns the XML version.
 boolean isFirstClone()
          Determines if this instance is the first generated from an updated template.
 Container replace(Container container)
          Deletes all the objects in this container, and replaces them with the cloned objects from another container.
 void setCached(boolean useCache)
          Determines whether this document will be cached by the browser.
 void setDestroyAfterWrite(boolean destroy)
          Determines if the destroy method will be called after each contained object has been written.
 void setDocType(DocType type)
          Sets the Document Type Declaration.
 void setDocType(java.lang.String type)
          Sets the Document Type Declaration.
 void setOnLoadAlert(java.lang.String message)
          Adds a JavaScript alert to the onLoad handler of the currently defined Body or Frameset instance.
 Paje setXHTMLCompliance(boolean compliant)
          Sets whether this document is XHTML compliant or not.
 Paje setXMLEncoding(java.lang.String encoding)
          Sets the XML encoding.
 Paje setXMLVersion(java.lang.String version)
          Sets the XML version.
 java.lang.String toString()
          Returns the HTML object as a string.
 Paje useCompression(boolean compress)
          Specifies whether the document should be written back to the browser using compression, if the browser supports it.
 Paje usePersistentConnection(boolean keepAlive)
          Specifies whether the document should be written back to the browser using a persistent ("keep-alive") connection.
 void write(Browser browser)
          Prints the <HTML> tags and any contained objects to the browser
 void write(javax.servlet.ServletContext context, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Convenience method to automatically create a Browser instance and then invoke write(Browser).
 
Methods inherited from class org.pajes.html.Container
add, add, addContent, clear, delete, delete, get, getContent, getContents, getPosition, insert, set, setContent, setContent, size, writeContent
 
Methods inherited from class org.pajes.html.TraversableElement
dump, dump, getAll, getFieldByName, getFirstFieldByName, getFirstTagByAttribute, getFirstTagByClass, getFirstTagByID, getFirstTagByName, getTagByAttribute, getTagByClass, getTagByID, getTagByName, setWritable
 
Methods inherited from class org.pajes.html.Tag
addAttribute, addAttributes, addAttributes, clearAttribute, clearAttributes, getAttribute, getAttributes, getAttributeSet, getContainer, getDocument, getId, getOnClickHandler, getOnDBLClickHandler, getOnKeyDownHandler, getOnKeyPressHandler, getOnKeyUpHandler, getOnMouseDownHandler, getOnMouseOutHandler, getOnMouseOverHandler, getOnMouseUpHandler, getParent, getStyle, getStyleSheetClass, getTagName, getTitle, getWritePermission, hasAttribute, init, initAttributes, isChildOf, isChildOf, isWritable, isWritable, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttributes, setAttributes, setContainer, setId, setOnClickHandler, setOnDBLClickHandler, setOnKeyDownHandler, setOnKeyPressHandler, setOnKeyUpHandler, setOnMouseDownHandler, setOnMouseOutHandler, setOnMouseOverHandler, setOnMouseUpHandler, setParent, setStyle, setStyleSheetClass, setTagName, setTitle, setWritable, setWriteAttributes, setWriteEndTag, setWritelnAfter, setWritelnAfterContent, setWritelnBefore, setWritelnBeforeContent, setWritePermission
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.pajes.html.Traversable
isWritable
 
Methods inherited from interface org.pajes.html.HTML
getContainer, getDocument, getId, getParent, getWritePermission, isChildOf, isChildOf, setContainer, setParent, setWritePermission
 

Constructor Detail

Paje

public Paje()
Create an empty document.


Paje

public Paje(PajeParser parser)
     throws java.io.IOException
Create a document from an HTML source document.

Parameters:
parser - the parser that will read the source HTML file.
Throws:
java.io.IOException - if an I/O exception occurs whilst generating the Paje.
Method Detail

add

public Traversable add(HTML htmlObject)
Adds an HTML element to the document.

Specified by:
add in interface Traversable
Overrides:
add in class Container
Parameters:
htmlObject - the object to add (eg. doc.add(new Body());)
Returns:
the modified Container object.

add

public Container add(java.lang.String code,
                     boolean suppressNewLine)
Adds a line of text to the document.

Overrides:
add in class Container
Parameters:
code - the line of text.
suppressNewLine - suppresses a new line after the text.
Returns:
the modified Container object.

clone

public java.lang.Object clone()
Description copied from class: Container
Allows a tag to be cloned. Over-rides the clone() method in Tag to do a deep clone: all the objects contained in this object will be cloned individually.

Specified by:
clone in interface HTML
Overrides:
clone in class Container
Returns:
a clone of this Container.
See Also:
Object.clone()

destroy

public void destroy()
Description copied from class: Container
Loops through the container and retrieves each object contained within it and then invokes that objects destroy method. It then clears all internal variables.

Sub-classes MUST call super.destroy(); if over-riding this method!

Specified by:
destroy in interface HTML
Overrides:
destroy in class Container
See Also:
HTML.destroy()

getBody

public Body getBody()
Returns the instance of PajeBody in this document. If no instance has been added to the document a new instance of Body will be created and returned.

Returns:
the reference to the document body.

getDocType

public DocType getDocType()
Returns the Document Type Declaration.

Returns:
the Document Type Declaration, or a null if the document type has not been defined.

getDocTypeHeader

public java.lang.String getDocTypeHeader()
Returns the Document Type Declaration string.

Returns:
the Document Type Declaration string, or a null if the document type has not been defined and cannot be determined.

getHead

public Head getHead()
Returns the instance of Head in this document. If no instance has been added to the document, a new instance of Head will be created and returned.

Returns:
the reference to the document header.

getXMLEncoding

public java.lang.String getXMLEncoding()
Returns the XML encoding.

Returns:
the XML encoding.

getXMLVersion

public java.lang.String getXMLVersion()
Returns the XML version.

Returns:
the XML version

isFirstClone

public boolean isFirstClone()
Determines if this instance is the first generated from an updated template.

Returns:
true if this instance is the first generated from an updated template, or false if it was not the first or not generated from a template.

replace

public Container replace(Container container)
Deletes all the objects in this container, and replaces them with the cloned objects from another container.

Overrides:
replace in class Container
Parameters:
container - the Container from which objects are to be copied.
Returns:
the modified Container object.

setCached

public void setCached(boolean useCache)
Determines whether this document will be cached by the browser. The default is for the document NOT to be cached.

Parameters:
useCache - if true, the document will be cached by the browser. The default is false.

setDestroyAfterWrite

public void setDestroyAfterWrite(boolean destroy)
Determines if the destroy method will be called after each contained object has been written.

By default, Paje destruction is enabled. To disable it as the default, the web application deployment descriptor must have a <context-param> with a <param-name> of org.pajes.html.Paje.setDestroyAfterWrite, and a <param-value> of false. For example:

   <context-param>
       <param-name>org.pajes.html.Paje.setDestroyAfterWrite</param-name>
       <param-value>false</param-value>
   </context-param>
 

Parameters:
destroy - true if the destroy method should be called, or false if it should not. The default is true.

setDocType

public void setDocType(DocType type)
Sets the Document Type Declaration.

Parameters:
type - the Document Type Declaration.

setDocType

public void setDocType(java.lang.String type)
                throws java.text.ParseException
Sets the Document Type Declaration.

Parameters:
type - the Document Type Declaration.
Throws:
java.text.ParseException - if the String containing the Document Type Declaration cannot be parsed.

setOnLoadAlert

public void setOnLoadAlert(java.lang.String message)
                    throws java.io.IOException
Adds a JavaScript alert to the onLoad handler of the currently defined Body or Frameset instance.

Parameters:
message - the message to be displayed when the document is loaded.
Throws:
java.io.IOException - if an I/O error occurs.

setXHTMLCompliance

public Paje setXHTMLCompliance(boolean compliant)
Sets whether this document is XHTML compliant or not. Note that no check for XHTML compliance is undertaken, apart from ensuring that is either the Head or one of either an Body or FrameSet have been defined.

Parameters:
compliant - true (the default) if the document is XHTML compliant, or false if it is not.
Returns:
the modified Paje.

setXMLEncoding

public Paje setXMLEncoding(java.lang.String encoding)
Sets the XML encoding.

Parameters:
encoding - the XML encoding.
Returns:
the modified Paje.

setXMLVersion

public Paje setXMLVersion(java.lang.String version)
Sets the XML version.

Parameters:
version - the XML version
Returns:
the modified Paje.

toString

public java.lang.String toString()
Description copied from class: Tag
Returns the HTML object as a string.

Overrides:
toString in class Tag
Returns:
the string of HTML.
See Also:
Tag.toString()

useCompression

public Paje useCompression(boolean compress)
Specifies whether the document should be written back to the browser using compression, if the browser supports it. The default is the application setting from the application configuration file.

WARNING: The Paje setting will over-ride the setting in the Browser class.

Parameters:
compress - if true, the document will be written to the browser using an appropriate compression encoding, based on the "Accept-Encoding" HTTP header.
Returns:
the modified Paje.

usePersistentConnection

public Paje usePersistentConnection(boolean keepAlive)
Specifies whether the document should be written back to the browser using a persistent ("keep-alive") connection. The default is the application setting from the application configuration file.

WARNING: The Paje setting will over-ride the setting in the Browser class.

Parameters:
keepAlive - if true, (the default) the document will be written to the browser using a keep-alive connection. If false, results are written directly to the output stream.
Returns:
the modified Paje.

write

public void write(Browser browser)
           throws java.io.IOException
Prints the <HTML> tags and any contained objects to the browser

Specified by:
write in interface HTML
Overrides:
write in class Tag
Parameters:
browser - the browser to which the results are to be output.
Throws:
java.io.IOException - if an I/O error occurs.
See Also:
Tag.setWriteEndTag(boolean), Tag.writeContent(org.pajes.servlet.Browser)

write

public void write(javax.servlet.ServletContext context,
                  javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response)
           throws java.io.IOException,
                  javax.servlet.ServletException
Convenience method to automatically create a Browser instance and then invoke write(Browser).

Parameters:
context - the servlet context.
request - the servlet request object.
response - the servlet response object.
Throws:
java.io.IOException - if an I/O error occurs.
javax.servlet.ServletException - if an unrecoverable exception occurs.

PAJES 3.0.21

Copyright 1998-2007 Viridian Pty Limited. All Rights Reserved.