本文整理汇总了Java中com.vaadin.server.Setter类的典型用法代码示例。如果您正苦于以下问题:Java Setter类的具体用法?Java Setter怎么用?Java Setter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Setter类属于com.vaadin.server包,在下文中一共展示了Setter类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readBean
import com.vaadin.server.Setter; //导入依赖的package包/类
@Override
public void readBean(BEAN bean) {
if (binder.getBean() == null) {
try {
Constructor<BEAN> ctor = clz.getConstructor();
binder.setBean(ctor.newInstance());
} catch (InvocationTargetException | IllegalArgumentException | IllegalAccessException
| InstantiationException | NoSuchMethodException | SecurityException e) {
throw new UnsupportedOperationException("Not supported");
}
}
BEAN targetBean = binder.getBean();
binder.removeBean();
binder.getBindings().stream().forEach(e -> {
@SuppressWarnings("unchecked")
Setter<BEAN, Object> setter = (Setter<BEAN, Object>) e.setter;
if (setter != null) {
setter.accept(targetBean, e.getter.apply(bean));
}
});
binder.setBean(targetBean);
}
示例2: writeBean
import com.vaadin.server.Setter; //导入依赖的package包/类
@Override
public void writeBean(BEAN bean) throws ValidationException {
if (!binder.isValid()) {
BasicBinderValidationStatus<BEAN> vs = binder.getValidationStatus();
throw new ValidationException(vs.getFieldValidationErrors(), vs.getBeanValidationErrors());
}
BEAN sourceBean = binder.getBean();
if (sourceBean == null) {
return;
}
binder.getBindings().stream().forEach(e -> {
@SuppressWarnings("unchecked")
Setter<BEAN, Object> setter = (Setter<BEAN, Object>) e.setter;
if (setter != null) {
setter.accept(bean, e.getter.apply(sourceBean));
}
});
// Trigger StatusChange (required by Grid editor).
binder.removeBean();
binder.setBean(sourceBean);
}
示例3: bind
import com.vaadin.server.Setter; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
public <PRESENTATION, MODEL> EasyBinding<BEAN, PRESENTATION, MODEL> bind(HasValue<PRESENTATION> field,
String propertyName, Converter<PRESENTATION, ?> converter, boolean readOnly) {
Objects.requireNonNull(converter);
Objects.requireNonNull(propertyName, "Property name cannot be null");
// checkUnbound();
PropertyDefinition<BEAN, ?> definition = propertySet.getProperty(propertyName)
.orElseThrow(() -> new IllegalArgumentException(
"Could not resolve property name " + propertyName + " from " + propertySet));
ValueProvider<BEAN, ?> getter = definition.getGetter();
Setter<BEAN, ?> setter = readOnly ? null : definition.getSetter().orElse(null);
EasyBinding<BEAN, PRESENTATION, MODEL> binding = bind(field, (ValueProvider) getter, (Setter) setter,
propertyName, (Converter) converter);
boundProperties.put(propertyName, binding);
Optional<Field> modelField = getDeclaredFieldByName(definition.getPropertyHolderType(), definition.getName());
if (Arrays.asList(modelField.get().getAnnotations()).stream().anyMatch(requiredConfigurator)) {
field.setRequiredIndicatorVisible(true);
}
return binding;
}
示例4: EasyBinding
import com.vaadin.server.Setter; //导入依赖的package包/类
public EasyBinding(BasicBinder<BEAN> binder, HasValue<FIELDVALUE> field, ValueProvider<BEAN, TARGET> getter,
Setter<BEAN, TARGET> setter, String property,
Converter<FIELDVALUE, TARGET> converterValidatorChain) {
this.field = field;
this.getter = getter;
this.setter = setter;
this.property = property;
this.converterValidatorChain = converterValidatorChain;
registration = field.addValueChangeListener(e -> {
if (binder.getBean() != null) {
if (binder.fieldToBean(this)) {
binder.fireValueChangeEvent(e);
}
}
});
if (setter == null) {
field.setReadOnly(true);
}
}
示例5: bind
import com.vaadin.server.Setter; //导入依赖的package包/类
public <FIELDVALUE, TARGET> EasyBinding<BEAN, FIELDVALUE, TARGET> bind(HasValue<FIELDVALUE> field,
ValueProvider<BEAN, TARGET> getter, Setter<BEAN, TARGET> setter, String property,
Converter<FIELDVALUE, TARGET> converter) {
Objects.requireNonNull(field);
Objects.requireNonNull(getter);
Objects.requireNonNull(converter);
// Register as binding
EasyBinding<BEAN, FIELDVALUE, TARGET> binding = new EasyBinding<BEAN, FIELDVALUE, TARGET>(this, field, getter,
setter, property, converter);
// TODO: remove from binding
/*
* binding.registration = field.addValueChangeListener(e -> { if (getBean() !=
* null) { if(fieldToBean(binding)) { fireValueChangeEvent(e); } } });
*/
bindings.add(binding);
// Add property to validation error map
if (property != null) {
propertyToBindingMap.put(property, binding);
}
if (getBean() != null) {
if (fieldToBean(binding)) {
// TODO: should this be fired?
// fireValueChangeEvent(e);
}
} else {
fireStatusChangeEvent();
}
return binding;
}
示例6: getSetter
import com.vaadin.server.Setter; //导入依赖的package包/类
@Override
public Optional<Setter<PropertyBox, V>> getSetter() {
if (property.isReadOnly()) {
return Optional.empty();
}
return Optional.of((pb, value) -> {
pb.setValue(property, value);
});
}
示例7: bind
import com.vaadin.server.Setter; //导入依赖的package包/类
@Override
public <FIELDVALUE> Binding<BEAN, FIELDVALUE> bind(HasValue<FIELDVALUE> field,
ValueProvider<BEAN, FIELDVALUE> getter, Setter<BEAN, FIELDVALUE> setter) {
throw new UnsupportedOperationException("Not supported");
}