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

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

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

Element.synchronizeProperty介绍

[英]Synchronize the given property's value when the given eventType occurs on this element on the client side. As a result the property's value is automatically updated to this Element.

Only properties which can be set using setProperty can be synchronized, e.g. classList cannot be synchronized.

This is convenience method for batching #addSynchronizedProperty(String) and #addSynchronizedPropertyEvent(String).

The method is shorthand for #synchronizeProperty(String,String,DisabledUpdateMode) with DisabledUpdateMode.ONLY_WHEN_ENABLED parameter value.
[中]当客户端的此元素上出现给定eventType时,同步给定属性的值。因此,属性的值会自动更新到此元素。
只能同步可以使用setProperty设置的属性,例如无法同步classList。
这是批处理#addSynchronizedProperty(字符串)和#addSynchronizedPropertyEvent(字符串)的方便方法。
该方法是#synchronizeProperty(String,String,DisabledUpdateMode)与DisabledUpdateMode的简写。仅当启用参数值时才启用。

代码示例

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

return synchronizeProperty(property, eventType,
    DisabledUpdateMode.ONLY_WHEN_ENABLED);

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

/**
 * Default constructor.
 */
public Checkbox() {
  // initial value, default value, accept null value
  super(false, false, false);
  getElement().synchronizeProperty("indeterminate",
      "indeterminate-changed");
  getElement().synchronizeProperty("checked", "checked-changed");
  // https://github.com/vaadin/vaadin-checkbox/issues/25
  setIndeterminate(false);
}

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

private void doSetSynchronizedEvent(String newEvent) {
  Element element = getElement();
  if (this.synchronizedEvent != null) {
    element.removeSynchronizedPropertyEvent(this.synchronizedEvent);
    element.removeSynchronizedProperty(propertyName);
  }
  this.synchronizedEvent = newEvent;
  if (newEvent != null) {
    element.synchronizeProperty(propertyName, newEvent);
  }
}

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

/**
 * Convenience constructor to create a date picker with a pre-selected date
 * in current UI locale format.
 *
 * @param initialDate
 *            the pre-selected date in the picker
 * @see #setValue(Object)
 */
public DatePicker(LocalDate initialDate) {
  super(initialDate, null, String.class, PARSER, FORMATTER);
  getElement().synchronizeProperty("invalid", "invalid-changed");
  setLocale(UI.getCurrent().getLocale());
}

相关文章

微信公众号

最新文章

更多