Package org.zkoss.zul

Class Tab

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, org.zkoss.zk.ui.Component, org.zkoss.zk.ui.ext.Scope, org.zkoss.zk.ui.sys.ComponentCtrl

    public class Tab
    extends LabelImageElement
    A tab.

    Default getZclass(): z-tab. (since 3.5.0)

    Support child component

    Caption child component is allowed. [ZK EE] [Since 6.5.0]
    Author:
    tomyeh
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.zkoss.zk.ui.AbstractComponent

        org.zkoss.zk.ui.AbstractComponent.Children, org.zkoss.zk.ui.AbstractComponent.ForwardInfo, org.zkoss.zk.ui.AbstractComponent.TargetInfo
    • Field Summary

      • Fields inherited from class org.zkoss.zk.ui.HtmlBasedComponent

        _zclass
      • 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

        AFTER_CHILD_ADDED, AFTER_CHILD_REMOVED, AFTER_CLONED, AFTER_PAGE_ATTACHED, AFTER_PAGE_DETACHED, AFTER_PARENT_CHANGED, CE_BUSY_IGNORE, CE_DUPLICATE_IGNORE, CE_IMPORTANT, CE_NON_DEFERRABLE, CE_REPEAT_IGNORE
    • Constructor Summary

      Constructors 
      Constructor Description
      Tab()  
      Tab​(java.lang.String label)  
      Tab​(java.lang.String label, java.lang.String image)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void beforeChildAdded​(org.zkoss.zk.ui.Component child, org.zkoss.zk.ui.Component refChild)  
      void beforeParentChanged​(org.zkoss.zk.ui.Component parent)  
      java.lang.Object clone()  
      void close()
      Closes this tab and the linked tabpanel.
      Caption getCaption()
      Returns the caption of this tab.
      int getIndex()
      Returns the index of this panel, or -1 if it doesn't belong to any tabs.
      Tabpanel getLinkedPanel()
      Returns the panel associated with this tab.
      Tabbox getTabbox()
      Returns the tabbox owns this component.
      <T> T getValue()
      Returns the value.
      java.lang.String getZclass()  
      boolean insertBefore​(org.zkoss.zk.ui.Component child, org.zkoss.zk.ui.Component refChild)  
      protected boolean isChildable()
      Child is allowed, Caption only.
      boolean isClosable()
      Returns whether this tab is closable.
      boolean isDisabled()
      Returns whether this tab is disabled.
      boolean isSelected()
      Returns whether this tab is selected.
      void onChildRemoved​(org.zkoss.zk.ui.Component child)  
      void onClose()
      Process the onClose event sent when the close button is pressed.
      void onCreate​(org.zkoss.zk.ui.event.Event evt)
      Internal use only
      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 setClosable​(boolean closable)
      Sets whether this tab is closable.
      void setDisabled​(boolean disabled)
      Sets whether this tab is disabled.
      void setSelected​(boolean selected)
      Sets whether this tab is selected.
      <T> void setValue​(T value)
      Sets the value.
      void setWidth​(java.lang.String width)  
      • Methods inherited from class org.zkoss.zk.ui.HtmlBasedComponent

        addSclass, evalCSSFlex, focus, getAction, getClientAction, getDraggable, getDroppable, getHeight, getHflex, getLeft, getRenderdefer, getSclass, getStyle, getTabindex, getTabindexInteger, getTooltiptext, getTop, getVflex, getWidth, getZindex, getZIndex, removeSclass, removeSclass, setAction, setClass, setClientAction, setDraggable, setDroppable, setFocus, setHeight, setHeight0, setHeightDirectly, setHflex, setHflex0, setHflexDirectly, setLeft, setLeftDirectly, setRenderdefer, setSclass, setStyle, setTabindex, setTabindex, setTooltiptext, setTop, setTopDirectly, setVflex, setVflex0, setVflexDirectly, setWidth0, setWidthDirectly, setZclass, setZindex, setZIndex, setZIndexDirectly
      • Methods inherited from class org.zkoss.zk.ui.AbstractComponent

        addAnnotation, addCallback, addClientEvent, addEventHandler, addEventListener, addEventListener, addForward, addForward, addForward, addForward, addMoved, addRedrawCallback, addScopeListener, addShadowRoot, addShadowRootBefore, addSharedEventHandlerMap, appendChild, applyProperties, beforeChildRemoved, destroyIndexCacheMap, detach, didActivate, didActivate, didDeserialize, didDeserialize, disableBindingAnnotation, disableClientUpdate, disableHostChanged, enableBindingAnnotation, enableHostChanged, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, 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, getForwards, getId, getIndexCacheMap, getLastChild, getMold, getNextSibling, getPage, getParent, getPreviousSibling, getRedrawCallback, getRoot, getShadowFellowIfAny, getShadowRoots, getShadowVariable, getShadowVariable, getShadowVariable0, getSpaceOwner, getSpecialRendererOutput, getStubonly, getSubBindingAnnotationCount, getTemplate, getTemplateNames, getUuid, getWidgetAttributeNames, getWidgetClass, getWidgetListener, getWidgetListenerNames, getWidgetOverride, getWidgetOverrideNames, hasAttribute, hasAttribute, hasAttribute, hasAttributeOrFellow, hasBindingAnnotation, hasFellow, hasFellow, hasSubBindingAnnotation, initIndexCacheMap, invalidate, isDisabledHostChanged, isInitialized, isInvalidated, isListenerAvailable, isVisible, onChildAdded, onPageAttached, onPageDetached, onParentChanged, onWrongValue, query, queryAll, redraw, redrawChildren, removeAttribute, removeAttribute, removeAttribute, removeCallback, removeChild, removeEventListener, removeForward, removeForward, removeRedrawCallback, removeScopeListener, removeShadowRoot, render, render, render, renderPropertiesOnly, 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, setVisible, setVisibleDirectly, setWidgetClass, setWidgetListener, setWidgetOverride, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdateWidgetListener, smartUpdateWidgetOverride, toString, updateByClient, updateSubBindingAnnotationCount, willPassivate, willPassivate, willSerialize, willSerialize
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Tab

        public Tab()
      • Tab

        public Tab​(java.lang.String label)
      • Tab

        public Tab​(java.lang.String label,
                   java.lang.String image)
    • Method Detail

      • getValue

        public <T> T getValue()
        Returns the value.

        Default: null.

        Note: the value is application dependent, you can place whatever value you want.

        Since:
        7.0.0
      • setValue

        public <T> void setValue​(T value)
        Sets the value.
        Parameters:
        value - the value.

        Note: the value is application dependent, you can place whatever value you want.

        Since:
        7.0.0
      • getCaption

        public Caption getCaption()
        Returns the caption of this tab.
        Since:
        6.5.0
      • setWidth

        public void setWidth​(java.lang.String width)
        Overrides:
        setWidth in class org.zkoss.zk.ui.HtmlBasedComponent
      • isClosable

        public boolean isClosable()
        Returns whether this tab is closable. If closable, a button is displayed and the onClose event is sent if a user clicks the button.

        Default: false.

      • setClosable

        public void setClosable​(boolean closable)
        Sets whether this tab is closable. If closable, a button is displayed and the onClose event is sent if a user clicks the button.

        Default: false.

        You can intercept the default behavior by either overriding onClose(), or listening the onClose event.

        If Tabbox.getModel() is assigned, there is no an action to do with onClose(), i.e. developer has to listen onClose event to delete that item in model not component itself. (since 7.0.0)

      • onClose

        public void onClose()
        Process the onClose event sent when the close button is pressed.

        Default: invoke close() to detach itself and the corresponding Tabpanel.

      • close

        public void close()
        Closes this tab and the linked tabpanel. This method detaches this component and the linked Tabpanel), only if Tabbox.getModel() is null. (since 7.0.0)
        Since:
        5.0.0
      • getTabbox

        public Tabbox getTabbox()
        Returns the tabbox owns this component.
      • getLinkedPanel

        public Tabpanel getLinkedPanel()
        Returns the panel associated with this tab.
      • isSelected

        public boolean isSelected()
        Returns whether this tab is selected.
      • setSelected

        public void setSelected​(boolean selected)
        Sets whether this tab is selected.
      • isDisabled

        public boolean isDisabled()
        Returns whether this tab is disabled.

        Default: false.

        Since:
        3.0.0
      • setDisabled

        public void setDisabled​(boolean disabled)
        Sets whether this tab is disabled. If a tab is disabled, then it cann't be selected or closed by user, but it still can be controlled by server side program.
        Since:
        3.0.0
      • getIndex

        public int getIndex()
        Returns the index of this panel, or -1 if it doesn't belong to any tabs.
      • getZclass

        public java.lang.String getZclass()
        Overrides:
        getZclass in class org.zkoss.zk.ui.HtmlBasedComponent
      • isChildable

        protected boolean isChildable()
        Child is allowed, Caption only.
        Overrides:
        isChildable in class org.zkoss.zk.ui.AbstractComponent
        Since:
        6.5.0
      • beforeChildAdded

        public void beforeChildAdded​(org.zkoss.zk.ui.Component child,
                                     org.zkoss.zk.ui.Component refChild)
        Specified by:
        beforeChildAdded in interface org.zkoss.zk.ui.sys.ComponentCtrl
        Overrides:
        beforeChildAdded in class org.zkoss.zk.ui.AbstractComponent
      • onCreate

        public void onCreate​(org.zkoss.zk.ui.event.Event evt)
        Internal use only
        Since:
        6.5.0
      • insertBefore

        public boolean insertBefore​(org.zkoss.zk.ui.Component child,
                                    org.zkoss.zk.ui.Component refChild)
        Specified by:
        insertBefore in interface org.zkoss.zk.ui.Component
        Overrides:
        insertBefore in class org.zkoss.zk.ui.AbstractComponent
      • onChildRemoved

        public void onChildRemoved​(org.zkoss.zk.ui.Component child)
        Specified by:
        onChildRemoved in interface org.zkoss.zk.ui.sys.ComponentCtrl
        Overrides:
        onChildRemoved in class org.zkoss.zk.ui.AbstractComponent
      • beforeParentChanged

        public void beforeParentChanged​(org.zkoss.zk.ui.Component parent)
        Specified by:
        beforeParentChanged in interface org.zkoss.zk.ui.sys.ComponentCtrl
        Overrides:
        beforeParentChanged in class org.zkoss.zk.ui.AbstractComponent
      • clone

        public java.lang.Object clone()
        Specified by:
        clone in interface org.zkoss.zk.ui.Component
        Overrides:
        clone in class LabelImageElement
      • service

        public void service​(org.zkoss.zk.au.AuRequest request,
                            boolean everError)
        Processes an AU request.

        Default: in addition to what are handled by HtmlBasedComponent.service(org.zkoss.zk.au.AuRequest, boolean), it also handles onSelect.

        Specified by:
        service in interface org.zkoss.zk.ui.sys.ComponentCtrl
        Overrides:
        service in class org.zkoss.zk.ui.HtmlBasedComponent
        Since:
        5.0.0
      • renderProperties

        protected void renderProperties​(org.zkoss.zk.ui.sys.ContentRenderer renderer)
                                 throws java.io.IOException
        Overrides:
        renderProperties in class LabelImageElement
        Throws:
        java.io.IOException