T
- the value typepublic abstract class ComponentWithValue<T> extends FormComponent
Modifier and Type | Class and Description |
---|---|
protected class |
ComponentWithValue.ValueChangeListenerImpl |
static class |
ComponentWithValue.ValueProperty<T>
Wraps the forms::Binding LSPS record and adapts it to the Vaadin Property interface.
|
Modifier and Type | Field and Description |
---|---|
protected boolean |
refreshing |
form, INTERNAL_STATE_RECORD_PROPERTY
Modifier | Constructor and Description |
---|---|
protected |
ComponentWithValue(Class<T> valueType)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected Variant.RecordVariant |
getBinding() |
RecordHolder |
getProperty()
Gets the binding of this component.
|
abstract ListHolder |
getValidationErrors()
Returns all validation errors produced by the validators attached to this
component.
|
abstract boolean |
isConvertible()
Indicates if the field value is convertible or not.
|
protected boolean |
isFullyInitialized() |
abstract boolean |
isValid()
Tests the current value against registered validators if the field is not
empty.
|
protected void |
onPropertyValueSet(Object newValue)
This method is called each time components property value is set.
|
void |
preventGC(Set<ValueHolder> set)
Override for all components which are actively using some record holders, not directly linked to the model.
|
void |
refresh()
Refreshes the component (binding, datasource, children).
|
void |
refreshBinding()
Refreshes the content of this component using the provided binding.
|
protected void |
restoreInternalState(Map<String,Object> state)
Restores the UI state of this component which was previously written
by
FormComponent.writeInternalState(Map) . |
void |
setProperty(RecordHolder property)
Sets the binding of this component.
|
protected void |
writeInternalState(Map<String,Object> state)
Writes the UI state of this component to the provided map.
|
addDataErrorMessage, addStyleName, attach, call, clearDataErrorMessages, createEvent, createWidget, equals, getCaption, getComponentAlignment, getContextClickHandler, getCustomErrorMessage, getDataErrorMessages, getDescription, getExpandRatio, getHasChildrenAdapter, getHeight, getIcon, getModelingId, getNamespace, getStyleName, getTabIndex, getWidget, getWidth, hashCode, isEnabled, isReadOnly, isVisible, localize, markAsDirty, removeStyleName, restoreState, saveState, setCaption, setComponentAlignment, setContextClickHandler, setContextMenuItems, setCustomErrorMessage, setDescription, setEnabled, setExpandRatio, setHeight, setIcon, setReadOnly, setStyleName, setTabIndex, setVisible, setWidth, toString
protected boolean isFullyInitialized()
true
if the component was truly initialized e.g. widgets attach() method is fully finished. The
`getWidget().isAttached()` does the job for most components, but not all of them. Notably, decimal field initializes
locale *after* `isAttached` was set to true and attachment event was set - therefore neither of those reliably tells
when the component is fully initialized.protected final Variant.RecordVariant getBinding()
public RecordHolder getProperty()
public void setProperty(RecordHolder property)
property
- public void refresh()
public void refreshBinding()
public void preventGC(Set<ValueHolder> set)
FormComponent
WTabSheet
maintains a set of opened tabs. These tab records are not referenced
directly from forms::TabSheet and will therefore be garbage-collected. We however need those records to not to be GCed as the user
may ask for them simply by calling getTab(Integer).
Please note that the component definition records (e.g. forms::Button) are already GC-protected and they do not need to be added to this set.
Also, any child components currently attached to the UI are automatically protected and are not required to be registered in the set.preventGC
in class FormComponent
set
- a set of records which are to be GC-prevented, never null. The component should add any records here.
Default implementation does nothing.protected void writeInternalState(Map<String,Object> state)
FormComponent
Many UI attributes such as size, caption, etc. are not held in the records but are stored exclusively in the Vaadin components. In the records the getter/setter methods of such attributes directly delegate to the underlying component. For the purposes of the Save Document/Todo use case the state of such attributes has to be preserved.
Subclasses should override this method. The overriding method should call
super.writeInternalState(state)
to store the state form the super
class as well. The attributes should be written to the provided state
parameter. The type of the values written to the state
can only by
Java representation of LSPS types. That is java.util.Date
,
java.lang.String
, Decimal
, RecordHolder
,
ListHolder
, ... The name of the attributes stored in the map
should be unique and should not collide with the names used by any
of the superclass. It is the responsibility of the overridden method to ensure
that.
Subclasses overriding this method should also override
FormComponent.restoreInternalState(Map)
and restore the state written
by this method.
writeInternalState
in class FormComponent
state
- a map to which this method should write the component's UI state.FormComponent.restoreInternalState(Map)
,
FormComponent.saveState()
protected void restoreInternalState(Map<String,Object> state)
FormComponent
FormComponent.writeInternalState(Map)
.
Subclasses should override and call super.restoreInternalState(state);
restoreInternalState
in class FormComponent
state
- a map of attributes and their valuesFormComponent.writeInternalState(Map)
protected void onPropertyValueSet(Object newValue)
newValue
- public abstract boolean isConvertible()
true
if the field value is convertible.public abstract boolean isValid()
true
if all registered validators claim that the
current value is valid or if the field is empty and not required,
false
otherwise.public abstract ListHolder getValidationErrors()
null
).
Note: does NOT contain error set by from FormComponent.setCustomErrorMessage(java.lang.String)
method.Copyright © 2007-2018 Whitestein Technologies. All Rights Reserved.