SilverStream
Application Server 3.5

com.sssw.shr.page
Class AgpHTMLControl

java.lang.Object
 |
 +--com.sssw.shr.page.AgpTag
       |
       +--com.sssw.shr.page.AgpControlBase
             |
             +--com.sssw.shr.page.AgpHTMLControl
All Implemented Interfaces:
AgiJavaScriptEnhanced, AgiPageControl, Cloneable, Externalizable, Serializable

public class AgpHTMLControl
extends AgpControlBase

The HTML control is the counterpart of the HTML edit control in the Java form environment.

The HTML control allows dynamic HTML content to be embedded into a page. The HTML may be taken from a database or it may be dynamically generated. The data can be a complete HTML file or a run of HTML snippet.

If the data is a complete HTML file, the HTML control optionally performs special processing on the HTML data so that it incorporates into the page correctly. For example, it can remove the header and footer of the embedded HTML file. The HTML control can also show the background color of the embedded file by setting the option of embedding the HTML in a table.

On the other hand, if all the application wants is some way to insert some raw HTML into the page, both options can be set to false. In that case, the content will be incoporated into the page without any further processing.

Note that unlike the HTML edit control in the form environment, this HTML control can only present the HTML. However, an application can use it together with the file upload control to provide an interactive way for the user to enter HTML data to a database. Refer to the example found in the openValueWriter method.

Properties:
Data Column, Embed HTML In Table, Enable HTML Generation, Height, Name, Process Value As Complete HTML Page, Value, Width
Events:
validationFailed, validationTest, valueChanged
See Also:
Serialized Form

Fields inherited from class com.sssw.shr.page.AgpTag
UNIT_PERCENT, UNIT_PIXEL
 
Constructor Summary
AgpHTMLControl()
           
 
Method Summary
 void closeValueWriter()
          Closes the value writer previously opened.
 AgpPage getContent()
          Returns the HTML data of the control as a page.
 boolean getEmbedHTMLInTable()
          Returns true if the subpage or HTML control should be embedded in a table.
 boolean getEnableHTMLParsing()
          Returns whether the content should be parsed.
 int getHeight()
          Returns the height of the control in pixels.
 String getValue()
          Returns the HTML data of this control.
 int getWidth()
          Returns the width of the control in pixels.
 PrintWriter openValueWriter()
          Opens a writer for the value of the HTML control.
 void setEmbedHTMLInTable(boolean embed)
          Specifies whether the subpage or HTML control should be embedded in a table.
 void setEnableHTMLParsing(boolean raw)
          Specifies whether the content should be parsed.
 void setHeight(int height)
          Sets the Height property of the control in pixels.
 void setValue(String value)
          Sets the HTML data of this control.
 void setWidth(int width)
          Sets the width of the control in pixels.
 
Methods inherited from class com.sssw.shr.page.AgpControlBase
getName
 
Methods inherited from class com.sssw.shr.page.AgpTag
getBoolProperty, getEnableHTMLGeneration, getIntArrayProperty, getIntProperty, getIntPropertyUnit, getProperty, getStringArrayProperty, invalidateHTML, removeProperty, setEnableHTMLGeneration, setIntProperty, setProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods implemented from interface com.sssw.shr.page.AgiJavaScriptEnhanced
generateFunction, generateRepaintScript, generateScriptInitializers, getFunctionNameForMethod, getFunctionNames, getMethodNames, getScriptObjectName, isHTMLRepaintPending, isJavaScriptRepaintPending
 
Methods implemented from interface com.sssw.shr.page.AgiPageControl
generateHTML, getPrefix, notifyPageLoaded, notifyPageRequestBegin, notifyPageRequestEnd, notifyPostValue, notifyPostValues
 
Methods implemented from interface java.io.Externalizable
readExternal, writeExternal
 

Constructor Detail

AgpHTMLControl

public AgpHTMLControl()
Method Detail

getEmbedHTMLInTable

