Package com.storedobject.vaadin.util
Class Data<T>
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddField(com.vaadin.flow.component.HasValue<?, ?> field) Add a field with auto-generated filed name.Add a field.<F> voidaddValidator(com.vaadin.flow.component.HasValue<?, F> field, Function<F, Boolean> validator, String errorMessage) Add a validator for the given field.voidClear all errors.voidClear all field values.booleanconnect(Collection<com.vaadin.flow.component.HasValue<?, ?>> fields) Connect a collection of fields so that their values will be updated whenever any of the field value is changed.com.vaadin.flow.data.binder.Binder<T> Get the embedded binder.com.vaadin.flow.component.HasTextGet the current error display.com.vaadin.flow.component.HasValue<?, ?> Get the field for the given field name.intGet the number of fields.Get the names of all the fields.Stream<com.vaadin.flow.component.HasValue<?, ?>> Get all the fields.Get the current field value handler.static StringgetLabel(com.vaadin.flow.component.HasValue<?, ?> field) Get the label for the given field.getName(com.vaadin.flow.component.HasValue<?, ?> field) Get the name of the given field.booleanIs this read-only?voidLoad all the fields from the bean.com.vaadin.flow.component.HasValue<?, ?> removeField(String fieldName) Remove a field.booleanSave all the field values to the bean.voidsetErrorDisplay(com.vaadin.flow.component.HasText display) Set the error display (If not set, a default mechanism is used to display errors and warnings).voidSet extra errors flag.voidsetFieldValueHandler(FieldValueHandler valueHandler) Set the field value handler.voidsetReadOnly(boolean readOnly) Set this as read-only.<F> voidsetRequired(com.vaadin.flow.component.HasValue<?, F> field, boolean required, String errorMessage) Set the "required" attribute of the field.Methods inherited from class java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, newHashMap, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, valuesMethods inherited from class java.util.AbstractMap
equals, hashCode, toString
-
Constructor Details
-
Data
-
-
Method Details
-
getBinder
Get the embedded binder.- Returns:
- The binder.
-
setErrorDisplay
public void setErrorDisplay(com.vaadin.flow.component.HasText display) Set the error display (If not set, a default mechanism is used to display errors and warnings).- Parameters:
display- Display to set.
-
getErrorDisplay
public com.vaadin.flow.component.HasText getErrorDisplay()Get the current error display.- Returns:
- Get the current error display.
-
setExtraErrors
public void setExtraErrors()Set extra errors flag. -
setFieldValueHandler
Set the field value handler.- Parameters:
valueHandler- Field value handler.
-
getFieldValueHandler
Get the current field value handler.- Returns:
- The field value handler.
-
addField
Add a field with auto-generated filed name.- Parameters:
field- The field to add.- Returns:
- Name of the field.
-
addField
-
connect
Connect a collection of fields so that their values will be updated whenever any of the field value is changed.- Parameters:
fields- Collection of fields to connect together.- Returns:
- Returns true if the field list contains at least 2 fields.
-
isReadOnly
public boolean isReadOnly()Is this read-only?- Returns:
- True or false.
-
setReadOnly
public void setReadOnly(boolean readOnly) Set this as read-only.- Parameters:
readOnly- True or false.
-
removeField
Remove a field.- Parameters:
fieldName- Name of the field to remove.- Returns:
- The field that is removed.
-
getName
Get the name of the given field.- Parameters:
field- Filed.- Returns:
- Name of the field.
-
getField
Get the field for the given field name.- Parameters:
fieldName- Field name.- Returns:
- Field if found.
-
getFieldCount
public int getFieldCount()Get the number of fields.- Returns:
- Number of fields.
-
getFieldNames
-
getFields
Get all the fields.- Returns:
- All the fields.
-
loadValues
public void loadValues()Load all the fields from the bean. -
saveValues
public boolean saveValues()Save all the field values to the bean.- Returns:
- True if the save is successful.
-
clearErrors
public void clearErrors()Clear all errors. -
clearFields
public void clearFields()Clear all field values. -
addValidator
public <F> void addValidator(com.vaadin.flow.component.HasValue<?, F> field, Function<F, Boolean> validator, String errorMessage) Add a validator for the given field.- Type Parameters:
F- Field value type.- Parameters:
field- Field.validator- Validator.errorMessage- Error message to show when validation fails.
-
setRequired
public <F> void setRequired(com.vaadin.flow.component.HasValue<?, F> field, boolean required, String errorMessage) Set the "required" attribute of the field.- Type Parameters:
F- Field value type.- Parameters:
field- Field.required- True/false.errorMessage- Error message to show when empty.
-
getLabel
Get the label for the given field.- Parameters:
field- Field.- Returns:
- Label string if exists, otherwise null.
-