@Override public void setPropertyDataSource(Property newDataSource) { field.setPropertyDataSource(newDataSource); }
public void setPropertyDataSource(Property newDataSource) { if (converter != null) { // note that assuming property == converter in this case converter.setPropertyDataSource(newDataSource); } else { wrappedField.setPropertyDataSource(newDataSource); } }
/** * Create a custom field wrapping a {@link Field} with a user-defined * {@link PropertyConverter}. * * Subclass constructors calling this constructor must create and set the * layout. * * When this constructor is used, the methods {@link #format(PC)} and * {@link #parse(Object)} are never called. * * @param wrappedField * @param propertyConverter * or null to bypass the use of a property converter * @param propertyType */ protected FieldWrapper(Field wrappedField, PropertyConverter<PC, ? extends Object> converter, Class<? extends PC> propertyType) { this.wrappedField = wrappedField; this.converter = converter; this.propertyType = propertyType; if (converter != null) { converter.setPropertyDataSource(wrappedField .getPropertyDataSource()); wrappedField.setPropertyDataSource(converter); property = converter; } else { property = wrappedField; } }
public void addExtraField(Item item, Object id) { final Property property = item.getItemProperty(id); final Field f = getFormFieldFactory().createField(item, id, this); if (f != null) { f.setPropertyDataSource(property); addField(id, f); } } public void changeVariables(Object source, Map<String, Object> variables) {
public void addExtraField(Item item, Object id) { final Property<?> property = item.getItemProperty(id); final Field<?> f = getFormFieldFactory().createField(item, id, this); if (f != null) { f.setPropertyDataSource(property); addField(id, f); } } public void changeVariables(Object source, Map<String, Object> variables) {
/** * Create a custom field wrapping a {@link Field}. * * Subclass constructors calling this constructor must create and set the * layout. * * When this constructor is used, value conversions are delegated to the * methods {@link #format(PC)} and {@link #parse(Object)}. * * @param wrappedField * @param propertyType */ protected FieldWrapper(Field wrappedField, Class<? extends PC> propertyType) { this.wrappedField = wrappedField; this.propertyType = propertyType; converter = new DefaultPropertyConverter(propertyType); converter.setPropertyDataSource(wrappedField.getPropertyDataSource()); wrappedField.setPropertyDataSource(converter); property = converter; }
/** * Override in order to set the converter if defined. */ @Override public void setPropertyDataSourceAndDefaultValue(Property<?> property) { if (converter != null) { ((AbstractSelect) field).setConverter((Converter) converter); } this.field.setPropertyDataSource(property); if ((item instanceof ItemAdapter && ((ItemAdapter) item).isNew()) || (!(item instanceof ItemAdapter) && property.getValue() == null)) { setPropertyDataSourceDefaultValue(property); } }
/** * Initialize and configure the internal wrapped field */ protected void init() { // build internal field this.internalField = buildInternalField(getType()); // use this field as data source for internal field if (this.internalField instanceof AbstractComponent) { ((AbstractComponent) this.internalField).setImmediate(true); } this.internalField.setBuffered(false); this.internalField.setPropertyDataSource(this); }
@Override public void addField(Object propertyId, Field field) { Item item = getItemDataSource(); field.setPropertyDataSource(item.getItemProperty(propertyId)); Class<? extends T> beanClass = this.beanClass; if (item instanceof BeanItem) { beanClass = (Class<? extends T>) ((BeanItem<T>) item).getBean() .getClass(); } BeanValidationValidator validator = BeanValidationValidator .addValidator(field, propertyId, beanClass); if (locale != null) { validator.setLocale(locale); } super.addField(propertyId, field); }
public Field createField(Item item, Object propertyId, Component uiContext) { logger.debug("creating field for {}",propertyId); com.vaadin.data.Property property = item.getItemProperty(propertyId); Field ret; if (property instanceof MaduraPropertyWrapper) { MaduraPropertyWrapper maduraProperty = (MaduraPropertyWrapper)property; ret = createFieldByPropertyType(maduraProperty); // logger.debug("created field {} class {} value {}",new Object[]{propertyId,ret.getClass().getName(),ret.getValue()}); } else if (item instanceof BeanItem) { MaduraPropertyWrapper maduraProperty = getMaduraSessionManager().getMaduraPropertyWrapper((ValidationObject)((BeanItem)item).getBean(), propertyId.toString()); ret = createFieldByPropertyType(maduraProperty); // logger.debug("created field {} class {} value {}",new Object[]{propertyId,ret.getClass().getName(),ret.getValue()}); } else { // this probably never gets called Field field = super.createField(item, propertyId, uiContext); field.setWidth(getHints().getWidth()); field.setReadThrough(true); field.setWriteThrough(true); field.setPropertyDataSource(property); ret = field; } return ret; } public Field createFieldByPropertyType(MaduraPropertyWrapper property) {
field.setWidth(getHints().getWidth()); field.setBuffered(false); field.setPropertyDataSource(property); ret = field;
field.setPropertyDataSource(property); field.setRequired(property.isRequired()); field.setWidth(100, Sizeable.UNITS_PERCENTAGE);