Class Cascader<E>

Type Parameters:
E - Element type in model
All Implemented Interfaces:
Serializable, Cloneable, Component, Disable, Scope, ComponentCtrl

public class Cascader<E> extends HtmlBasedComponent implements Disable
A Cascader is a dropdown list in tree structure, and it supports TreeModel. It does not create child widgets for each data, so the memory usage is much lower at the server.

Available in ZK EE.

Default getZclass(): z-cascader.

Since:
9.0.0
Author:
jameschu
See Also:
  • Constructor Details

    • Cascader

      public Cascader()
  • Method Details

    • getModel

      public TreeModel<E> getModel()
      Returns the model associated with this cascader, or null if this cascader is not associated with any tree data model.
    • setModel

      public void setModel(TreeModel model)
      Sets the tree model associated with this cascader.
      Parameters:
      model - the list model to associate, or null to dis-associate any previous model. If not null, it must implement Selectable.
      Throws:
      UiException - if failed to initialize with the model
    • onInitRender

      public void onInitRender()
      Handles a private event, onInitRender. It is used only for implementation, and you rarely need to invoke it explicitly.
    • getItemRenderer

      public ItemRenderer<E> getItemRenderer()
      Returns the renderer to render each item, or null if the default renderer is used.
    • setItemRenderer

      public void setItemRenderer(ItemRenderer<E> renderer)
      Sets the renderer which is used to render each item if getModel() is not null.

      Note: changing a render will cause the cascader to re-render.

      Parameters:
      renderer - the renderer, or null to use the default.
    • setItemRenderer

      public void setItemRenderer(String clsnm) throws ReflectiveOperationException
      Sets the renderer by use of a class name. It creates an instance automatically.
      Parameters:
      clsnm - The class name
      Throws:
      ReflectiveOperationException - if failed to initialize the renderer
    • getItemConverter

      public Converter<Collection<E>,String> getItemConverter()
      Returns the converter that generates the label text shown in the cascader from selected items, or null to use the default implementation. (joining by slashes, i.g. "A/B/C")
    • setItemConverter

      public void setItemConverter(Converter<Collection<E>,String> converter)
      Sets the converter that generates the label text shown in the cascader from selected items.
      Parameters:
      converter - the converter, or null to use the default implementation.
    • setItemConverter

      public void setItemConverter(String clsnm) throws ReflectiveOperationException
      Sets the converter by use of a class name. It creates an instance automatically.
      Parameters:
      clsnm - The class name
      Throws:
      ReflectiveOperationException - if failed to initialize the converter
    • getPlaceholder

      public String getPlaceholder()
      Returns the placeholder text.
    • setPlaceholder

      public void setPlaceholder(String placeholder)
      Sets the placeholder text that is displayed when the selected item is empty.
    • isOpen

      public boolean isOpen()
      Returns whether this cascader is open.

      Default: false.

    • setOpen

      public void setOpen(boolean open)
      Drops down or closes the list of items.
    • isDisabled

      public boolean isDisabled()
      Description copied from interface: Disable
      Returns whether it is disabled.

      Default: false.

      Specified by:
      isDisabled in interface Disable
    • setDisabled

      public void setDisabled(boolean disabled)
      Description copied from interface: Disable
      Sets whether it is disabled.
      Specified by:
      setDisabled in interface Disable
    • getSelectedItems

      public Set<E> getSelectedItems()
      Returns all selected items.
    • getSelectedItem

      public E getSelectedItem()
      Returns the selected item.
    • setSelectedItem

      public void setSelectedItem(E item)
      Deselects selected item and selects the given item.
    • renderProperties

      protected void renderProperties(ContentRenderer renderer) throws IOException
      Description copied from class: HtmlBasedComponent
      Renders the content of this component, excluding the enclosing tags and children.

      See also ZK Client-side Reference: Property Rendering

      Overrides:
      renderProperties in class HtmlBasedComponent
      Throws:
      IOException
    • service

      public void service(AuRequest request, boolean everError)
      Description copied from class: HtmlBasedComponent
      Processes an AU request.

      Default: it handles onClick, onDoubleClick, onRightClick onMove, onSize, onZIndex.

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

      public void onPageAttached(Page newpage, Page oldpage)
      Description copied from class: AbstractComponent
      Default: handles special event listeners.
      Specified by:
      onPageAttached in interface ComponentCtrl
      Overrides:
      onPageAttached in class AbstractComponent
      Parameters:
      newpage - the new page (never null).
      oldpage - the previous page, if any, or null if it didn't belong to any page.
      See Also:
    • onPageDetached

      public void onPageDetached(Page page)
      Description copied from class: AbstractComponent
      Default: handles special event listeners.
      Specified by:
      onPageDetached in interface ComponentCtrl
      Overrides:
      onPageDetached in class AbstractComponent
      Parameters:
      page - the previous page (never null)
      See Also:
    • 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
      Overrides:
      invalidate in class AbstractComponent
    • clone

      public 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 HtmlBasedComponent
      Returns:
      the new component. Notice that it doesn't belong to any page, nor desktop. It doesn't have a parent, either.
    • 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
      Overrides:
      sessionWillPassivate in class AbstractComponent
    • 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
      Overrides:
      sessionDidActivate in class AbstractComponent
    • getZclass

      public String getZclass()
      Description copied from class: HtmlBasedComponent
      Returns the ZK Cascading Style class for this component. It usually depends on the implementation of the mold (AbstractComponent.getMold()).

      Default: null (the default value depends on element).

      HtmlBasedComponent.setZclass(java.lang.String)) will completely replace the default style of a component. In other words, the default style of a component is associated with the default value of HtmlBasedComponent.getZclass(). Once it is changed, the default style won't be applied at all. If you want to perform small adjustments, use HtmlBasedComponent.setSclass(java.lang.String) instead.

      Overrides:
      getZclass in class HtmlBasedComponent
      See Also: