DhElement Class

DhElement Class

This Package | All Packages

DhStyleBase
  |
  +--DhElement
public class DhElement
extends DhStyleBase

Represents the super class for all user interface (UI) elements in this package. An instance of this class should be thought of as the Java representation of a given UI element in an HTML document. DhElement objects are never created directly. Instead, you instantiate a derivation of this class and then add the instance to the document (or a container destined for, or already on, the document). Alternatively, you can call the DhDocument.findElement method to locate and bind to an existing element, then cast the return value to the proper derivation.

Also see DhStyle, DhText, DhDocument, DhSection, and DhPanel.

Fields
Name Description
OK_TO_CACHE_ATTRIBUTES Setting this flag to false (default is true) forces all HTML tag attributes to be drawn from the client peer instead of a cached value.
OK_TO_EMIT_CODECLASS Setting this flag to false (default is true) stops the default behavior of emitting the __CODECLASS attribute used exclusively by this package.

Methods
Name Description
addOnClick ( DhEventHandler h ) Sets the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

addOnDoubleClick ( DhEventHandler h ) Sets the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

addOnKeyDown ( DhEventHandler h ) Sets the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

addOnKeyPress ( DhEventHandler h ) Sets the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

addOnKeyUp ( DhEventHandler h ) Sets the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

addOnMouseDown( DhEventHandler h ) Sets the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

addOnMouseEnter( DhEventHandler h ) Sets the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

addOnMouseLeave ( DhEventHandler h ) Sets the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

addOnMouseMove( DhEventHandler h ) Sets the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

addOnMouseUp ( DhEventHandler h ) Sets the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

addOnSetParent(DhEventHandler h) Sets up the callback that is invoked when the parent is set on this element.
cloneSettings( DhElement eSrc ) Topic under construction.
dataSource() Retrieves the data source for this element.
generateHTML() Retrieves a string that contains the representative HTML text for this element and all its child elements.
getAlign( ) Returns the alignment of the element.
getDataField() Retrieves the data field this element is to display.
getDataSource() Returns the current data source as a DhDataSource object.
getDocument() Retrieves the document object associated with this element.
getElementCount() Topic under construction.
getElements() Topic under construction.
getEvents() Retrieves the event event for this element.
getHTMLGenerator() Retrieves the current HTML generator for this element.
getID() Returns the ID attribute of the HTML element underlying this class.
getLocation() Topic under construction.
getModule() Retrieves the module object associated with element.
getParent() Retrieves the parent element which contains this element.
getPeer() Retrieves the underlying HTML peer element for this class.
getSize() Topic under construction.
getStyle() Retrieves the DhStyle style object associated with this element.
getTagName() Retrieves the string that contains the tag name that corresponds to this element given its current state (for example, "SPAN").
getTagNameID() Returns the DhStringIDs string identifier that will be generated when the generateHTML method is called.
getToolTip() Retrieves the string that represents the tooltip that appears when the user's mouse pointer is hovering over this element.
hasPeer() Return the underlying HTML peer element for this class.
onStateChange( int stateChange ) Implements a callback method for the stateChange event.
removeAttribute(String strAttr) removeOnClick
final public void removeOnClick ( DhEventHandler h );

Removes the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

removeOnClick ( DhEventHandler h ) Removes the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

removeOnDoubleClick ( DhEventHandler h ) Removes the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

removeOnKeyDown ( DhEventHandler h ) Removes the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

removeOnKeyPress ( DhEventHandler h ) Removes the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

removeOnKeyUp ( DhEventHandler h ) Removes the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

removeOnMouseDown( DhEventHandler h ) Removes the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

removeOnMouseEnter( DhEventHandler h ) Removes the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

removeOnMouseLeave ( DhEventHandler h ) Removes the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

removeOnMouseMove( DhEventHandler h ) Removes the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

removeOnMouseUp ( DhEventHandler h ) Removes the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

removeOnSetParent(DhEventHandler h) Sets the alignment of the element.
setAlign( int nAlign )  
setAttribute(String strAttr, String value)  
setAttribute(String strAttr, String value)  
setAttributeInt(String strAttr, int value) Sets the data field for this object to display.
setDataField( String strDataField ) Sets the data source for this element.
setDataSource( DhDataSource ds ) Sets the data source for this element.
setDataSource( DhElement dsParent ) Sets the document that is associated with this element.
setDocument( DhDocument document ) Sets the height of the element using one of the DhUnit constants to express the units of measurement.
setHeightUnit( int h, int unit ) Sets the HTML generator to use for this element.
setHTMLGenerator( DhHTMLGenerator htmlGen ) Sets the size of the element.
setSize(int w, int h) Set the style object associated with this element.
setStyle(DhStyle style) Sets the tooltip that appears when the user's mouse pointer is hovering over this element.
setToolTip(String string) Sets the width of the element using one of the DhUnit constants to express the units of measurement.
setWidthUnit( int w, int unit )

