Class Link<T>

    • Method Detail

      • getAnchor

        public Component getAnchor()
        Gets any anchor component.
        Returns:
        Any anchor component to jump to, might be null
      • getAutoEnable

        public final boolean getAutoEnable()
        Gets whether link should automatically enable/disable based on current page.
        Returns:
        Whether this link should automatically enable/disable based on current page.
      • getPopupSettings

        public final PopupSettings getPopupSettings()
        Gets the popup specification. If not-null, a javascript on-click event handler will be generated that opens a new window using the popup properties.
        Returns:
        the popup specification.
      • isEnabled

        public boolean isEnabled()
        Description copied from class: Component
        Gets whether this component is enabled. Specific components may decide to implement special behavior that uses this property, like web form components that add a disabled='disabled' attribute when enabled is false.
        Overrides:
        isEnabled in class Component
        Returns:
        Whether this component is enabled.
        See Also:
        Component.isEnabled()
      • getStatelessHint

        protected boolean getStatelessHint()
        Description copied from class: Component
        Returns whether the component can be stateless. Also the component behaviors must be stateless, otherwise the component will be treat as stateful. In order for page to be stateless (and not to be stored in session), all components (and component behaviors) must be stateless.
        Overrides:
        getStatelessHint in class Component
        Returns:
        whether the component can be stateless
        See Also:
        Component.getStatelessHint()
      • onClick

        public abstract void onClick()
        Called when a link is clicked.
      • onRequest

        public void onRequest()
        THIS METHOD IS NOT PART OF THE WICKET API. DO NOT ATTEMPT TO OVERRIDE OR CALL IT. Called when a link is clicked. The implementation of this method is currently to simply call onClick(), but this may be augmented in the future.
        Specified by:
        onRequest in interface IRequestListener
      • setAnchor

        public Link<TsetAnchor​(Component anchor)
        Sets an anchor component. An anchor (form 'http://server/app/etc#someAnchor') will be appended to the link so that after this link executes, it will jump to the provided anchor component's position. The provided anchor must either have the Component.getOutputMarkupId() flag true, or it must be attached to a <a tag with a href attribute of more than one character starting with '#' ('<a href="#someAnchor" ... ').
        Parameters:
        anchor - The anchor
        Returns:
        this
      • setAutoEnable

        public final Link<TsetAutoEnable​(boolean autoEnable)
        Sets whether this link should automatically enable/disable based on current page.
        Parameters:
        autoEnable - whether this link should automatically enable/disable based on current page.
        Returns:
        This
      • setPopupSettings

        public final Link<TsetPopupSettings​(PopupSettings popupSettings)
        Sets the popup specification. If not-null, a javascript on-click event handler will be generated that opens a new window using the popup properties.
        Parameters:
        popupSettings - the popup specification.
        Returns:
        This
      • appendAnchor

        protected CharSequence appendAnchor​(ComponentTag tag,
                                            CharSequence url)
        Appends any anchor to the url if the url is not null and the url does not already contain an anchor (url.indexOf('#') != -1). This implementation looks whether an anchor component was set, and if so, it will append the markup id of that component. That markup id is gotten by either calling Component.getMarkupId() if Component.getOutputMarkupId() returns true, or if the anchor component does not output it's id, this method will try to retrieve the id from the markup directly. If neither is found, an exception is thrown. If no anchor component was set, but the link component is attached to a <a element, this method will append what is in the href attribute if there is one, starts with a '#' and has more than one character.

        You can override this method, but it means that you have to take care of whatever is done with any set anchor component yourself. You also have to manually append the '#' at the right place.

        Parameters:
        tag - The component tag
        url - The url to start with
        Returns:
        The url, possibly with an anchor appended
      • getURL

        protected CharSequence getURL()
        Gets the url to use for this link.
        Returns:
        The URL that this link links to
      • linksTo

        protected boolean linksTo​(Page page)
        Whether this link refers to the given page.
        Parameters:
        page - A page
        Returns:
        True if this link goes to the given page
      • useJSEventBindingWhenNeeded

        protected boolean useJSEventBindingWhenNeeded()
        This method can be overridden by a subclass to disable the JS event binding or provide custom event binding code is used.
        Returns:
        true when a javascripot event binding must used to handle the click event.