Package com.vaadin.ui.declarative
Class FieldBinder
- java.lang.Object
-
- com.vaadin.ui.declarative.FieldBinder
-
- All Implemented Interfaces:
Serializable
public class FieldBinder extends Object implements Serializable
Binder utility that binds member fields of a design class instance to given component instances. Only fields of typeComponent
are bound- Since:
- 7.4
- Author:
- Vaadin Ltd
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description FieldBinder(Object design)
Creates a new instance of LayoutFieldBinder.FieldBinder(Object design, Class<?> classWithFields)
Creates a new instance of LayoutFieldBinder.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
bindField(Component instance)
Tries to bind the givenComponent
instance to a member field of the bind target.boolean
bindField(Component instance, String localId)
Tries to bind the givenComponent
instance to a member field of the bind target.protected static List<Field>
getFields(Class<?> searchClass)
Returns a list containing Field objects reflecting all the fields of the class or interface represented by this Class object.Collection<String>
getUnboundFields()
Returns a collection of field names that are not bound.
-
-
-
Constructor Detail
-
FieldBinder
public FieldBinder(Object design) throws IntrospectionException
Creates a new instance of LayoutFieldBinder.- Parameters:
design
- the design class instance containing the fields to bind- Throws:
IntrospectionException
- if the given design class can not be introspected
-
FieldBinder
public FieldBinder(Object design, Class<?> classWithFields) throws IntrospectionException
Creates a new instance of LayoutFieldBinder.- Parameters:
design
- the instance containing the fieldsclassWithFields
- the class which defines the fields to bind- Throws:
IntrospectionException
- if the given design class can not be introspected
-
-
Method Detail
-
getUnboundFields
public Collection<String> getUnboundFields() throws FieldBindingException
Returns a collection of field names that are not bound.- Returns:
- a collection of fields assignable to Component that are not bound
- Throws:
FieldBindingException
-
bindField
public boolean bindField(Component instance)
Tries to bind the givenComponent
instance to a member field of the bind target. The name of the bound field is constructed based on the id or caption of the instance, depending on which one is defined. If a field is already bound (not null),FieldBindingException
is thrown.- Parameters:
instance
- the instance to be bound to a field- Returns:
- true on success, otherwise false
- Throws:
FieldBindingException
- if error occurs when trying to bind the instance to a field
-
bindField
public boolean bindField(Component instance, String localId)
Tries to bind the givenComponent
instance to a member field of the bind target. The fields are matched based on localId, id and caption.- Parameters:
instance
- the instance to be bound to a fieldlocalId
- the localId used for mapping the field to an instance field- Returns:
- true on success
- Throws:
FieldBindingException
- if error occurs when trying to bind the instance to a field
-
getFields
protected static List<Field> getFields(Class<?> searchClass)
Returns a list containing Field objects reflecting all the fields of the class or interface represented by this Class object. The fields in superclasses are excluded.- Parameters:
searchClass
- the class to be scanned for fields- Returns:
- the list of fields in this class
-
-