HtmlBasedComponent

A skeletal implementation for HTML based components. It simplifies to implement methods common to HTML based components.

Class Name

org.zkoss.zk.ui.HtmlBasedComponent

Supported Child Components

*ALL

Supported Events

Event Name

Event Type

onDrop

org.zkoss.zk.ui.event.DropEvent

Description: Represents an event cause by user's dragging and dropping a component.

Properties

Property

Description

Data Type

Default Value

droppable

Sets "true" or "false" to denote whether a component is droppable, or a list of identifiers of draggable types of objects that could be dropped to this component.

Value:true | false|the identifier of a draggable type of objects

java.lang.String

<null>

droppable

Sets "true" or "false" to denote whether a component is droppable, or a list of identifiers of draggable types of objects that could be droped to this component.

Value:true | false|

the identifier of a draggable type of objects

java.lang.String

<null>

height

Sets the height.

java.lang.String

<null>

left

Sets the left position.

java.lang.String

<null>

sclass

Sets the CSS class.

java.lang.String

<null>

style

Sets the CSS style.

java.lang.String

<null>

tooltiptext

Sets the text as the tooltip.

java.lang.String

<null>

top

Sets the top position.

java.lang.String

<null>

width

Sets the width.

java.lang.String

<null>

zIndex

Sets the Z index.

int

0

Methods

Name

Description

Return Data Type

addEventListener(java.lang.String, EventListener)

Adds an event listener to specified event for this component.

boolean

focus()

Sets focus to this element.

void

getInnerAttrs()

Returns the interior attributes for generating the inner HTML tag; never return null.

Used only by component developers.

Default: empty string. Refer to getOuterAttrs for more details.

java.lang.String

getOuterAttrs()

Returns the exterior attributes for generating the enclosing HTML tag; never return null.

Used only by component developers.

Default: Generates the tooltip text, style, sclass, draggable and droppable attribute if necessary. In other words, the corresponding attribute is generated if getTooltiptext, getRealStyle, getSclass, getDraggable, getDroppable are defined.

You have to call both getOuterAttrs and getInnerAttrs to generate complete attributes.

For simple components that all attributes are put on the outset HTML element, all you need is as follows.

<xx id="${self.uuid}"${self.outerAttrs}${self.innerAttrs}>

If you want to put attributes in a nested HTML element, you shall use the following pattern. Notice: if getInnerAttrs in a different tag, the tag must be named with "${self.uuid}!real".

<xx id="${self.uuid}"${self.outerAttrs}>

<yy id="${self.uuid}!real"${self.innerAttrs}>...

Note: This class handles non-deferrable event listeners automatically. However, you have to invoke appendAsapAttr for each event the component handles in getOuterAttrs as follows.

appendAsapAttr(sb, Events.ON_OPEN);

appendAsapAttr(sb, Events.ON_CHANGE);

Theoretically, you could put any attributes in either getInnerAttrs or getOuterAttrs. However, zkau.js assumes all attributes are put at the outer one. If you want something different, you have to provide your own setAttr (refer to how checkbox is implemented).

java.lang.String

removeEventListener(java.lang.String, EventListener)

Removes an event listener.

boolean

Inherited From