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!
Issue Tracker
Source Code
Online Demo

ActiveLink version 1.0
null

ActiveLink version 7.0.0
Updated to work with Vaadin 7, and API changed: you now get a complete click event (with modifiers etc) server-side whenever the , and can make your own decisions regarding what has been opened where. This is more flexible, but one feature has been removed: the ability to 'cancel' a plain click. Please feel free to comment on the new API (preferable in the forum).

ActiveLink version 7.0.1
Fixed the removeListener() bug mentioned in comments.

ActiveLink version 7.0.2
This version works with Vaadin 7.0 final (the previous version targeted 7-alpha, small changes were needed)

ActiveLink version 7.3.0
Now works with Vaadin 7.3+ thanks to Sami Viitanen. Also moved to GitHub.

ActiveLink version 7.3.1
Removed DemoUI that was accidentally included in the jar

Online