Fields

DhElement.OK_TO_CACHE_ATTRIBUTES

Syntax
public static boolean OK_TO_CACHE_ATTRIBUTES;
Description
Setting this flag to false (default is true) forces all HTML tag attributes to be drawn from the client peer instead of a cached value.

DhElement.OK_TO_EMIT_CODECLASS

Syntax
public static boolean OK_TO_EMIT_CODECLASS;
Description
Setting this flag to false (default is true) stops the default behavior of emitting the __CODECLASS attribute used exclusively by this package.

Methods

DhElement.addOnClick

Syntax
final public void addOnClick ( DhEventHandler h );
Parameters
h
The event handler callback method.
Description

Sets the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

DhElement.addOnDoubleClick

Syntax
final public void addOnDoubleClick ( DhEventHandler h );
Parameters
h
The event handler callback method.
Description

Sets the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

DhElement.addOnKeyDown

Syntax
final public void addOnKeyDown ( DhEventHandler h );
Parameters
h
The event handler callback method.
Description

Sets the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

DhElement.addOnKeyPress

Syntax
final public void addOnKeyPress ( DhEventHandler h );
Parameters
h
The event handler callback method.
Description

Sets the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

DhElement.addOnKeyUp

Syntax
final public void addOnKeyUp ( DhEventHandler h );
Parameters
h
The event handler callback method.
Description

Sets the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

DhElement.addOnMouseDown

Syntax
final public void addOnMouseDown( DhEventHandler h );
Parameters
h
The event handler callback method.
Description

Sets the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

DhElement.addOnMouseEnter

Syntax
final public void addOnMouseEnter( DhEventHandler h );
Parameters
h
The event handler callback method.
Description

Sets the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

DhElement.addOnMouseLeave

Syntax
final public void addOnMouseLeave ( DhEventHandler h );
Parameters
h
The event handler callback method.
Description

Sets the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

DhElement.addOnMouseMove

Syntax
final public void addOnMouseMove( DhEventHandler h );
Parameters
h
The event handler callback method.
Description

Sets the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

DhElement.addOnMouseUp

Syntax
final public void addOnMouseUp ( DhEventHandler h );
Parameters
h
The event handler callback method.
Description

Sets the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

DhElement.addOnSetParent

Syntax
protected void addOnSetParent( DhEventHandler h );
Parameters
onSetParent
The DhEventHandler callback method to invoke when the parent is set on this element.
Description

Sets up the callback that is invoked when the parent is set on this element.

DhElement.cloneSettings

Syntax
public synchronized void cloneSettings( DhElement eSrc );
Description

Topic under construction.

DhElement.dataSource

Syntax
protected DhDataSource dataSource();
Return Value

Returns s null for DhElement.

Description

Retrieves the data source for this element.

See Also
wfc.html.DhObjectDataSource, DhAppletDataSource

DhElement.generateHTML

Syntax
public String generateHTML();
Return Value

Returns the HTML string that represents this element and all its children.

Description

Retrieves a string that contains the representative HTML text for this element and all its child elements.

DhElement.getAlign

Syntax
public int getAlign( );
Return Value

Returns the desired alignment, or returns -1 if alignment is uninitialized.

Description

Returns the alignment of the element. Specified as one of the DhAlignEnum constants.

DhElement.getDataField

Syntax
public String getDataField();
Return Value

Returns the current field name.

Description

Retrieves the data field this element is to display.

DhElement.getDataSource

Syntax
public DhDataSource getDataSource();
Return Value

Returns the associated DhDataSourceObject, or returns null if there is not one attached.

Description

Returns the current data source as a DhDataSource object. If there is no attached data source or another error occurs, null is returned.

DhElement.getDocument

Syntax
public synchronized DhDocument getDocument();
Return Value

Returns the DhDocument that this element has associated with it.

Description

Retrieves the document object associated with this element.

DhElement.getElementCount

Syntax
public int getElementCount();
Description

