Class StubComponent

java.lang.Object
org.zkoss.zk.ui.AbstractComponent
org.zkoss.zk.ui.sys.StubComponent
All Implemented Interfaces:
Serializable, Cloneable, Component, Scope, ComponentCtrl
Direct Known Subclasses:
StubsComponent

public class StubComponent extends AbstractComponent
A stub component is a 'degenerated' component that does not maintain the states at the server. Rather, the states are maintained at the peer widget (running at the client).

Application isn't really aware the existence of a stub component. Rather, it is used by ZK Loader to minimize the footprint, if it found a component doesn't have to maintain the states at the server after rendered. For example, HtmlNativeComponent and stub-only components will degenerate to StubComponent or StubsComponent after rendered. Refer Component.setStubonly(java.lang.String) for details about a stub-only component.

A component that wants to degenerate to a stub component usually invoke replace(org.zkoss.zk.ui.Component, boolean, boolean, boolean) after AbstractComponent.redraw(java.io.Writer) is called.

Since:
6.0.0
Author:
tomyeh
See Also:
  • Constructor Details

    • StubComponent

      public StubComponent()
  • Method Details

    • getId

      public String getId(String uuid)
      Returns ID of the given UUID, or null if not found or no ID assigned. It assumes the given UUID belonged to one of the component being merged into this component.

      Notice that it searches all descendants of this component.

    • replace

      public 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. A stub component assumes there is a full-functional widget running at the client to handle everything.

      Overrides:
      replace in class AbstractComponent
      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.
      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:
      IllegalStateException - if this component has a parent, sibling or child.
    • getWidgetClass

      public String getWidgetClass()
      Returns the widget class, "#stub".
      Specified by:
      getWidgetClass in interface Component
      Overrides:
      getWidgetClass in class AbstractComponent
      See Also:
    • service

      public void service(AuRequest request, boolean everError)
      Description copied from class: AbstractComponent
      Handles an AU request. It is invoked internally.

      Default: it handles echo and setAttr, and it converts other request to an event (by Event.getEvent(org.zkoss.zk.au.AuRequest)) and then posts the event (by Events.postEvent(org.zkoss.zk.ui.event.Event)).

      Application developer can plug the custom service to handle the AU request by AbstractComponent.setAuService(org.zkoss.zk.au.AuService).

      Specified by:
      service in interface ComponentCtrl
      Overrides:
      service in class AbstractComponent
      everError - whether any error ever occurred before processing this request.
      See Also:
    • service

      public void service(Event event, Scope scope) throws Exception
      Description copied from interface: ComponentCtrl
      Handles an event. This method will invoke the event handlers registered in a ZUML page, the event listeners registered in Java, and the event handlers declared as part of the component.
      Specified by:
      service in interface ComponentCtrl
      Overrides:
      service in class AbstractComponent
      Parameters:
      event - the event to handle
      scope - the scope to evaluate the zscript, if any. (see also Page.interpret(java.lang.String, java.lang.String, org.zkoss.zk.ui.ext.Scope).
      Throws:
      Exception