本文整理汇总了Java中com.vaadin.ui.AbstractField.setValue方法的典型用法代码示例。如果您正苦于以下问题:Java AbstractField.setValue方法的具体用法?Java AbstractField.setValue怎么用?Java AbstractField.setValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.vaadin.ui.AbstractField
的用法示例。
在下文中一共展示了AbstractField.setValue方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBuildAndBind
import com.vaadin.ui.AbstractField; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testBuildAndBind() {
AutoBinder<MyEntity> binder = new AutoBinder<>(MyEntity.class);
binder.buildAndBind("car", "car.frontLeft", "car.frontLeft.tire", "spare", "spare.tire");
MyEntity entity = new MyEntity();
binder.setBean(entity);
assertTrue(binder.getFieldForProperty("street").isPresent());
assertTrue(binder.getFieldForProperty("number").isPresent());
assertTrue(binder.getFieldForProperty("number2").isPresent());
assertTrue(binder.getFieldForProperty("car.frontLeft.tire.type").isPresent());
assertTrue(binder.getFieldForProperty("spare.tire.type").isPresent());
assertTrue(binder.getFieldForProperty("unknown").isPresent());
AbstractField<String> numberField = (AbstractField<String>) binder.getFieldForProperty("number").get();
AbstractField<String> numberField2 = (AbstractField<String>) binder.getFieldForProperty("number2").get();
((HasValue<String>) binder.getFieldForProperty("street").get()).setValue("mystreet");
assertEquals("mystreet", entity.getStreet());
numberField.setValue("100");
assertEquals(new Integer(100), entity.getNumber());
assertNull(numberField.getComponentError());
numberField.setValue("0");
assertNotNull(numberField.getComponentError());
numberField.setValue("");
assertEquals(null, entity.getNumber());
assertNull(numberField.getComponentError());
numberField2.setValue("");
assertNotNull(numberField2.getComponentError());
}
示例2: getLangueLayout
import com.vaadin.ui.AbstractField; //导入方法依赖的package包/类
/** Renvoie un layout contenant un choix de langue et une traduction
* @param traductionOther
* @return le layout
*/
private HorizontalLayout getLangueLayout(I18nTraduction traductionOther){
/*Le layout renvoyé*/
HorizontalLayout hlLangueOther = new HorizontalLayout();
listLayoutTraductions.add(hlLangueOther);
hlLangueOther.setSpacing(true);
hlLangueOther.setWidth(100, Unit.PERCENTAGE);
/*La combobox avec les icones de drapeaux*/
ComboBoxLangue cbLangue = new ComboBoxLangue(listeLangueEnService,false);
cbLangue.selectLangue((traductionOther==null?null:traductionOther.getLangue()));
cbLangue.setWidth(75, Unit.PIXELS);
hlLangueOther.addComponent(cbLangue);
/*Le textField... ou */
AbstractField<String> tfValOther = getNewValueComponent();
tfValOther.setWidth(100, Unit.PERCENTAGE);
if (traductionOther!=null){
tfValOther.setValue(traductionOther.getValTrad());
}
hlLangueOther.addComponent(tfValOther);
hlLangueOther.setExpandRatio(tfValOther,1);
/*Le bouton de suppression de la langue*/
OneClickButton removeLangue = new OneClickButton(FontAwesome.MINUS_SQUARE_O);
removeLangue.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
removeLangue.addStyleName(ValoTheme.BUTTON_BORDERLESS);
removeLangue.addClickListener(e->{layoutLangue.removeComponent(hlLangueOther);listLayoutTraductions.remove(hlLangueOther);checkVisibleAddLangue();centerWindow();});
hlLangueOther.addComponent(removeLangue);
return hlLangueOther;
}
示例3: isMandatoryFieldNotEmptyAndValid
import com.vaadin.ui.AbstractField; //导入方法依赖的package包/类
private boolean isMandatoryFieldNotEmptyAndValid(final Component currentChangedComponent, final Object newValue) {
boolean valid = true;
final List<AbstractField<?>> requiredComponents = allComponents.stream().filter(AbstractField::isRequired)
.filter(AbstractField::isEnabled).collect(Collectors.toList());
requiredComponents.addAll(allComponents.stream().filter(this::hasNullValidator).collect(Collectors.toList()));
for (final AbstractField field : requiredComponents) {
Object value = getCurrentVaue(currentChangedComponent, newValue, field);
if (String.class.equals(field.getType())) {
value = Strings.emptyToNull((String) value);
}
if (Set.class.equals(field.getType())) {
value = emptyToNull((Collection<?>) value);
}
if (value == null) {
return false;
}
// We need to loop through the entire loop for validity testing.
// Otherwise the UI will only mark the
// first field with errors and then stop. If there are several
// fields with errors, this is bad.
field.setValue(value);
if (!field.isValid()) {
valid = false;
}
}
return valid;
}
示例4: resetAbstractField
import com.vaadin.ui.AbstractField; //导入方法依赖的package包/类
private void resetAbstractField(final AbstractField<?> next)
{
if (next instanceof AbstractTextField)
{
((AbstractTextField) next).setValue(Constants.EMPTY);
}
else
{
next.setValue(null);
}
}
示例5: addProfileInputField
import com.vaadin.ui.AbstractField; //导入方法依赖的package包/类
protected void addProfileInputField(GridLayout layout, String name, AbstractField inputField, String inputFieldValue) {
Label label = new Label(name + ": ");
label.addStyleName(ExplorerLayout.STYLE_PROFILE_FIELD);
label.setSizeUndefined();
layout.addComponent(label);
layout.setComponentAlignment(label, Alignment.MIDDLE_LEFT);
if (inputFieldValue != null) {
inputField.setValue(inputFieldValue);
}
layout.addComponent(inputField);
layout.setComponentAlignment(inputField, Alignment.MIDDLE_LEFT);
}
示例6: setControlValue
import com.vaadin.ui.AbstractField; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
public void setControlValue(Object value) {
AbstractField<Object> field = (AbstractField<Object>) getControl();
field.setValue(value);
}
示例7: getLangueLayoutInactive
import com.vaadin.ui.AbstractField; //导入方法依赖的package包/类
/** Renvoie un layout contenant un choix de langue et une traduction
* @param traductionInactive
* @return le layout
*/
private HorizontalLayout getLangueLayoutInactive(I18nTraduction traductionInactive){
Langue langueInactive = traductionInactive.getLangue();
/*Ajout de la langue par defaut*/
HorizontalLayout hlLangueInactive = new HorizontalLayout();
listLayoutTraductions.add(hlLangueInactive);
hlLangueInactive.setSpacing(true);
hlLangueInactive.setWidth(100, Unit.PERCENTAGE);
layoutLangue.addComponent(hlLangueInactive);
Image flag = new Image(null, new ThemeResource("images/flags/"+langueInactive.getCodLangue()+".png"));
HorizontalLayout hlFlag = new HorizontalLayout();
hlFlag.setWidth(75,Unit.PIXELS);
hlFlag.addComponent(flag);
hlFlag.setComponentAlignment(flag, Alignment.MIDDLE_CENTER);
hlLangueInactive.addComponent(hlFlag);
/*La valeur de la traduction*/
AbstractField<String> tfVal = getNewValueComponent();
tfVal.setId(langueInactive.getCodLangue());
tfVal.setWidth(100, Unit.PERCENTAGE);
/*Recuperation de la valeur de la traduction par defaut dans la liste des traductions*/
if (listeTraduction.size() != 0){
Optional<I18nTraduction> opt = listeTraduction.stream().filter(l->l.getLangue().getCodLangue().equals(langueInactive.getCodLangue())).findFirst();
if (opt.isPresent()){
tfVal.setValue(opt.get().getValTrad());
}
}
hlLangueInactive.addComponent(tfVal);
hlLangueInactive.setExpandRatio(tfVal,1);
/*Le bouton de suppression de la langue*/
OneClickButton removeLangue = new OneClickButton(FontAwesome.MINUS_SQUARE_O);
removeLangue.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
removeLangue.addStyleName(ValoTheme.BUTTON_BORDERLESS);
removeLangue.addClickListener(e->{layoutLangue.removeComponent(hlLangueInactive);listLayoutTraductions.remove(hlLangueInactive);checkVisibleAddLangue();centerWindow();});
hlLangueInactive.addComponent(removeLangue);
return hlLangueInactive;
}