Topic under construction.

DhElement.getElements

Syntax
public DhElement[] getElements();
Description

Topic under construction.

DhElement.getEvents

Syntax
public synchronized DhEvents getEvents();
Return Value

Returns the event event for this element.

Description

Retrieves the event event for this element. Despite the fact that this method is public in this class, most derivations hide it.

DhElement.getHTMLGenerator

Syntax
public DhHTMLGenerator getHTMLGenerator();
Description

Retrieves the current HTML generator for this element.

See Also
setHTMLGenerator

DhElement.getID

Syntax
public synchronized String getID();
Return Value

Returns the string used for the ID attribute of the element.

Description

Returns the ID attribute of the HTML element underlying this class. This ID is one persisted with the generateHTML method.

Note Calling this method is not typically part of the usage of this package. The package automatically generates an ID for all DhElements even if this method isn't directly called.

DhElement.getLocation

Syntax
public Point getLocation();
Description

Topic under construction.

DhElement.getModule

Syntax
public DhModule getModule();
Return Value

Returns the DhModule that this element has associated with it.

Description

Retrieves the module object associated with element.

DhElement.getParent

Syntax
public synchronized DhElement getParent();
Return Value

Returns the parent element that this element has associated with it.

Description

Retrieves the parent element which contains this element.

See Also
wfc.html.DhDocument.add, wfc.html.DhPanel.add, wfc.html.DhSection.add

DhElement.getPeer

Syntax
public IUnknown getPeer();
Return Value

Returns the element peer underlying the HTML peer for this class.

Description

Retrieves the underlying HTML peer element for this class. This method may return null if the element or its parent was never added to a document. Java code that is running in a trusted environment can freely cast the resulting reference to a specific element peer type (for example, wfc.html.om.IHTMLElement). This method always returns null if the code is running in a Web server environment.

Note that calling this method represents a very advanced usage scenario. Typically, you would never use this method.

DhElement.getSize

Syntax
public Point getSize();
Description

Topic under construction.

DhElement.getStyle

Syntax
public synchronized DhStyle getStyle();
Return Value

Returns the DhStyle style object associated with this element.

Description

Retrieves the DhStyle style object associated with this element.

See Also
wfc.html.DhStyle, setStyle

DhElement.getTagName

Syntax
public synchronized String getTagName();
Description

Retrieves the string that contains the tag name that corresponds to this element given its current state (for example, "SPAN").

Note that this value can change during the life of the instance. In many cases, it depends on specific attribute settings known only to the derivation of this class.

This method is not very useful except in special cases.

DhElement.getTagNameID

Syntax
protected int getTagNameID();
Return Value

Returns s (int) the DhStringIDs string identifier for the tag name of this element. (The base class returns -1, an invalid ID.)

Description

Returns the DhStringIDs string identifier that will be generated when the generateHTML method is called.

DhElement.getToolTip

Syntax
public String getToolTip();
Return Value

Returns the tooltip string.

Description

Retrieves the string that represents the tooltip that appears when the user's mouse pointer is hovering over this element.

See Also
setToolTip

DhElement.hasPeer

Syntax
public synchronized IUnknown hasPeer();
Return Value

Returns the element peer underlying the HTML peer for this class, assuming it is available.

Description

Return the underlying HTML peer element for this class. This method may return null even if the element or its parent was added to a document, but there hasn't been occasion to bind to its peer. Java code that is running in a trusted environment can freely cast the resulting reference to a specific element peer type (for example, wfc.html.om.IHTMLElement). This method always returns null if the code is running in a Web server environment.

Calling getPeer() retrieve the peer element even if the element hasn't had a chance to bind to the document yet.

Note that calling this method represents a very advanced usage scenario. Typically, you would never use this method.

DhElement.onStateChange

Syntax
protected synchronized void onStateChange( int stateChange );
Parameters
stateChange
Topic under construction.
Description

Implements a callback method for the stateChange event. Derivations of this class that keep peers cached around must override this method and destroy that reference.

DhElement.removeAttribute

Syntax
public void removeAttribute( String strAttr );
Description

DhElement.removeOnClick

Syntax
final public void removeOnClick ( DhEventHandler h );
Parameters
h
The event handler callback method.
Description

Removes the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

DhElement.removeOnDoubleClick

Syntax
final public void removeOnDoubleClick ( DhEventHandler h );
Parameters
h
The event handler callback method.
Description

Removes the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

DhElement.removeOnKeyDown

