|
||||||||||
| 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(). |
| Nested classes/interfaces inherited from class org.zkoss.zk.ui.AbstractComponent |
|---|
AbstractComponent.Children |
| Field Summary | |
|---|---|
protected java.lang.String |
_zclass
The ZK CSS class. |
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 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 |
| Constructor Summary | |
|---|---|
protected |
HtmlBasedComponent()
|
| Method Summary | |
|---|---|
void |
focus()
Sets focus to this element. |
protected java.lang.String |
getAllOnClickAttrs()
Returns the attributes for onClick, onRightClick and onDoubleClick by checking whether the corresponding listeners are added, or null if none is added. |
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 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 |
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 |
getMoldSclass()
Deprecated. As of release 3.5.1, replaced with getZclass(). |
java.lang.String |
getOuterAttrs()
Returns the exterior attributes for generating the enclosing HTML tag; never return null. |
protected java.lang.String |
getRealSclass()
Returns the real style class that will be generated to the client (when getOuterAttrs() is called). |
protected java.lang.String |
getRealStyle()
Returns the real style that will be generated to client (when getOuterAttrs() is called). |
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. |
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. |
void |
redraw(java.io.Writer out)
Redraws this component. |
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 |
setLeft(java.lang.String left)
Sets the left position. |
void |
setMoldSclass(java.lang.String moldSclass)
Deprecated. As of release 3.5.1, replaced with setZclass(java.lang.String). |
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 |
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 java.lang.Object |
|---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected java.lang.String _zclass
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()
getLeft in interface HtmlBasedComponentpublic void setLeft(java.lang.String left)
setLeft in interface HtmlBasedComponentpublic java.lang.String getTop()
getTop in interface HtmlBasedComponentpublic void setTop(java.lang.String top)
setTop in interface HtmlBasedComponentpublic int getZIndex()
Default: -1 (means system default;
getZIndex in interface HtmlBasedComponentpublic void setZIndex(int zIndex)
setZIndex in interface HtmlBasedComponentpublic int getZindex()
getZIndex().
getZindex in interface HtmlBasedComponentpublic void setZindex(int zIndex)
setZIndex(int).
setZindex in interface HtmlBasedComponentpublic java.lang.String getHeight()
Default: null.
getHeight in interface HtmlBasedComponentpublic void setHeight(java.lang.String height)
setHeight in interface HtmlBasedComponentpublic java.lang.String getWidth()
Default: null.
getWidth in interface HtmlBasedComponentpublic void setWidth(java.lang.String width)
setWidth in interface HtmlBasedComponentpublic java.lang.String getTooltiptext()
Default: null.
getTooltiptext in interface HtmlBasedComponentpublic void setTooltiptext(java.lang.String tooltiptext)
setTooltiptext in interface HtmlBasedComponentpublic java.lang.String getMoldSclass()
getZclass().
public void setMoldSclass(java.lang.String moldSclass)
setZclass(java.lang.String).
public java.lang.String getZclass()
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.
getZclass in interface HtmlBasedComponentgetSclass(),
getRealSclass()public void setZclass(java.lang.String zclass)
setZclass in interface HtmlBasedComponentsetSclass(java.lang.String),
getZclass()public java.lang.String getSclass()
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.
getSclass in interface HtmlBasedComponentgetRealSclass(),
getZclass()public void setSclass(java.lang.String sclass)
setSclass in interface HtmlBasedComponentsetZclass(java.lang.String)public final void setClass(java.lang.String sclass)
setSclass(java.lang.String).
public java.lang.String getStyle()
Default: null.
getStyle in interface HtmlBasedComponentpublic void setStyle(java.lang.String style)
setStyle in interface HtmlBasedComponentpublic 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.
setDraggable in interface HtmlBasedComponentdraggable - "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.
setDroppable in interface HtmlBasedComponentdroppable - "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()
focus in interface HtmlBasedComponentpublic void setFocus(boolean focus)
focus(), but used to allow ZUML to set focus
to particular component.
<textbox focus="true"/>
setFocus in interface HtmlBasedComponentfocus - whether to set focus. If false, this method has no effect.protected java.lang.String getAllOnClickAttrs()
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 AbstractComponent.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 getRealSclass()
getOuterAttrs() is called).
Default: it simply returns the catenation of getSclass()
and getZclass() (since 3.5.0).
Derived classes might override it to provide, say, dual style classes. For example,
final String sclass = getSclass();
return sclass != null ? sclass + " my-addon": "myaddon";
getZclass()protected java.lang.String getRealStyle()
getOuterAttrs() is called).
Default: this method will append width, height and others
to 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.
public void redraw(java.io.Writer out)
throws java.io.IOException
AbstractComponentAbstractComponent.getMoldURI() to retrieve the mold
to redraw. The mold is either an URI (String) or a
ComponentRenderer instance.
Execution.include(java.io.Writer, java.lang.String, java.util.Map, int) to generate
the output.ComponentRenderer instance, ComponentRenderer.render(org.zkoss.zk.ui.Component, java.io.Writer)
is called to generate the output.
redraw in interface Componentredraw in class AbstractComponentjava.io.IOExceptionprotected 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 | |||||||||