com.vaadin.data.fieldgroup
Class BeanFieldGroup<T>

java.lang.Object
  extended by com.vaadin.data.fieldgroup.FieldGroup
      extended by com.vaadin.data.fieldgroup.BeanFieldGroup<T>
All Implemented Interfaces:
java.io.Serializable

public class BeanFieldGroup<T>
extends FieldGroup

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.vaadin.data.fieldgroup.FieldGroup
FieldGroup.BindException, FieldGroup.CommitEvent, FieldGroup.CommitException, FieldGroup.CommitHandler
 
Constructor Summary
BeanFieldGroup(java.lang.Class<T> beanType)
           
 
Method Summary
 void bind(Field field, java.lang.Object propertyId)
          Binds the field with the given propertyId from the current item.
 Field<?> buildAndBind(java.lang.String caption, java.lang.Object propertyId)
          Builds a field using the given caption and binds it to the given property id using the field binder.
protected  void configureField(Field<?> field)
          Configures a field with the settings set for this FieldBinder.
 BeanItem<T> getItemDataSource()
          Gets the item used by this FieldBinder.
protected  java.lang.Class<?> getPropertyType(java.lang.Object propertyId)
          Gets the type of the property with the given property id.
protected static boolean isBeanValidationImplementationAvailable()
          Checks whether a bean validation implementation (e.g.
 void setItemDataSource(Item item)
          Updates the item that is used by this FieldBinder.
 void setItemDataSource(T bean)
          Helper method for setting the data source directly using a bean.
 
Methods inherited from class com.vaadin.data.fieldgroup.FieldGroup
addCommitHandler, bindMemberFields, build, buildAndBind, buildAndBind, buildAndBindMemberFields, buildAndBindMemberFields, commit, discard, getBoundPropertyIds, getCommitHandlers, getField, getFieldFactory, getFields, getFieldsInDeclareOrder, getItemProperty, getPropertyId, getUnboundPropertyIds, isBuffered, isEnabled, isModified, isReadOnly, isValid, removeCommitHandler, setBuffered, setEnabled, setFieldFactory, setReadOnly, unbind
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BeanFieldGroup

public BeanFieldGroup(java.lang.Class<T> beanType)
Method Detail

getPropertyType

protected java.lang.Class<?> getPropertyType(java.lang.Object propertyId)
Description copied from class: FieldGroup
Gets the type of the property with the given property id.

Overrides:
getPropertyType in class FieldGroup
Parameters:
propertyId - The propertyId. Must be find
Returns:
The type of the property

setItemDataSource

public void setItemDataSource(T bean)
Helper method for setting the data source directly using a bean. This method wraps the bean in a BeanItem and calls setItemDataSource(Item).

Parameters:
bean - The bean to use as data source.

setItemDataSource

public void setItemDataSource(Item item)
Description copied from class: FieldGroup
Updates the item that is used by this FieldBinder. Rebinds all fields to the properties in the new item.

Overrides:
setItemDataSource in class FieldGroup
Parameters:
item - The new item to use

getItemDataSource

public BeanItem<T> getItemDataSource()
Description copied from class: FieldGroup
Gets the item used by this FieldBinder. Note that you must call FieldGroup.commit() for the item to be updated unless buffered mode has been switched off.

Overrides:
getItemDataSource in class FieldGroup
Returns:
The item used by this FieldBinder
See Also:
FieldGroup.setBuffered(boolean), FieldGroup.commit()

bind

public void bind(Field field,
                 java.lang.Object propertyId)
Description copied from class: FieldGroup
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 FieldGroup.setItemDataSource(Item).

This method also adds validators when applicable.

Overrides:
bind in class FieldGroup
Parameters:
field - The field to bind
propertyId - The propertyId to bind to the field

buildAndBind

public Field<?> buildAndBind(java.lang.String caption,
                             java.lang.Object propertyId)
                      throws FieldGroup.BindException
Description copied from class: FieldGroup
Builds a field using the given caption and binds it to the given property id using the field binder.

Overrides:
buildAndBind in class FieldGroup
Parameters:
caption - The caption for the field
propertyId - The property id to bind to. Must be present in the field finder.
Returns:
The created and bound field. Can be any type of Field.
Throws:
FieldGroup.BindException - If there is a problem while building or binding

configureField

protected void configureField(Field<?> field)
Description copied from class: FieldGroup
Configures a field with the settings set for this FieldBinder.

By default this updates the buffered, read only and enabled state of the field. Also adds validators when applicable. Fields with read only data source are always configured as read only.

Overrides:
configureField in class FieldGroup
Parameters:
field - The field to update

isBeanValidationImplementationAvailable

protected static boolean isBeanValidationImplementationAvailable()
Checks whether a bean validation implementation (e.g. Hibernate Validator or Apache Bean Validation) is available. TODO move this method to some more generic location

Returns:
true if a JSR-303 bean validation implementation is available


Copyright © 2000-2011 Vaadin Ltd. All Rights Reserved.