4.3. Link

The Link component allows making references to resources that are either external or provided by the web server or by the application itself. While a Link appears like a hyperlink, it is not handled in the web browser. When a user clicks a link, the server receives an event and typically opens the referenced resource in the target window of the link. Resources are explained in Section 3.5, “Referencing Resources”.

Links to external resources can be made by using a URI as follows:

main.addComponent(new Link ("link to a resource",
                            new ExternalResource("http://www.itmill.com/")));

With the simple contructor used in the above example, the link is opened in the current window. Using the constructor that takes the target window as a parameter, or by setting the window with setWindow, you can open the resource in another window, such as a native popup window or a FrameWindow. As the target window can be defined as a target string managed by the browser, the target can be any window, including windows not managed by the application itself.

When the user clicks the link, the application will receive an event regarding the click and handle it to provide the resource. The link is therefore not an <a href> element in HTML and it does not have an URI. This has some additional consequences, such as that a link can not be marked as "visited" by the browser, unlike normal hyperlinks. If you wish to have an actual HTML anchor element, you need to customize the rendering of the component or use a Label with XHTML content mode and write the anchor element by yourself.

CSS Style Rules

The Link component has i-link style by default.

.i-link { }

When the mouse pointer hovers over the link, it will also have the over style.