Package io.jmix.flowui.data.value
Class ContainerValueSource<E,V>
java.lang.Object
io.jmix.flowui.data.value.ContainerValueSource<E,V>
- Type Parameters:
E- the type of entity contained in theInstanceContainerV- the type of the bound property value
- All Implemented Interfaces:
DataUnit,EntityDataUnit,EntityValueSource<E,,V> HasType<V>,ValueSource<V>,org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware
- Direct Known Subclasses:
BufferedContainerValueSource
public class ContainerValueSource<E,V>
extends Object
implements EntityValueSource<E,V>, org.springframework.context.ApplicationContextAware
Provides a value source implementation powered by an
InstanceContainer.
It binds a container's property with a value source that reflects changes to the property
or its individual elements, and allows bidirectional updates.-
Nested Class Summary
Nested classes/interfaces inherited from interface io.jmix.flowui.data.DataUnit
DataUnit.StateChangeEventNested classes/interfaces inherited from interface io.jmix.flowui.data.EntityValueSource
EntityValueSource.InstanceChangeEvent<E>Nested classes/interfaces inherited from interface io.jmix.flowui.data.ValueSource
ValueSource.ValueChangeEvent<V> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final InstanceContainer<E>protected booleanprotected EventBusprotected MetaPropertyPathprotected Stringprotected BindingState -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.vaadin.flow.shared.RegistrationRegisters a listener that will be notified when the related entity instance is changed.com.vaadin.flow.shared.RegistrationRegisters a new state change listener.com.vaadin.flow.shared.RegistrationaddValueChangeListener(Consumer<ValueSource.ValueChangeEvent<V>> listener) Registers a new value change listener.protected booleanprotected voidprotected voidprotected Collection<? extends V>copyPropertyCollection(Collection<? extends V> propertyValue) Returns theInstanceContainerassociated with this value source.protected DataContextprotected MetaPropertygetItem()Returns the current item associated with the source.getState()getType()getValue()Returns the current value stored in the value source.protected booleanbooleanprotected booleanbooleanChecks whether the value source is read-only.voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext) voidsetDataModelSecurityEnabled(boolean enabled) Sets data model security enabled for data binding.protected voidsetState(BindingState state) voidSets the given value to this value source.protected voidupdateMasterRefs(V value)
-
Field Details
-
container
-
metaPropertyPath
-
property
-
state
-
events
-
dataModelSecurityEnabled
protected boolean dataModelSecurityEnabled
-
-
Constructor Details
-
ContainerValueSource
-
-
Method Details
-
setDataModelSecurityEnabled
public void setDataModelSecurityEnabled(boolean enabled) Sets data model security enabled for data binding.
Caller may set false in order to disable built-in security check on data binding.- Parameters:
enabled- enabled flag
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) - Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware
-
getEntityMetaClass
- Specified by:
getEntityMetaClassin interfaceEntityDataUnit- Returns:
MetaClassof an entity contained in the source
-
getMetaPropertyPath
- Specified by:
getMetaPropertyPathin interfaceEntityValueSource<E,V> - Returns:
- property path
-
getItem
Description copied from interface:EntityValueSourceReturns the current item associated with the source.- Specified by:
getItemin interfaceEntityValueSource<E,V> - Returns:
- the current item if available, or null if not set
-
isDataModelSecurityEnabled
public boolean isDataModelSecurityEnabled()- Specified by:
isDataModelSecurityEnabledin interfaceEntityValueSource<E,V> - Returns:
- true if data model security check is required on data binding
-
getValue
Description copied from interface:ValueSourceReturns the current value stored in the value source.- Specified by:
getValuein interfaceValueSource<E>- Returns:
- the current value, or
nullif no value is set
-
setValue
Description copied from interface:ValueSourceSets the given value to this value source.- Specified by:
setValuein interfaceValueSource<E>- Parameters:
value- the value to be set
-
isReadOnly
public boolean isReadOnly()Description copied from interface:ValueSourceChecks whether the value source is read-only.- Specified by:
isReadOnlyin interfaceValueSource<E>- Returns:
trueif the value source is read-only,falseotherwise
-
getType
-
getState
-
addInstanceChangeListener
public com.vaadin.flow.shared.Registration addInstanceChangeListener(Consumer<EntityValueSource.InstanceChangeEvent<E>> listener) Description copied from interface:EntityValueSourceRegisters a listener that will be notified when the related entity instance is changed.- Specified by:
addInstanceChangeListenerin interfaceEntityValueSource<E,V> - Parameters:
listener- the listener to add- Returns:
- a
Registrationinstance that allows the removal of the listener
-
addStateChangeListener
public com.vaadin.flow.shared.Registration addStateChangeListener(Consumer<DataUnit.StateChangeEvent> listener) Description copied from interface:DataUnitRegisters a new state change listener.- Specified by:
addStateChangeListenerin interfaceDataUnit- Parameters:
listener- the listener to be added- Returns:
- a registration object for removing an event listener added to a source
-
addValueChangeListener
public com.vaadin.flow.shared.Registration addValueChangeListener(Consumer<ValueSource.ValueChangeEvent<V>> listener) Description copied from interface:ValueSourceRegisters a new value change listener.- Specified by:
addValueChangeListenerin interfaceValueSource<E>- Parameters:
listener- the listener to be added- Returns:
- a registration object for removing an event listener added to a source
-
setState
-
containerItemChanged
-
containerItemPropertyChanged
-
canUpdateMasterRefs
protected boolean canUpdateMasterRefs() -
updateMasterRefs
-
copyPropertyCollection
@Nullable protected Collection<? extends V> copyPropertyCollection(@Nullable Collection<? extends V> propertyValue) -
getDataContext
-
getInverseProperty
-
getContainer
Returns theInstanceContainerassociated with this value source.- Returns:
- the associated instance container
-
isCollectionPropertyType
protected boolean isCollectionPropertyType() -
isEqualCollectionValue
-