Search in sources :

Example 1 with Anchor

use of com.vaadin.flow.component.html.Anchor in project flow by vaadin.

the class RouterLinkView method addImageLink.

private void addImageLink() {
    Anchor anchor = new Anchor("image/link", null);
    anchor.getElement().setAttribute("router-link", true);
    anchor.getStyle().set("display", "block");
    Image image = new Image("", "IMAGE");
    image.setWidth("200px");
    image.setHeight("200px");
    anchor.add(image);
    add(anchor);
}
Also used : Anchor(com.vaadin.flow.component.html.Anchor) Image(com.vaadin.flow.component.html.Image)

Example 2 with Anchor

use of com.vaadin.flow.component.html.Anchor in project flow by vaadin.

the class StreamResourceView method onAttach.

@Override
protected void onAttach(AttachEvent attachEvent) {
    StreamResource resource = new StreamResource("filename", () -> new ByteArrayInputStream("Hello world".getBytes(StandardCharsets.UTF_8)));
    Anchor download = new Anchor("", "Download file");
    download.setHref(resource);
    download.setId("download");
    add(download);
}
Also used : Anchor(com.vaadin.flow.component.html.Anchor) StreamResource(com.vaadin.flow.server.StreamResource) ByteArrayInputStream(java.io.ByteArrayInputStream)

Example 3 with Anchor

use of com.vaadin.flow.component.html.Anchor in project flow by vaadin.

the class DemoNavigationBar method addLink.

/**
 * Adds a menu item inside the navigation bar.
 *
 * @param text
 *            the text shown for the anchor
 * @param href
 *            the href of the anchor
 */
public void addLink(String text, String href) {
    Element item = new Element(Tag.LI);
    Anchor anchor = new Anchor(href, text);
    item.appendChild(anchor.getElement());
    list.appendChild(item);
    anchors.put(href, anchor);
}
Also used : Anchor(com.vaadin.flow.component.html.Anchor) Element(com.vaadin.flow.dom.Element)

Example 4 with Anchor

use of com.vaadin.flow.component.html.Anchor in project flow by vaadin.

the class ScrollView method createAnchorUrl.

static Anchor createAnchorUrl(boolean isRouterLink, String id, String url, String text) {
    Anchor result = new Anchor(url, text);
    result.getElement().setAttribute(ROUTER_LINK_ATTRIBUTE_NAME, isRouterLink);
    result.getStyle().set("display", "block");
    result.setId(id);
    return result;
}
Also used : Anchor(com.vaadin.flow.component.html.Anchor)

Aggregations

Anchor (com.vaadin.flow.component.html.Anchor)4 Image (com.vaadin.flow.component.html.Image)1 Element (com.vaadin.flow.dom.Element)1 StreamResource (com.vaadin.flow.server.StreamResource)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1