Class DefaultSelectorSectionRenderer

  • All Implemented Interfaces:
    SectionRenderer
    Direct Known Subclasses:
    CmsCatalogSelectorSectionRenderer, DefaultSectionSelectorSectionRenderer

    public class DefaultSelectorSectionRenderer
    extends AbstractNavigationAreaSectionRenderer
    Default selector section renderer. Provides a default internal list item renderer which makes use of the Cockpit framework's LabelService for rendering values.

    The internal renderer for rendering selector items used by this section renderer can easily be replaced. However, in order for the general selector functionality to work correctly, you need to set the value of the Listitem passed to the ListitemRenderer#render(Listitem, Object) method to the corresponding TypedObject, just as in the example below.

    Example: Custom list item renderer

    public void render(final Listitem li, final Object value) throws Exception
    {
       if (value instanceof TypedObject)
       {
          li.setValue(value);
           ...
          final Listcell cell = new Listcell(someText);
          li.appendChild(cell);
          cell.setSclass("cockpitSelectorItem");
       }
       else
       {
          LOG.warn("Can not render item since it is not a TypedObject");
       }
    }

    See Also:
    setListRenderer(ListitemRenderer)
    • Constructor Detail

      • DefaultSelectorSectionRenderer

        public DefaultSelectorSectionRenderer()
    • Method Detail

      • setListRenderer

        public void setListRenderer​(org.zkoss.zul.ListitemRenderer listRenderer)
        Sets the list item renderer to be used when rendering list items to listRenderer.

        Note: Calling this method with a null argument, will cause the default fallback renderer to be used when rendering.

        Parameters:
        listRenderer - the renderer to use or null if the fallback renderer should be used
      • getListRenderer

        public org.zkoss.zul.ListitemRenderer getListRenderer()
        Returns the list renderer used for rendering the list items displayed in the selector.
        Returns:
        the list renderer used
      • extractSelectedItems

        protected java.util.List<TypedObject> extractSelectedItems​(java.util.Set<java.lang.Object> listValues)
        Extracts the selected TypedObjects corresponding to the selector's current selection.
        Parameters:
        listValues - the selected ZK items e.g. Listitems
        Returns:
        the real selected values
      • getSection

        protected SelectorSection getSection()
        Returns the last section which this renderer rendered.
        Returns:
        the last section