Class AbstractComponent

    • Constructor Detail

      • AbstractComponent

        public AbstractComponent()
        Constructs a component with auto-generated ID.
        Since:
        3.0.7 (becomes public)
      • AbstractComponent

        protected AbstractComponent​(boolean useless)
        Constructs a dummy component that is not associated with any component definition.
        Parameters:
        useless - an useless argument (it is ignored but used to distinguish the default constructor)
        Since:
        6.0.0
    • Method Detail

      • getDesktop

        public Desktop getDesktop()
        Description copied from interface: Component
        Returns the desktop of this component, or null if this component doesn't belong to any desktop.

        When a component is created in an event listener, it is assigned to the current desktop automatically. If a component is created not in any event listener, it doesn't belong to any desktop and this method returns null. Once a component is attached to a desktop (by use of Component.setPage(org.zkoss.zk.ui.Page) or Component.setParent(org.zkoss.zk.ui.Component)), it belongs to the desktop.

        Notice: there is no way to detach a component from a desktop, once it is attached as described above. In other words, you cannot move a component (or page) from one desktop to another.

        In summary, there are only two ways to handle components.

        1. Handle them all in event listeners and don't access any components from other desktops. This is simplest and clearest.
        2. Creates components in another thread (other than event listener) and attach them to a page (and then desktop) upon an event is received.
        Specified by:
        getDesktop in interface Component
      • setPageBefore

        public void setPageBefore​(Page page,
                                  Component refRoot)
        Description copied from interface: Component
        Sets what page this component belongs to, and insert this component right before the reference component.

        For child components, the page they belong is maintained automatically. You need to invoke this method only for root components.

        It is similar to Component.setPage(org.zkoss.zk.ui.Page), except this component will be placed before the reference component. If the reference component is null, this component is placed at the end of all root components.

        Specified by:
        setPageBefore in interface Component
        refRoot - another root component used as a reference which this component will be placed before. If null, this component will be placed at the end of all root components (no matter whether it already belongs to the same page).
        See Also:
        Component.setPage(org.zkoss.zk.ui.Page)
      • addMoved

        protected void addMoved​(Component oldparent,
                                Page oldpg,
                                Page newpg)
        Called when this component is moved from the specified parent and/or page to the new page.

        Default: it notifies UiEngine to update the component at the client (usually remove-and-add).

        It is designed to let derived classes overriding this method to disable this update. However, you rarely need to override it. One possible but rare case: the component's visual part at the client updates the visual representation at the client and then notify the component at the server to update its children accordingly. In this case, it is redundant if we ask UI Engine to send the updates to client.

        Parameters:
        oldparent - the parent before moved. The new parent can be found by calling getParent().
        oldpg - the parent before moved.
        newpg - the new page. getPage() might return the old page.
      • getId

        public java.lang.String getId()
        Description copied from interface: Component
        Returns the ID.

        Default: "" (an empty string; it means no ID at all).

        If a component belongs to an ID space (see IdSpace), the ID must also be unique in the ID space it belongs. any its parent and ancestor implements IdSpace. If it is a root component (i.e., without any parent), its ID must be unique among root components of the same page.

        A page itself is also an ID space, so you could retrieve components in a page by use of IdSpace.getFellow(java.lang.String), unless the component is a descendant of another component that implements IdSpace. In this case, you have to retrieve the parent first (by use of IdSpace.getFellow(java.lang.String) and then use Component.getFellow(java.lang.String) against the owner of the ID space.

        In zscript and EL, a component with explicit ID can be accessed directly by the ID.

        Specified by:
        getId in interface Component
        See Also:
        Path
      • setId

        public void setId​(java.lang.String id)
        Description copied from interface: Component
        Sets the ID. The scope of uniqueness depends on whether this component is a root component. Refer to Component.getId() for more details.

        Default: "" (an empty string; it means no ID at all).

        Specified by:
        setId in interface Component
        Parameters:
        id - the identifier. You could specify null or an empty string to remove ID.
        See Also:
        Selectors
      • getUuid

        public java.lang.String getUuid()
        Description copied from interface: Component
        Returns UUID (universal unique ID) which is unique in the whole session. The UUID is generated automatically and immutable, unless RawId is also implemented.

        It is mainly used for communication between client and server and you rarely need to access it.

        If RawId is implemented as part of a component, UUID is the same as Component.getId() if Component.setId(java.lang.String) is ever called. It is designed to migrate HTML pages to ZK, such that the element ID could remain the same.

        Specified by:
        getUuid in interface Component
      • hasFellow

        public boolean hasFellow​(java.lang.String compId)
        Description copied from interface: Component
        Returns whether a fellow exists in the same ID space of this component.
        Specified by:
        hasFellow in interface Component
      • hasFellow

        public boolean hasFellow​(java.lang.String compId,
                                 boolean recurse)
        Description copied from interface: Component
        Returns whether there is a fellow named with the specified component ID in the same ID space as this component. It is the same as getSpaceOwner().hasFellow(id, recurse);
        Specified by:
        hasFellow in interface Component
        recurse - whether to look up the parent ID space for the existence of the fellow
      • getFellowIfAny

        public Component getFellowIfAny​(java.lang.String compId,
                                        boolean recurse)
        Description copied from interface: Component
        Returns a component of the specified ID in the same ID space, or null if not found. It is the same as getSpaceOwner().getFellowIfAny(id, recurse);

        Unlike Component.getFellow(String, boolean), it returns null if not found.

        Specified by:
        getFellowIfAny in interface Component
        recurse - whether to look up the parent ID space for the existence of the fellow
      • getFellows

        public java.util.Collection<Component> getFellows()
        Description copied from interface: Component
        Returns all fellows in the same ID space of this component. Notice that only components that are assigned with ID are considered as fellows. The returned collection is read-only.
        Specified by:
        getFellows in interface Component
      • getNextSibling

        public Component getNextSibling()
        Description copied from interface: Component
        Returns the next sibling, or null if it is the last child.
        Specified by:
        getNextSibling in interface Component
      • getPreviousSibling

        public Component getPreviousSibling()
        Description copied from interface: Component
        Returns the previous sibling, or null if it is the first child.
        Specified by:
        getPreviousSibling in interface Component
      • getFirstChild

        public Component getFirstChild()
        Description copied from interface: Component
        Returns the first child component, or null if no child at all.
        Specified by:
        getFirstChild in interface Component
      • getLastChild

        public Component getLastChild()
        Description copied from interface: Component
        Returns the last child component, or null if no child at all.
        Specified by:
        getLastChild in interface Component
      • setWidgetListener

        public java.lang.String setWidgetListener​(java.lang.String evtnm,
                                                  java.lang.String script)
        Description copied from interface: Component
        Sets or removes an event listener of the peer widget. If there is an event listener associated with the same event, the previous one will be replaced and returned.
        Specified by:
        setWidgetListener in interface Component
        Parameters:
        evtnm - the event name, such as onClick
        script - the script to handle the event. If null, the event handler is removed.
        Returns:
        the previous script if any
      • getWidgetListener

        public java.lang.String getWidgetListener​(java.lang.String evtnm)
        Description copied from interface: Component
        Returns the script of the client event, or null if not found.
        Specified by:
        getWidgetListener in interface Component
      • getWidgetListenerNames

        public java.util.Set<java.lang.String> getWidgetListenerNames()
        Description copied from interface: Component
        Returns a read-only collection of event names (String) that the listener of the peer widget are assigned, or an empty collection if none is registered.
        Specified by:
        getWidgetListenerNames in interface Component
      • setWidgetOverride

        public java.lang.String setWidgetOverride​(java.lang.String name,
                                                  java.lang.String script)
        Description copied from interface: Component
        Sets or removes a method or a property of the peer widget (at the client). If there is a method or a property associated with the same name, the previous one will be replaced and returned.

        For example,

        comp.setWidgetOverride("setValue", "function (value) {}"); //override a method
        comp.setWidgetOverride("myfield", "new Date()"); //override a property
        

        If there is no previous method or property, the method/property will be assigned directly.

        Notice that, unlike Component.setWidgetListener(java.lang.String, java.lang.String), if the method has been sent to the client for update, it cannot be removed by calling this method with a null value. In other words, invoking this method with a null value only removes the method overrides if it has not YET been to sent to the client.

        The previous method/property can be accessed by this.$xxx. For example

        function (value, fromServer) {
          this.$setValue(value, fromServer);
          if (this.desktop) {
            this._cnt = !this._cnt;
            this.setStyle('background:'+(this._cnt ? 'red':'green'));
          }
        }

        Notice that, since it is not extending, so this.$super references the superclass's method, rather than the old method.

        Specified by:
        setWidgetOverride in interface Component
        Parameters:
        name - the property name to override, such as setValue and miles.
        script - the method definition, such as function (arg) {...}, or a value, such as 123 and new Date(). If not null, this method will be added to the peer widget. If there was a method with the same name, it will be renamed to $name so can you call it back.
        <label w:setValue="function (value) {
          this.$setValue(value); //old method
        }"/>
        If null, the previous method, if any, will be restored.
        Returns:
        the previous script if any
      • getWidgetOverride

        public java.lang.String getWidgetOverride​(java.lang.String name)
        Description copied from interface: Component
        Returns the script of the method definition to override widget's method, or null if not found.
        Specified by:
        getWidgetOverride in interface Component
      • getWidgetOverrideNames

        public java.util.Set<java.lang.String> getWidgetOverrideNames()
        Description copied from interface: Component
        Returns a read-only collection of the property names (String) that shall be overridden, or an empty collection if none is registered.
        Specified by:
        getWidgetOverrideNames in interface Component
      • setWidgetAttribute

        public java.lang.String setWidgetAttribute​(java.lang.String name,
                                                   java.lang.String value)
        Specified by:
        setWidgetAttribute in interface Component
      • getWidgetAttribute

        public java.lang.String getWidgetAttribute​(java.lang.String name)
        Specified by:
        getWidgetAttribute in interface Component
      • getClientAttribute

        public java.lang.String getClientAttribute​(java.lang.String name)
        Description copied from interface: Component
        Returns the value of a DOM attribute
        Specified by:
        getClientAttribute in interface Component
      • setClientDataAttribute

        public java.lang.String setClientDataAttribute​(java.lang.String name,
                                                       java.lang.String value)
        Description copied from interface: Component
        Sets a DOM data attribute of the peer widget (at the client). If it has previous value, the component will invalidate. ZK pass the attributes directly to the DOM attribute generated at the client.

        Notice that the parameter - name would be expanded by adding the prefix "data-" automatically.

        Specified by:
        setClientDataAttribute in interface Component
        Parameters:
        name - the attribute name to generate to the DOM element, such as mask.
        value - the value of the attribute. It could be anything depending on the attribute. If null, the attribute will be removed. Make sure to specify an empty string if you want an attribute with an empty value.
        Returns:
        the previous value if any
        See Also:
        Component.setClientDataAttribute(String, String)
      • getAttribute

        public java.lang.Object getAttribute​(java.lang.String name,
                                             boolean recurse)
        Description copied from interface: Scope
        Returns the custom attribute associated with this object.
        Specified by:
        getAttribute in interface Scope
        recurse - whether to search its ancestor scope. If true and the current scope doen't define the attribute, it searches up its ancestor to see any of them has defined the specified attribute.
      • hasAttribute

        public boolean hasAttribute​(java.lang.String name,
                                    boolean recurse)
        Description copied from interface: Scope
        Returns if a custom attribute is associated with this object.

        Notice that null is a valid value, so you can tell if an attribute is associated by examining the return value of Scope.getAttribute(java.lang.String).

        Specified by:
        hasAttribute in interface Scope
        recurse - whether to search its ancestor scope. If true and the current scope doen't define the attribute, it searches up its ancestor to see any of them has defined the specified attribute.
      • setAttribute

        public java.lang.Object setAttribute​(java.lang.String name,
                                             java.lang.Object value)
        Description copied from interface: Component
        Sets the custom attribute associated with this component, i.e., Component.COMPONENT_SCOPE.
        Specified by:
        setAttribute in interface Component
        Specified by:
        setAttribute in interface Scope
        Returns:
        the previous value associated with the attribute, if any
      • setAttribute

        public java.lang.Object setAttribute​(java.lang.String name,
                                             java.lang.Object value,
                                             boolean recurse)
        Description copied from interface: Scope
        Sets the custom attribute associated with this scope, or the parent scope.
        Specified by:
        setAttribute in interface Scope
        recurse - whether to look up the parent scope for the existence of the attribute.
        If recurse is true and the attribute is defined in one of its ancestor (including page), the attribute is replaced. Otherwise, it is the same as Scope.setAttribute(String,Object).
      • removeAttribute

        public java.lang.Object removeAttribute​(java.lang.String name)
        Description copied from interface: Component
        Removes the custom attribute associated with this component, i.e., Component.COMPONENT_SCOPE.
        Specified by:
        removeAttribute in interface Component
        Specified by:
        removeAttribute in interface Scope
        Returns:
        the previous value associated with the attribute, if any,
      • removeAttribute

        public java.lang.Object removeAttribute​(java.lang.String name,
                                                boolean recurse)
        Description copied from interface: Scope
        Removes the custom attribute associated with this scope.
        Specified by:
        removeAttribute in interface Scope
        recurse - whether to look up the parent scope for the existence of the attribute.
        If recurse is true and the attribute is defined in one of its ancestor (including page), the attribute is removed. Otherwise, it is the same as Scope.removeAttribute(String).
      • getAttributeOrFellow

        public java.lang.Object getAttributeOrFellow​(java.lang.String name,
                                                     boolean recurse)
        Description copied from interface: Component
        Returns the custom attribute associated with this component, or the fellow of this component; or null if not found.

        Notice that it doesn't check any variable defined in VariableResolver (of Page.addVariableResolver(org.zkoss.xel.VariableResolver)).

        Specified by:
        getAttributeOrFellow in interface Component
        recurse - whether to look up the parent component for the existence of the attribute.
        Notice that, if recurse is false and this component is not an ID space owner, it won't look at the fellow.
        If recurse is true, it will look up all parents, page, desktop, session and application until found. If any of them is a space owner, the fellows will be searched.
      • getShadowVariable

        public java.lang.Object getShadowVariable​(java.lang.String name,
                                                  boolean recurse)
        Description copied from interface: Component
        Returns the shadow variable associated with this component or its parent component; or null if not found.

        Notice that it doesn't check any variable defined in VariableResolver (of Page.addVariableResolver(org.zkoss.xel.VariableResolver)).

        Specified by:
        getShadowVariable in interface Component
        recurse - whether to look up the parent component for the existence of the shadow variable.
        If recurse is true, it will look up all parents until found. If any of them is a shadow host.
      • getShadowVariable

        public java.lang.Object getShadowVariable​(Component baseChild,
                                                  java.lang.String name,
                                                  boolean recurse)
        Description copied from interface: Component
        Returns the shadow variable enclosed with the base component, which associated with this component or its parent component; or null if not found.

        Notice that it doesn't check any variable defined in VariableResolver (of Page.addVariableResolver(org.zkoss.xel.VariableResolver)).

        Specified by:
        getShadowVariable in interface Component
        Parameters:
        baseChild - the base component to seek the variable.
        recurse - whether to look up the parent component for the existence of the shadow variable.
        If recurse is true, it will look up all parents until found. If any of them is a shadow host.
        See Also:
        Component.getShadowVariable(String, boolean)
      • getShadowVariable0

        protected java.lang.Object getShadowVariable0​(Component baseChild,
                                                      java.lang.String name,
                                                      boolean recurse)
      • hasAttributeOrFellow

        public boolean hasAttributeOrFellow​(java.lang.String name,
                                            boolean recurse)
        Description copied from interface: Component
        Returns if a custom attribute is associated with this component, or the fellow of this component.

        Notice that it doesn't check any variable defined in VariableResolver (of Page.addVariableResolver(org.zkoss.xel.VariableResolver)).

        Specified by:
        hasAttributeOrFellow in interface Component
        recurse - whether to look up the parent component for the existence of the attribute.
        Notice that, if recurse is false and this component is not an ID space owner, it won't look at the fellow.
        If recurse is true, it will look up all parents, page, desktop, session and application until found. If any of them is a space owner, the fellows will be searched.
      • addScopeListener

        public boolean addScopeListener​(ScopeListener listener)
        Description copied from interface: Scope
        Adds a listener to listen whether this scope is changed. The listener is called when a custom attribute is added, removed, or the parent is changed.
        Specified by:
        addScopeListener in interface Scope
        Returns:
        weather the listener is added successfully. Note: if the resolver was added before, it won't be added again and this method returns false.
      • removeScopeListener

        public boolean removeScopeListener​(ScopeListener listener)
        Description copied from interface: Scope
        Removes a change listener from this scope.
        Specified by:
        removeScopeListener in interface Scope
        Returns:
        false if listener is not added before.
      • getAutag

        public java.lang.String getAutag()
        Description copied from interface: Component
        Returns the AU tag for this widget. The AU tag tag is used to tag the AU requests sent by the peer widget. For instance, if the AU tag is xxx,yyy and the desktop's request path (Desktop.getRequestPath()) is /foo.zul, then the URL of the AU request will contain /_/foo.zul/xxx,yyy,.

        Default: null (no AU tag for this widget).

        Specified by:
        getAutag in interface Component
        See Also:
        Component.setAutag(java.lang.String)
      • setAutag

        public void setAutag​(java.lang.String tag)
        Description copied from interface: Component
        Sets the AU tag for this widget. The AU tag tag is used to tag the AU requests sent by the peer widget.
        Specified by:
        setAutag in interface Component
        Parameters:
        tag - the AU tag. Both an empty string and null are considered as null, i.e., no AU tag for this widget.
        See Also:
        Component.getAutag()
      • getParent

        public Component getParent()
        Description copied from interface: Component
        Returns the parent component, or null if this is the root component.
        Specified by:
        getParent in interface Component
      • replace

        protected void replace​(Component comp,
                               boolean bFellow,
                               boolean bListener,
                               boolean bChildren)
        Replace the specified component with this component in the component tree. In other words, the parent of the given component will become the parent of this components, so are siblings and children. Furthermore, comp will be detached at the end.

        Notice that the replacement won't change anything at the client. It is the caller'job to maintain the consistency between the server and the client.

        This method is rarely used.

        Parameters:
        comp - the component. In this implementation it supports only derived classes of AbstractComponent.
        bFellow - whether to add this component to the map of fellows if it is assigned with an ID. If false, the component (comp) cannot be retrieved back even with an ID (note: ID is always preserved).
        bListener - whether to retain the event listeners and handlers. If true, the event listeners and handlers, if any, will be registered to this stub component. In other words, the event will be processed. However, it is a stub component, rather than the original one. I means the event is the most generic format: an instance of Event (rather than MouseEvent or others).
        bChildren - whether to have the children of the given component.
        If false, this component won't have any children, and all UUID of children reference back to this component.
        If true, the given component's children will belong to this component.
        Throws:
        java.lang.IllegalStateException - if this component has a parent, sibling or child.
        Since:
        6.0.0
      • isChildable

        protected boolean isChildable()
        Returns whether this component can have a child.

        Default: return true (means it can have children).

      • getChildren

        public <T extends Component> java.util.List<T> getChildren()
        Returns a live list of children. By live we mean the developer could add or remove a child by manipulating the returned list directly.

        Default: instantiates and returns an instance of AbstractComponent.Children.

        Specified by:
        getChildren in interface Component
      • getRoot

        public Component getRoot()
        Returns the root of the specified component.
        Specified by:
        getRoot in interface Component
      • setVisible

        public boolean setVisible​(boolean visible)
        Description copied from interface: Component
        Sets whether this component is visible. A component is visible by default. Both visible and invisible components are rendered in a browser's DOM. But an invisible component's DOM elements with CSS display:none. Since a DOM element will inherit its parent's CSS rules, a component is visible only if all of its parents are also visible.
        To remove a component's DOM elements, use Component.detach().
        Specified by:
        setVisible in interface Component
        Returns:
        the previous visibility
      • setVisibleDirectly

        protected void setVisibleDirectly​(boolean visible)
        Changes the visibility directly without sending any update to the client. It is the caller's responsibility to maintain the consistency. It is rarely called. In most cases, you shall use setVisible(boolean) instead.
        Since:
        5.0.4
      • getStubonly

        public java.lang.String getStubonly()
        Description copied from interface: Component
        Returns whether this component is stub-only. By stub-only, we mean we don't need to maintain the states of the component at the server side.

        There are three possible values: "true", "false", and "inherit", and "ignore-native".

        Notice that the native components will be stub-ized, no matter this property is set. Though rarely required, you could control whether to stub-ize the native components with a component attribute called Attributes.STUB_NATIVE.

        Specified by:
        getStubonly in interface Component
      • setStubonly

        public void setStubonly​(java.lang.String stubonly)
        Description copied from interface: Component
        Sets whether this component is stub-only. By stub-only, we mean we don't need to maintain the states of the component at the server side.

        Default: "inherit" (i.e., the same as the parent's stub-only, and "false" is assumed if none of parents is specified with stub-only).

        If a component is set to stub-only, the application running at the server shall not access it anymore after rendered to the client. The ZK loader will try to minimize the memory footprint by merging stub-only components and replacing with light-weight components.

        However, the event listeners and handlers are preserved, so they will be invoked if the corresponding event is received. Since the original component is gone, the event is the more generic format: an instance of Event (rather than MouseEvent or others).

        If a component is stub-only, the application usually access it only at the client since all widgets are preserved at the client (so are events).

        This method is available only for ZK EE.

        Specified by:
        setStubonly in interface Component
        Parameters:
        stubonly - whether it is stub-only. The allowed values include "true", "false" and "inherit".
      • setStubonly

        public void setStubonly​(boolean stubonly)
        Description copied from interface: Component
        Sets whether this component is stub-only. It is the same as setStubonly(stubonly ? "true": "false").
        Specified by:
        setStubonly in interface Component
      • isInvalidated

        public boolean isInvalidated()
        Description copied from interface: Component
        Returns if this component needs to be redrawn at the client.

        Application developers rarely need to call this method.

        Note:

        1. It always returns true if it doesn't belong to any page (since redraw is required if it is attached to a page later).
        2. It always returns true if the current execution is not an asynchronous update (so redrawn is always required).
        3. If its parent is invalidated, this component will be redrawn too, but this method returns false if Component.invalidate() was not called against this component.
        Specified by:
        isInvalidated in interface Component
      • invalidate

        public void invalidate()
        Description copied from interface: Component
        Invalidates this component by setting the dirty flag such that it will be redraw the whole content of this component and its dependencies later. And, the widget associated with this component and all its descendant at the client will be deleted and recreated, too.

        If the application is totally controlled by the server side (i.e., you don't write client codes), you rarely need to access this method.

        It can be called only in the request-processing and event-processing phases. However, it is NOT allowed in the rendering phase.

        Specified by:
        invalidate in interface Component
      • invalidatePartial

        public void invalidatePartial()
        Description copied from interface: ComponentCtrl
        Invalidates this component by setting the dirty flag such that it will be redraw the partial content of this component and its dependencies later. And, the widget associated with this component and all its descendant at the client will be deleted and recreated, too.

        If the application is totally controlled by the server side (i.e., you don't write client codes), you rarely need to access this method.

        It can be called only in the request-processing and event-processing phases. However, it is NOT allowed in the rendering phase.

        Specified by:
        invalidatePartial in interface ComponentCtrl
      • response

        protected void response​(AuResponse response)
        Causes a response to be sent to the client. It is the same as response(response.getOverrideKey(), response)

        If AuResponse.getDepends() is not null, the response depends on the existence of the component returned by AuResponse.getDepends(). In other words, the response is removed if the component is removed. If it is null, the response is component-independent and it is always sent to the client.

        Unlike smartUpdate(java.lang.String, java.lang.Object), responses are sent even if Component.invalidate() was called. Typical examples include setting the focus, selecting the text and so on.

        It can be called only in the request-processing and event-processing phases; excluding the redrawing phase.

        Since:
        5.0.2
        See Also:
        response(String, AuResponse)
      • response

        protected void response​(java.lang.String key,
                                AuResponse response)
        Causes a response to be sent to the client by overriding the key returned by AuResponse.getOverrideKey()).

        If AuResponse.getDepends() is not null, the response depends on the existence of the component returned by AuResponse.getDepends(). In other words, the response is removed if the component is removed. If it is null, the response is component-independent and it is always sent to the client.

        Unlike smartUpdate(java.lang.String, java.lang.Object), responses are sent even if Component.invalidate() was called. Typical examples include setting the focus, selecting the text and so on.

        It can be called only in the request-processing and event-processing phases; excluding the redrawing phase.

        Parameters:
        key - could be anything. The second invocation of this method in the same execution with the same key and the same depends (AuResponse.getDepends()) will override the previous one. However, if key is null, it won't override any other. All responses with key == null will be sent.
        Notice that if AuResponse.getDepends() is null, then be careful of the key you used since it is shared in the same execution (rather than a particular component).
        Since:
        5.0.0 (become protected)
      • response

        protected void response​(java.lang.String key,
                                AuResponse response,
                                int priority)
        Causes a response to be sent to the client by overriding the key returned by AuResponse.getOverrideKey()).

        If AuResponse.getDepends() is not null, the response depends on the existence of the component returned by AuResponse.getDepends(). In other words, the response is removed if the component is removed. If it is null, the response is component-independent and it is always sent to the client.

        Unlike smartUpdate(java.lang.String, java.lang.Object), responses are sent even if Component.invalidate() was called. Typical examples include setting the focus, selecting the text and so on.

        It can be called only in the request-processing and event-processing phases; excluding the redrawing phase.

        Parameters:
        key - could be anything. The second invocation of this method in the same execution with the same key and the same depends (AuResponse.getDepends()) will override the previous one. However, if key is null, it won't override any other. All responses with key == null will be sent.
        Notice that if AuResponse.getDepends() is null, then be careful of the key you used since it is shared in the same execution (rather than a particular component).
        priority - The higher priority, the earlier the update is executed. The priority of response(AuResponse) and response(String, AuResponse) is assumed to be 0.

        If the priority is the same, the update is executed in the order of first-in-first out.

        Since:
        6.0.1
      • smartUpdate

        protected void smartUpdate​(java.lang.String attr,
                                   java.lang.Object value)
        Smart-updates a property of the peer widget associated with the component, running at the client, with the given value.

        The second invocation with the same property will replace the previous call. In other words, the same property will be set only once in each execution. If you prefer to send both updates to the client, use smartUpdate(String, Object, boolean) instead.

        This method has no effect if invalidate() is ever invoked (in the same execution), since invalidate() assumes the whole content shall be redrawn and all smart updates to this components can be ignored,

        Once invalidate() is called, all invocations to smartUpdate(String, Object) will then be ignored, and redraw(java.io.Writer) will be invoked later.

        It can be called only in the request-processing and event-processing phases; excluding the redrawing phase.

        There are two ways to draw a component, one is to invoke Component.invalidate(), and the other is smartUpdate(String, Object). While Component.invalidate() causes the whole content to redraw, smartUpdate(String, Object) let component developer control which part to redraw.

        Parameters:
        value - the new value. If it is DeferredValue, the value will be retrieved (by calling DeferredValue.getValue()) in the rendering phase. It is useful if the value can not be determined now.

        For some old application servers (example, Websphere 5.1), Execution.encodeURL(java.lang.String) cannot be called in the event processing thread. So, the developers have to use DeferredValue or disable the use of the event processing thread (by use of disable-event-thread in zk.xml).

        If you want to generate the JavaScript code directly (i.e., the value is a valid JavaScript snippet), you can use JavaScriptValue. Notice that the JavaScript code will be evaluated before assigning it to the widget.

        If the value is a Date object, a special pattern will be generated (a.k.a., marshaling) to ensure it can be unmarshalled back correctly at the client. Notice that it is marshalled to a string based on TimeZones.getCurrent(), and then unmarshalled back at the client. In other words, if the client is in different time-zone, the value returned by getTime() might be different. However, the value will remain the same if the client marshalled the Date object back. In other words, it assumes the browser's time zone from enduser's perspective (not really browser's setting) shall be the same as TimeZones.getCurrent().

        If the value is a component, a special pattern will be generated to ensure it can be unmarshalled back correctly at the client.

        In addition, the value can be any kind of objects that the client accepts (marshaled by JSON) (see also JSONAware).

        Since:
        5.0.0 (become protected)
        See Also:
        updateByClient(java.lang.String, java.lang.Object), smartUpdate(String, Object, boolean)
      • smartUpdate

        protected void smartUpdate​(java.lang.String attr,
                                   java.lang.Object value,
                                   boolean append)
        Smart-updates a property of the peer widget with the given value that allows caller to decide whether to append or overwrite. In other words, smartUpdate(String, Object) is a shortcut of smartUpdate(attr, value, false).

        For example, if you invoke smartUpdate("attr", "value1") and smartUpdate("attr", "value2"), then only value2 will be sent to the client.

        However, if you invoke smartUpdate("attr", "value1", true) and smartUpdate("attr", "value2", true), then both value1 and value2 will be sent to the client. In other words, wgt.setAttr("value1") and wgt.setAttr("value2") will be invoked at the client accordingly.

        Parameters:
        append - whether to append the updates of properties with the same name. If false, only the last value of the same property will be sent to the client.
        Since:
        5.0.0
        See Also:
        smartUpdate(String, Object)
      • smartUpdate

        protected void smartUpdate​(java.lang.String attr,
                                   int value)
        A special smart update to update a value in int.

        It is the same as smartUpdate(String, Object).

        Since:
        5.0.0
      • smartUpdate

        protected void smartUpdate​(java.lang.String attr,
                                   long value)
        A special smart update to update a value in long.

        It is the same as smartUpdate(String, Object).

        Since:
        5.0.0
      • smartUpdate

        protected void smartUpdate​(java.lang.String attr,
                                   byte value)
        A special smart update to update a value in byte.

        It is the same as smartUpdate(String, Object).

        Since:
        5.0.0
      • smartUpdate

        protected void smartUpdate​(java.lang.String attr,
                                   char value)
        A special smart update to update a value in character.

        It is the same as smartUpdate(String, Object).

        Since:
        5.0.0
      • smartUpdate

        protected void smartUpdate​(java.lang.String attr,
                                   boolean value)
        A special smart update to update a value in boolean.

        It is the same as smartUpdate(String, Object).

        Since:
        5.0.0
      • smartUpdate

        protected void smartUpdate​(java.lang.String attr,
                                   float value)
        A special smart update to update a value in float.

        It is the same as smartUpdate(String, Object).

        Since:
        5.0.0
      • smartUpdate

        protected void smartUpdate​(java.lang.String attr,
                                   double value)
        A special smart update to update a value in double.

        It is the same as smartUpdate(String, Object).

        Since:
        5.0.0
      • smartUpdateWidgetListener

        protected void smartUpdateWidgetListener​(java.lang.String evtnm,
                                                 java.lang.String script)
        A special smart update to update an event listener for the peer widget. By default, it assumes the peer widget has a method called setListener and it will be invoked as follows.
        wgt.setListener([evtnm, script]);

        Devices that supports it in another way have to override this method. Devices that don't support it have to override this method to throw UnsupportedOperationException.

        Parameters:
        evtnm - the event name, such as onClick
        script - the script. If null, it means to remove the event listener from the peer widget
        Since:
        5.0.0
      • smartUpdateWidgetOverride

        protected void smartUpdateWidgetOverride​(java.lang.String name,
                                                 java.lang.String script)
        A special smart update to update a method or a field of the peer widget. By default, it invokes the client widget's setOverride as follows.
        wgt.setOverride([name: script]);

        Devices that supports it in another way have to override this method. Devices that don't support it have to override this method to throw UnsupportedOperationException.

        Parameters:
        name - the method name, such as setValue
        script - the content of the method or field to override. Notice that it must be a valid JavaScript snippet. If null, the previous method/field override will be removed. And, the method/field defined in original widget will be restored.
        Since:
        5.0.0
      • setWidgetClass

        public void setWidgetClass​(java.lang.String wgtcls)
        Description copied from interface: Component
        Sets the widget class (a.k.a., the widget type). The widget class is a JavaScript class, including the package name. For example, "zul.wnd.Window".
        Specified by:
        setWidgetClass in interface Component
        Parameters:
        wgtcls - the widget's class name at the client side. If null (or empty), the default one is used (see Component.getWidgetClass()).
      • getMold

        public java.lang.String getMold()
        Description copied from interface: Component
        Returns the mold used to render this component.

        Default: "default"

        Since 5.0, the default can be overridden by specify a library property. For example, if the component's class name is org.zkoss.zul.Button, then you can override the default mold by specifying the property called "org.zkoss.zul.Button.mold" with the mold you want in zk.xml. For example,

        <library-property>
                <name>org.zkoss.zul.Button.mold</name>
                <value>trendy</value>
                </library-property>

        Notice that it doesn't affect the deriving classes. If you want to change the deriving class's default mold, you have to specify them explicitly, too.

        Specified by:
        getMold in interface Component
        See Also:
        ComponentDefinition
      • setMold

        public void setMold​(java.lang.String mold)
        Description copied from interface: Component
        Sets the mold to render this component.
        Specified by:
        setMold in interface Component
        Parameters:
        mold - the mold. If null or empty, "default" is assumed.
        See Also:
        ComponentDefinition
      • getSpecialRendererOutput

        protected java.lang.String getSpecialRendererOutput​(Component comp)
                                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • disableClientUpdate

        public boolean disableClientUpdate​(boolean disable)
        Description copied from interface: ComponentCtrl
        Sets whether to disable the update of the client widgets of this component and its descendants.

        By default, if a component is attached to a page, modifications that change the visual representation will be sent to the client to ensure the consistency.

        Though rarely needed, you can disable the synchronization of the visual representation, if you prefer to update the client in a batch or the modification is caused by the client.

        Notice:

        • Once disabled, it not only affects the synchronization of this component but also all its descendants.
        • The disable remains until the end of this execution (or the invocation of this method with false). In other words, it is enabled automatically in the next execution.
        • The updates, if any, before calling this method will still be sent to the client.
        • It does nothing, if there is no current execution.

        Also notice that, with Component.invalidate(), it is easy to synchronize the content of a component (and its descendants) to the client.

        Specified by:
        disableClientUpdate in interface ComponentCtrl
        Returns:
        whether it has been disabled before this invocation, i.e., the previous disable status
      • addCallback

        public boolean addCallback​(java.lang.String name,
                                   Callback callback)
        Description copied from interface: ComponentCtrl
        Adds a callback at component in specific name
        Specified by:
        addCallback in interface ComponentCtrl
      • removeCallback

        public boolean removeCallback​(java.lang.String name,
                                      Callback callback)
        Description copied from interface: ComponentCtrl
        Removes a callback for component by specific name.
        Specified by:
        removeCallback in interface ComponentCtrl
      • getCallback

        public java.util.Collection<Callback> getCallback​(java.lang.String name)
        Description copied from interface: ComponentCtrl
        Returns all of callbacks by specific name
        Specified by:
        getCallback in interface ComponentCtrl
      • redrawChildren

        protected void redrawChildren​(java.io.Writer out)
                               throws java.io.IOException
        Redraws children (and then recursively descendants).

        Default: it invokes redraw(java.io.Writer) for all its children.

        If a derived class renders only a subset of its children (such as paging/cropping), it could override redrawChildren(java.io.Writer).

        Throws:
        java.io.IOException
        Since:
        5.0.0
        See Also:
        redraw(java.io.Writer)
      • addEventListener

        public boolean addEventListener​(int priority,
                                        java.lang.String evtnm,
                                        EventListener<? extends Event> listener)
        Description copied from interface: Component
        Adds an event listener to specified event name for this component with the given priority.

        You could register listener to all components in the same page by use of Page.addEventListener(java.lang.String, org.zkoss.zk.ui.event.EventListener<? extends org.zkoss.zk.ui.event.Event>).

        Version Difference

        ZK 5.0 and earlier, the second registration is ignored if an event listener has been registered twice. However, since 6.0.0 and later, it won't be ignored. If a listener has been registered multiple times, it will be invoked multiple times.

        If you prefer to ignore the second registration, you could specify a library property called "org.zkoss.zk.ui.EventListener.duplicateIgnored" to true.

        Specified by:
        addEventListener in interface Component
        Parameters:
        priority - the priority of the event. The higher the priority is, the earlier it is invoked.
        Notice:
        • If the priority equals or is greater than 1000, the event listener will be invoked before the event handlers registered in a ZUML page (i.e., the onXxx attribute declared in ZUML). On the other hand, if the priority is lower than 1000, it is invoked after the ZUML's event handler.
        • The priority registered by Component.addEventListener(String, EventListener) is 0.
        • Applications shall not use the priority higher than 10,000 and lower than -10,000 since they are reserved for component development.
        evtnm - what event to listen (never null)
        Returns:
        whether the listener is added successfully
        See Also:
        Page.addEventListener(java.lang.String, org.zkoss.zk.ui.event.EventListener<? extends org.zkoss.zk.ui.event.Event>)
      • removeEventListener

        public boolean removeEventListener​(java.lang.String evtnm,
                                           EventListener<? extends Event> listener)
        Description copied from interface: Component
        Removes an event listener.
        Specified by:
        removeEventListener in interface Component
        Returns:
        whether the listener is removed; false if it was never added.
      • addForward

        public boolean addForward​(java.lang.String orgEvent,
                                  Component target,
                                  java.lang.String targetEvent)
        Description copied from interface: Component
        Adds a forward condition to forward the event received by this component to another component.

        Default: no forward condition at all.

        Once the condition is added, a event called targetEvent is posted to the target component, when this component receives the orginalEvent event.

        Specified by:
        addForward in interface Component
        Parameters:
        orgEvent - the original event that was received by this component. If null, "onClick" is assumed.
        target - the target component to receive the event. If null, the space owner Component.getSpaceOwner() is assumed. If null and the space owner is the page, the root component is assumed.
        targetEvent - the target event that the target component will receive. If null, it is the same as the original event.
        Returns:
        whether it is added successfully. It returns false if the condition was always added before.
        See Also:
        Component.removeForward(String, Component, String), Component.addForward(String, Component, String, Object)
      • addForward

        public boolean addForward​(java.lang.String orgEvent,
                                  java.lang.String targetPath,
                                  java.lang.String targetEvent)
        Description copied from interface: Component
        Adds a forward condition to forward the event received by this component to another component, specified with a path.

        Note: the target component is retrieved from the path, each time the event is received. Thus, you can reference to a component that is created later.

        Specified by:
        addForward in interface Component
        Parameters:
        orgEvent - the original event that was received by this component. If null, "onClick" is assumed.
        targetPath - the target component's path related to this component. If ".", this component is assumed. If null, the space owner is assumed. If null and the space owner is the page, the root component is assumed.
        targetEvent - the target event that the target component will receive. If null, it is the same as the original event.
        Returns:
        whether it is added successfully. It returns false if the condition was always added before.
        See Also:
        Component.addForward(String, Component, String), Component.removeForward(String, String, String)
      • addForward

        public boolean addForward​(java.lang.String orgEvent,
                                  java.lang.String targetPath,
                                  java.lang.String targetEvent,
                                  java.lang.Object eventData)
        Description copied from interface: Component
        Adds a forward condition to forward the event received by this component to another component of the specified path with extra event data.
        Specified by:
        addForward in interface Component
        eventData - the extra data that can be retrieve by Event.getData().
        See Also:
        Component.addForward(String, String, String)
      • removeForward

        public boolean removeForward​(java.lang.String orgEvent,
                                     java.lang.String targetPath,
                                     java.lang.String targetEvent)
        Description copied from interface: Component
        Removes a forward condition that was added by Component.addForward(String, String, String). If no such forward condition exists, nothing happens but return false.
        Specified by:
        removeForward in interface Component
        Parameters:
        orgEvent - the original event that was received by this component. It must be the same as the one passed to Component.addForward(String, Component, String).
        targetPath - the target component's path related to this component. If ".", this component is assumed. If null, the space owner is assumed. If null and the space owner is the page, the root component is assumed.
        targetEvent - the target event that the target component will receive. It must be the same as the one passed to Component.addForward(String, Component, String).
        Returns:
        whether the forward is removed successfully. It returns false if the forward condition is not found
        See Also:
        Component.addForward(String, String, String)
      • applyProperties

        public void applyProperties()
        Description copied from interface: Component
        Initializes the properties (a.k.a. members) based on what are defined in the component definition.

        This method is invoked automatically if a component is created by evaluating a ZUML page, i.e., if it is specified as an element of a ZUML page.

        On the other hand, if it is created manually (by program), developer might choose to invoke this method or not, depending whether he wants to initializes the component with the properties defined in the ZUML page (PageDefinition) and the language definition (LanguageDefinition).

        Notice that, since 5.0.7, custom-attributes are applied automatically in the constructor of AbstractComponent, so they are always available no matter this method is called or not.

        Specified by:
        applyProperties in interface Component
      • setDefinition

        public void setDefinition​(ComponentDefinition compdef)
        Description copied from interface: ComponentCtrl
        Sets the component definition.

        The component definition affects how a component behaves. Developers rarely need to call this method. If a wrong definition is assigned, the result is unpredictable (and hard to debug). It is mainly designed for developing tools.

        Specified by:
        setDefinition in interface ComponentCtrl
      • setDefinition

        public void setDefinition​(java.lang.String name)
        Description copied from interface: ComponentCtrl
        Sets the component definition by specifying the name.
        Specified by:
        setDefinition in interface ComponentCtrl
        Parameters:
        name - the name of the component definition
      • getAnnotation

        public Annotation getAnnotation​(java.lang.String propName,
                                        java.lang.String annotName)
        Description copied from interface: ComponentCtrl
        Returns the annotation associated with the definition of the specified property, or null if not available.

        If there are multiple annotation with the given name, this method will merge them before return. If you prefer to get all of them without merging, please use ComponentCtrl.getAnnotations(String, String) instead. For example,

        <textbox value="@bind(abc, param1=foo1) @bind(xyz, param2=foo2)">

        This method will return a single annotation with three attributes: value=xyz, param1=foo1 and param2=foo2. On the other hand, ComponentCtrl.getAnnotations(String, String) will return a two-element collections.

        Notice that the property is not limited the 'real' property. For example, the following statement is correct though button doesn't have setFoo method. And, you can retrieve it by use of this method (getAnnotation("foo", "bind"))

        <button foo="@bind(whatever=123)"/>

        Furthermore, you can declare it as custom-attribute. For example, the following is equivalent to the above.

        <button>
          <custom-attribute foo="@bind(whatever=123}">
        </button>
        Specified by:
        getAnnotation in interface ComponentCtrl
        Parameters:
        propName - the property name, e.g., "value". If null, this method returns the annotation(s) associated with this component (rather than a particular property).
        annotName - the annotation name
        See Also:
        ComponentCtrl.getAnnotations(String, String)
      • getAnnotations

        public java.util.Collection<Annotation> getAnnotations​(java.lang.String propName,
                                                               java.lang.String annotName)
        Description copied from interface: ComponentCtrl
        Returns the annotations associated with the definition of the specified property. It never returns null.

        Notice that the property is not limited the 'real' property. For example, the following statement is correct though button doesn't have setFoo method. And, you can retrieve it by use of this method (getAnnotation("foo", "bind"))

        <button foo="@bind(whatever=123)"/>

        Furthermore, you can declare it as custom-attribute. For example, the following is equivalent to the above.

        <button>
          <custom-attribute foo="@bind(whatever=123}">
        </button>
        Specified by:
        getAnnotations in interface ComponentCtrl
        Parameters:
        propName - the property name, e.g., "value". If null, this method returns the annotation(s) associated with this component (rather than a particular property).
        annotName - the annotation name
        See Also:
        ComponentCtrl.getAnnotation(String, String)
      • getAnnotations

        public java.util.Collection<Annotation> getAnnotations​(java.lang.String propName)
        Description copied from interface: ComponentCtrl
        Returns a read-only collection of all annotations (Annotation) associated with the specified property. It never returns null.
        Specified by:
        getAnnotations in interface ComponentCtrl
        Parameters:
        propName - the property name, e.g., "value". If null, this method returns the annotation(s) associated with this component (rather than a particular property).
      • getAnnotatedPropertiesBy

        public java.util.List<java.lang.String> getAnnotatedPropertiesBy​(java.lang.String annotName)
        Description copied from interface: ComponentCtrl
        Returns a read-only list of the names of the properties that are associated with the specified annotation (never null).
        Specified by:
        getAnnotatedPropertiesBy in interface ComponentCtrl
      • getAnnotatedProperties

        public java.util.List<java.lang.String> getAnnotatedProperties()
        Description copied from interface: ComponentCtrl
        Returns a read-only list of the name of properties that are associated at least one annotation (never null).
        Specified by:
        getAnnotatedProperties in interface ComponentCtrl
      • addAnnotation

        public void addAnnotation​(java.lang.String propName,
                                  java.lang.String annotName,
                                  java.util.Map<java.lang.String,​java.lang.String[]> annotAttrs)
        Description copied from interface: ComponentCtrl
        Adds an annotation to the specified property of this component.

        If the given property is null, the annotation is associated to this component, rather than a particular property.

        Unlike Java, you can add annotations dynamically, and each component has its own annotations.

        Specified by:
        addAnnotation in interface ComponentCtrl
        Parameters:
        propName - the property name. If null, the annotation is associated with the component (rather than a particular property).
        annotName - the annotation name (never null, nor empty).
        annotAttrs - a map of attributes, or null if no attribute at all. This method will make a copy of annotAttrs, so the caller can use it after the invocation.
      • sessionWillPassivate

        public void sessionWillPassivate​(Page page)
        Description copied from interface: ComponentCtrl
        Notification that the session, which owns this component, is about to be passivated (a.k.a., serialized).

        Note: only root components are notified by this method.

        Specified by:
        sessionWillPassivate in interface ComponentCtrl
      • sessionDidActivate

        public void sessionDidActivate​(Page page)
        Description copied from interface: ComponentCtrl
        Notification that the session, which owns this component, has just been activated (a.k.a., deserialized).

        Note: only root components are notified by this method.

        Specified by:
        sessionDidActivate in interface ComponentCtrl
      • getExtraCtrl

        public java.lang.Object getExtraCtrl()
        Returns the extra controls that tell ZK how to handle this component specially. It is used only by component developers.

        Default: null.

        Specified by:
        getExtraCtrl in interface ComponentCtrl
        Returns:
        null if no special handling required. If the component requires some special controls, it could return an object that implements one or several interfaces in the org.zkoss.zk.ui.ext.render package. For example, Cropper.
        See Also:
        ComponentCtrl.getExtraCtrl()
      • getPropertyAccess

        public PropertyAccess getPropertyAccess​(java.lang.String prop)
        Description copied from interface: ComponentCtrl
        Returns the corresponding property access object from the given property name, if any.
        Specified by:
        getPropertyAccess in interface ComponentCtrl
        Parameters:
        prop - the name of the property
        Returns:
        null it means not to support for the property name.
      • onWrongValue

        public WrongValueException onWrongValue​(WrongValueException ex)
        Notifies that an WrongValueException instance is thrown, and WrongValueException.getComponent() is this component. It is a callback and the component can store the error message, show up the custom information, or even 'eat' the exception.

        Default: does nothing but returns ex.

        Specified by:
        onWrongValue in interface ComponentCtrl
        Parameters:
        ex - the exception being thrown (never null)
        Returns:
        the exception to throw, or null to ignore the exception In most cases, just return ex
        Since:
        2.4.0
      • getAuService

        public AuService getAuService()
        Description copied from interface: Component
        Returns an AU service to process the AU request before the component's default handling.

        Default: null

        Specified by:
        getAuService in interface Component
      • getEventListenerMap

        public EventListenerMap getEventListenerMap()
        Description copied from interface: ComponentCtrl
        Returns the map of event handlers and listeners defined in this component. This method is rarely used, but it is useful if you'd like to retrieve the behavior of the event handling of this component (and if you don't have the reference to the component)
        Specified by:
        getEventListenerMap in interface ComponentCtrl
      • updateByClient

        protected void updateByClient​(java.lang.String name,
                                      java.lang.Object value)
        Called when the widget running at the client asks the server to update a value. The update is caused by an AU request named setAttr (by invoking zk.Widget's smartUpdate at client).

        By default, it does nothing but log a warning message, since it is not safe to allow the client to update a field arbitrary.

        However, if you'd like to allow the update for a particular component you could do one of the following

        1. For component developers: override this method to update the field directly. For example,
          protected void updateByClient(String name, Object value) {
                  if ("disabled".equals(name))
                          setDisabled(name, ((Boolean)value).booleanValue());
                  else
                          super.updateByClient(name, value);
        2. For application developers: set an attribute called org.zkoss.zk.ui.updateByClient to be true. Then, this method will use reflection to find out the setter to update the value. Nothing happens if the method is not found.
        3. Notice: this method will invoke disableClientUpdate(boolean) to disable any update to the client, when calling the setter.

          If you want to enable the client update for all instances of a given component (though not recommended for the security reason), you could refer to here.

          See also zk.Widget.smartUpdate().

        Since:
        5.0.0
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • clone

        public java.lang.Object clone()
        Description copied from interface: Component
        Clones the component. All of its children and descendants are cloned. Also, ID are preserved.
        Specified by:
        clone in interface Component
        Overrides:
        clone in class java.lang.Object
        Returns:
        the new component. Notice that it doesn't belong to any page, nor desktop. It doesn't have a parent, either.
      • getDefaultMold

        protected java.lang.String getDefaultMold​(java.lang.Class<? extends Component> klass)
        Returns the default mold for the given class.

        Default: check the library property called xxx.mold, where xxx is the name of the give class. If not found or empty, "default" is assumed.

        Subclass might override this method to use the default mold of the base class, such as

        
        protected String getDefaultMold(Class klass) {
           return super.getDefaultMold(Button.class);
        }
        Since:
        5.0.3
      • setTemplate

        public Template setTemplate​(java.lang.String name,
                                    Template template)
        Description copied from interface: Component
        Sets a UI template which could be retrieved later with Component.getTemplate(java.lang.String).
        Specified by:
        setTemplate in interface Component
        Parameters:
        name - the template's name. It cannot be empty or null.
        template - the template to assign. If it is null, the previous template, if any, will be removed
        Returns:
        the previous template, if any
      • getTemplateNames

        public java.util.Set<java.lang.String> getTemplateNames()
        Description copied from interface: Component
        Returns a readonly set of the names of all templates.
        Specified by:
        getTemplateNames in interface Component
      • query

        public Component query​(java.lang.String selector)
        Description copied from interface: Component
        Find the first component that matches the given CSS3 selector.
        Specified by:
        query in interface Component
        Parameters:
        selector - the CSS3 selector. For example, comp.query("#id div").
        Returns:
        the first matched component, or null if not found
        See Also:
        Component.queryAll(java.lang.String)
      • queryAll

        public java.lang.Iterable<Component> queryAll​(java.lang.String selector)
        Description copied from interface: Component
        Returns an iterable object for components that match the given CSS3 selector.

        Notice: this method traverses the whole component tree, only if you iterate through the whole iterable object. In other words, the performance is good, and you can iterate it find the object that matches your criteria.

        Specified by:
        queryAll in interface Component
        Parameters:
        selector - the CSS3 selector. For example, comp.queryAll("#id div").
        Returns:
        a list of all matched component, or an empty list if none is found.
        See Also:
        Component.query(java.lang.String)
      • initIndexCacheMap

        protected java.util.Map<Component,​java.lang.Integer> initIndexCacheMap​(Component host)
      • getIndexCacheMap

        protected java.util.Map<Component,​java.lang.Integer> getIndexCacheMap​(Component host)
      • destroyIndexCacheMap

        protected void destroyIndexCacheMap​(Component host)
      • isDisabledHostChanged

        protected boolean isDisabledHostChanged()
      • disableHostChanged

        protected void disableHostChanged()
      • enableHostChanged

        protected void enableHostChanged()
      • removeShadowRoot

        public boolean removeShadowRoot​(ShadowElement shadow)
        Description copied from interface: ComponentCtrl
        Removes the given shadow root from this host. (Shadow developer use only)
        Specified by:
        removeShadowRoot in interface ComponentCtrl
        Parameters:
        shadow - a shadow element
        Returns:
        true if child is removed successfully; false if it doesn't have the specified child
      • addShadowRoot

        public boolean addShadowRoot​(ShadowElement shadow)
        Description copied from interface: ComponentCtrl
        Adds the given shadow root from this host. (Shadow developer use only)
        Specified by:
        addShadowRoot in interface ComponentCtrl
        Parameters:
        shadow - a shadow element
        Returns:
        true if child is added successfully
      • addShadowRootBefore

        public boolean addShadowRootBefore​(ShadowElement shadow,
                                           ShadowElement insertBefore)
        Description copied from interface: ComponentCtrl
        Adds the given shadow root from this host. (Shadow developer use only)
        Specified by:
        addShadowRootBefore in interface ComponentCtrl
        Parameters:
        shadow - a shadow element
        insertBefore - the shadow before which you want the new child
        Returns:
        true if child is added successfully
      • hasBindingAnnotation

        public boolean hasBindingAnnotation()
        Description copied from interface: ComponentCtrl
        Returns whether the component itself has binding annotation or not. (Internal or component developer use only.)
        Specified by:
        hasBindingAnnotation in interface ComponentCtrl
        Returns:
        true if the component itself has binding annotation
      • hasSubBindingAnnotation

        public boolean hasSubBindingAnnotation()
        Description copied from interface: ComponentCtrl
        Returns whether the component and its children have binding annotation or not. (Internal or component developer use only.)
        Specified by:
        hasSubBindingAnnotation in interface ComponentCtrl
        Returns:
        true if the component and its children have binding annotation
      • getSubBindingAnnotationCount

        public int getSubBindingAnnotationCount()
        Description copied from interface: ComponentCtrl
        Returns the count of the component's subtree binding annotation. (Internal or component developer use only.)
        Specified by:
        getSubBindingAnnotationCount in interface ComponentCtrl
        Returns:
        0 if the component and its children have no binding annotation , more than 0 if they have binding annotation
      • updateSubBindingAnnotationCount

        protected void updateSubBindingAnnotationCount​(int diff)
      • setSubBindingAnnotationCount

        protected void setSubBindingAnnotationCount​(int diff,
                                                    AbstractComponent node)
      • enableBindingAnnotation

        public void enableBindingAnnotation()
        Description copied from interface: ComponentCtrl
        Set to enable the component with binding annotation. (Internal or component developer use only.)
        Specified by:
        enableBindingAnnotation in interface ComponentCtrl
      • disableBindingAnnotation

        public void disableBindingAnnotation()
        Description copied from interface: ComponentCtrl
        Set to disable the component with binding annotation. (Internal or component developer use only.)
        Specified by:
        disableBindingAnnotation in interface ComponentCtrl
      • isInitialized

        public boolean isInitialized()
        Returns if it's finished layout phase (initializing).
        Returns:
        true if it's initialized.
        Since:
        9.5.1