com.google.gwt.dom.client.Element.setAttribute()方法的使用及代码示例

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

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

Element.setAttribute介绍

[英]Adds a new attribute. If an attribute with that name is already present in the element, its value is changed to be that of the value parameter.
[中]添加新属性。如果元素中已存在具有该名称的属性,则其值将更改为value参数的值。

代码示例

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
 * Assigns the specified element the specified role and value for that role.
 *
 * @param elem the element to be given the specified role
 * @param roleName the name of the role
 */
public static void setRole(Element elem, String roleName) {
 elem.setAttribute(ATTR_NAME_ROLE, roleName);
}

代码示例来源:origin: com.google.gwt/gwt-servlet

@Override
public void set(Element element) {
 assert element != null : "Element cannot be null.";
 element.setAttribute(ATTR_NAME_ROLE, roleName);
}

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
 * Assigns the specified element the specified state and value for that state.
 *
 * @param elem the element to be given the specified state
 * @param stateName the name of the state
 * @param stateValue the value of the state
 */
public static void setState(Element elem, String stateName, String stateValue) {
 elem.setAttribute(stateName, stateValue);
}

代码示例来源:origin: com.google.gwt/gwt-servlet

@Override
public void onDetach() {
 panel.container.setAttribute("onresize", null);
}

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
 * Sets an attribute on a given element.
 * 
 * @param elem element whose attribute is to be set
 * @param attr the name of the attribute
 * @param value the value to which the attribute should be set
 * @deprecated Use {@link Element#setAttribute(String, String)} instead.
 */
@Deprecated
public static void setElementAttribute(Element elem, String attr, String value) {
 elem.setAttribute(attr, value);
}

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
 * Sets the state/property value to the defaultValue if not null. If a list of default values is
 * set, every default value is converted to string and the string values are concatenated in a
 * string token list. There is an assertion checking whether the default is null. Note that the
 * asserts are enabled during development and testing but they will be stripped in production
 * mode.
 *
 * @param element HTML element
 */
public void setDefault(Element element) {
 assert element != null : "Element cannot be null.";
 assert defaultValue != null && !defaultValue.isEmpty() : "Default value cannot be null.";
 element.setAttribute(name, defaultValue);
}

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
 * Sets the state/property {@code value} for the HTML element {@code element}.
 *
 * @param element HTML element
 * @param values Attribute value
 */
public void set(Element element, T... values) {
 assert element != null : "Element cannot be null.";
 assert values.length > 0;
 element.setAttribute(name, getAriaValue(values));
}

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
 * Convenience methods to set an attribute on a cell.
 * 
 * @param row cell's row
 * @param column cell's column
 * @param attrName attribute to set
 * @param value value to set
 * @throws IndexOutOfBoundsException
 */
protected void setAttr(int row, int column, String attrName, String value) {
 Element elem = ensureElement(row, column);
 elem.setAttribute(attrName, value);
}

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
  * Convenience methods to set an attribute on a row.
  * 
  * @param row cell's row
  * @param attrName attribute to set
  * @param value value to set
  * @throws IndexOutOfBoundsException
  */
 protected void setAttr(int row, String attrName, String value) {
  Element elem = ensureElement(row);
  elem.setAttribute(attrName, value);
 }
}

代码示例来源:origin: com.google.gwt/gwt-servlet

@Override
public void setTitle(String title) {
 Element containerElement = getContainerElement();
 if (title == null || title.length() == 0) {
  containerElement.removeAttribute("title");
 } else {
  containerElement.setAttribute("title", title);
 }
}

代码示例来源:origin: com.google.gwt/gwt-servlet

@Override
public R attribute(String name, int value) {
 assertCanAddAttribute().setAttribute(name, String.valueOf(value));
 return getReturnBuilder();
}

代码示例来源:origin: com.google.gwt/gwt-servlet

@Override
public R attribute(String name, String value) {
 assertCanAddAttribute().setAttribute(name, value);
 return getReturnBuilder();
}

代码示例来源:origin: com.google.gwt/gwt-servlet

