wrapper.detachFromProperty(); field.setPropertyDataSource(null);
/** * Binds the field with the given propertyId from the current item. If an * item has not been set then the binding is postponed until the item is set * using {@link #setItemDataSource(Item)}. * <p> * This method also adds validators when applicable. * </p> * * @param field * The field to bind * @param propertyId * The propertyId to bind to the field * @throws BindException * If the field is null or the property id is already bound to * another field by this field binder */ public void bind(Field<?> field, Object propertyId) throws BindException { throwIfFieldIsNull(field, propertyId); throwIfPropertyIdAlreadyBound(field, propertyId); fieldToPropertyId.put(field, propertyId); propertyIdToField.put(propertyId, field); if (itemDataSource == null) { clearField(field); // Will be bound when data source is set return; } field.setPropertyDataSource( wrapInTransactionalProperty(getItemProperty(propertyId))); configureField(field); }
/** * Binds an item property to a field. The default behavior is to bind * property straight to Field. If Property.Viewer type property (e.g. * PropertyFormatter) is already set for field, the property is bound to * that Property.Viewer. * * @param propertyId * @param property * @param field * @since 6.7.3 */ protected void bindPropertyToField(final Object propertyId, final Property property, final Field field) { // check if field has a property that is Viewer set. In that case we // expect developer has e.g. PropertyFormatter that he wishes to use and // assign the property to the Viewer instead. boolean hasFilterProperty = field.getPropertyDataSource() != null && field.getPropertyDataSource() instanceof Property.Viewer; if (hasFilterProperty) { ((Property.Viewer) field.getPropertyDataSource()) .setPropertyDataSource(property); } else { field.setPropertyDataSource(property); } }
/** * Binds an item property to a field generated by TableFieldFactory. The * default behavior is to bind property straight to Field. If * Property.Viewer type property (e.g. PropertyFormatter) is already set for * field, the property is bound to that Property.Viewer. * * @param rowId * @param colId * @param property * @param field * @since 6.7.3 */ protected void bindPropertyToField(Object rowId, Object colId, Property property, Field field) { // check if field has a property that is Viewer set. In that case we // expect developer has e.g. PropertyFormatter that he wishes to use and // assign the property to the Viewer instead. boolean hasFilterProperty = field.getPropertyDataSource() != null && (field.getPropertyDataSource() instanceof Property.Viewer); if (hasFilterProperty) { ((Property.Viewer) field.getPropertyDataSource()) .setPropertyDataSource(property); } else { field.setPropertyDataSource(property); } }
/** * Clears field and any possible existing binding. * * @param field * The field to be cleared * @since 7.7.5 */ protected void clearField(Field<?> field) { // Clear any possible existing binding to clear the field field.setPropertyDataSource(null); boolean fieldReadOnly = field.isReadOnly(); if (!fieldReadOnly) { field.clear(); } else { // Temporarily make the field read-write so we can clear the // value. Needed because setPropertyDataSource(null) does not // currently clear the field // (https://dev.vaadin.com/ticket/14733) field.setReadOnly(false); field.clear(); field.setReadOnly(true); } }
oldField.setPropertyDataSource(null); newField.setPropertyDataSource(property);