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

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

本文整理了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

  1. /**
  2. * Creates a new {@code PropertyChangeEvent} event containing the current
  3. * property value of the given element.
  4. *
  5. * @param element
  6. * the source element owning the property, not null
  7. * @param propertyName
  8. * the property name
  9. * @param oldValue
  10. * the previous value held by the source of this event
  11. * @param userOriginated
  12. * {@code true} if this event originates from the client,
  13. * {@code false} otherwise.
  14. */
  15. public PropertyChangeEvent(Element element, String propertyName,
  16. Serializable oldValue, boolean userOriginated) {
  17. super(element);
  18. this.propertyName = propertyName;
  19. this.oldValue = oldValue;
  20. this.value = element.getPropertyRaw(propertyName);
  21. this.userOriginated = userOriginated;
  22. }

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

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

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

  1. @Override
  2. protected boolean hasValidValue() {
  3. Set<T> selectedItems = presentationToModel(this,
  4. (JsonArray) getElement().getPropertyRaw(VALUE));
  5. if (selectedItems == null || selectedItems.isEmpty()) {
  6. return true;
  7. }
  8. return selectedItems.stream().allMatch(itemEnabledProvider);
  9. }

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

  1. /**
  2. * <p>
  3. * Description copied from corresponding location in WebComponent:
  4. * </p>
  5. * <p>
  6. * An object used to localize this component. The properties are used e.g.
  7. * as the tooltips for the editor toolbar buttons.
  8. * <p>
  9. * This property is not synchronized automatically from the client side, so
  10. * the returned value may not be the same as in client side.
  11. * </p>
  12. *
  13. * @return the {@code i18n} property from the webcomponent
  14. */
  15. protected JsonArray getI18nJsonArray() {
  16. return (JsonArray) getElement().getPropertyRaw("i18n");
  17. }

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

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

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

  1. /**
  2. * <p>
  3. * Description copied from corresponding location in WebComponent:
  4. * </p>
  5. * <p>
  6. * The target element that's listened to for context menu opening events. By
  7. * default the vaadin-context-menu listens to the target's
  8. * {@code vaadin-contextmenu} events.
  9. * <p>
  10. * This property is not synchronized automatically from the client side, so
  11. * the returned value may not be the same as in client side.
  12. * </p>
  13. *
  14. * @return the {@code listenOn} property from the webcomponent
  15. */
  16. protected JsonObject getListenOnJsonObject() {
  17. return (JsonObject) getElement().getPropertyRaw("listenOn");
  18. }

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

  1. /**
  2. * Gets the value of the given property as a boolean, or the given default
  3. * value if the underlying value is <code>null</code>.
  4. * <p>
  5. * A value defined as some other type than boolean is converted according to
  6. * JavaScript semantics:
  7. * <ul>
  8. * <li>String values are <code>true</code>, except for the empty string.
  9. * <li>Numerical values are <code>true</code>, except for 0 and
  10. * <code>NaN</code>.
  11. * <li>JSON object and JSON array values are always <code>true</code>.
  12. * </ul>
  13. *
  14. * @param name
  15. * the property name, not <code>null</code>
  16. * @param defaultValue
  17. * the value to return if the property is not set, or if the
  18. * value is <code>null</code>
  19. * @return the property value
  20. */
  21. public boolean getProperty(String name, boolean defaultValue) {
  22. Object value = getPropertyRaw(name);
  23. if (value == null) {
  24. return defaultValue;
  25. } else {
  26. return JavaScriptSemantics.isTrueish(value);
  27. }
  28. }

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

  1. Object value = getPropertyRaw(name);
  2. if (value == null) {
  3. return defaultValue;

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

  1. private <C extends AbstractField<C, V>, V> SerializableBiFunction<C, V, V> createReader(
  2. Element element, String propertyName,
  3. SerializableBiFunction<C, P, V> presentationToModel) {
  4. return (component, defaultModelValue) -> {
  5. if (element.getPropertyRaw(propertyName) != null) {
  6. P presentationValue = getter.apply(element, propertyName);
  7. return presentationToModel.apply(component,
  8. presentationValue);
  9. } else {
  10. return defaultModelValue;
  11. }
  12. };
  13. }

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

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

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

  1. Object value = getPropertyRaw(name);
  2. if (value == null) {
  3. return defaultValue;

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

  1. private static <P extends JsonValue> TypeHandler<P> getHandler(
  2. Class<P> type) {
  3. ElementGetter<P> getter = (element, property, defaultValue) -> {
  4. Serializable value = element.getPropertyRaw(property);
  5. // JsonValue is passed straight through, other primitive
  6. // values are jsonified
  7. return type.cast(JsonCodec.encodeWithoutTypeInfo(value));
  8. };
  9. ElementSetter<P> setter = (element, property, value) -> element
  10. .setPropertyJson(property, value);
  11. return new TypeHandler<P>(setter, getter, null);
  12. }

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

  1. /**
  2. * Get the list of {@link ResponsiveStep}s used to configure this layout.
  3. *
  4. * @see ResponsiveStep
  5. *
  6. * @return the list of {@link ResponsiveStep}s used to configure this layout
  7. */
  8. public List<ResponsiveStep> getResponsiveSteps() {
  9. JsonArray stepsJsonArray = (JsonArray) getElement()
  10. .getPropertyRaw("responsiveSteps");
  11. if (stepsJsonArray == null) {
  12. return Collections.emptyList();
  13. }
  14. List<ResponsiveStep> steps = new ArrayList<>();
  15. for (int i = 0; i < stepsJsonArray.length(); i++) {
  16. steps.add(stepsJsonArray.get(i));
  17. }
  18. return steps;
  19. }

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

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

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

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

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

  1. private String getStringObject(String propertyName, String subName) {
  2. String result = null;
  3. JsonObject json = (JsonObject) getElement()
  4. .getPropertyRaw(propertyName);
  5. if (json != null && json.hasKey(subName)
  6. && !(json.get(subName) instanceof JsonNull)) {
  7. result = json.getString(subName);
  8. }
  9. return result;
  10. }

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

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

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

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

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

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

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

  1. private String getStringObject(String propertyName, String object,
  2. String subName) {
  3. String result = null;
  4. JsonObject json = (JsonObject) getElement()
  5. .getPropertyRaw(propertyName);
  6. if (json != null && json.hasKey(object)
  7. && !(json.get(object) instanceof JsonNull)) {
  8. json = json.getObject(object);
  9. if (json != null && json.hasKey(subName)
  10. && !(json.get(subName) instanceof JsonNull)) {
  11. result = json.getString(subName);
  12. }
  13. }
  14. return result;
  15. }

相关文章