Package com.vaadin.ui
Class DefaultFieldFactory
- java.lang.Object
-
- com.vaadin.ui.DefaultFieldFactory
-
- All Implemented Interfaces:
FormFieldFactory
,TableFieldFactory
,Serializable
public class DefaultFieldFactory extends Object implements FormFieldFactory, TableFieldFactory
This class contains a basic implementation for bothFormFieldFactory
andTableFieldFactory
. The class is singleton, useget()
method to get reference to the instance.There are also some static helper methods available for custom built field factories.
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DefaultFieldFactory()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static String
createCaptionByPropertyId(Object propertyId)
If name follows method naming conventions, convert the name to spaced upper case text.Field
createField(Container container, Object itemId, Object propertyId, Component uiContext)
Creates a field based on the Container, item id, property id and the component responsible for displaying the field (most commonlyTable
).Field<?>
createField(Item item, Object propertyId, Component uiContext)
Creates a field based on the item, property id and the component (most commonlyForm
) where the Field will be presented.static Field<?>
createFieldByPropertyType(Class<?> type)
Creates fields based on the property type.static DefaultFieldFactory
get()
Singleton method to get an instance of DefaultFieldFactory.
-
-
-
Method Detail
-
get
public static DefaultFieldFactory get()
Singleton method to get an instance of DefaultFieldFactory.- Returns:
- an instance of DefaultFieldFactory
-
createField
public Field<?> createField(Item item, Object propertyId, Component uiContext)
Description copied from interface:FormFieldFactory
Creates a field based on the item, property id and the component (most commonlyForm
) where the Field will be presented.- Specified by:
createField
in interfaceFormFieldFactory
- Parameters:
item
- the item where the property belongs to.propertyId
- the Id of the property.uiContext
- the component where the field is presented, most commonly this isForm
. uiContext will not necessary be the parent component of the field, but the one that is responsible for creating it.- Returns:
- the field suitable for editing the specified data.
-
createField
public Field createField(Container container, Object itemId, Object propertyId, Component uiContext)
Description copied from interface:TableFieldFactory
Creates a field based on the Container, item id, property id and the component responsible for displaying the field (most commonlyTable
).- Specified by:
createField
in interfaceTableFieldFactory
- Parameters:
container
- the Container where the property belongs to.itemId
- the item Id.propertyId
- the Id of the property.uiContext
- the component where the field is presented.- Returns:
- A field suitable for editing the specified data or null if the property should not be editable.
-
createCaptionByPropertyId
public static String createCaptionByPropertyId(Object propertyId)
If name follows method naming conventions, convert the name to spaced upper case text. For example, convert "firstName" to "First Name"- Parameters:
propertyId
-- Returns:
- the formatted caption string
-
createFieldByPropertyType
public static Field<?> createFieldByPropertyType(Class<?> type)
Creates fields based on the property type.The default field type is
TextField
. Other field types generated by this method:Boolean:
CheckBox
.
Date:DateField
(resolution: day).
Item:Form
.
default field type:TextField
.- Parameters:
type
- the type of the property- Returns:
- the most suitable generic
Field
for given type
-
-