Package com.vaadin.ui.declarative
Class FieldBinder
- java.lang.Object
-
- com.vaadin.ui.declarative.FieldBinder
-
- All Implemented Interfaces:
java.io.Serializable
public class FieldBinder extends java.lang.Object implements java.io.SerializableBinder utility that binds member fields of a design class instance to given component instances. Only fields of typeComponentare bound- Since:
- 7.4
- Author:
- Vaadin Ltd
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description FieldBinder(java.lang.Object design)Creates a new instance of LayoutFieldBinder.FieldBinder(java.lang.Object design, java.lang.Class<?> classWithFields)Creates a new instance of LayoutFieldBinder.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanbindField(Component instance)Tries to bind the givenComponentinstance to a member field of the bind target.booleanbindField(Component instance, java.lang.String localId)Tries to bind the givenComponentinstance to a member field of the bind target.protected static java.util.List<java.lang.reflect.Field>getFields(java.lang.Class<?> searchClass)Returns a list containing Field objects reflecting all the fields of the class or interface represented by this Class object.java.util.Collection<java.lang.String>getUnboundFields()Returns a collection of field names that are not bound.
-
-
-
Constructor Detail
-
FieldBinder
public FieldBinder(java.lang.Object design) throws java.beans.IntrospectionExceptionCreates a new instance of LayoutFieldBinder.- Parameters:
design- the design class instance containing the fields to bind- Throws:
java.beans.IntrospectionException- if the given design class can not be introspected
-
FieldBinder
public FieldBinder(java.lang.Object design, java.lang.Class<?> classWithFields) throws java.beans.IntrospectionExceptionCreates a new instance of LayoutFieldBinder.- Parameters:
design- the instance containing the fieldsclassWithFields- the class which defines the fields to bind- Throws:
java.beans.IntrospectionException- if the given design class can not be introspected
-
-
Method Detail
-
getUnboundFields
public java.util.Collection<java.lang.String> getUnboundFields() throws FieldBindingExceptionReturns 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 givenComponentinstance 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),FieldBindingExceptionis 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, java.lang.String localId)
Tries to bind the givenComponentinstance 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 java.util.List<java.lang.reflect.Field> getFields(java.lang.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
-
-