Package org.zkoss.zuti.zul

## Class Choose

- java.lang.Object
- - org.zkoss.zk.ui.AbstractComponent
  - - org.zkoss.zk.ui.HtmlShadowElement
    - - org.zkoss.zuti.zul.TemplateBasedShadowElement
      - - org.zkoss.zuti.zul.Choose

- All Implemented Interfaces:
    `java.io.Serializable`, `java.lang.Cloneable`, `Component`, `AfterCompose`, `Scope`, `ShadowElement`, `ShadowElementCtrl`, `ComponentCtrl`

      public class Choose
      extends TemplateBasedShadowElement

  The `choose` tag works like a Java switch statement in that it lets you choose between a number of alternatives. Where the switch statement has case statements, the `choose` tag has `when` tags. A a switch statement has default clause to specify a default action and similar way `choose` has `otherwise` as default clause.
  Since:
    8.0.0
  Author:
    jumperchen
  See Also:
    `When`, `Otherwise`, Serialized Form

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.zkoss.zk.ui.HtmlShadowElement

      `HtmlShadowElement.Direction`

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

      `AbstractComponent.Children, AbstractComponent.ForwardInfo, AbstractComponent.TargetInfo`

  - ### Field Summary

    - ### Fields inherited from class org.zkoss.zuti.zul.TemplateBasedShadowElement

      `_dirtyBinding, FOREACH_RENDERED_COMPONENTS, ON_BINDING_READY, SHADOW_VARIABLE`

    - ### Fields inherited from class org.zkoss.zk.ui.HtmlShadowElement

      `_afterComposed, _dynamicValue, BIND_ANNO, BINDER, FOREACH_IN_RENDER, INIT_ANNO, LOAD_ANNO, ON_REBUILD_SHADOW_TREE_LATER, REFERENCE_ANNO, SAVE_ANNO, SKIP_DISTRIBUTED_CHILDREN_PROPERTY_CHANGE`

    - ### 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
    --- | ---
    `Choose()` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `beforeChildAdded​(Component child, Component refChild)` | Default: does nothing.
    `java.lang.Object` | `clone()` | Clones the component.
    `protected void` | `compose​(Component host)` | Composes the shadow element.
    `void` | `detach()` | Removes the relation points between shadow host and this shadow element.
    `protected java.util.Set<java.lang.String>` | `getDynamicKeys()` |
    `boolean` | `isDynamicValue()` | Returns whether the shadow element contains a dynamic value, it means the shadow element cannot be destroyed after evaluated.
    `boolean` | `isEffective()` | Returns whether the shadow element is effective
    `void` | `mergeSubTree()` | Merge the all sub-tree into the parent's insertions, unlike `AbstractComponent.appendChild(Component)`
    `void` | `onChildRemoved​(Component child)` | Default: handles special event listeners.
    `protected void` | `rebuildSubShadowTree()` | Rebuilds the shadow tree if the shadow element contains a dynamic value, it should be alive, otherwise, it will be detached.
    `void` | `recreate()` | Detaches all child components and then recreate them by use of `HtmlShadowElement.compose(org.zkoss.zk.ui.Component)`.

    - ### Methods inherited from class org.zkoss.zuti.zul.TemplateBasedShadowElement

      `addBindingListener, afterCompose, docheck0, isBindingReady, isDirtyBinding, onChildAdded, removeBindingListener`

    - ### Methods inherited from class org.zkoss.zk.ui.HtmlShadowElement

      `afterHostChildAdded, afterHostChildRemoved, asShadow, beforeHostChildAdded, beforeHostChildRemoved, beforeHostParentChanged, beforeParentChanged, clearChildren, destroyIndexCacheMap, getDistributedChildren, getFirstInsertion, getIndex, getIndexCacheMap, getLastInsertion, getNextInsertion, getNextInsertionComponentIfAny, getPreviousInsertion, getPreviousInsertionComponentIfAny, getShadowHost, getShadowHostIfAny, initClone, initIndexCacheMap, inRange, invalidate, isDynamicValue, mergeToHost, onHostAttached, onHostChildAdded, onHostChildRemoved, onHostDetached, removeFromParent, resolveVariable, setDynamicValue, setParent, setPrevInsertion, setShadowHost, shrinkRange, stretchRange, toString, updateFirstInsertion, updateLastInsertion, updateNextInsertion, updatePreviousInsertion, updateSubBindingAnnotationCount`

    - ### 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, 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, getExtraCtrl, getFellow, getFellow, getFellowIfAny, getFellowIfAny, getFellows, getFirstChild, getForwards, getId, getLastChild, getMold, getNextSibling, getPage, getParent, getPreviousSibling, getPropertyAccess, 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, insertBefore, isChildable, isDisabledHostChanged, isInitialized, isInvalidated, isListenerAvailable, isVisible, onPageAttached, onPageDetached, onParentChanged, onWrongValue, query, queryAll, redraw, redrawChildren, removeAttribute, removeAttribute, removeAttribute, removeCallback, removeChild, removeEventListener, removeForward, removeForward, removeRedrawCallback, removeScopeListener, removeShadowRoot, render, render, render, renderProperties, renderPropertiesOnly, replace, response, response, response, service, service, sessionDidActivate, sessionWillPassivate, setAttribute, setAttribute, setAttribute, setAuService, setAutag, setClientAttribute, setClientDataAttribute, setDefinition, setDefinition, setId, setMold, setPage, setPageBefore, setStubonly, setStubonly, setSubBindingAnnotationCount, setTemplate, setVisible, setVisibleDirectly, setWidgetClass, setWidgetListener, setWidgetOverride, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdateWidgetListener, smartUpdateWidgetOverride, updateByClient, willPassivate, willPassivate, willSerialize, willSerialize`

    - ### Methods inherited from class java.lang.Object

      `equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### Choose

          public Choose()

  - ### Method Detail

    - #### beforeChildAdded

          public void beforeChildAdded​(Component child,
                                       Component refChild)

      Description copied from class: `AbstractComponent`
      Default: does nothing.
      Specified by:
        `beforeChildAdded` in interface `ComponentCtrl`
      Overrides:
        `beforeChildAdded` in class `HtmlShadowElement`
      Parameters:
        `child` - the child to be added (never null).
        `refChild` - another child component that the new child will be inserted before it. If null, the new child will be the last child.
      See Also:
        `ComponentCtrl.beforeChildAdded(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component)`

    - #### onChildRemoved

          public void onChildRemoved​(Component child)

      Description copied from class: `AbstractComponent`
      Default: handles special event listeners.
      Specified by:
        `onChildRemoved` in interface `ComponentCtrl`
      Overrides:
        `onChildRemoved` in class `TemplateBasedShadowElement`
      See Also:
        `ComponentCtrl.onChildRemoved(org.zkoss.zk.ui.Component)`

    - #### compose

          protected void compose​(Component host)

      Description copied from class: `HtmlShadowElement`
      Composes the shadow element. It is called by `HtmlShadowElement.afterCompose()` if the shadow host is not null. Otherwise, it will skip this method call.

      The second invocation is ignored. If you want to recreate child components, use `HtmlShadowElement.recreate()` instead.

      Overrides:
        `compose` in class `TemplateBasedShadowElement`
      Parameters:
        `host` - the shadow host component, never null.

    - #### getDynamicKeys

          protected java.util.Set<java.lang.String> getDynamicKeys()

    - #### isEffective

          public boolean isEffective()

      Description copied from class: `HtmlShadowElement`
      Returns whether the shadow element is effective
      Overrides:
        `isEffective` in class `TemplateBasedShadowElement`

    - #### rebuildSubShadowTree

          protected void rebuildSubShadowTree()

      Description copied from class: `HtmlShadowElement`
      Rebuilds the shadow tree if the shadow element contains a dynamic value, it should be alive, otherwise, it will be detached.
      Overrides:
        `rebuildSubShadowTree` in class `TemplateBasedShadowElement`

    - #### isDynamicValue

          public boolean isDynamicValue()

      Description copied from interface: `ShadowElementCtrl`
      Returns whether the shadow element contains a dynamic value, it means the shadow element cannot be destroyed after evaluated.
      Specified by:
        `isDynamicValue` in interface `ShadowElementCtrl`
      Overrides:
        `isDynamicValue` in class `TemplateBasedShadowElement`

    - #### detach

          public void detach()

      Description copied from class: `HtmlShadowElement`
      Removes the relation points between shadow host and this shadow element.
      Specified by:
        `detach` in interface `Component`
      Specified by:
        `detach` in interface `ShadowElement`
      Overrides:
        `detach` in class `TemplateBasedShadowElement`

    - #### mergeSubTree

          public void mergeSubTree()

      Description copied from class: `HtmlShadowElement`
      Merge the all sub-tree into the parent's insertions, unlike `AbstractComponent.appendChild(Component)`
      Overrides:
        `mergeSubTree` in class `HtmlShadowElement`

    - #### 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 `TemplateBasedShadowElement`
      Returns:
        the new component. Notice that it doesn't belong to any page, nor desktop. It doesn't have a parent, either.

    - #### recreate

          public void recreate()

      Description copied from class: `HtmlShadowElement`
      Detaches all child components and then recreate them by use of `HtmlShadowElement.compose(org.zkoss.zk.ui.Component)`.
      Specified by:
        `recreate` in interface `ShadowElement`
      Overrides:
        `recreate` in class `HtmlShadowElement`