Class TransactionalPropertyWrapper<T>
- Type Parameters:
T-
- All Implemented Interfaces:
Property<T>,Property.ReadOnlyStatusChangeNotifier,Property.Transactional<T>,Property.ValueChangeNotifier,Serializable
TransactionalPropertyWrapper are only
fired at the end of a successful transaction, whereas listeners attached to
the underlying property may receive multiple value change events.- Since:
- 7.0
- Author:
- Vaadin Ltd
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vaadin.featurepack.data.util.AbstractProperty
AbstractProperty.ReadOnlyStatusChangeEventNested classes/interfaces inherited from interface com.vaadin.featurepack.data.Property
Property.Editor, Property.ReadOnlyException, Property.ReadOnlyStatusChangeEvent, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.Transactional<T>, Property.ValueChangeEvent, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcommit()Commits and ends the transaction that is in progress.voidRemoves the ValueChangeListener from wrapped Property that was added by TransactionalPropertyWrapper.protected voidprotected voidSends a value change event to all registered listeners.getType()Returns the type of the Property.getValue()Gets the value stored in the Property.booleanTests if the Property is in read-only mode.voidrollback()Aborts and rolls back the transaction that is in progress.voidsetPropertyReadOnly(boolean newStatus) Sets the Property's read-only mode to the specified status.voidSets the value of the Property.voidStarts a transaction.Methods inherited from class com.vaadin.featurepack.data.util.AbstractProperty
addReadOnlyStatusChangeListener, addValueChangeListener, fireReadOnlyStatusChange, getListeners, removeReadOnlyStatusChangeListener, removeValueChangeListenerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.featurepack.data.Property.ValueChangeNotifier
addValueChangeListener, removeValueChangeListener
-
Constructor Details
-
TransactionalPropertyWrapper
-
-
Method Details
-
detachFromProperty
public void detachFromProperty()Removes the ValueChangeListener from wrapped Property that was added by TransactionalPropertyWrapper.- Since:
- 7.1.15
-
getType
Description copied from interface:PropertyReturns the type of the Property. The methodsgetValueandsetValuemust be compatible with this type: one must be able to safely cast the value returned fromgetValueto the given type and pass any variable assignable to this type as an argument tosetValue. -
getValue
Description copied from interface:PropertyGets the value stored in the Property. The returned object is compatible with the class returned by getType(). -
setValue
Description copied from interface:PropertySets the value of the Property.Implementing this functionality is optional. If the functionality is missing, one should declare the Property to be in read-only mode and throw
Note : Since Vaadin 7.0, setting the value of a non-String property as a String is no longer supported.Property.ReadOnlyExceptionin this function.- Specified by:
setValuein interfaceProperty<T>- Parameters:
newValue- New value of the Property. This should be assignable to the type returned by getType- Throws:
Property.ReadOnlyException- if the object is in read-only mode
-
startTransaction
public void startTransaction()Description copied from interface:Property.TransactionalStarts a transaction.If the value is set during a transaction the value must not replace the original value until
Property.Transactional.commit()is called. Still,Property.getValue()must return the current value set in the transaction. CallingProperty.Transactional.rollback()while in a transaction must rollback the value to what it was before the transaction started.Property.ValueChangeEvents must not be emitted for internal value changes during a transaction. If the value changes as a result ofProperty.Transactional.commit(), aProperty.ValueChangeEventshould be emitted.- Specified by:
startTransactionin interfaceProperty.Transactional<T>
-
commit
public void commit()Description copied from interface:Property.TransactionalCommits and ends the transaction that is in progress.If the value is changed as a result of this operation, a
Property.ValueChangeEventis emitted if such are supported.This method has no effect if there is no transaction is in progress.
This method must never throw an exception.
- Specified by:
commitin interfaceProperty.Transactional<T>
-
rollback
public void rollback()Description copied from interface:Property.TransactionalAborts and rolls back the transaction that is in progress.The value is reset to the value before the transaction started. No
Property.ValueChangeEventis emitted as a result of this.This method has no effect if there is no transaction is in progress.
This method must never throw an exception.
- Specified by:
rollbackin interfaceProperty.Transactional<T>
-
endTransaction
protected void endTransaction() -
fireValueChange
protected void fireValueChange()Description copied from class:AbstractPropertySends a value change event to all registered listeners.- Overrides:
fireValueChangein classAbstractProperty<T>
-
getWrappedProperty
-
isPropertyReadOnly
public boolean isPropertyReadOnly()Description copied from class:AbstractPropertyTests if the Property is in read-only mode. In read-only mode calls to the methodsetValuewill throwReadOnlyExceptionand will not modify the value of the Property. Override for additional restrictions on what is considered a read-only property.- Specified by:
isPropertyReadOnlyin interfaceProperty<T>- Overrides:
isPropertyReadOnlyin classAbstractProperty<T>- Returns:
trueif the Property is in read-only mode,falseif it's not
-
setPropertyReadOnly
public void setPropertyReadOnly(boolean newStatus) Description copied from interface:PropertySets the Property's read-only mode to the specified status. This functionality is optional, but all properties must implement theisReadOnlymode query correctly.- Specified by:
setPropertyReadOnlyin interfaceProperty<T>- Overrides:
setPropertyReadOnlyin classAbstractProperty<T>- Parameters:
newStatus- new read-only status of the Property
-