public class Window extends XulElement implements Framable, org.zkoss.zk.ui.IdSpace
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.(since 3.5.0)
Modifier and Type | Class and Description |
---|---|
static class |
Window.Mode
The window's mode used with
setMode(Mode) . |
Modifier and Type | Field and Description |
---|---|
static int |
EMBEDDED
Embeds the window as normal component.
|
static int |
HIGHLIGHTED
Makes the window as highlighted.
|
static int |
MODAL
Makes the window as a modal dialog.
|
static int |
OVERLAPPED
Makes the window as overlapped other components.
|
static int |
POPUP
Makes the window as popup.
|
AFTER_PAGE_ATTACHED, AFTER_PAGE_DETACHED
Constructor and Description |
---|
Window() |
Window(String title,
String border,
boolean closable) |
Modifier and Type | Method and Description |
---|---|
void |
beforeChildAdded(org.zkoss.zk.ui.Component child,
org.zkoss.zk.ui.Component refChild) |
Object |
clone() |
void |
doEmbedded()
Makes this window as embedded with other components (Default).
|
void |
doHighlighted()
Makes this window as highlighted.
|
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-hidden when user clicks outside of the window.
|
String |
getBorder()
Returns the border.
|
Caption |
getCaption()
Returns the caption of this window.
|
String |
getContentSclass()
Returns the style class used for the content block.
|
String |
getContentStyle()
Returns the CSS style for the content block of the window.
|
static String |
getDefaultActionOnShow()
Deprecated.
As release of 5.0.0, replaced with
HtmlBasedComponent.setAction(java.lang.String) . |
int |
getMinheight()
Returns the minimum height.
|
int |
getMinwidth()
Returns the minimum width.
|
String |
getMode()
Returns the current mode.
|
Window.Mode |
getModeType()
Returns the current mode.
|
String |
getPosition()
Returns how to position the window at the client screen.
|
String |
getTitle()
Returns the title.
|
String |
getZclass() |
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(org.zkoss.zk.ui.Component child,
org.zkoss.zk.ui.Component refChild) |
boolean |
isClosable()
Returns whether to show a close button on the title bar.
|
boolean |
isCollapsible()
Always return false.
|
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.
|
void |
onChildRemoved(org.zkoss.zk.ui.Component child) |
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(org.zkoss.zk.ui.Page page) |
protected void |
renderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer) |
void |
service(org.zkoss.zk.au.AuRequest request,
boolean everError)
Processes an AU request.
|
void |
setBorder(boolean border)
Enables or disables the border.
|
void |
setBorder(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(String scls)
Sets the style class used for the content block.
|
void |
setContentStyle(String style)
Sets the CSS style for the content block of the window.
|
static void |
setDefaultActionOnShow(String onshow)
Deprecated.
As release of 5.0.0, replaced with
HtmlBasedComponent.setAction(java.lang.String) . |
void |
setDraggable(String draggable) |
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(String name)
Sets the mode to overlapped, popup, modal, embedded or highlighted.
|
void |
setMode(Window.Mode mode)
Sets the mode.
|
void |
setPosition(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(String title)
Sets the title.
|
void |
setTopmost()
Makes this window as topmost.
|
boolean |
setVisible(boolean visible)
Changes the visibility of the window.
|
getContext, getCtrlKeys, getPopup, getPropertyAccess, getTooltip, setContext, setContext, setContextAttributes, setCtrlKeys, setPopup, setPopup, setPopupAttributes, setTooltip, setTooltip, setTooltipAttributes
focus, getAction, getDraggable, getDroppable, getExtraCtrl, getHeight, getHflex, getLeft, getRenderdefer, getSclass, getStyle, getTabindex, getTabindexInteger, getTooltiptext, getTop, getVflex, getWidth, getZindex, getZIndex, setAction, setClass, setDroppable, setFocus, setHeight, setHeight0, setHeightDirectly, setHflex, setHflex0, setHflexDirectly, setLeft, setLeftDirectly, setRenderdefer, setSclass, setStyle, setTabindex, setTabindex, setTooltiptext, setTop, setTopDirectly, setVflex, setVflex0, setVflexDirectly, setWidth, setWidth0, setWidthDirectly, setZclass, setZindex, setZIndex, setZIndexDirectly
addAnnotation, addAnnotation, addCallback, addClientEvent, addEventHandler, addEventListener, addEventListener, addForward, addForward, addForward, addForward, addMoved, addRedrawCallback, addScopeListener, addShadowRoot, addShadowRootBefore, addSharedEventHandlerMap, appendChild, applyProperties, beforeChildRemoved, beforeParentChanged, detach, didActivate, didActivate, didDeserialize, didDeserialize, disableBindingAnnotation, disableClientUpdate, enableBindingAnnotation, equals, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotation, getAnnotations, getAnnotations, getAnnotations, getAttribute, getAttribute, getAttribute, getAttributeOrFellow, getAttributes, getAttributes, getAuService, getAutag, getCallback, getChildren, getClientAttribute, getClientDataAttribute, getClientEvents, getDefaultMold, getDefinition, getDesktop, getEventHandler, getEventHandlerNames, getEventListenerMap, getEventListeners, getFellow, getFellow, getFellowIfAny, getFellowIfAny, getFellows, getFirstChild, getId, getLastChild, getListenerIterator, getMold, getNextSibling, getPage, getParent, getPreviousSibling, getRedrawCallback, getRoot, getShadowFellowIfAny, getShadowRoots, getShadowVariable, getShadowVariable, getShadowVariable0, getSpaceOwner, getSpecialRendererOutput, getStubonly, getSubBindingAnnotationCount, getTemplate, getTemplateNames, getUuid, getWidgetAttribute, getWidgetAttributeNames, getWidgetClass, getWidgetListener, getWidgetListenerNames, getWidgetOverride, getWidgetOverrideNames, hasAttribute, hasAttribute, hasAttribute, hasAttributeOrFellow, hasBindingAnnotation, hasFellow, hasFellow, hasSubBindingAnnotation, invalidate, isChildable, isInvalidated, isListenerAvailable, isVisible, onChildAdded, onPageAttached, onWrongValue, query, queryAll, redraw, redrawChildren, removeAttribute, removeAttribute, removeAttribute, removeCallback, removeChild, removeEventListener, removeForward, removeForward, removeRedrawCallback, removeScopeListener, removeShadowRoot, render, render, render, replace, response, response, response, service, sessionDidActivate, sessionWillPassivate, setAttribute, setAttribute, setAttribute, setAuService, setAutag, setClientAttribute, setClientDataAttribute, setDefinition, setDefinition, setId, setMold, setPage, setPageBefore, setParent, setStubonly, setStubonly, setSubBindingAnnotationCount, setTemplate, setVisibleDirectly, setWidgetAttribute, setWidgetClass, setWidgetListener, setWidgetOverride, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdateWidgetListener, smartUpdateWidgetOverride, toString, updateByClient, updateSubBindingAnnotationCount, willPassivate, willPassivate, willSerialize, willSerialize
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
public static final int EMBEDDED
public static final int MODAL
doModal()
is called, the execution of the event processing thread
is suspended until one of the following occurs.
setMode(org.zkoss.zul.Window.Mode)
is called with a mode other than MODAL.doOverlapped()
, doPopup()
,
doEmbedded()
, or doHighlighted()
is called.setVisible(boolean)
is called with false.Note: In the last two cases, the mode becomes OVERLAPPED
.
In other words, one might say a modal window is a special overlapped window.
HIGHLIGHTED
,
Constant Field Valuespublic static final int OVERLAPPED
public static final int POPUP
OVERLAPPED
, except it is auto hidden
when user clicks outside of the window.public static final int HIGHLIGHTED
MODAL
.
However, from the server side's viewpoint, it is similar to
OVERLAPPED
. The execution won't be suspended when
doHighlighted()
is called.MODAL
,
OVERLAPPED
,
Constant Field Valuespublic Window()
public Window(String title, 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)
).public boolean isMaximized()
isMaximized
in interface Framable
public 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.
org.zkoss.zk.ui.UiException
- if isMaximizable()
is false.public boolean isMaximizable()
Default: false.
isMaximizable
in interface Framable
public void setMaximizable(boolean maximizable)
Default: false.
Note: the maximize button won't be displayed if no title or caption at all.
public boolean isMinimized()
Default: false.
public void setMinimized(boolean minimized)
Default: false.
org.zkoss.zk.ui.UiException
- if isMinimizable()
is false.public boolean isMinimizable()
Default: false.
isMinimizable
in interface Framable
public void setMinimizable(boolean minimizable)
Default: false.
Note: the maximize button won't be displayed if no title or caption at all.
MinimizeEvent
public void setMinheight(int minheight)
Default: 100.
Note: Only applies when isSizable()
= true.
public int getMinheight()
Default: 100.
public void setMinwidth(int minwidth)
Default: 200.
Note: Only applies when isSizable()
= true.
public int getMinwidth()
Default: 200.
public static void setDefaultActionOnShow(String onshow)
HtmlBasedComponent.setAction(java.lang.String)
.public static String getDefaultActionOnShow()
HtmlBasedComponent.setAction(java.lang.String)
.public Caption getCaption()
public String getBorder()
Default: "none".
public void setBorder(String border)
border
- the border. If null, "0" or "false", "none" is assumed.
If "true", "normal" is assumed (since 5.0.8).public void setBorder(boolean border)
border
- whether to have a border. If true is specified,
it is the same as setBorder("normal")
.public String getTitle()
Caption
to define
a more sophisticated caption (a.k.a., title).
If a window has a caption whose label (LabelElement.getLabel()
)
is not empty, then this attribute is ignored.
Default: empty.
public void setTitle(String title)
public String getMode()
getModeType()
public void setMode(Window.Mode mode)
public void setMode(String name)
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.
Refer to Overlapped, Popup, Modal, Highlighted and Embedded for more information.
name
- the mode which could be one of
"embedded", "overlapped", "popup", "modal", "highlighted".
Note: it cannot be "modal". Use doModal()
instead.public void setMode(int mode)
setMode(String)
public Window.Mode getModeType()
getMode()
,
setMode(Mode)
public boolean inModal()
public boolean inEmbedded()
doEmbedded()
public boolean inOverlapped()
public boolean inPopup()
public boolean inHighlighted()
public void doModal()
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(org.zkoss.zul.Window.Mode)
won't suspend the execution immediately,
but doModal()
will.
doModal()
can be called only in an event listener,
while setMode(org.zkoss.zul.Window.Mode)
can be called anytime.
public void doOverlapped()
public void doPopup()
public void doHighlighted()
public void doEmbedded()
public boolean isClosable()
isClosable
in interface Framable
public 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.
public boolean isSizable()
public void setSizable(boolean sizable)
Default: false.
public boolean isShadow()
public void setShadow(boolean shadow)
Default: true.
public 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.
public void setPosition(String pos)
pos
- 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.setTop(java.lang.String)
and HtmlBasedComponent.setLeft(java.lang.String)
(since 5.0.4)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()
public String getContentStyle()
public void setContentStyle(String style)
Default: null.
public String getContentSclass()
setContentSclass(java.lang.String)
public void setContentSclass(String scls)
getContentSclass()
public void setTopmost()
protected void renderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer) throws IOException
renderProperties
in class XulElement
IOException
public String getZclass()
getZclass
in class org.zkoss.zk.ui.HtmlBasedComponent
public void beforeChildAdded(org.zkoss.zk.ui.Component child, org.zkoss.zk.ui.Component refChild)
beforeChildAdded
in interface org.zkoss.zk.ui.sys.ComponentCtrl
beforeChildAdded
in class org.zkoss.zk.ui.AbstractComponent
public boolean insertBefore(org.zkoss.zk.ui.Component child, org.zkoss.zk.ui.Component refChild)
insertBefore
in interface org.zkoss.zk.ui.Component
insertBefore
in class org.zkoss.zk.ui.AbstractComponent
public void onChildRemoved(org.zkoss.zk.ui.Component child)
onChildRemoved
in interface org.zkoss.zk.ui.sys.ComponentCtrl
onChildRemoved
in class org.zkoss.zk.ui.AbstractComponent
public void onPageDetached(org.zkoss.zk.ui.Page page)
onPageDetached
in interface org.zkoss.zk.ui.sys.ComponentCtrl
onPageDetached
in class org.zkoss.zk.ui.AbstractComponent
public boolean setVisible(boolean visible)
Note if you turned on the event thread:
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.
In other words, the modal window (MODAL
) can not be invisible
(while a window in other modes could be invisible).
However, if the event thread is not enabled (default), there is no such limitation. In other words, it remains the same mode when becoming invisible.
setVisible
in interface org.zkoss.zk.ui.Component
setVisible
in class org.zkoss.zk.ui.AbstractComponent
public void setDraggable(String draggable)
setDraggable
in class org.zkoss.zk.ui.HtmlBasedComponent
public Object clone()
clone
in interface org.zkoss.zk.ui.Component
clone
in class XulElement
public void service(org.zkoss.zk.au.AuRequest request, boolean everError)
Default: in addition to what are handled by HtmlBasedComponent.service(org.zkoss.zk.au.AuRequest, boolean)
,
it also handles onOpen.
service
in interface org.zkoss.zk.ui.sys.ComponentCtrl
service
in class org.zkoss.zk.ui.HtmlBasedComponent
public boolean isCollapsible()
isCollapsible
in interface Framable
Copyright © 2017. All rights reserved.