Directory

← Back

ActiveLink

A Link component that sends event to the server - "Link and Button, all in one"

Author

Rating

Popularity

<100

ActiveLink is an extended Link component that sends an event to the server when clicked, before navigating to the linked URL. This allows an application to allow a user to open stuff in new windows/tabs while still doing the ajaxy-thing when when the user does not. "Best of both worlds."

It also sends some additional information about which modifiers where held (e.g shift) and which mouse button was clicked. (Plain-old left-click is reliable, but some other situations are more difficult depending on the browser; verify in the relevant browsers if it covers your needs.)

If no listeners are attached, it will behave like a regular Link.

Thanks to Sami Viitanen for fixing 7.3 compatibility.

NOTE Now on GitHub!

Sample code

package org.vaadin.activelink;

import org.vaadin.activelink.ActiveLink.LinkActivatedEvent;
import org.vaadin.activelink.ActiveLink.LinkActivatedListener;

import com.vaadin.Application;
import com.vaadin.terminal.ExternalResource;
import com.vaadin.ui.Window;
import com.vaadin.ui.Window.Notification;

public class ActivelinkDemo extends Application {

    private static final long serialVersionUID = 2856538106955458591L;

    @Override
    public void init() {
        Window mainWindow = new Window("ActiveLink Demo");
        setMainWindow(mainWindow);

        ActiveLink link = new ActiveLink("Active link", new ExternalResource(
                "http://vaadin.com"));
        link.addListener(new LinkActivatedListener() {
            private static final long serialVersionUID = -7680743472997645381L;

            public void linkActivated(LinkActivatedEvent event) {
                getMainWindow()
                        .showNotification(
                                "Link "
                                        + (event.isLinkOpened() ? "opened in tab/window"
                                                : "clicked - but let's stay here"),
                                Notification.TYPE_WARNING_MESSAGE);

            }
        });
        mainWindow.addComponent(link);

    }
}

Compatibility

(Loading compatibility data...)

Was this helpful? Need more help?
Leave a comment or a question below. You can also join the chat on Discord or ask questions on StackOverflow.

Version

Removed DemoUI that was accidentally included in the jar

Released
2014-11-24
Maturity
BETA
License
Apache License 2.0

Compatibility

Framework
Vaadin 7.0+
Vaadin 6.0+ in 1.0
Browser
N/A

ActiveLink - Vaadin Add-on Directory

A Link component that sends event to the server - "Link and Button, all in one" ActiveLink - Vaadin Add-on Directory
ActiveLink is an extended Link component that sends an event to the server when clicked, before navigating to the linked URL. This allows an application to allow a user to open stuff in new windows/tabs while still doing the ajaxy-thing when when the user does not. "Best of both worlds." It also sends some additional information about which modifiers where held (e.g shift) and which mouse button was clicked. (Plain-old left-click is reliable, but some other situations are more difficult depending on the browser; verify in the relevant browsers if it covers your needs.) If no listeners are attached, it will behave like a regular Link. Thanks to Sami Viitanen for fixing 7.3 compatibility. NOTE Now on GitHub!
Online