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

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

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

Element.getPropertyRaw介绍

[英]Gets the raw property value without any value conversion. The type of the value is String, Double, Boolean or JsonValue. null is returned if there is no property with the given name or if the value is set to null.
[中]获取未经任何值转换的原始属性值。值的类型为String、Double、Boolean或JsonValue。如果没有具有给定名称的属性或该值设置为null,则返回null

代码示例

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

/**
 * Creates a new {@code PropertyChangeEvent} event containing the current
 * property value of the given element.
 *
 * @param element
 *            the source element owning the property, not null
 * @param propertyName
 *            the property name
 * @param oldValue
 *            the previous value held by the source of this event
 * @param userOriginated
 *            {@code true} if this event originates from the client,
 *            {@code false} otherwise.
 */
public PropertyChangeEvent(Element element, String propertyName,
    Serializable oldValue, boolean userOriginated) {
  super(element);
  this.propertyName = propertyName;
  this.oldValue = oldValue;
  this.value = element.getPropertyRaw(propertyName);
  this.userOriginated = userOriginated;
}

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

/**
 * This property is not synchronized automatically from the client side, so
 * the returned value may not be the same as in client side.
 *
 * @return the {@code file} property from the webcomponent
 */
protected JsonObject getFileJsonObject() {
  return (JsonObject) getElement().getPropertyRaw("file");
}

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

@Override
protected boolean hasValidValue() {
  Set<T> selectedItems = presentationToModel(this,
      (JsonArray) getElement().getPropertyRaw(VALUE));
  if (selectedItems == null || selectedItems.isEmpty()) {
    return true;
  }
  return selectedItems.stream().allMatch(itemEnabledProvider);
}

代码示例来源:origin: com.vaadin/vaadin-rich-text-editor-flow

/**
 * <p>
 * Description copied from corresponding location in WebComponent:
 * </p>
 * <p>
 * An object used to localize this component. The properties are used e.g.
 * as the tooltips for the editor toolbar buttons.
 * <p>
 * This property is not synchronized automatically from the client side, so
 * the returned value may not be the same as in client side.
 * </p>
 * 
 * @return the {@code i18n} property from the webcomponent
 */
protected JsonArray getI18nJsonArray() {
  return (JsonArray) getElement().getPropertyRaw("i18n");
}

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

/**
 * <p>
 * Description copied from corresponding location in WebComponent:
 * </p>
 * <p>
 * Key-Value map to send to the server. If you set this property as an
 * attribute, use a valid JSON string, for example: {@code <vaadin-upload
 * headers=' "X-Foo": "Bar"}'></vaadin-upload>}
 * <p>
 * This property is not synchronized automatically from the client side, so
 * the returned value may not be the same as in client side.
 * </p>
 *
 * @return the {@code headers} property from the webcomponent
 */
protected JsonObject getHeadersJsonObject() {
  return (JsonObject) getElement().getPropertyRaw("headers");
}

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

/**
 * <p>
 * Description copied from corresponding location in WebComponent:
 * </p>
 * <p>
 * The target element that's listened to for context menu opening events. By
 * default the vaadin-context-menu listens to the target's
 * {@code vaadin-contextmenu} events.
 * <p>
 * This property is not synchronized automatically from the client side, so
 * the returned value may not be the same as in client side.
 * </p>
 *
 * @return the {@code listenOn} property from the webcomponent
 */
protected JsonObject getListenOnJsonObject() {
  return (JsonObject) getElement().getPropertyRaw("listenOn");
}

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

/**
 * Gets the value of the given property as a boolean, or the given default
 * value if the underlying value is <code>null</code>.
 * <p>
 * A value defined as some other type than boolean is converted according to
 * JavaScript semantics:
 * <ul>
 * <li>String values are <code>true</code>, except for the empty string.
 * <li>Numerical values are <code>true</code>, except for 0 and
 * <code>NaN</code>.
 * <li>JSON object and JSON array values are always <code>true</code>.
 * </ul>
 *
 * @param name
 *            the property name, not <code>null</code>
 * @param defaultValue
 *            the value to return if the property is not set, or if the
 *            value is <code>null</code>
 * @return the property value
 */
public boolean getProperty(String name, boolean defaultValue) {
  Object value = getPropertyRaw(name);
  if (value == null) {
    return defaultValue;
  } else {
    return JavaScriptSemantics.isTrueish(value);
  }
}

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

