|
||||||||||
| 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
org.zkoss.zul.impl.XulElement
org.zkoss.zul.Window
public class Window
A generic window.
Unlike other elements, each Window is an independent ID space
(by implementing IdSpace).
It means a window and all its descendants forms a ID space and
the ID of each of them is unique in this space.
You could retrieve any of them in this space by calling AbstractComponent.getFellow(java.lang.String).
If a window X is a descendant of another window Y, X's descendants are not visible in Y's space. To retrieve a descendant, say Z, of X, you have to invoke Y.getFellow('X').getFellow('Z').
Events:
onMove, onOpen, onMaximize, onMinimize, and onClose.
Note: to have better performance, onOpen is sent only if a
non-deferrable event listener is registered
(see Deferrable).
onMaximize and onMinimize are supported. (since 3.5.0)
onClose is sent when the close button is pressed
(if isClosable() is true). The window has to detach or hide
the window. By default, onClose() detaches the window. To prevent
it from detached, you have to call Event.stopPropagation()
to prevent onClose() is called.
On the other hand, onOpen is sent when a popup
window (i.e., getMode() is popup) is closed due to user's activity
(such as press ESC). This event is only a notification.
In other words, the popup is hidden before the event is sent to the server.
The application cannot prevent the window from being hidden.
Default getZclass(): z-window-getMode().(since 3.5.0)
| Nested Class Summary | |
|---|---|
protected class |
Window.ExtraCtrl
A utility class to implement AbstractComponent.getExtraCtrl(). |
| Nested classes/interfaces inherited from class org.zkoss.zk.ui.AbstractComponent |
|---|
AbstractComponent.Children |
| Field Summary |
|---|
| Fields inherited from class org.zkoss.zk.ui.HtmlBasedComponent |
|---|
_zclass, RS_NO_DISPLAY, RS_NO_HEIGHT, RS_NO_WIDTH |
| 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 | |
|---|---|
Window()
|
|
Window(java.lang.String title,
java.lang.String border,
boolean closable)
|
|
| Method Summary | |
|---|---|
java.lang.Object |
clone()
Clones the component. |
void |
doEmbedded()
Makes this window as embeded with other components (Default). |
void |
doHighlighted()
Makes this window as highlited. |
void |
doModal()
Makes this window as a modal dialog. |
void |
doOverlapped()
Makes this window as overlapped with other components. |
void |
doPopup()
Makes this window as popup, which is overlapped with other component and auto-hiden when user clicks outside of the window. |
java.lang.String |
getBorder()
Returns the border. |
Caption |
getCaption()
Returns the caption of this window. |
Caption |
getCaptionApi()
Returns the caption of this window. |
java.lang.String |
getContentSclass()
Returns the style class used for the content block. |
java.lang.String |
getContentStyle()
Returns the CSS style for the content block of the window. |
static java.lang.String |
getDefaultActionOnShow()
Returns the animating name of function. |
int |
getMinheight()
Returns the minimum height. |
int |
getMinwidth()
Returns the minimum width. |
java.lang.String |
getMode()
Returns the current mode. |
java.lang.String |
getOuterAttrs()
Returns the exterior attributes for generating the enclosing HTML tag; never return null. |
java.lang.String |
getPosition()
Returns how to position the window at the client screen. |
protected java.lang.String |
getRealStyle()
Returns the real style that will be generated to client (when HtmlBasedComponent.getOuterAttrs() is called). |
java.lang.String |
getTitle()
Returns the title. |
java.lang.String |
getTitleSclass()
Deprecated. As of release 3.5.0 |
java.lang.String |
getZclass()
Returns the ZK Cascading Style class(es) for this component. |
boolean |
inEmbedded()
Returns whether this is embedded with other components (Default). |
boolean |
inHighlighted()
Returns whether this is a highlighted window. |
boolean |
inModal()
Returns whether this is a modal dialog. |
boolean |
inOverlapped()
Returns whether this is a overlapped window. |
boolean |
inPopup()
Returns whether this is a popup window. |
boolean |
insertBefore(Component child,
Component insertBefore)
Inserts a child before the reference child. |
boolean |
isClosable()
Returns whether to show a close button on the title bar. |
boolean |
isMaximizable()
Returns whether to display the maximizing button and allow the user to maximize the window. |
boolean |
isMaximized()
Returns whether the window is maximized. |
boolean |
isMinimizable()
Returns whether to display the minimizing button and allow the user to minimize the window. |
boolean |
isMinimized()
Returns whether the window is minimized. |
boolean |
isShadow()
Returns whether to show the shadow of an overlapped/popup/modal window. |
boolean |
isSizable()
Returns whether the window is sizable. |
protected java.lang.Object |
newExtraCtrl()
Used by AbstractComponent.getExtraCtrl() to create a client control. |
void |
onChildRemoved(Component child)
Default: does nothing. |
void |
onClose()
Process the onClose event sent when the close button is pressed. |
void |
onModal()
Process the onModal event by making itself a modal window. |
void |
onPageDetached(Page page)
Default: handles special event listeners. |
void |
setBorder(java.lang.String border)
Sets the border (either none or normal). |
void |
setClosable(boolean closable)
Sets whether to show a close button on the title bar. |
void |
setContentSclass(java.lang.String scls)
Sets the style class used for the content block. |
void |
setContentStyle(java.lang.String style)
Sets the CSS style for the content block of the window. |
static void |
setDefaultActionOnShow(java.lang.String onshow)
Sets the action of window component to show the animating effect by default. |
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 |
setMaximizable(boolean maximizable)
Sets whether to display the maximizing button and allow the user to maximize the window, when a window is maximized, the button will automatically change to a restore button with the appropriate behavior already built-in that will restore the window to its previous size. |
void |
setMaximized(boolean maximized)
Sets whether the window is maximized, and then the size of the window will depend on it to show a appropriate size. |
void |
setMinheight(int minheight)
Sets the minimum height in pixels allowed for this window. |
void |
setMinimizable(boolean minimizable)
Sets whether to display the minimizing button and allow the user to minimize the window. |
void |
setMinimized(boolean minimized)
Sets whether the window is minimized. |
void |
setMinwidth(int minwidth)
Sets the minimum width in pixels allowed for this window. |
void |
setMode(int mode)
Sets the mode to overlapped, popup, modal, embedded or highlighted. |
void |
setMode(java.lang.String name)
Sets the mode to overlapped, popup, modal, embedded or highlighted. |
void |
setPosition(java.lang.String pos)
Sets how to position the window at the client screen. |
void |
setShadow(boolean shadow)
Sets whether to show the shadow of an overlapped/popup/modal window. |
void |
setSizable(boolean sizable)
Sets whether the window is sizable. |
void |
setTitle(java.lang.String title)
Sets the title. |
boolean |
setVisible(boolean visible)
Changes the visibility of the window. |
| Methods inherited from class org.zkoss.zul.impl.XulElement |
|---|
getAction, getActionAttrs, getAllOnClickAttrs, getContext, getCtrlKeys, getInnerAttrs, getPopup, getTooltip, setAction, setContext, setContext, setCtrlKeys, setPopup, setPopup, setTooltip, setTooltip |
| Methods inherited from class org.zkoss.zk.ui.HtmlBasedComponent |
|---|
focus, getAllOnClickAttrs, getDraggable, getDroppable, getHeight, getLeft, getMoldSclass, getRealSclass, getRealStyleFlags, getSclass, getStyle, getTooltiptext, getTop, getWidth, getZindex, getZIndex, redraw, setClass, setDroppable, setFocus, setHeight, setLeft, setMoldSclass, setSclass, setStyle, setTooltiptext, setTop, setWidth, setZclass, setZindex, setZIndex |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.zkoss.zk.ui.IdSpace |
|---|
getFellow, getFellowIfAny, getFellows, hasFellow |
| Methods inherited from interface org.zkoss.zul.impl.api.XulElement |
|---|
getAction, getContext, getCtrlKeys, getPopup, getTooltip, setAction, setContext, setContext, setCtrlKeys, setPopup, setPopup, setTooltip, setTooltip |
| Methods inherited from interface org.zkoss.zk.ui.api.HtmlBasedComponent |
|---|
focus, getHeight, getLeft, getSclass, getStyle, getTooltiptext, getTop, getWidth, getZindex, getZIndex, setDroppable, setFocus, setHeight, setLeft, setSclass, setStyle, setTooltiptext, setTop, setWidth, setZclass, setZindex, setZIndex |
| Constructor Detail |
|---|
public Window()
public Window(java.lang.String title,
java.lang.String border,
boolean closable)
title - the window title (see setTitle(java.lang.String)).border - the border (see setBorder(java.lang.String)).closable - whether it is closable (see setClosable(boolean)).| Method Detail |
|---|
public boolean isMaximized()
isMaximized in interface Windowpublic void setMaximized(boolean maximized)
inEmbedded()) or its parent node. Otherwise, its size
will be original size. Note that the maximized effect will run at client's
sizing phase not initial phase.
Default: false.
setMaximized in interface WindowUiException - if isMaximizable() is false.public boolean isMaximizable()
Default: false.
isMaximizable in interface Windowpublic void setMaximizable(boolean maximizable)
Default: false.
Note: the maximize button won't be displayed if no title or caption at all.
setMaximizable in interface Windowpublic boolean isMinimized()
Default: false.
isMinimized in interface Windowpublic void setMinimized(boolean minimized)
Default: false.
setMinimized in interface WindowUiException - if isMinimizable() is false.public boolean isMinimizable()
Default: false.
isMinimizable in interface Windowpublic void setMinimizable(boolean minimizable)
Default: false.
Note: the maximize button won't be displayed if no title or caption at all.
setMinimizable in interface WindowMinimizeEventpublic void setMinheight(int minheight)
Default: 100.
Note: Only applies when isSizable() = true.
setMinheight in interface Windowpublic int getMinheight()
Default: 100.
getMinheight in interface Windowpublic void setMinwidth(int minwidth)
Default: 200.
Note: Only applies when isSizable() = true.
setMinwidth in interface Windowpublic int getMinwidth()
Default: 200.
getMinwidth in interface Windowpublic static void setDefaultActionOnShow(java.lang.String onshow)
Default: null. In other words, if the property is null, it will refer to the configuration of zk.xml to find the preference with "org.zkoss.zul.Window.defaultActionOnShow", if any. For example,
<preference> <name>org.zkoss.zul.Window.defaultActionOnShow</name> <value>moveDown</value> </preference>Otherwise, the animating effect is depended on component itself.
In JavaScript, the property will match the same function name with the prefix "anima.". For example, if the property is "moveDown", the function name should be "anima.moveDown" accordingly.
Node: The method is available in modal mode only. And if
the onshow command of client-side action has been assigned on the
component, its priority is higher than this method.
For example,
action="onshow:anima.appear(#{self});"
onshow - the function name in JavaScript. You could use the following
animations, e.g. "moveDown", "moveRight", "moveDiagonal", "appear",
"slideDown", and so forth.public static java.lang.String getDefaultActionOnShow()
public Caption getCaption()
public Caption getCaptionApi()
getCaptionApi in interface Windowpublic java.lang.String getBorder()
getContentSclass() for more details.
Default: "none".
getBorder in interface Windowpublic void setBorder(java.lang.String border)
setBorder in interface Windowborder - the border. If null or "0", "none" is assumed.
Since 2.4.1, We assume "0" to be "none".public java.lang.String getTitle()
Caption to define
a more sophiscated caption (aka., title).
If a window has a caption whose label (LabelElement.getLabel())
is not empty, then this attribute is ignored.
Default: empty.
getTitle in interface Windowpublic void setTitle(java.lang.String title)
setTitle in interface Windowpublic java.lang.String getMode()
getMode in interface Window
public void setMode(java.lang.String name)
throws java.lang.InterruptedException
Notice: Events.ON_MODAL is posted if you specify
"modal" to this method.
Unlike doModal(), Events.ON_MODAL is posted, so
the window will become modal later (since 3.0.4).
In other words, setMode("modal") never suspends the execution
of the current thread. On the other hand, doModal() will
suspends the execution if executed in an event listener, or
throws an exception if not executed in an event listener.
setMode in interface Windowname - the mode which could be one of
"embedded", "overlapped", "popup", "modal", "highlighted".
Note: it cannot be "modal". Use doModal() instead.
java.lang.InterruptedException - thrown if "modal" is specified,
and one of the following conditions occurs:
1) the desktop or the Web application is being destroyed, or
2) DesktopCtrl.ceaseSuspendedThread(org.zkoss.zk.ui.sys.EventProcessingThread, java.lang.String).
To tell the difference, check the getMessage method of InterruptedException.
public void setMode(int mode)
throws java.lang.InterruptedException
setMode in interface Windowjava.lang.InterruptedExceptionsetMode(String)public boolean inModal()
inModal in interface Windowpublic boolean inEmbedded()
inEmbedded in interface WindowdoEmbedded()public boolean inOverlapped()
inOverlapped in interface Windowpublic boolean inPopup()
inPopup in interface Windowpublic boolean inHighlighted()
inHighlighted in interface Window
public void doModal()
throws java.lang.InterruptedException,
SuspendNotAllowedException
HtmlBasedComponent.getLeft() and
HtmlBasedComponent.getTop()).
Notice: though both setMode("modal") and doModal() both
causes the window to become modal, they are a bit different.
doModal causes the event listener to suspend immediately,
while setMode("modal") posts an event (Events.ON_MODAL).
That is, setMode(java.lang.String) won't suspend the execution immediately,
but doModal() will.
doModal() can be called only in an event listener,
while setMode(java.lang.String) can be called anytime.
doModal in interface WindowSuspendNotAllowedException - if
1) not in an event listener;java.lang.InterruptedException - thrown if the desktop or
the Web application is being destroyed, or
DesktopCtrl.ceaseSuspendedThread(org.zkoss.zk.ui.sys.EventProcessingThread, java.lang.String).
To tell the difference, check the getMessage method of InterruptedException.public void doOverlapped()
doOverlapped in interface Windowpublic void doPopup()
doPopup in interface Windowpublic void doHighlighted()
doHighlighted in interface Windowpublic void doEmbedded()
doEmbedded in interface Windowpublic boolean isClosable()
isClosable in interface Windowpublic void setClosable(boolean closable)
Default: false.
You can intercept the default behavior by either overriding
onClose(), or listening the onClose event.
Note: the close button won't be displayed if no title or caption at all.
setClosable in interface Windowpublic boolean isSizable()
isSizable in interface Windowpublic void setSizable(boolean sizable)
Default: false.
setSizable in interface Windowpublic boolean isShadow()
public void setShadow(boolean shadow)
Default: true.
public java.lang.String getPosition()
Default: null which depends on getMode():
If overlapped or popup, HtmlBasedComponent.setLeft(java.lang.String) and HtmlBasedComponent.setTop(java.lang.String) are
assumed. If modal or highlighted, it is centered.
getPosition in interface Windowpublic void setPosition(java.lang.String pos)
setPosition in interface Windowpos - how to position. It can be null (the default), or
a combination of the following values (by separating with comma).
HtmlBasedComponent.setTop(java.lang.String) and HtmlBasedComponent.setLeft(java.lang.String)
are both ignored.HtmlBasedComponent.setLeft(java.lang.String) is ignored.HtmlBasedComponent.setLeft(java.lang.String) is ignored.HtmlBasedComponent.setTop(java.lang.String) is ignored.HtmlBasedComponent.setTop(java.lang.String) is ignored.HtmlBasedComponent.getTop() and HtmlBasedComponent.getLeft())
is an offset to his parent's let-top corner. (since 3.0.2)For example, "left,center" means to position it at the center of the left edge.
public void onClose()
Default: detach itself.
public void onModal()
throws java.lang.InterruptedException
java.lang.InterruptedExceptionpublic java.lang.String getContentStyle()
getContentStyle in interface Windowpublic void setContentStyle(java.lang.String style)
Default: null.
setContentStyle in interface Windowpublic java.lang.String getContentSclass()
getContentSclass in interface WindowsetContentSclass(java.lang.String)public void setContentSclass(java.lang.String scls)
setContentSclass in interface WindowgetContentSclass()public java.lang.String getTitleSclass()
It returns "wt-sclass" is returned,
where sclass is the value returned by HtmlBasedComponent.getSclass().
public java.lang.String getZclass()
HtmlBasedComponentDefault: null (the default value depends on element).
HtmlBasedComponent.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 HtmlBasedComponent.getZclass().
Once it is changed, the default style won't be applied at all.
If you want to perform small adjustments, use HtmlBasedComponent.setSclass(java.lang.String)
instead.
getZclass in interface HtmlBasedComponentgetZclass in class HtmlBasedComponentHtmlBasedComponent.getSclass(),
HtmlBasedComponent.getRealSclass()
public boolean insertBefore(Component child,
Component insertBefore)
ComponentYou could use Component.setParent(org.zkoss.zk.ui.Component) or Component.appendChild(org.zkoss.zk.ui.Component)
instead of this method, unless
you want to control where to put the child.
Note: Component.setParent(org.zkoss.zk.ui.Component) always calls back Component.insertBefore(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component)
and/or Component.removeChild(org.zkoss.zk.ui.Component),
while Component.insertBefore(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component) and Component.removeChild(org.zkoss.zk.ui.Component)
always calls back Component.setParent(org.zkoss.zk.ui.Component),
if the parent is changed. Thus, you don't need to override
both Component.insertBefore(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component) and Component.setParent(org.zkoss.zk.ui.Component), if you want
to customize the behavior.
insertBefore in interface ComponentinsertBefore in class AbstractComponentchild - the new child to be inserted.insertBefore - the child before which you want the new child
being inserted. If null, the new child is append to the end.
public void onChildRemoved(Component child)
AbstractComponent
onChildRemoved in interface ComponentCtrlonChildRemoved in class AbstractComponentComponentCtrl.onChildRemoved(org.zkoss.zk.ui.Component)public void onPageDetached(Page page)
AbstractComponent
onPageDetached in interface ComponentCtrlonPageDetached in class AbstractComponentpage - the previous page (never null)ComponentCtrl.onPageDetached(org.zkoss.zk.ui.Page)public boolean setVisible(boolean visible)
Note: If a modal dialog becomes invisible, the modal state
will be ended automatically. In other words, the mode (getMode())
will become OVERLAPPED and the suspending thread is resumed.
setVisible in interface ComponentsetVisible in class AbstractComponentpublic void setDraggable(java.lang.String draggable)
HtmlBasedComponentThe 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 HtmlBasedComponentsetDraggable in class HtmlBasedComponentdraggable - "false", null or "" to denote non-draggable; "true" for draggable
with anonymous identifier; others for an identifier of draggable.protected java.lang.String getRealStyle()
HtmlBasedComponentHtmlBasedComponent.getOuterAttrs() is called).
Default: this method will append width, height and others
to HtmlBasedComponent.setStyle(java.lang.String) (never null).
Use HtmlBasedComponent.getRealStyleFlags() to control what attributes to
exclude.
getRealStyle in class HtmlBasedComponentpublic java.lang.String getOuterAttrs()
HtmlBasedComponentUsed 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
HtmlBasedComponent.getTooltiptext(), HtmlBasedComponent.getRealStyle(),
HtmlBasedComponent.getSclass(), HtmlBasedComponent.getDraggable(), HtmlBasedComponent.getDroppable()
are defined.
You have to call both HtmlBasedComponent.getOuterAttrs() and
HtmlBasedComponent.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 HtmlBasedComponent.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 HtmlBasedComponent.getOuterAttrs() as follows.
appendAsapAttr(sb, Events.ON_OPEN);
appendAsapAttr(sb, Events.ON_CHANGE);
Theorectically, you could put any attributes in either
HtmlBasedComponent.getInnerAttrs() or HtmlBasedComponent.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).
getOuterAttrs in class XulElementpublic java.lang.Object clone()
Component
clone in interface Componentclone in class AbstractComponentprotected java.lang.Object newExtraCtrl()
HtmlBasedComponentAbstractComponent.getExtraCtrl() to create a client control.
It is used only by component developers.
Defaut: creates an instance of HtmlBasedComponent.ExtraCtrl.
newExtraCtrl in class HtmlBasedComponent
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||