com.creamtec.ajaxswing.rendering.html

## Class HTMLPage

- java.lang.Object
- - java.util.Observable
  - - com.creamtec.ajaxswing.rendering.AbstractDocument
    - - com.creamtec.ajaxswing.rendering.html.HTMLPage

- All Implemented Interfaces:
    Document
  Direct Known Subclasses:
    AjaxPage

      public class HTMLPage
      extends AbstractDocument

  Represents HTML page that will be sent to the browser. The page stores the HTML code in a buffer and provides methods to access and modify it. Each page is associated with a client agent for which the rendering is performed, and a rendering context which stores the rendering attributes and can be used to set flags during rendering. HTMLPage is different from StringBuffer in that it maintains an indent making reading HTML easier. Notice that to decrease the size of rendered HTML page you can opt not to maintain indents.
  The page has a current output stream which can be either the header or the body. By default it is body when renderers are invoked. Page uses Observable pattern to support listeners on page rendering state. When the page is cleared either right before the processing of a new HTTP request or when the client agent is being shutdown, it notifies all registered listeners allowing them to do resource cleanup and other tasks. The parameter to Observer's update method is the page itself.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `HTMLPage()` Creates an empty page with the given buffer size and associates it with the client agent
    `HTMLPage(HTMLPage page)` Creates a page that has the same indents as the given page and is associated with the same client agent

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `afterRender()` Callback function called after a document is rendered
    `void` | `appendHeaderScript(java.lang.String script)` Use to append JavaScript to the HTML page header together with other AjaxSwing's JavaScripts.
    `void` | `appendOnLoadScriptBody(java.lang.String onLoadFunctionBody)` Appends JavaScript statements to the body of onLoad function.
    `void` | `appendWindowFooter()` Appends footer to the current component's body
    `void` | `beforeRender()` Callback function called before a document is rendered
    `java.lang.String` | `cleanupImageUrl(java.lang.String url)` Helper function used by getImageUrl to clean up the image URL in case it originated from a jar or from a file
    `void` | `clearWindowFooter()`
    `static java.lang.String` | `generateName(java.lang.Object obj)` Delegates the generation of component name to WindowUpdater
    `java.lang.StringBuilder` | `getBody()` Returns the buffer representing the page body (HTML between <body> and </body> tags)
    `java.lang.String` | `getComponentName(java.awt.Component comp)`
    `static java.lang.String` | `getComponentName(java.awt.MenuBar comp)` If a component has a name, it is returned.
    `java.lang.String` | `getCssClass()`
    `java.lang.String` | `getDocsStampURL(java.lang.String name)`
    `java.lang.StringBuilder` | `getHeader()` Returns the buffer representing the page header (HTML between <header> and </header> tags)
    `java.lang.StringBuilder` | `getHeaderScript()` Returns the buffer representing the page header (HTML between <header> and </header> tags)
    `java.lang.String` | `getImageUrl(javax.swing.Icon icon, java.awt.Component component)` Helper function that can be used to obtain a URL that should be used on a page for a given Icon.
    `java.lang.String` | `getImageUrl(java.awt.Image image)` Helper function that can be used to obtain a URL that should be used on a page for a given Image.
    `int` | `getNextComponentNameIndex(java.lang.Object obj)`
    `java.lang.String` | `getOnLoadScriptBody()`
    `HTMLPageRenderer` | `getPageRenderer()` Returns the page renderer associated with the page.
    `int` | `getSnapshotImageIndex()` Returns an index for generating the snapshot name
    `java.lang.String` | `getSubmitURL()` Returns the URL
    `java.lang.String` | `getTempFileURL(java.lang.String fileName)` Appends a full URL to a file located in AjaxSwing temp directory
    `java.lang.String` | `getThemeDocsStampURL(java.lang.String name)`
    `java.awt.Component` | `getV4RootComponent()`
    `java.lang.StringBuilder` | `getWindowFooter()` Returns the buffer representing the end of the page body.
    `void` | `incSnapshotIndex()` Increments an index for generating the snapshot name by one
    `void` | `reset(boolean complete)` Clears the page and its buffers.
    `void` | `setRenderContext(RenderContext context)` Sets rendering context
    `void` | `setUseOnLoad(boolean useOnLoad)` Sets weather or not the page should have onLoad function specified for the tag
    `void` | `setV4RootComponent(java.awt.Component v4RootComponent)`
    `java.lang.String` | `toString()` Renders page as string using the specified template

    - ### Methods inherited from class com.creamtec.ajaxswing.rendering.AbstractDocument

      `getClientAgent, getDocsURL, getDocumentRenderer, getProps, getRedirectURL, getRenderContext, getThemeDocsURL, getThemeName, getTitle, isPartialUpdateAllowed, setClientAgent, setComponentDirty, setDocumentRenderer, setPartialUpdateAllowed, setRedirectURL, setTitle`

    - ### Methods inherited from class java.util.Observable

      `addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### HTMLPage

          public HTMLPage()

      Creates an empty page with the given buffer size and associates it with the client agent

    - #### HTMLPage

          public HTMLPage(HTMLPage page)

      Creates a page that has the same indents as the given page and is associated with the same client agent

  - ### Method Detail

    - #### getPageRenderer

          public HTMLPageRenderer getPageRenderer()

      Returns the page renderer associated with the page. PageRenderer can be used to render components and containers

    - #### setRenderContext

          public void setRenderContext(RenderContext context)

      Sets rendering context

    - #### getBody

          public java.lang.StringBuilder getBody()

      Returns the buffer representing the page body (HTML between <body> and </body> tags)

    - #### getWindowFooter

          public java.lang.StringBuilder getWindowFooter()

      Returns the buffer representing the end of the page body. It is appended after all rendering is done but before </body> tag

    - #### clearWindowFooter

          public void clearWindowFooter()

    - #### getHeader

          public java.lang.StringBuilder getHeader()

      Returns the buffer representing the page header (HTML between <header> and </header> tags)

    - #### getHeaderScript

          public java.lang.StringBuilder getHeaderScript()

      Returns the buffer representing the page header (HTML between <header> and </header> tags)

    - #### toString

          public java.lang.String toString()

      Renders page as string using the specified template
      Overrides:
        `toString` in class `java.lang.Object`

    - #### getCssClass

          public java.lang.String getCssClass()

    - #### getSubmitURL

          public java.lang.String getSubmitURL()

      Returns the URL

    - #### generateName

          public static java.lang.String generateName(java.lang.Object obj)

      Delegates the generation of component name to WindowUpdater
      Parameters:
        `obj` - UI element
      Returns:
        name

    - #### reset

          public void reset(boolean complete)

      Clears the page and its buffers. Resets indexes and counters to their defaults Observers are notified before the page state is reset
      Overrides:
        `reset` in class `AbstractDocument`

    - #### getComponentName

          public static java.lang.String getComponentName(java.awt.MenuBar comp)

      If a component has a name, it is returned. Otherwise, a name is generated based on the component type, the request number and the index of the component in the container (for example, MenuBar11)

    - #### getComponentName

          public java.lang.String getComponentName(java.awt.Component comp)

    - #### getImageUrl

          public java.lang.String getImageUrl(javax.swing.Icon icon,
                                     java.awt.Component component)

      Helper function that can be used to obtain a URL that should be used on a page for a given Icon. AjaxSwing tries to locate the URL from which the Icon was loaded. If it is absolute URL such as http://mysite.com/images/myimage.gif then it is returned as is. If it is relative or file based, this function will prepend the URL with the themeURL and return the composite absolute URL

    - #### getImageUrl

          public java.lang.String getImageUrl(java.awt.Image image)

      Helper function that can be used to obtain a URL that should be used on a page for a given Image. AjaxSwing tries to locate the URL from which the Icon was loaded. If it is absolute URL such as http://mysite.com/images/myimage.gif then it is returned as is. If it is relative or file based, this function will prepend the URL with the themeURL and return the composite absolute URL

    - #### cleanupImageUrl

          public java.lang.String cleanupImageUrl(java.lang.String url)

      Helper function used by getImageUrl to clean up the image URL in case it originated from a jar or from a file

    - #### getTempFileURL

          public java.lang.String getTempFileURL(java.lang.String fileName)

      Appends a full URL to a file located in AjaxSwing temp directory
      Parameters:
        `fileName` -

    - #### appendOnLoadScriptBody

          public void appendOnLoadScriptBody(java.lang.String onLoadFunctionBody)

      Appends JavaScript statements to the body of onLoad function.
      Parameters:
        `onLoadFunctionBody` - statements to appear inside the body of function onLoad()

    - #### getOnLoadScriptBody

          public java.lang.String getOnLoadScriptBody()

    - #### setUseOnLoad

          public void setUseOnLoad(boolean useOnLoad)

      Sets weather or not the page should have onLoad function specified for the
      tag

    - #### beforeRender

          public void beforeRender()

      Description copied from interface: `Document`
      Callback function called before a document is rendered
      Specified by:
        `beforeRender` in interface `Document`
      Overrides:
        `beforeRender` in class `AbstractDocument`

    - #### afterRender

          public void afterRender()

      Description copied from interface: `Document`
      Callback function called after a document is rendered
      Specified by:
        `afterRender` in interface `Document`
      Overrides:
        `afterRender` in class `AbstractDocument`

    - #### appendWindowFooter

          public void appendWindowFooter()

      Appends footer to the current component's body

    - #### getThemeDocsStampURL

          public java.lang.String getThemeDocsStampURL(java.lang.String name)

    - #### getDocsStampURL

          public java.lang.String getDocsStampURL(java.lang.String name)

    - #### appendHeaderScript

          public void appendHeaderScript(java.lang.String script)

      Use to append JavaScript to the HTML page header together with other AjaxSwing's JavaScripts. The script should represent a JavaScript function without <script> tags.

    - #### getSnapshotImageIndex

          public int getSnapshotImageIndex()

      Returns an index for generating the snapshot name
      Returns:
        index

    - #### incSnapshotIndex

          public void incSnapshotIndex()

      Increments an index for generating the snapshot name by one

    - #### getNextComponentNameIndex

          public int getNextComponentNameIndex(java.lang.Object obj)

      Specified by:
        `getNextComponentNameIndex` in class `AbstractDocument`

    - #### setV4RootComponent

          public void setV4RootComponent(java.awt.Component v4RootComponent)

    - #### getV4RootComponent

          public java.awt.Component getV4RootComponent()

Copyright © 2000-2012 CreamTec LLC. All Rights Reserved.