/** * Sets the converter used to convert the field value to property data * source type. The converter must have a presentation type that matches the * field type. * * @param converter * The new converter to use. * @return this (for method chaining) * @see AbstractField#setConverter(com.vaadin.v7.data.util.converter.Converter) */ public default S withConverter(Converter<T, ?> converter) { ((AbstractField<T>) this).setConverter(converter); return (S) this; }
/** * Retrieves a converter for the field from the converter factory defined * for the application. Clears the converter if no application reference is * available or if the factory returns null. * * @param datamodelType * The type of the data model that we want to be able to convert * from * @return this (for method chaining) * @see AbstractField#setConverter(java.lang.Class) */ public default S withConverter(Class<?> datamodelType) { ((AbstractField<T>) this).setConverter(datamodelType); return (S) this; }
/** * Retrieves a converter for the field from the converter factory defined * for the application. Clears the converter if no application reference is * available or if the factory returns null. * * @param datamodelType * The type of the data model that we want to be able to convert * from */ public void setConverter(Class<?> datamodelType) { Converter<T, ?> c = (Converter<T, ?>) ConverterUtil .getConverter(getType(), datamodelType, getSession()); setConverter(c); }
@SuppressWarnings("unchecked") protected Field<?> createField(Container container, Object itemId, Object propertyId, Component uiContext) { ColumnModel model = getColumnModel(String.valueOf(propertyId)); boolean editable = tableEditable && itemId.equals(editableId) && model.isEditable() ; Field<?> f = null; Class<?> type = container.getType(propertyId); f = createFieldForType(type); f.setCaption(null); f.setWidth("100%"); f.setReadOnly(!editable); if (f instanceof AbstractField) { if (model.getConverter() == null) { model.setConverter(findDefaultConverter(model,type)); } if (model.getConverter() != null) ((AbstractField<String>)f).setConverter((Converter<String, ?>)model.generateConverter(type)); } return f; }
setConverter(newDataSource.getType());