List of usage examples for com.vaadin.data Binder.BindingBuilder withValidator
public Binder<BEAN> withValidator(Validator<? super BEAN> validator)
From source file:org.jpos.qi.eeuser.UsersView.java
License:Open Source License
protected Component buildAndBindCustomComponent(String propertyId) { if ("roles".equals(propertyId)) { CheckBoxGroup g = new CheckBoxGroup(StringUtils.capitalize(getCaptionFromId(propertyId))); g.setItems(((UsersHelper) getHelper()).getRoles()); g.setItemCaptionGenerator((ItemCaptionGenerator<Role>) item -> StringUtils.capitalize(item.getName())); List<Validator> v = getValidators(propertyId); Binder.BindingBuilder builder = getBinder().forField(g); for (Validator val : v) { builder.withValidator(val); }// www .j av a 2 s . c o m builder.bind(propertyId); return g; } return null; }
From source file:org.jpos.qi.QIEntityView.java
License:Open Source License
protected DateField buildAndBindDateField(String id) { DateField dateField = new DateField(getCaptionFromId("field." + id)); List<Validator> v = getValidators(id); Binder.BindingBuilder builder = getBinder().forField(dateField); for (Validator val : v) { builder.withValidator(val); }// ww w. java2 s. com if (isRequired(id)) { builder.asRequired(getApp().getMessage("errorMessage.req", StringUtils.capitalize(getCaptionFromId("field." + id)))); } ; builder.withConverter(new LocalDateToDateConverter()).bind(id); return dateField; }
From source file:org.jpos.qi.QIEntityView.java
License:Open Source License
protected Binder.BindingBuilder formatField(String id, HasValue field) { List<Validator> v = getValidators(id); Binder.BindingBuilder builder = getBinder().forField(field); for (Validator val : v) builder.withValidator(val); if (isRequired(id)) builder.asRequired(getApp().getMessage("errorMessage.req", StringUtils.capitalize(getCaptionFromId("field." + id)))); ViewConfig.FieldConfig config = viewConfig.getFields().get(id); String width = config != null ? config.getWidth() : null; if (field instanceof AbstractComponent) ((AbstractComponent) field).setWidth(width); builder = builder.withNullRepresentation(""); return builder; }
From source file:org.jpos.util.FieldFactory.java
License:Open Source License
public DateField buildAndBindDateField(String id) { DateField dateField = new DateField(getCaptionFromId("field." + id)); Binder.BindingBuilder builder = getBinder().forField(dateField); builder.withConverter(new LocalDateToDateConverter()).bind(id); if (viewConfig == null) return dateField; List<Validator> v = getValidators(id); for (Validator val : v) builder.withValidator(val); if (isRequired(id)) builder.asRequired(getApp().getMessage("errorMessage.req", StringUtils.capitalize(getCaptionFromId("field." + id)))); if ("endDate".equals(id)) dateField.addValueChangeListener( (HasValue.ValueChangeListener<LocalDate>) event -> dateField.addStyleName("expired-date")); return dateField; }
From source file:org.jpos.util.FieldFactory.java
License:Open Source License
public Binder.BindingBuilder formatField(String id, HasValue field) { Binder.BindingBuilder builder = getBinder().forField(field); builder = builder.withNullRepresentation(""); if (viewConfig == null) return builder; List<Validator> v = getValidators(id); for (Validator val : v) builder.withValidator(val); if (isRequired(id)) builder.asRequired(getApp().getMessage("errorMessage.req", StringUtils.capitalize(getCaptionFromId("field." + id)))); ViewConfig.FieldConfig config = viewConfig.getFields().get(id); String width = config != null ? config.getWidth() : null; if (field instanceof AbstractComponent) ((AbstractComponent) field).setWidth(width); return builder; }