@Tag(value="a") public class Anchor extends HtmlContainer
<a> element.| Constructor and Description |
|---|
Anchor()
Creates a new empty anchor component.
|
Anchor(AbstractStreamResource href,
String text)
Creates an anchor component with the given text content and stream
resource.
|
Anchor(String href,
String text)
Creates an anchor component with the given text content and href.
|
| Modifier and Type | Method and Description |
|---|---|
String |
getHref()
Gets the URL that this anchor links to.
|
Optional<String> |
getTarget()
Gets the target window, tab or frame name for this anchor.
|
void |
removeHref()
Removes href attribute.
|
void |
setHref(AbstractStreamResource href)
Sets the URL that this anchor links to with the URL of the given
StreamResource. |
void |
setHref(String href)
Sets the URL that this anchor links to.
|
void |
setTarget(String target)
Sets the target window, tab or frame for this anchor.
|
getTitle, setTitleaddListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getUI, hasListener, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, set, setElement, setId, setVisibleclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitadd, addComponentAsFirst, addComponentAtIndex, remove, removeAllisEnabled, setEnabledgetElementgetHeight, getWidth, setHeight, setSizeFull, setSizeUndefined, setWidthaddClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameaddAttachListeneraddDetachListenerpublic Anchor()
public Anchor(String href, String text)
href - the href to settext - the text content to setsetHref(String),
HasText.setText(String)public Anchor(AbstractStreamResource href, String text)
href - the resource value, not nulltext - the text content to setsetHref(AbstractStreamResource),
HasText.setText(String)public void setHref(String href)
Use the method removeHref() to remove the href attribute
instead of setting it to an empty string.
href - the href to setremoveHref(),
setHref(AbstractStreamResource)public void removeHref()
setHref(String)public void setHref(AbstractStreamResource href)
StreamResource.href - the resource value, not nullpublic String getHref()
"" if no href has been setsetHref(String)public void setTarget(String target)
window.name of a specific target, or one of these
special values:
_self: Open the link in the current context. This is the
default behavior.
_blank: Opens the link in a new unnamed context.
_parent: Opens the link in the parent context, or the
current context if there is no parent context.
_top: Opens the link in the top most grandparent
context, or the current context if there is no parent context.
target - the target value, or "" to remove the target
valuepublic Optional<String> getTarget()
setTarget(String)Copyright © 2000–2019 Vaadin Ltd. All rights reserved.