com.vaadin.flow.dom.Element.setAttribute()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(341)

本文整理了Java中com.vaadin.flow.dom.Element.setAttribute()方法的一些代码示例,展示了Element.setAttribute()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.setAttribute()方法的具体详情如下:
包路径:com.vaadin.flow.dom.Element
类名称:Element
方法名:setAttribute

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

  1. private void updateThemeAttribute() {
  2. if (themes.isEmpty()) {
  3. element.removeAttribute(THEME_ATTRIBUTE_NAME);
  4. } else {
  5. element.setAttribute(THEME_ATTRIBUTE_NAME, themes.stream()
  6. .collect(Collectors.joining(THEME_NAMES_DELIMITER)));
  7. }
  8. }

代码示例来源:origin: com.vaadin/flow-server

  1. /**
  2. * Sets the CSS class names of this component. This method overwrites any
  3. * previous set class names.
  4. *
  5. * @param className
  6. * a space-separated string of class names to set, or
  7. * <code>null</code> to remove all class names
  8. */
  9. default void setClassName(String className) {
  10. getElement().setAttribute("class", className);
  11. }

代码示例来源:origin: com.vaadin/flow-server

  1. /**
  2. * Creates a new empty router link.
  3. */
  4. public RouterLink() {
  5. getElement()
  6. .setAttribute(ApplicationConstants.ROUTER_LINK_ATTRIBUTE, "");
  7. }

代码示例来源:origin: com.vaadin/flow-server

  1. /**
  2. * Creates an {@code &lt;a>} with the given {@code href} attribute.
  3. *
  4. * @param href
  5. * the href attribute for the link
  6. * @return an {@code &lt;a>} element.
  7. */
  8. static Element createAnchor(String href) {
  9. return createAnchor().setAttribute("href", href);
  10. }

代码示例来源:origin: com.vaadin/flow-server

  1. /**
  2. * Sets the theme names of this component. This method overwrites any
  3. * previous set theme names.
  4. *
  5. * @param themeName
  6. * a space-separated string of theme names to set, or empty
  7. * string to remove all theme names
  8. */
  9. default void setThemeName(String themeName) {
  10. getElement().setAttribute("theme", themeName);
  11. }

代码示例来源:origin: com.vaadin/flow-server

  1. /**
  2. * Creates an {@code &lt;input>} element with the given type.
  3. *
  4. * @param type
  5. * the type attribute for the element
  6. * @return an {@code &lt;input>} element
  7. */
  8. static Element createInput(String type) {
  9. return new Element(Tag.INPUT).setAttribute("type", type);
  10. }

代码示例来源:origin: com.vaadin/flow-component-demo-helpers

  1. /**
  2. * Card constructor that set wanted styles.
  3. */
  4. public Card() {
  5. getElement().setAttribute("class", "component-card");
  6. }

代码示例来源:origin: com.vaadin/vaadin-checkbox-flow

  1. /**
  2. * Set the accessibility label of this checkbox.
  3. *
  4. * @param ariaLabel
  5. * the accessibility label to set
  6. * @see <a href=
  7. * "https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-label_attribute"
  8. * >aria-label at MDN</a>
  9. */
  10. public void setAriaLabel(String ariaLabel) {
  11. getElement().setAttribute("aria-label", ariaLabel);
  12. }

代码示例来源:origin: com.holon-platform.vaadin/holon-vaadin-flow

  1. /**
  2. * Set the component title text.
  3. * @param title The title text to set
  4. */
  5. public void setTitle(String title) {
  6. getElement().setAttribute("title", (title != null) ? title : "");
  7. }

代码示例来源:origin: appreciated/vaadin-app-layout

  1. public void setSelected(AppSubmenu appMenu) {
  2. if (subparent != null) {
  3. subparent.setSelected();
  4. }
  5. getElement().setAttribute("selected", String.valueOf(indexOf(appMenu)));
  6. }

代码示例来源:origin: com.vaadin/vaadin-app-layout-flow

  1. /**
  2. * Sets the element into branding area
  3. *
  4. * @param branding {@link Element} to set into branding area
  5. */
  6. public void setBranding(Element branding) {
  7. Objects.requireNonNull(branding, "Branding cannot be null");
  8. removeBranding();
  9. this.branding = branding;
  10. branding.setAttribute("slot", "branding");
  11. getElement().appendChild(branding);
  12. }