Object value = getPropertyRaw(name);
if (value == null) {
  return defaultValue;

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

private <C extends AbstractField<C, V>, V> SerializableBiFunction<C, V, V> createReader(
    Element element, String propertyName,
    SerializableBiFunction<C, P, V> presentationToModel) {
  return (component, defaultModelValue) -> {
    if (element.getPropertyRaw(propertyName) != null) {
      P presentationValue = getter.apply(element, propertyName);
      return presentationToModel.apply(component,
          presentationValue);
    } else {
      return defaultModelValue;
    }
  };
}

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

return (JsonObject) getElement().getPropertyRaw("i18n");

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

Object value = getPropertyRaw(name);
if (value == null) {
  return defaultValue;

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

private static <P extends JsonValue> TypeHandler<P> getHandler(
    Class<P> type) {
  ElementGetter<P> getter = (element, property, defaultValue) -> {
    Serializable value = element.getPropertyRaw(property);
    // JsonValue is passed straight through, other primitive
    // values are jsonified
    return type.cast(JsonCodec.encodeWithoutTypeInfo(value));
  };
  ElementSetter<P> setter = (element, property, value) -> element
      .setPropertyJson(property, value);
  return new TypeHandler<P>(setter, getter, null);
}

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

/**
 * Get the list of {@link ResponsiveStep}s used to configure this layout.
 *
 * @see ResponsiveStep
 *
 * @return the list of {@link ResponsiveStep}s used to configure this layout
 */
public List<ResponsiveStep> getResponsiveSteps() {
  JsonArray stepsJsonArray = (JsonArray) getElement()
      .getPropertyRaw("responsiveSteps");
  if (stepsJsonArray == null) {
    return Collections.emptyList();
  }
  List<ResponsiveStep> steps = new ArrayList<>();
  for (int i = 0; i < stepsJsonArray.length(); i++) {
    steps.add(stepsJsonArray.get(i));
  }
  return steps;
}

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

return (JsonArray) getElement().getPropertyRaw("files");

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

private void updateEnabled(Tab tab) {
  boolean enabled = tab.isEnabled();
  Serializable rawValue = tab.getElement().getPropertyRaw("disabled");
  if (rawValue instanceof Boolean) {
    // convert the boolean value to a String to force update the
    // property value. Otherwise since the provided value is the same as
    // the current one the update don't do anything.
    tab.getElement().setProperty("disabled",
        enabled ? null : Boolean.TRUE.toString());
  } else {
    tab.setEnabled(enabled);
  }
}

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

private String getStringObject(String propertyName, String subName) {
  String result = null;
  JsonObject json = (JsonObject) getElement()
      .getPropertyRaw(propertyName);
  if (json != null && json.hasKey(subName)
      && !(json.get(subName) instanceof JsonNull)) {
    result = json.getString(subName);
  }
  return result;
}

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

private void updateEnabled(RadioButton<T> button) {
  boolean disabled = isDisabledBoolean()
      || !getItemEnabledProvider().test(button.getItem());
  Serializable rawValue = button.getElement().getPropertyRaw("disabled");
  if (rawValue instanceof Boolean) {
    // convert the boolean value to a String to force update the
    // property value. Otherwise since the provided value is the same as
    // the current one the update don't do anything.
    button.getElement().setProperty("disabled",
        disabled ? Boolean.TRUE.toString() : null);
  } else {
    button.setDisabled(disabled);
  }
}

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

private void updateEnabled(CheckBoxItem<T> checkbox) {
  boolean disabled = isDisabledBoolean()
      || !getItemEnabledProvider().test(checkbox.getItem());
  Serializable rawValue = checkbox.getElement()
      .getPropertyRaw("disabled");
  if (rawValue instanceof Boolean) {
    // convert the boolean value to a String to force update the
    // property value. Otherwise since the provided value is the same as
    // the current one the update don't do anything.
    checkbox.getElement().setProperty("disabled",
        disabled ? Boolean.TRUE.toString() : null);
  } else {
    checkbox.setDisabled(disabled);
  }
}

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

.createElement(element.getTag());
if (element.hasProperty("innerHTML")) {
  target.html((String) element.getPropertyRaw("innerHTML"));

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

private String getStringObject(String propertyName, String object,
    String subName) {
  String result = null;
  JsonObject json = (JsonObject) getElement()
      .getPropertyRaw(propertyName);
  if (json != null && json.hasKey(object)
      && !(json.get(object) instanceof JsonNull)) {
    json = json.getObject(object);
    if (json != null && json.hasKey(subName)
        && !(json.get(subName) instanceof JsonNull)) {
      result = json.getString(subName);
    }
  }
  return result;
}

相关文章

微信公众号

最新文章

更多