org.zkoss.zk.ui
Class HtmlBasedComponent

java.lang.Object
  extended by org.zkoss.zk.ui.AbstractComponent
      extended by org.zkoss.zk.ui.HtmlBasedComponent
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, HtmlBasedComponent, Component, Scope, ComponentCtrl
Direct Known Subclasses:
Applet, Borderlayout, Flash, HtmlMacroComponent, Iframe, Timer, XulElement

public abstract class HtmlBasedComponent
extends AbstractComponent
implements HtmlBasedComponent

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

It supports

Author:
tomyeh
See Also:
Serialized Form

Nested Class Summary
protected  class HtmlBasedComponent.ExtraCtrl
          A utility class to implement AbstractComponent.getExtraCtrl().
 
Nested classes/interfaces inherited from class org.zkoss.zk.ui.AbstractComponent
AbstractComponent.Children
 
Field Summary
protected  java.lang.String _height
          The height.
protected  java.lang.String _left
           
protected  java.lang.String _top
           
protected  java.lang.String _width
          The width.
protected  java.lang.String _zclass
          The ZK CSS class.
 
Fields inherited from class org.zkoss.zk.ui.AbstractComponent
_visible
 
Fields inherited from interface org.zkoss.zk.ui.Component
APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPE
 
Fields inherited from interface org.zkoss.zk.ui.sys.ComponentCtrl
CE_BUSY_IGNORE, CE_DUPLICATE_IGNORE, CE_IMPORTANT, CE_NON_DEFERRABLE, CE_REPEAT_IGNORE
 
Constructor Summary
protected HtmlBasedComponent()
           
 
Method Summary
 void focus()
          Sets focus to this element.
 java.lang.String getDraggable()
          Returns the identifier of a draggable type of objects, or "false" if not draggable (never null nor empty).
 java.lang.String getDroppable()
          Returns the identifier, or a list of identifiers of a droppable type of objects, or "false" if not droppable (never null nor empty).
 java.lang.String getHeight()
          Returns the height.
 java.lang.String getHflex()
          Returns horizontal flex hint of this component.
 java.lang.String getLeft()
          Returns the left position.
 java.lang.String getSclass()
          Returns the CSS class.
 java.lang.String getStyle()
          Returns the CSS style.
 java.lang.String getTooltiptext()
          Returns the text as the tooltip.
 java.lang.String getTop()
          Returns the top position.
 java.lang.String getVflex()
          Return vertical flex hint of this component.
 java.lang.String getWidth()
          Returns the width.
 java.lang.String getZclass()
          Returns the ZK Cascading Style class(es) for this component.
 int getZindex()
          Returns the Z index.
 int getZIndex()
          Returns the Z index.
protected  java.lang.Object newExtraCtrl()
          Used by AbstractComponent.getExtraCtrl() to create a client control.
