|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.Observable creamtec.webcream.rendering.html.HTMLPage
public class HTMLPage
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 | |
---|---|
HTMLPage()
Creates an empty page with default parameters |
|
HTMLPage(ClientAgent agent)
Creates an empty page with default parameters and associates it with the given client agent |
|
HTMLPage(ClientAgent agent,
int bufferSize)
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 | |
---|---|
void |
append(char ch)
Appends a character |
void |
append(int i)
Appends an integer |
void |
append(java.lang.String s)
Appends a string |
void |
appendCommonScripts()
Appends scripts that are commont to all WebCream generated pages |
void |
appendEventHandler(java.lang.String eventName,
java.awt.Component comp)
Appends a JavaScript event handler to the component HTML tag. |
void |
appendHTMLText(java.lang.String htmlText,
boolean noBreak)
Appends text which can have HTML tags in it. |
void |
appendHTMLText(java.lang.String htmlText,
boolean noBreak,
boolean ignoreAllTags)
Appends text which can have HTML tags in it. |
void |
appendJavaScript(java.lang.String script)
Use to append JavaScript to the HTML page header together with other WebCream's JavaScripts. |
void |
appendln(java.lang.String s)
Appends a string and an end-of-line character |
void |
appendOnLoadScriptBody(java.lang.String onLoadFunctionBody)
Appends JavaScript statements to the body of onLoad function. |
void |
appendOnSubmitScript(java.lang.String script)
Use to append code to the function that is called when WebCream page is submitted (any action is taken by the user) |
void |
appendText(java.lang.String text)
Appends the given text to the page with parameters noBreak as false and ignoreHTMLTags as false. |
void |
appendText(java.lang.String text,
boolean noBreak,
boolean ignoreAllHTMLTags)
Appends the given text to the page. |
void |
appendText(java.lang.String text,
boolean noBreak,
java.awt.Component comp)
Appends the given text to HTML page. |
void |
appendText(java.lang.String text,
java.awt.Component comp)
Appends the given text as non-breakable spaced text. |
void |
appendTrailerScript(java.lang.String script)
Appends a JavaScript to the end of the HTML page |
void |
appendTreeScripts()
Appends tree scripts to the page buffer |
void |
beginTable(int border)
Helper method that appends the tags that start HTML table |
void |
beginTable(int border,
int cellPadding)
Helper method that appends the tags that start HTML table |
void |
beginTable(int border,
int cellPadding,
java.lang.String props)
Helper method that appends the tags that start HTML table |
void |
beginTable(int border,
int cellPadding,
java.lang.String props,
java.lang.Object component)
Helper method that appends the tags that start HTML table |
void |
beginTable(int border,
int cellPadding,
java.lang.String props,
java.lang.Object component,
java.lang.String style)
Helper method that appends the tags that start HTML table. |
void |
beginTable(int border,
java.lang.String props)
Helper method that appends the tags that start HTML table |
void |
beginTableCell()
Helper method to begin table cell |
void |
beginTableCell(java.lang.String props)
Helper method to begin table cell |
void |
beginTableRow()
Helper method to begin HTML table row |
void |
beginTableRow(java.lang.String props)
Helper method to begin HTML table row using <tr> tag |
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 |
decreaseIndent()
Decreases the indent on the page |
void |
endTable()
Helper method to end HTML table |
void |
endTableCell()
Helper method to end table cell |
void |
endTableRow()
Helper method to end table row |
static java.lang.String |
generateName(java.lang.Object obj)
Delegates the generation of component name to WindowUpdater |
FormattedStringBuffer |
getBody()
Returns the buffer representing the page body (HTML between <body> and </body> tags) |
ClientAgent |
getClientAgent()
Returns the client agent, associated with this page. |
java.lang.String |
getComponentName(java.awt.Component comp)
By default, names are generated based on the component type and the hashCode If a component has a name and renderContext forces names to be used, the component name is returned |
static java.lang.String |
getComponentName(java.awt.MenuBar comp)
If a component has a name, it is returned. |
java.lang.String |
getDocsURL()
Returns the URL that specifies the location of the documents for the current application. |
FormattedStringBuffer |
getHeader()
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 |
getIndent()
Returns the current indent as the number of spaces before the line text starts |
int |
getNextComponentNameIndex(java.lang.Object obj)
|
java.lang.String |
getOnLoadScriptBody()
|
FormattedStringBuffer |
getOutput()
Returns the buffer (body/header) that the page is currently outputing to |
HTMLPageRenderer |
getPageRenderer()
Returns the page renderer associated with the page. |
java.util.Map |
getProps()
Properties map can be used to store a list of standard and user-defined properties |
java.lang.String |
getRedirectURL()
Returns the redirection URL |
RenderContext |
getRenderContext()
Returns the rendering context associated with this page |
int |
getSnapshotImageIndex()
Returns an index for generating the snapshot name |
java.lang.String |
getSubmitURL()
Returns the URL |
java.lang.String |
getThemeDocsURL()
Returns the URL that specifies the location of the theme-specificdocuments for the current application. |
java.lang.String |
getThemeName()
Returns the name of the application HTML theme. |
java.lang.String |
getTitle()
Returns page title |
FormattedStringBuffer |
getWindowFooter()
Returns the buffer representing the end of the page body. |
void |
includeJavaScript(java.lang.String srcUrl)
Includes an external JavaScript file identified by the source URL Behaves correctly if called multiple times for the same URL |
void |
includeStylesheet(java.lang.String srcUrl)
Includes an external JavaScript file identified by the source URL Behaves correctly if called multiple times for the same URL |
void |
increaseIndent()
Increases the indent on the page |
void |
incSnapshotIndex()
Increments an index for generating the snapshot name by one |
void |
insertMarked(java.lang.String string)
Inserts the given string into the buffer at the positioned that was previously marked with markPosition. |
void |
markPosition()
Saves the end of the buffer as the current marked position. |
static java.lang.String |
nameToHTML(java.lang.String str)
Converts the given name to HTML manageable name that can be used for HTML and JavaScript elements |
void |
newLine()
Ensure that next text appended will be written on the new line. |
void |
outputBody()
Instructs the page to append all text to the body |
void |
outputHeader()
Instructs the page to append all text to the header |
void |
prependJavaScript(java.lang.String script)
Use to insert a JavaScript to the HTML page header before any other JavaScript functions. |
void |
reset(boolean complete)
Clears the page and its buffers. |
void |
resetComponentNameIndexes()
|
void |
setClientAgent(ClientAgent agent)
Used by WebCream to associate an agent with the page. |
void |
setIndent(int indent)
Sets the current indent as the number of spaces before the line text starts |
void |
setNoBreak(boolean noBreak)
If noBreak is set to true, the current HTML is wrapped with |
void |
setNoBreak(boolean noBreak,
java.awt.Component comp)
If component is passed in, <nobr> tag will be styled/positioned according to component position |
void |
setOutput(FormattedStringBuffer output)
Sets the buffer (body/header) that the page is currently outputing to |
void |
setPageRenderer(HTMLPageRenderer pageRenderer)
Used by WebCream to associate a page renderer with the page. |
void |
setRedirectURL(java.lang.String url)
Sets the URL that WebCream should redirect browser to |
void |
setRenderContext(RenderContext context)
Sets rendering context |
void |
setTitle(java.lang.String title)
Sets page title |
void |
setUseOnLoad(boolean useOnLoad)
Sets weather or not the page should have onLoad function specified for the tag |
boolean |
shouldIgnoreTag(java.lang.String tag)
Returns true if the tag should be skipped |
java.lang.String |
toString()
Returns stringified representation of the page |
void |
writeTrailer()
Writes the trailer script the to page output |
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 |
---|
public HTMLPage()
public HTMLPage(ClientAgent agent)
public HTMLPage(ClientAgent agent, int bufferSize)
public HTMLPage(HTMLPage page)
Method Detail |
---|
public void setClientAgent(ClientAgent agent)
public void setPageRenderer(HTMLPageRenderer pageRenderer)
public HTMLPageRenderer getPageRenderer()
public void appendln(java.lang.String s)
public void newLine()
public void append(java.lang.String s)
public void append(char ch)
public void append(int i)
public void appendText(java.lang.String text, java.awt.Component comp)
text
- text to appendcomp
- component that will be used to determine the style of the text such as the color and fontpublic void appendText(java.lang.String text)
text
- text to appendpublic void appendText(java.lang.String text, boolean noBreak, boolean ignoreAllHTMLTags)
text
- text to appendnoBreak
- if set to true, the text will be enclosed in HTML <nobreak> tagsignoreAllHTMLTags
- if set to true, all HTML tags will be removed from the textpublic void appendText(java.lang.String text, boolean noBreak, java.awt.Component comp)
text
- text to appendnoBreak
- if true, the text will not wrap on the HTML page even if it does not fit into the areacomp
- component that will be used to determine the style of the text such as the color and fontpublic void appendHTMLText(java.lang.String htmlText, boolean noBreak)
htmlText
- HTML buffer to appendnoBreak
- if true then the passed text will not wrap on the page even if the display area is too smallpublic void appendHTMLText(java.lang.String htmlText, boolean noBreak, boolean ignoreAllTags)
htmlText
- HTML buffer to appendnoBreak
- if true then the passed text will not wrap on the page even if the display area is too smallignoreAllTags
- if true all HTML tags in the text will be skipped while appendingpublic boolean shouldIgnoreTag(java.lang.String tag)
public void appendEventHandler(java.lang.String eventName, java.awt.Component comp)
eventName
- name of the JavaScript eventcomp
- component who's name will be used to submit the eventpublic void increaseIndent()
public void decreaseIndent()
public int getIndent()
public void setIndent(int indent)
public void beginTable(int border)
beginTable(int, int, String, Object)
public void beginTable(int border, int cellPadding)
beginTable(int, int, String, Object)
public void beginTable(int border, java.lang.String props)
beginTable(int, int, String, Object)
public void beginTable(int border, int cellPadding, java.lang.String props)
beginTable(int, int, String, Object, String)
public void beginTable(int border, int cellPadding, java.lang.String props, java.lang.Object component)
beginTable(int, int, String, Object, String)
public void beginTable(int border, int cellPadding, java.lang.String props, java.lang.Object component, java.lang.String style)
border
- thickness of table border in pixelscellPadding
- the value of cellpadding table attributeprops
- if not null, will be inserted into the <table> tagcomponent
- if not null, the style of the component will be inserted into <table> tag using getPageRenderer().appendComponentStylestyle
- if not null, will be inserted into the style property of <table> tagpublic void endTable()
public void beginTableRow()
public void beginTableRow(java.lang.String props)
props
- if not null, will be inserted into <tr> tagpublic void endTableRow()
public void beginTableCell()
public void beginTableCell(java.lang.String props)
props
- if not null, the properties will be inserted into <td> tagpublic void endTableCell()
public void markPosition()
public void insertMarked(java.lang.String string)
public void appendJavaScript(java.lang.String script)
public void prependJavaScript(java.lang.String script)
public void appendOnSubmitScript(java.lang.String script)
public void appendTrailerScript(java.lang.String script)
public void includeJavaScript(java.lang.String srcUrl)
srcUrl
- public void includeStylesheet(java.lang.String srcUrl)
srcUrl
- public void writeTrailer()
public RenderContext getRenderContext()
public java.util.Map getProps()
public void setRenderContext(RenderContext context)
public FormattedStringBuffer getBody()
public FormattedStringBuffer getWindowFooter()
public FormattedStringBuffer getHeader()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getSubmitURL()
public java.lang.String getDocsURL()
public java.lang.String getThemeDocsURL()
public java.lang.String getThemeName()
public void setRedirectURL(java.lang.String url)
url
- URLpublic java.lang.String getRedirectURL()
public static java.lang.String generateName(java.lang.Object obj)
obj
- UI element
public java.lang.String getTitle()
public void setTitle(java.lang.String title)
title
- titlepublic void setNoBreak(boolean noBreak)
noBreak
- booleanpublic void setNoBreak(boolean noBreak, java.awt.Component comp)
public ClientAgent getClientAgent()
public void reset(boolean complete)
public void appendCommonScripts()
public java.lang.String getComponentName(java.awt.Component comp)
public static java.lang.String getComponentName(java.awt.MenuBar comp)
public void outputBody()
public void outputHeader()
public FormattedStringBuffer getOutput()
public void setOutput(FormattedStringBuffer output)
public java.lang.String getImageUrl(javax.swing.Icon icon, java.awt.Component component) throws java.lang.Exception
java.lang.Exception
public java.lang.String getImageUrl(java.awt.Image image)
public java.lang.String cleanupImageUrl(java.lang.String url)
public void appendTreeScripts()
public void appendOnLoadScriptBody(java.lang.String onLoadFunctionBody)
onLoadFunctionBody
- statements to appear inside the body of function onLoad()public java.lang.String getOnLoadScriptBody()
public void setUseOnLoad(boolean useOnLoad)
public int getSnapshotImageIndex()
public void incSnapshotIndex()
public static java.lang.String nameToHTML(java.lang.String str)
public int getNextComponentNameIndex(java.lang.Object obj)
public void resetComponentNameIndexes()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |