本文整理了Java中com.vaadin.flow.dom.Element.setPropertyJson()
方法的一些代码示例,展示了Element.setPropertyJson()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.setPropertyJson()
方法的具体详情如下:
包路径:com.vaadin.flow.dom.Element
类名称:Element
方法名:setPropertyJson
[英]Sets the given property to the given JSON value.
Please note that this method does not accept null
as a value, since Json#createNull() should be used instead for JSON values.
Note that properties changed on the server are updated on the client but changes made on the client side are not reflected back to the server unless configured using #addSynchronizedProperty(String) and #addSynchronizedPropertyEvent(String).
[中]将给定属性设置为给定的JSON值。
请注意,此方法不接受null
作为值,因为Json#createNull()应该用于Json值。
请注意,在服务器上更改的属性将在客户端更新,但在客户端所做的更改不会反映回服务器,除非使用#addSynchronizedProperty(字符串)和#addSynchronizedPropertyEvent(字符串)进行配置。
代码示例来源:origin: com.vaadin/vaadin-upload-flow
/**
* @param file
* the JsonObject value to set
*/
protected void setFile(JsonObject file) {
getElement().setPropertyJson("file", file);
}
代码示例来源: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>
*
* @param i18n
* the JsonArray value to set
*/
protected void setI18n(JsonArray i18n) {
getElement().setPropertyJson("i18n", 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>
*
* @param headers
* the JsonObject value to set
*/
protected void setHeaders(JsonObject headers) {
getElement().setPropertyJson("headers", 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>
*
* @param listenOn
* the JsonObject value to set
*/
protected void setListenOn(JsonObject listenOn) {
getElement().setPropertyJson("listenOn", listenOn);
}
代码示例来源:origin: com.vaadin/vaadin-time-picker-flow
getElement().setPropertyJson("i18n", i18n);
代码示例来源:origin: com.vaadin/vaadin-form-layout-flow
getElement().setPropertyJson("responsiveSteps", responsiveSteps);
代码示例来源: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-upload-flow
getElement().setPropertyJson("files", files);
代码示例来源:origin: com.vaadin/vaadin-upload-flow
getElement().setPropertyJson("i18n", i18n);
代码示例来源:origin: com.vaadin/vaadin-date-picker-flow
getElement().setPropertyJson("i18n", i18n);
代码示例来源:origin: com.vaadin/vaadin-form-layout-flow
/**
* Configure the responsive steps used in this layout.
*
* @see ResponsiveStep
*
* @param steps
* list of {@link ResponsiveStep}s to set
*/
public void setResponsiveSteps(List<ResponsiveStep> steps) {
AtomicInteger index = new AtomicInteger();
getElement().setPropertyJson("responsiveSteps",
steps.stream().map(ResponsiveStep::toJson).collect(
Json::createArray,
(arr, value) -> arr.set(index.getAndIncrement(), value),
(arr, arrOther) -> {
int startIndex = arr.length();
for (int i = 0; i < arrOther.length(); i++) {
JsonValue value = arrOther.get(i);
arr.set(startIndex + i, value);
}
}));
}
代码示例来源:origin: com.vaadin/vaadin-crud-flow
private void setI18n(CrudI18n i18n, boolean fireEvent) {
getElement().setPropertyJson("i18n", JsonSerializer.toJson(i18n));
if (fireEvent) {
ComponentUtil.fireEvent(this.grid, new CrudI18nUpdatedEvent(this, false, i18n));
}
}
代码示例来源:origin: com.vaadin/vaadin-checkbox-flow
private void validateSelectionEnabledState(PropertyChangeEvent event) {
if (!hasValidValue()) {
Set<T> oldValue = presentationToModel(this,
(JsonArray) event.getOldValue());
// return the value back on the client side
try {
validationRegistration.remove();
getElement().setPropertyJson(VALUE,
modelToPresentation(this, oldValue));
} finally {
registerValidation();
}
// Now make sure that the button is still in the correct state
Set<T> value = presentationToModel(this,
(JsonArray) event.getValue());
getCheckboxItems()
.filter(checkbox -> value.contains(checkbox.getItem()))
.forEach(this::updateEnabled);
}
}
内容来源于网络,如有侵权,请联系作者删除!