Syntax
final public void removeOnKeyDown ( DhEventHandler h );
Parameters
h
The event handler callback method.
Description

Removes the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

DhElement.removeOnKeyPress

Syntax
final public void removeOnKeyPress ( DhEventHandler h );
Parameters
h
The event handler callback method.
Description

Removes the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

DhElement.removeOnKeyUp

Syntax
final public void removeOnKeyUp ( DhEventHandler h );
Parameters
h
The event handler callback method.
Description

Removes the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

DhElement.removeOnMouseDown

Syntax
final public void removeOnMouseDown( DhEventHandler h );
Parameters
h
The event handler callback method.
Description

Removes the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

DhElement.removeOnMouseEnter

Syntax
final public void removeOnMouseEnter( DhEventHandler h );
Parameters
h
The event handler callback method.
Description

Removes the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

DhElement.removeOnMouseLeave

Syntax
final public void removeOnMouseLeave ( DhEventHandler h );
Parameters
h
The event handler callback method.
Description

Removes the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

DhElement.removeOnMouseMove

Syntax
final public void removeOnMouseMove( DhEventHandler h );
Parameters
h
The event handler callback method.
Description

Removes the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

DhElement.removeOnMouseUp

Syntax
final public void removeOnMouseUp ( DhEventHandler h );
Parameters
h
The event handler callback method.
Description

Removes the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

DhElement.removeOnSetParent

Syntax
protected void removeOnSetParent( DhEventHandler h );
Parameters
h
The event handler callback method.
Description

Removes the DhEventHandler event handler method callback.

Note that not all elements support all events exposed in DhElement.

DhElement.setAlign

Syntax
public void setAlign( int nAlign );
Parameters
nAlign
The desired alignment.
Description

Sets the alignment of the element. Specified as one of the DhAlignEnum constants.

DhElement.setAttribute

Syntax 1
public void setAttribute( String strAttr, String value );
Description



Syntax 2
public void setAttribute( String strAttr, String value );
Description

DhElement.setAttributeInt

Syntax
public void setAttributeInt( String strAttr, int value );
Description

DhElement.setDataField

Syntax
public void setDataField( String strDataField );
Parameters
strDataField
The name of a field in the available data set.
Description

Sets the data field for this object to display. This value must match the name of a returned column in the database queried by the current data source.

See Also
setDataSource

DhElement.setDataSource

Syntax 1
public void setDataSource( DhDataSource ds );
Parameters
A
DhDataSource
Description

Sets the data source for this element.



Syntax 2
public void setDataSource( DhElement dsParent );
Parameters
A
DhDataSource
Description

Sets the data source for this element.

DhElement.setDocument

Syntax
public synchronized void setDocument( DhDocument document );
Parameters
document
The DhDocument associated with this element.
Description

Sets the document that is associated with this element.

Care should be used when setting this value. Unexpected results in behavior can occur if done outside the confines of this package.

DhElement.setHeightUnit

Syntax
public synchronized void setHeightUnit( int h, int unit );
Parameters
h
The height value.
unit
One of DhUnit constants to express the units of measurement.
Description

Sets the height of the element using one of the DhUnit constants to express the units of measurement.

See Also
wfc.html.DhStyleBase.getBounds

DhElement.setHTMLGenerator

Syntax
public synchronized void setHTMLGenerator( DhHTMLGenerator htmlGen );
Description

Sets the HTML generator to use for this element. This allows you to override the library's default method of generating HTML syntax to represent an element.

See Also
getHTMLGenerator

DhElement.setSize

Syntax
public synchronized void setSize( int w, int h );
Parameters
width
The new width of the element.
height
The new height of the element.
Description

Sets the size of the element.

See Also
setWidthUnit, setHeightUnit

DhElement.setStyle

Syntax
public synchronized void setStyle( DhStyle style );
Parameters
style
The style object associated with this element.
Description

Set the style object associated with this element.

DhElement.setToolTip

Syntax
public void setToolTip( String string );
Parameters
string
The string to use for the tooltip.
Description

Sets the tooltip that appears when the user's mouse pointer is hovering over this element.

DhElement.setWidthUnit

Syntax
public synchronized void setWidthUnit( int w, int unit );
Parameters
w
The width values.
unit
One of DhUnitEnum constants to express the units of measurement.
Description

Sets the width of the element using one of the DhUnit constants to express the units of measurement.

See Also
wfc.html.DhStyleBase.getBounds