Interface IAnchornav<I extends IAnyGroup>

  • All Superinterfaces:
    IAnyGroup<IAnchornav<I>>, IChildable<IAnchornav<I>,​I>, IComponent<IAnchornav<I>>, IHtmlBasedComponent<IAnchornav<I>>, IXulElement<IAnchornav<I>>

    public interface IAnchornav<I extends IAnyGroup>
    extends IXulElement<IAnchornav<I>>, IChildable<IAnchornav<I>,​I>, IAnyGroup<IAnchornav<I>>
    Immutable Anchornav component

    This component synchronizes the scrolling position on a page or within ZK containers (Div, Window, etc.) with hyperlinks and buttons. It allows you to both navigate to desired ZK components in a page and to highlight the current navigation link based on the current scroll position.

    Example

     @RichletMapping("/example")
     public IComponent example() {
         return IHlayout.of(IAnchornav.of(IListbox.of(
             IListitem.of(IListcell.of(IA.of("First Window").withClientAttribute("data-anchornav-target", "$win1"))),
             IListitem.of(IListcell.of(IA.of("Second Window").withClientAttribute("data-anchornav-target", "$win2")))
         )).withName("a1").withWidth("250px"),
         IDiv.of(
             IWindow.ofId("win1").withHeight("700px").withBorder(IWindow.Border.NORMAL)
                 .withTitle("1. First Window").withChildren(ILabel.of("Hello world.")),
             IWindow.ofId("win2").withHeight("700px").withBorder(IWindow.Border.NORMAL)
                 .withTitle("2. Second Window").withChildren(ILabel.of("Welcome to ZK world."))
         ).withWidth("750px"));
     }
     

    By default, the Anchornav component will watch the scroll position of a page. Other scrollable containers can be associated with a named Anchornav by setting the "client-attribute" with .withClientAttribute("data-anchornav-scroll", "NAME").

    For example,

     
     IDiv.of("... other components ...").withClientAttribute("data-anchornav-scroll", "a1");
     
     

    Anchor or Button components can be used as links and targets are specified by the IComponent.withClientAttribute(String, String) ("data-anchornav-target", [selector]). Here the JQuery-based selector syntax (#domId / .class / elementName) is extended by ZK specific selectors using $componentId or @componentName.

    Author:
    katherine
    See Also:
    Anchornav
    • Field Detail

      • DEFAULT

        static final IAnchornav<IAnyGroup> DEFAULT
        Constant for default attributes of this immutable component.
    • Method Detail

      • getWidgetClass

        default java.lang.String getWidgetClass()
        Returns the client widget class.

        Default: "zkmax.nav.Anchornav"

        Specified by:
        getWidgetClass in interface IComponent<I extends IAnyGroup>
      • getName

        default java.lang.String getName()
        Returns the name of the component to be associated with other scrollable containers.

        Default: "" (empty)

      • withName

        IAnchornav<I> withName​(java.lang.String name)
        Returns a copy of this immutable component with the specified name.

        Sets the name of the component to be associated with other scrollable containers.

        Parameters:
        name - The name of the component to be associated with other scrollable containers.

        Default: "" (empty).

        Returns:
        A modified copy of the this object
      • isPositionFixed

        default boolean isPositionFixed()
        Returns whether it would be fixed position when out of current viewport.

        Default: true

      • withPositionFixed

        IAnchornav<I> withPositionFixed​(boolean positionFixed)
        Returns a copy of this immutable component with the specified positionFixed.

        Sets whether it would be fixed position when out of current viewport.

        Parameters:
        positionFixed - Whether it would be fixed position when out of current viewport.

        Default: true.

        Returns:
        A modified copy of the this object
      • of

        static <I extends IAnyGroupIAnchornav<I> of​(java.lang.Iterable<? extends I> children)
        Returns the instance with the given any group children.
        Parameters:
        children - The children belong to any group
        See Also:
        IAnyGroup
      • of

        static <I extends IAnyGroupIAnchornav<I> of​(I... children)
        Returns the instance with the given any group children.
        Parameters:
        children - The children belong to any group
        See Also:
        IAnyGroup
      • ofId

        static <I extends IAnyGroupIAnchornav<I> ofId​(java.lang.String id)
        Returns the instance with the given id.
        Parameters:
        id - The id to identify this component