代码示例来源:origin: com.vaadin/vaadin-app-layout-flow

  1. /**
  2. * Sets the element to be placed in the menu slot.
  3. *
  4. * @param menu {@link Element} to placed in the menu slot.
  5. */
  6. public void setMenu(Element menu) {
  7. Objects.requireNonNull(menu, "Menu cannot be null");
  8. removeMenu();
  9. this.menu = menu;
  10. menu.setAttribute("slot", "menu");
  11. getElement().appendChild(menu);
  12. }

代码示例来源:origin: appreciated/vaadin-app-layout

  1. public void setSelected(AppMenuItem selected) {
  2. if (subparent != null) {
  3. subparent.setSelected();
  4. }
  5. getElement().setAttribute("selected", String.valueOf(indexOf(selected)));
  6. }

代码示例来源:origin: appreciated/vaadin-app-layout

  1. public PaperBadge(Component bind, String icon, String label) {
  2. if (icon != null) {
  3. getElement().setAttribute("icon", icon);
  4. }
  5. if (label != null) {
  6. setText(label);
  7. }
  8. getElement().setAttribute("for", bind.getElement().getAttribute("id"));
  9. }

代码示例来源:origin: com.vaadin/vaadin-select-flow

  1. VaadinItem(String key, T item) {
  2. this.item = item;
  3. getElement().setProperty("value", key);
  4. getElement().setAttribute("value", key);
  5. }

代码示例来源:origin: com.holon-platform.vaadin/holon-vaadin-flow

  1. public AbstractButtonConfigurator(Button component) {
  2. super(component);
  3. this.sizeConfigurator = new DefaultHasSizeConfigurator(component);
  4. this.styleConfigurator = new DefaultHasStyleConfigurator(component);
  5. this.enabledConfigurator = new DefaultHasEnabledConfigurator(component);
  6. this.textConfigurator = new DefaultHasTextConfigurator(component, this);
  7. this.titleConfigurator = new DefaultHasTitleConfigurator<>(component, title -> {
  8. component.getElement().setAttribute("title", (title != null) ? title : "");
  9. }, this);
  10. }

代码示例来源:origin: com.vaadin/vaadin-select-flow

  1. private void updateItemEnabled(VaadinItem<T> item) {
  2. boolean itemEnabled = isItemEnabled(item.getItem());
  3. boolean disabled = isDisabledBoolean() || !itemEnabled;
  4. // The disabled attribute should be set when the item is disabled,
  5. // but not if only the select is disabled, because setting disabled
  6. // attribute clears the selected value of an item.
  7. item.getElement().setEnabled(!disabled);
  8. item.getElement().setAttribute("disabled", !itemEnabled);
  9. }

代码示例来源:origin: appreciated/vaadin-app-layout

  1. public TopClickableComponent(String name, Icon icon, ComponentEventListener<ClickEvent<?>> listener) {
  2. super(name, icon);
  3. this.name = name;
  4. this.icon = icon;
  5. this.listener = listener;
  6. getElement().setAttribute("theme", "tertiary");
  7. getStyle().set("margin", "unset").set("--lumo-primary-text-color", "var(--app-layout-bar-font-color)");
  8. addClickListener(appMenuIconItemClickEvent -> getListener().onComponentEvent(null));
  9. }

代码示例来源:origin: com.vaadin/flow-component-demo-helpers

  1. private void addSourceCodeBlock(String text, String className) {
  2. Element pre = new Element("pre");
  3. Element code = new Element("code");
  4. pre.appendChild(code);
  5. code.setAttribute("spellcheck", "false");
  6. code.getClassList().add(className);
  7. code.setText(text);
  8. getElement().appendChild(pre);
  9. }
  10. }

代码示例来源:origin: appreciated/vaadin-app-layout

  1. public AppMenuItem() {
  2. getElement().getClassList().add("app-menu-item");
  3. getElement().setAttribute("href", "javascript:void(0)");
  4. getElement().getStyle().set("position", "relative")
  5. .set("padding", "var(--app-layout-menu-button-padding)")
  6. .set("margin", "var(--app-layout-menu-button-margin)")
  7. .set("border-radius", "var(--app-layout-menu-button-border-radius)")
  8. .set("--lumo-primary-text-color", "var(--app-layout-app-color)")
  9. .set("text-decoration", "none");
  10. getElement().appendChild(new PaperRipple().getElement());
  11. }

相关文章