@Override
 public void ensureDebugId(Element elem, String baseID, String id) {
  assert baseID != null;
  baseID = (baseID.length() > 0) ? baseID + "-" : "";
  String prefix = DebugInfo.getDebugIdPrefix();
  String debugId = ((prefix == null) ? "" : prefix) + baseID + id;
  String attribute = DebugInfo.getDebugIdAttribute();
  if (DebugInfo.isDebugIdAsProperty()) {
   elem.setPropertyString(attribute, debugId);
  } else {
   elem.setAttribute(attribute, debugId);
  }
 }
}

代码示例来源:origin: com.google.gwt/gwt-servlet

String attr = "__gwtCellBasedWidgetImplDispatchingFocus";
if (!"true".equals(elem.getAttribute(attr))) {
 elem.setAttribute(attr, "true");
 sinkFocusEvents(elem);

代码示例来源:origin: com.google.gwt/gwt-servlet

@Override
protected int sinkEvent(Widget widget, String typeName) {
 if (nonBubblingEvents.contains(typeName)) {
  // Initialize the event system.
  if (dispatchNonBubblingEvent == null) {
   initEventSystem();
  }
  // Sink the non-bubbling event.
  Element elem = widget.getElement();
  if (!isNonBubblingEventHandled(elem, typeName)) {
   elem.setAttribute("__gwtCellBasedWidgetImplDispatching" + typeName, "true");
   sinkEventImpl(elem, typeName);
  }
  return -1;
 } else {
  return super.sinkEvent(widget, typeName);
 }
}

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
 * Creates an empty tree item.
 *
 * @param isRoot true if this item is the root of a tree
 */
TreeItem(boolean isRoot) {
 this.isRoot = isRoot;
 Element elem = DOM.clone(BASE_BARE_ELEM, true);
 setElement(elem);
 contentElem = DOM.getFirstChild(elem);
 contentElem.setAttribute("id", DOM.createUniqueId());
 // The root item always has children.
 if (isRoot) {
  initChildren();
 }
}

代码示例来源:origin: com.google.gwt/gwt-servlet

private void init(ImageAdapter images, boolean useLeafImages) {
 setImages(images, useLeafImages);
 setElement(DOM.createDiv());
 getElement().getStyle().setProperty("position", "relative");
 // Fix rendering problem with relatively-positioned elements and their
 // children by
 // forcing the element that is positioned relatively to 'have layout'
 getElement().getStyle().setProperty("zoom", "1");
 focusable = FocusPanel.impl.createFocusable();
 focusable.getStyle().setProperty("fontSize", "0");
 focusable.getStyle().setProperty("position", "absolute");
 // Hide focus outline in Mozilla/Webkit
 focusable.getStyle().setProperty("outline", "0px");
 // Hide focus outline in IE 6/7
 focusable.setAttribute("hideFocus", "true");
 DOM.setIntStyleAttribute(focusable, "zIndex", -1);
 DOM.appendChild(getElement(), focusable);
 sinkEvents(Event.ONMOUSEDOWN | Event.ONCLICK | Event.KEYEVENTS);
 DOM.sinkEvents(focusable, Event.FOCUSEVENTS);
 // The 'root' item is invisible and serves only as a container
 // for all top-level items.
 root = new TreeItem(true);
 root.setTree(this);
 setStyleName("gwt-Tree");
 // Add a11y role "tree"
 Roles.getTreeRole().set(focusable);
}

代码示例来源:origin: GwtMaterialDesign/gwt-material

public MaterialDropDown(Element activatorElement) {
  this();
  activatorElement.setAttribute("data-activates", getId());
  this.activatorElement = activatorElement;
}

代码示例来源:origin: GwtMaterialDesign/gwt-material

@Override
public void setLength(int length) {
  this.length = length;
  Element e = uiObject.getElement();
  if (uiObject instanceof MaterialValueBox) {
    e = ((MaterialValueBox) uiObject).asValueBoxBase().getElement();
  }
  if (e != null) {
    e.setAttribute("length", String.valueOf(length));
    initialize(e);
  }
}

代码示例来源:origin: GwtMaterialDesign/gwt-material

@Override
public void load() {
  if (getResource() != null && !getResource().isEmpty()) {
    // Check whether manifestElement was already attached to the head element.
    if (manifestElement == null) {
      manifestElement = Document.get().createLinkElement();
      getManager().getHeadElement().appendChild(manifestElement);
    }
    manifestElement.setAttribute("rel", "manifest");
    manifestElement.setAttribute("href", getResource());
  }
}

相关文章

微信公众号

最新文章

更多

Element类方法