protected  void renderProperties(ContentRenderer renderer)
          Renders the content of this component, excluding the enclosing tags and children.
 void service(AuRequest request, boolean everError)
          Processes an AU request.
 void setClass(java.lang.String sclass)
          Sets the CSS class.
 void setDraggable(java.lang.String draggable)
          Sets "true" or "false" to denote whether a component is draggable, or an identifier of a draggable type of objects.
 void setDroppable(java.lang.String 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.
 void setFocus(boolean focus)
          Sets focus to this element.
 void setHeight(java.lang.String height)
          Sets the height.
 void setHflex(java.lang.String flex)
          Sets horizontal flex hint of this component.
 void setLeft(java.lang.String left)
          Sets the left position.
 void setSclass(java.lang.String sclass)
          Sets the CSS class.
 void setStyle(java.lang.String style)
          Sets the CSS style.
 void setTooltiptext(java.lang.String tooltiptext)
          Sets the text as the tooltip.
 void setTop(java.lang.String top)
          Sets the top position.
 void setVflex(java.lang.String flex)
          Sets vertical flexibility hint of this component.
 void setWidth(java.lang.String width)
          Sets the width.
 void setZclass(java.lang.String zclass)
          Sets the ZK Cascading Style class(es) for this component.
 void setZindex(int zIndex)
          Sets the Z index.
 void setZIndex(int zIndex)
          Sets the Z index.
 
Methods inherited from class org.zkoss.zk.ui.AbstractComponent
addAnnotation, addAnnotation, addClientEvent, addEventHandler, addEventListener, addForward, addForward, addForward, addForward, addMoved, addScopeListener, addSharedAnnotationMap, addSharedEventHandlerMap, appendChild, applyProperties, beforeChildAdded, beforeChildRemoved, beforeParentChanged, clone, containsVariable, detach, didActivate, didActivate, didDeserialize, didDeserialize, disableClientUpdate, equals, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotation, getAnnotations, getAnnotations, getAttribute, getAttribute, getAttribute, getAttributeOrFellow, getAttributes, getAttributes, getAuService, getChildren, getClientEvents, getDefinition, getDesktop, getEventHandler, getEventHandlerNames, getExtraCtrl, getFellow, getFellow, getFellowIfAny, getFellowIfAny, getFellows, getFirstChild, getId, getLastChild, getListenerIterator, getMold, getNamespace, getNextSibling, getPage, getParent, getPreviousSibling, getRoot, getSpaceOwner, getUuid, getVariable, getWidgetClass, getWidgetListener, getWidgetListenerNames, getWidgetOverride, getWidgetOverrideNames, hasAttribute, hasAttribute, hasAttribute, hasAttributeOrFellow, hasFellow, hasFellow, insertBefore, invalidate, isChildable, isInvalidated, isListenerAvailable, isVisible, newChildren, onChildAdded, onChildRemoved, onPageAttached, onPageDetached, onWrongValue, redraw, redrawChildren, removeAttribute, removeAttribute, removeAttribute, removeChild, removeEventListener, removeForward, removeForward, removeScopeListener, render, render, render, response, sessionDidActivate, sessionWillPassivate, setAttribute, setAttribute, setAttribute, setAuService, setDefinition, setDefinition, setId, setMold, setPage, setPageBefore, setParent, setVariable, setVisible, setWidgetListener, setWidgetOverride, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdateWidgetListener, smartUpdateWidgetOverride, toString, unsetVariable, updateByClient, willPassivate, willPassivate, willSerialize, willSerialize
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.zkoss.zk.ui.Component
addEventListener, addForward, addForward, addForward, addForward, appendChild, applyProperties, clone, containsVariable, detach, getAttribute, getAttribute, getAttributeOrFellow, getAttributes, getAttributes, getAuService, getChildren, getDefinition, getDesktop, getFellow, getFellow, getFellowIfAny, getFellowIfAny, getFellows, getFirstChild, getId, getLastChild, getListenerIterator, getMold, getNamespace, getNextSibling, getPage, getParent, getPreviousSibling, getRoot, getSpaceOwner, getUuid, getVariable, getWidgetClass, getWidgetListener, getWidgetListenerNames, getWidgetOverride, getWidgetOverrideNames, hasAttribute, hasAttribute, hasAttributeOrFellow, hasFellow, hasFellow, insertBefore, invalidate, isInvalidated, isListenerAvailable, isVisible, removeAttribute, removeAttribute, removeChild, removeEventListener, removeForward, removeForward, setAttribute, setAttribute, setAuService, setId, setMold, setPage, setPageBefore, setParent, setVariable, setVisible, setWidgetListener, setWidgetOverride, unsetVariable
 
Methods inherited from interface org.zkoss.zk.ui.ext.Scope
addScopeListener, getAttribute, hasAttribute, removeAttribute, removeScopeListener, setAttribute
 

Field Detail

_width

protected java.lang.String _width
The width.


_height

protected java.lang.String _height
The height.


_zclass

protected java.lang.String _zclass
The ZK CSS class.


_left

protected java.lang.String _left

_top

protected java.lang.String _top
Constructor Detail

HtmlBasedComponent

protected HtmlBasedComponent()
Method Detail

getLeft

public java.lang.String getLeft()
Returns the left position.

Specified by:
getLeft in interface HtmlBasedComponent

setLeft

public void setLeft(java.lang.String left)
Sets the left position.

If you want to specify right, use setStyle(java.lang.String) instead. For example, setStyle("right: 0px");

Specified by:
setLeft in interface HtmlBasedComponent
Parameters:
left - the left position. Remember to specify px, pt or %.

getTop

public java.lang.String getTop()
Returns the top position.

Specified by:
getTop in interface HtmlBasedComponent

setTop

public void setTop(java.lang.String top)
Sets the top position.

If you want to specify bottom, use setStyle(java.lang.String) instead. For example, setStyle("bottom: 0px");

Specified by:
setTop in interface HtmlBasedComponent
Parameters:
top - the top position. Remember to specify px, pt or %.

getZIndex

public int getZIndex()
Returns the Z index.

Default: -1 (means system default;

Specified by:
getZIndex in interface HtmlBasedComponent

setZIndex

public void setZIndex(int zIndex)
Sets the Z index.

Specified by:
setZIndex in interface HtmlBasedComponent

getZindex

public int getZindex()
Returns the Z index. It is the same as getZIndex().

Specified by:
getZindex in interface HtmlBasedComponent
Since:
3.5.2

setZindex

public void setZindex(int zIndex)
Sets the Z index. It is the same as setZIndex(int).

Specified by:
setZindex in interface HtmlBasedComponent
Since:
3.5.2

getHeight

public java.lang.String getHeight()
Returns the height. If null, the best fit is used.

Default: null.

Specified by:
getHeight in interface HtmlBasedComponent

setHeight

public void setHeight(java.lang.String height)
Sets the height. If null, the best fit is used.

Specified by:
setHeight in interface HtmlBasedComponent

getWidth

public java.lang.String getWidth()
Returns the width. If null, the best fit is used.

Default: null.

Specified by:
getWidth in interface HtmlBasedComponent

setWidth

public void setWidth(java.lang.String width)
Sets the width. If null, the best fit is used.

Specified by:
setWidth in interface HtmlBasedComponent

getTooltiptext

public java.lang.String getTooltiptext()
Returns the text as the tooltip.

Default: null.

Specified by:
getTooltiptext in interface HtmlBasedComponent

setTooltiptext

public void setTooltiptext(java.lang.String tooltiptext)
Sets the text as the tooltip.

Specified by:
setTooltiptext in interface HtmlBasedComponent

getZclass

public java.lang.String getZclass()
Returns the ZK Cascading Style class(es) for this component. It usually depends on the implementation of the mold (@{link #getMold}).

Default: null (the default value depends on element).

setZclass(java.lang.String)) will completely replace the default style of a component. In other words, the default style of a component is associated with the default value of getZclass(). Once it is changed, the default style won't be applied at all. If you want to perform small adjustments, use setSclass(java.lang.String) instead.

Specified by:
getZclass in interface HtmlBasedComponent
Since:
3.5.1
See Also:
getSclass()

setZclass

public void setZclass(java.lang.String zclass)
Sets the ZK Cascading Style class(es) for this component. It usually depends on the implementation of the mold (@{link #getMold}).

Specified by:
setZclass in interface HtmlBasedComponent
Parameters:
zclass - the style class used to apply the whote widget.
Since:
3.5.0
See Also:
setSclass(java.lang.String), getZclass()

getSclass

public java.lang.String getSclass()
Returns the CSS class.

Default: null.

The default styles of ZK components doesn't depend on the value of getSclass(). Rather, setSclass(java.lang.String) is provided to perform small adjustment, e.g., only changing the font size. In other words, the default style is still applied if you change the value of getSclass(), unless you override it. To replace the default style completely, use setZclass(java.lang.String) instead.

Specified by:
getSclass in interface HtmlBasedComponent
See Also:
getZclass()

setSclass

public void setSclass(java.lang.String sclass)
Sets the CSS class.

Specified by:
setSclass in interface HtmlBasedComponent
See Also:
setZclass(java.lang.String)

setClass

public void setClass(java.lang.String sclass)
Sets the CSS class. This method is a bit confused with Java's class, but we provide it for XUL compatibility. The same as setSclass(java.lang.String).


getStyle

public java.lang.String getStyle()
Returns the CSS style.

Default: null.

Specified by:
getStyle in interface HtmlBasedComponent

setStyle

public void setStyle(java.lang.String style)
Sets the CSS style.

Specified by:
setStyle in interface HtmlBasedComponent

setDraggable

public void setDraggable(java.lang.String draggable)
Sets "true" or "false" to denote whether a component is draggable, or an identifier of a draggable type of objects.

The simplest way to make a component draggable is to set this attribute to true. To disable it, set this to false.

If there are several types of draggable objects, you could assign an identifier for each type of draggable object. The identifier could be anything but empty.

Specified by:
setDraggable in interface HtmlBasedComponent
Parameters:
draggable - "false", null or "" to denote non-draggable; "true" for draggable with anonymous identifier; others for an identifier of draggable.

getDraggable

public java.lang.String getDraggable()
Returns the identifier of a draggable type of objects, or "false" if not draggable (never null nor empty).


setDroppable

public void setDroppable(java.lang.String 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.

The simplest way to make a component droppable is to set this attribute to true. To disable it, set this to false.

If there are several types of draggable objects and this component accepts only some of them, you could assign a list of identifiers that this component accepts, separated by comma. For example, if this component accepts dg1 and dg2, then assign "dg1, dg2" to this attribute.

Specified by:
setDroppable in interface HtmlBasedComponent
Parameters:
droppable - "false", null or "" to denote not-droppable; "true" for accepting any draggable types; a list of identifiers, separated by comma for identifiers of draggables this component accept (to be dropped in).

getDroppable

public java.lang.String getDroppable()
Returns the identifier, or a list of identifiers of a droppable type of objects, or "false" if not droppable (never null nor empty).


focus

public void focus()
Sets focus to this element. If an element does not accept focus, this method has no effect.

Specified by:
focus in interface HtmlBasedComponent

setFocus

public void setFocus(boolean focus)
Sets focus to this element. It is same as focus(), but used to allow ZUML to set focus to particular component.
<textbox focus="true"/>

Specified by:
setFocus in interface HtmlBasedComponent
Parameters:
focus - whether to set focus. If false, this method has no effect.
Since:
3.0.5

setVflex

public void setVflex(java.lang.String flex)
Sets vertical flexibility hint of this component.

Number flex indicates how this component's container distributes remaining empty space among its children vertically. Flexible component grow and shrink to fit their given space. Flexible components with larger flex values will be made larger than components with lower flex values, at the ratio determined by all flexible components. The actual flex value is not relevant unless there are other flexible components within the same container. Once the default sizes of components in a container are calculated, the remaining space in the container is divided among the flexible components, according to their flex ratios.

Specify a flex value of negative value, 0, or "false" has the same effect as leaving the flex attribute out entirely. Specify a flex value of "true" has the same effect as a flex value of 1.

Special flex hint, "min", indicates that the minimum space shall be given to this flexible component to enclose all of its children components. That is, the flexible component grow and shrink to fit its children components.

Parameters:
flex - the vertical flex hint.
Since:
5.0.0
See Also:
setHflex(java.lang.String), getVflex()

getVflex

public java.lang.String getVflex()
Return vertical flex hint of this component.

Returns:
vertical flex hint of this component.
Since:
5.0.0
See Also:
setVflex(java.lang.String)

setHflex

public void setHflex(java.lang.String flex)
Sets horizontal flex hint of this component.

Number flex indicates how this component's container distributes remaining empty space among its children horizontally. Flexible component grow and shrink to fit their given space. Flexible components with larger flex values will be made larger than components with lower flex values, at the ratio determined by all flexible components. The actual flex value is not relevant unless there are other flexible components within the same container. Once the default sizes of components in a container are calculated, the remaining space in the container is divided among the flexible components, according to their flex ratios.

Specify a flex value of negative value, 0, or "false" has the same effect as leaving the flex attribute out entirely. Specify a flex value of "true" has the same effect as a flex value of 1.

Special flex hint, "min", indicates that the minimum space shall be given to this flexible component to enclose all of its children components. That is, the flexible component grow and shrink to fit its children components.

Parameters:
flex - horizontal flex hint of this component.
Since:
5.0.0
See Also:
setVflex(java.lang.String), getHflex()

getHflex

public java.lang.String getHflex()
Returns horizontal flex hint of this component.

Returns:
horizontal flex hint of this component.
Since:
5.0.0
See Also:
setHflex(java.lang.String)

renderProperties

protected void renderProperties(ContentRenderer renderer)
                         throws java.io.IOException
Renders the content of this component, excluding the enclosing tags and children.

See also Render Special Properties

Overrides:
renderProperties in class AbstractComponent
Throws:
java.io.IOException
Since:
5.0.0

service

public void service(AuRequest request,
                    boolean everError)
Processes an AU request.

Default: it handles onClick, onDoubleClick, onRightClick onMove, onSize, onZIndex.

Specified by:
service in interface ComponentCtrl
Overrides:
service in class AbstractComponent
everError - whether any error ever occured before processing this request.
Since:
5.0.0
See Also:
AbstractComponent.setAuService(org.zkoss.zk.au.AuService)

newExtraCtrl

protected java.lang.Object newExtraCtrl()
Used by AbstractComponent.getExtraCtrl() to create a client control. It is used only by component developers.

Defaut: creates an instance of HtmlBasedComponent.ExtraCtrl.

Overrides:
newExtraCtrl in class AbstractComponent


Copyright © 2005-2009 Potix Corporation. All Rights Reserved. SourceForge.net Logo