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

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

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

Element.addSynchronizedProperty介绍

[英]Adds the property whose value should automatically be synchronized from the client side and updated in this Element.

Synchronization takes place whenever one of the events defined using #addSynchronizedPropertyEvent(String) is fired for the element.

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

The method is shorthand for #addSynchronizedProperty(String,DisabledUpdateMode) with DisabledUpdateMode.ONLY_WHEN_ENABLED parameter value. #addSynchronizedProperty(String,DisabledUpdateMode)
[中]添加属性,该属性的值应自动从客户端同步并在此元素中更新。
每当为元素触发使用#addSynchronizedPropertyEvent(字符串)定义的一个事件时,就会发生同步。
只能同步可以使用setProperty设置的属性,例如无法同步classList。
该方法是#addSynchronizedProperty(String,DisabledUpdateMode)与DisabledUpdateMode的缩写。仅当启用参数值时才启用#addSynchronizedProperty(字符串,DisabledUpdateMode)

代码示例

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

  1. public Element synchronizeProperty(String property, String eventType,
  2. DisabledUpdateMode mode) {
  3. addSynchronizedProperty(property, mode);
  4. addSynchronizedPropertyEvent(eventType);
  5. return this;

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

  1. /**
  2. * Adds the property whose value should automatically be synchronized from
  3. * the client side and updated in this {@link Element}.
  4. * <p>
  5. * Synchronization takes place whenever one of the events defined using
  6. * {@link #addSynchronizedPropertyEvent(String)} is fired for the element.
  7. * <p>
  8. * Only properties which can be set using setProperty can be synchronized,
  9. * e.g. classList cannot be synchronized.
  10. * <p>
  11. * The method is shorthand for
  12. * {@link #addSynchronizedProperty(String, DisabledUpdateMode)} with
  13. * {@literal DisabledUpdateMode.ONLY_WHEN_ENABLED} parameter value.
  14. * {@link #addSynchronizedProperty(String, DisabledUpdateMode)}
  15. *
  16. * @param property
  17. * the property name to synchronize
  18. * @return this element
  19. * @deprecated Use
  20. * {@link #addPropertyChangeListener(String, String, PropertyChangeListener)}
  21. * or
  22. * {@link DomListenerRegistration#synchronizeProperty(String)}
  23. * instead.
  24. */
  25. @Deprecated
  26. public Element addSynchronizedProperty(String property) {
  27. return addSynchronizedProperty(property,
  28. DisabledUpdateMode.ONLY_WHEN_ENABLED);
  29. }

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

  1. getElement().addSynchronizedProperty("opened")
  2. .addPropertyChangeListener("opened", event -> {
  3. if ((Boolean) event.getValue())

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

  1. /**
  2. * Configures synchronized properties based on given annotations.
  3. */
  4. private void configureSynchronizedProperties() {
  5. ComponentUtil.getSynchronizedProperties(getClass()).forEach(
  6. info -> getElement().addSynchronizedProperty(info.getProperty(),
  7. info.getUpdateMode()));
  8. ComponentUtil.getSynchronizedPropertyEvents(getClass())
  9. .forEach(getElement()::addSynchronizedPropertyEvent);
  10. }

相关文章