public boolean getEmbedHTMLInTable()
Returns true if the subpage or HTML control should be embedded in a table. If the subpage is not embedded in a table, it appears "free-flow" into the text.
See Also:
Embed HTML In Table property, AgpHTMLControl.setEmbedHTMLInTable(boolean embed)

setEmbedHTMLInTable

public void setEmbedHTMLInTable(boolean embed)
Specifies whether the subpage or HTML control should be embedded in a table.
Parameters:
embed - true to embed the subpage or HTML control in a table, or false to make it "free-flow" into the text.
See Also:
Embed HTML In Table property, AgpHTMLControl.getEmbedHTMLInTable()

getWidth

public int getWidth()
Returns the width of the control in pixels.
Usage:

The dimension of the control is meaningful only if the control has EmbedHTMLInTable set.

See Also:
Width property, AgpHTMLControl.setWidth(int width)

setWidth

public void setWidth(int width)
Sets the width of the control in pixels.
Parameters:
width - the number of pixels in the width.
Usage:

The dimension of the control is meaningful only if the control has EmbedHTMLInTable set.

See Also:
Width property, AgpHTMLControl.getWidth()

getHeight

public int getHeight()
Returns the height of the control in pixels.
Usage:

The dimension of the control is meaningful only if the control has EmbedHTMLInTable set.

See Also:
Height property, AgpHTMLControl.setHeight(int height)

setHeight

public void setHeight(int height)
Sets the Height property of the control in pixels.
Parameters:
height - the number of pixels in the height.
Usage:

The dimension of the control is meaningful only if the control has EmbedHTMLInTable set.

See Also:
Height property, AgpHTMLControl.getHeight()

getValue

public String getValue()
Returns the HTML data of this control.
Example:
 
See Also:
Value property, AgpHTMLControl.setValue(String value)

setValue

public void setValue(String value)
Sets the HTML data of this control.
Parameters:
value - a string representing the value.
Example:
 
See Also:
Value property, AgpHTMLControl.getValue()

getEnableHTMLParsing

public boolean getEnableHTMLParsing()
Returns whether the content should be parsed.
See Also:
AgpHTMLControl.setEnableHTMLParsing(boolean raw)

setEnableHTMLParsing

public void setEnableHTMLParsing(boolean raw)
Specifies whether the content should be parsed.
Parameters:
raw - true if the content should be parsed, otherwise false.
Usage:

If EnableHTMLParsing is set, the HTML data is processed like an AgpPage. In general, set this to false if a snippet of dynamically generated HTML is the value of the control.

See Also:
AgpHTMLControl.getEnableHTMLParsing()

getContent

public AgpPage getContent()
                   throws ServletException,
                          IOException
Returns the HTML data of the control as a page.
Usage:

In order for getContent() to work, the control must have EnableHTMLParsing set. Otherwise, getContent() returns null.


openValueWriter

public PrintWriter openValueWriter()
Opens a writer for the value of the HTML control.
Example:

Assuming the users have some tools to create HTML files, the file upload control is a convenient way to get HTML files from the user. The following code fragment reads the content from a file upload event, treats it as an HTML file encoded in a specific charset, and sets the HTML to an HTML control. The user will see the content of the uploaded HTML file through the control.

 	AgpFileUploadEvent evt = ...
 	AgpHTMLControl htmlcontrol = ...
 	byte binary_content[] = evt.getContent();
 	ByteArrayInputStream binary_stream = new
 		ByteArrayInputStream(binary_content);
 	InputStreamReader reader = new
 		InputStreamReader(binary_stream, "cp1252");
 	PrintWriter writer = htmlcontrol.openValueWriter();
 	char c = reader.read();
 	while (c != -1)
 	{
 	    writer.write((char) c);
 	    c = reader.read();
 	}
 	htmlcontrol.closeValueWriter();
 
See Also:
AgpHTMLControl.closeValueWriter()

closeValueWriter

public void closeValueWriter()
Closes the value writer previously opened. If this method is not called explicitly, it will be called before HTML generation.
Example:
 
See Also:
AgpHTMLControl.openValueWriter()

SilverStream
Application Server 3.5