|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.zkoss.zk.ui.AbstractComponent
org.zkoss.zk.ui.HtmlBasedComponent
public abstract class HtmlBasedComponent
A skeletal implementation for HTML based components. It simplifies to implement methods common to HTML based components.
It supports
getSclass() and getStyle().getWidth(), getHeight(), getLeft(),
getTop(), getZIndex()getOuterAttrs()getInnerAttrs()focus()
| Nested Class Summary | |
|---|---|
protected class |
HtmlBasedComponent.ExtraCtrl
A utility class to implement AbstractComponent.getExtraCtrl(). |
| Field Summary | |
|---|---|
protected static int |
RS_NO_DISPLAY
Used by getRealStyleFlags() to denote that getRealStyle()
shall not generate the display style. |
protected static int |
RS_NO_HEIGHT
Used by getRealStyleFlags() to denote that getRealStyle()
shall not generate the height style. |
protected static int |
RS_NO_WIDTH
Used by getRealStyleFlags() to denote that getRealStyle()
shall not generate the width style. |
| Fields inherited from interface org.zkoss.zk.ui.Component |
|---|
APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPE |
| Constructor Summary | |
|---|---|
protected |
HtmlBasedComponent()
|
| Method Summary | |
|---|---|
boolean |
addEventListener(java.lang.String evtnm,
EventListener listener)
Adds an event listener to specified event for this component. |
protected java.lang.StringBuffer |
appendAsapAttr(java.lang.StringBuffer sb,
java.lang.String evtnm)
Appends the HTML attribute for the specified event name, say, onChange. |
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 or empty). |
java.lang.String |
getDroppable()
Returns the identifier of a droppable type of objects, or "false" if not droppable (never null or empty). |
java.lang.String |
getHeight()
Returns the height. |
java.lang.String |
getInnerAttrs()
Returns the interior attributes for generating the inner HTML tag; never return null. |
java.lang.String |
getLeft()
Returns the left position. |
java.lang.String |
getOuterAttrs()
Returns the exterior attributes for generating the enclosing HTML tag; never return null. |
protected java.lang.String |
getRealStyle()
Returns the real style after appending width, height and others to setStyle(java.lang.String) (never null). |
protected int |
getRealStyleFlags()
Returns a combination of RS_NO_WIDTH and RS_NO_HEIGHT. |
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 |
getWidth()
Returns the width. |
int |
getZIndex()
Returns the Z index. |
protected boolean |
isAsapRequired(java.lang.String evtnm)
Returns whether to send back the request of the specified event immediately -- i.e., non-deferrable. |
protected java.lang.Object |
newExtraCtrl()
Used by AbstractComponent.getExtraCtrl() to create a client control. |
boolean |
removeEventListener(java.lang.String evtnm,
EventListener listener)
Removes an event listener. |
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 |
setHeight(java.lang.String height)
Sets the height. |
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 |
setWidth(java.lang.String width)
Sets the width. |
void |
setZIndex(int zIndex)
Sets the Z index. |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected static final int RS_NO_WIDTH
getRealStyleFlags() to denote that getRealStyle()
shall not generate the width style.
protected static final int RS_NO_HEIGHT
getRealStyleFlags() to denote that getRealStyle()
shall not generate the height style.
protected static final int RS_NO_DISPLAY
getRealStyleFlags() to denote that getRealStyle()
shall not generate the display style.
| Constructor Detail |
|---|
protected HtmlBasedComponent()
| Method Detail |
|---|
public java.lang.String getLeft()
public void setLeft(java.lang.String left)
public java.lang.String getTop()
public void setTop(java.lang.String top)
public int getZIndex()
Default: -1 (means system default;
public void setZIndex(int zIndex)
public java.lang.String getHeight()
Default: null.
public void setHeight(java.lang.String height)
public java.lang.String getWidth()
Default: null.
public void setWidth(java.lang.String width)
public java.lang.String getTooltiptext()
Default: null.
public void setTooltiptext(java.lang.String tooltiptext)
public java.lang.String getSclass()
Default: null (the default value depends on element).
public void setSclass(java.lang.String sclass)
public final void setClass(java.lang.String sclass)
setSclass(java.lang.String).
public java.lang.String getStyle()
Default: null.
public void setStyle(java.lang.String style)
public void setDraggable(java.lang.String draggable)
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.
draggable - "false", null or "" to denote non-draggable; "true" for draggable
with anonymous identifier; others for an identifier of draggable.public final java.lang.String getDraggable()
public void setDroppable(java.lang.String droppable)
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 accpets dg1 and dg2, then assign "dg1, dg2" to this attribute.
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 compoent
accept (to be dropped in).public final java.lang.String getDroppable()
public void focus()
public java.lang.String getOuterAttrs()
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 outest 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(java.lang.StringBuffer, java.lang.String) for each event
the component handles in getOuterAttrs() as follows.
appendAsapAttr(sb, Events.ON_OPEN);
appendAsapAttr(sb, Events.ON_CHANGE);
Theorectically, 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).
public java.lang.String getInnerAttrs()
Used only by component developers.
Default: empty string.
Refer to getOuterAttrs() for more details.
protected java.lang.String getRealStyle()
setStyle(java.lang.String) (never null).
Use getRealStyleFlags() to control what attributes to
exclude.
protected int getRealStyleFlags()
RS_NO_WIDTH and RS_NO_HEIGHT.
Default: return 0.
protected boolean isAsapRequired(java.lang.String evtnm)
Default: return true if any non-deferable event listener of
the specified event is found. In other words, it returns
Events.isListened(org.zkoss.zk.ui.Component, java.lang.String, boolean) with asap = true.
protected java.lang.StringBuffer appendAsapAttr(java.lang.StringBuffer sb,
java.lang.String evtnm)
getOuterAttrs().
sb - the string buffer to hold the HTML attribute. If null and
isAsapRequired(java.lang.String) is true, a string buffer is created and returned.
isAsapRequired(java.lang.String)
returns false, null is returned.
If the caller passed non-null sb, the returned value must be the same
as sb (so it usually ignores the returned value).
public boolean addEventListener(java.lang.String evtnm,
EventListener listener)
ComponentYou could register listener to all components in the same page
by use of Page.addEventListener(java.lang.String, org.zkoss.zk.ui.event.EventListener).
addEventListener in interface ComponentaddEventListener in class AbstractComponentevtnm - what event to listen (never null)
Page.addEventListener(java.lang.String, org.zkoss.zk.ui.event.EventListener)
public boolean removeEventListener(java.lang.String evtnm,
EventListener listener)
Component
removeEventListener in interface ComponentremoveEventListener in class AbstractComponentprotected java.lang.Object newExtraCtrl()
AbstractComponent.getExtraCtrl() to create a client control.
It is used only by component developers.
Defaut: creates an instance of HtmlBasedComponent.ExtraCtrl.
newExtraCtrl in class AbstractComponent
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||