本文整理了Java中com.vaadin.flow.dom.Element.setAttribute()
方法的一些代码示例,展示了Element.setAttribute()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.setAttribute()
方法的具体详情如下:
包路径:com.vaadin.flow.dom.Element
类名称:Element
方法名:setAttribute
[英]Sets the given attribute to the given StreamResource value.
Attribute names are considered case insensitive and all names will be converted to lower case automatically.
This is a convenience method to register a StreamResourceinstance into the session and use the registered resource URI as an element attribute.
[中]将给定属性设置为给定的StreamResource值。
属性名称不区分大小写,所有名称将自动转换为小写。
这是一种方便的方法,可以将StreamResourceinstance注册到会话中,并将注册的资源URI用作元素属性。
代码示例来源:origin: com.vaadin/flow-server
private void updateThemeAttribute() {
if (themes.isEmpty()) {
element.removeAttribute(THEME_ATTRIBUTE_NAME);
} else {
element.setAttribute(THEME_ATTRIBUTE_NAME, themes.stream()
.collect(Collectors.joining(THEME_NAMES_DELIMITER)));
}
}
代码示例来源:origin: com.vaadin/flow-server
/**
* Sets the CSS class names of this component. This method overwrites any
* previous set class names.
*
* @param className
* a space-separated string of class names to set, or
* <code>null</code> to remove all class names
*/
default void setClassName(String className) {
getElement().setAttribute("class", className);
}
代码示例来源:origin: com.vaadin/flow-server
/**
* Creates a new empty router link.
*/
public RouterLink() {
getElement()
.setAttribute(ApplicationConstants.ROUTER_LINK_ATTRIBUTE, "");
}
代码示例来源:origin: com.vaadin/flow-server
/**
* Creates an {@code <a>} with the given {@code href} attribute.
*
* @param href
* the href attribute for the link
* @return an {@code <a>} element.
*/
static Element createAnchor(String href) {
return createAnchor().setAttribute("href", href);
}
代码示例来源:origin: com.vaadin/flow-server
/**
* Sets the theme names of this component. This method overwrites any
* previous set theme names.
*
* @param themeName
* a space-separated string of theme names to set, or empty
* string to remove all theme names
*/
default void setThemeName(String themeName) {
getElement().setAttribute("theme", themeName);
}
代码示例来源:origin: com.vaadin/flow-server
/**
* Creates an {@code <input>} element with the given type.
*
* @param type
* the type attribute for the element
* @return an {@code <input>} element
*/
static Element createInput(String type) {
return new Element(Tag.INPUT).setAttribute("type", type);
}
代码示例来源:origin: com.vaadin/flow-component-demo-helpers
/**
* Card constructor that set wanted styles.
*/
public Card() {
getElement().setAttribute("class", "component-card");
}
代码示例来源:origin: com.vaadin/vaadin-checkbox-flow
/**
* Set the accessibility label of this checkbox.
*
* @param ariaLabel
* the accessibility label to set
* @see <a href=
* "https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-label_attribute"
* >aria-label at MDN</a>
*/
public void setAriaLabel(String ariaLabel) {
getElement().setAttribute("aria-label", ariaLabel);
}
代码示例来源:origin: com.holon-platform.vaadin/holon-vaadin-flow
/**
* Set the component title text.
* @param title The title text to set
*/
public void setTitle(String title) {
getElement().setAttribute("title", (title != null) ? title : "");
}
代码示例来源:origin: appreciated/vaadin-app-layout
public void setSelected(AppSubmenu appMenu) {
if (subparent != null) {
subparent.setSelected();
}
getElement().setAttribute("selected", String.valueOf(indexOf(appMenu)));
}
代码示例来源:origin: com.vaadin/vaadin-app-layout-flow
/**
* Sets the element into branding area
*
* @param branding {@link Element} to set into branding area
*/
public void setBranding(Element branding) {
Objects.requireNonNull(branding, "Branding cannot be null");
removeBranding();
this.branding = branding;
branding.setAttribute("slot", "branding");
getElement().appendChild(branding);
}
代码示例来源:origin: com.vaadin/vaadin-app-layout-flow
/**
* Sets the element to be placed in the menu slot.
*
* @param menu {@link Element} to placed in the menu slot.
*/
public void setMenu(Element menu) {
Objects.requireNonNull(menu, "Menu cannot be null");
removeMenu();
this.menu = menu;
menu.setAttribute("slot", "menu");
getElement().appendChild(menu);
}
代码示例来源:origin: appreciated/vaadin-app-layout
public void setSelected(AppMenuItem selected) {
if (subparent != null) {
subparent.setSelected();
}
getElement().setAttribute("selected", String.valueOf(indexOf(selected)));
}
代码示例来源:origin: appreciated/vaadin-app-layout
public PaperBadge(Component bind, String icon, String label) {
if (icon != null) {
getElement().setAttribute("icon", icon);
}
if (label != null) {
setText(label);
}
getElement().setAttribute("for", bind.getElement().getAttribute("id"));
}
代码示例来源:origin: com.vaadin/vaadin-select-flow
VaadinItem(String key, T item) {
this.item = item;
getElement().setProperty("value", key);
getElement().setAttribute("value", key);
}
代码示例来源:origin: com.holon-platform.vaadin/holon-vaadin-flow
public AbstractButtonConfigurator(Button component) {
super(component);
this.sizeConfigurator = new DefaultHasSizeConfigurator(component);
this.styleConfigurator = new DefaultHasStyleConfigurator(component);
this.enabledConfigurator = new DefaultHasEnabledConfigurator(component);
this.textConfigurator = new DefaultHasTextConfigurator(component, this);
this.titleConfigurator = new DefaultHasTitleConfigurator<>(component, title -> {
component.getElement().setAttribute("title", (title != null) ? title : "");
}, this);
}
代码示例来源:origin: com.vaadin/vaadin-select-flow
private void updateItemEnabled(VaadinItem<T> item) {
boolean itemEnabled = isItemEnabled(item.getItem());
boolean disabled = isDisabledBoolean() || !itemEnabled;
// The disabled attribute should be set when the item is disabled,
// but not if only the select is disabled, because setting disabled
// attribute clears the selected value of an item.
item.getElement().setEnabled(!disabled);
item.getElement().setAttribute("disabled", !itemEnabled);
}
代码示例来源:origin: appreciated/vaadin-app-layout
public TopClickableComponent(String name, Icon icon, ComponentEventListener<ClickEvent<?>> listener) {
super(name, icon);
this.name = name;
this.icon = icon;
this.listener = listener;
getElement().setAttribute("theme", "tertiary");
getStyle().set("margin", "unset").set("--lumo-primary-text-color", "var(--app-layout-bar-font-color)");
addClickListener(appMenuIconItemClickEvent -> getListener().onComponentEvent(null));
}
代码示例来源:origin: com.vaadin/flow-component-demo-helpers
private void addSourceCodeBlock(String text, String className) {
Element pre = new Element("pre");
Element code = new Element("code");
pre.appendChild(code);
code.setAttribute("spellcheck", "false");
code.getClassList().add(className);
code.setText(text);
getElement().appendChild(pre);
}
}
代码示例来源:origin: appreciated/vaadin-app-layout
public AppMenuItem() {
getElement().getClassList().add("app-menu-item");
getElement().setAttribute("href", "javascript:void(0)");
getElement().getStyle().set("position", "relative")
.set("padding", "var(--app-layout-menu-button-padding)")
.set("margin", "var(--app-layout-menu-button-margin)")
.set("border-radius", "var(--app-layout-menu-button-border-radius)")
.set("--lumo-primary-text-color", "var(--app-layout-app-color)")
.set("text-decoration", "none");
getElement().appendChild(new PaperRipple().getElement());
}
内容来源于网络,如有侵权,请联系作者删除!