C - the type of the content componentS - the source type for value change eventsT - the value typepublic abstract class AbstractCompositeField<C extends Component,S extends AbstractCompositeField<C,S,T>,T> extends Composite<C> implements HasValueAndElement<AbstractField.ComponentValueChangeEvent<S,T>,T>, HasEnabled
See the detailed documentation for AbstractField and
Composite for detailed information.
HasValue.ValueChangeEvent<V>, HasValue.ValueChangeListener<E extends HasValue.ValueChangeEvent<?>>| Constructor and Description |
|---|
AbstractCompositeField(T defaultValue)
Creates a new field.
|
| Modifier and Type | Method and Description |
|---|---|
Registration |
addValueChangeListener(HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<S,T>> listener)
Adds a value change listener.
|
T |
getEmptyValue()
Returns the value that represents an empty value.
|
T |
getValue()
Returns the current value of this object.
|
boolean |
isEmpty()
Returns whether this
HasValue is considered to be empty. |
protected void |
setModelValue(T newModelValue,
boolean fromClient)
Updates the model value if the value has actually changed.
|
protected abstract void |
setPresentationValue(T newPresentationValue)
Updates the presentation of this field to display the provided value.
|
void |
setValue(T value)
Sets the value of this object.
|
protected boolean |
valueEquals(T value1,
T value2)
Compares to value instances to each other to determine whether they are
equal.
|
getChildren, getContent, getElement, initContentaddListener, fireEvent, from, get, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getUI, hasListener, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, set, setElement, setId, setVisibleclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisReadOnly, isRequiredIndicatorVisible, setReadOnly, setRequiredIndicatorVisibleclear, getOptionalValueisEnabled, setEnabledgetElementaddAttachListeneraddDetachListenerpublic AbstractCompositeField(T defaultValue)
getEmptyValue() and is also used as the initial value of this
instance.defaultValue - the default valuepublic void setValue(T value)
HasValuegetValue(), fires a value change event. May throw
IllegalArgumentException if the value is not acceptable.
Implementation note: the implementing class should document
whether null values are accepted or not, and override
HasValue.getEmptyValue() if the empty value is not null.
setValue in interface HasValue<AbstractField.ComponentValueChangeEvent<S extends AbstractCompositeField<C,S,T>,T>,T>value - the new valuepublic T getValue()
HasValue
Implementation note: the implementing class should document
whether null values may be returned or not, and override
HasValue.getEmptyValue() if the empty value is not null.
getValue in interface HasValue<AbstractField.ComponentValueChangeEvent<S extends AbstractCompositeField<C,S,T>,T>,T>public T getEmptyValue()
HasValue
By default HasValue is expected to support null as empty
values. Specific implementations might not support this.
getEmptyValue in interface HasValue<AbstractField.ComponentValueChangeEvent<S extends AbstractCompositeField<C,S,T>,T>,T>public boolean isEmpty()
HasValueHasValue is considered to be empty.
By default this is an equality check between current value and empty value.
isEmpty in interface HasValue<AbstractField.ComponentValueChangeEvent<S extends AbstractCompositeField<C,S,T>,T>,T>true if considered empty; false if notpublic Registration addValueChangeListener(HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<S,T>> listener)
HasValueHasValue is changed either by the user or programmatically.addValueChangeListener in interface HasValue<AbstractField.ComponentValueChangeEvent<S extends AbstractCompositeField<C,S,T>,T>,T>listener - the value change listener, not nullprotected abstract void setPresentationValue(T newPresentationValue)
If setModelValue(Object, boolean) is called from within this
method, then value of the last invocation will be used as the model value
instead of the value passed to this method. In this case
setPresentationValue(Object) will not be called again. Changing
the provided value might be useful if the provided value is sanitized.
See AbstractField for an overall description on the difference
between model values and presentation values.
newPresentationValue - the new value to showprotected void setModelValue(T newModelValue, boolean fromClient)
valueEquals(Object, Object).
If the value is from the client-side and this field is in readonly mode,
then the new model value will be ignored.
setPresentationValue(Object) will be called with the previous
model value so that the representation shown to the user can be reverted.
See AbstractField for an overall description on the difference
between model values and presentation values.
newModelValue - the new internal value to usefromClient - true if the new value originates from the client;
otherwise falseprotected boolean valueEquals(T value1, T value2)
setValue(Object) or
setModelValue(Object, boolean) is called. Subclasses can
override this method to define an alternative comparison method instead
of Object.equals(Object).value1 - the first instancevalue2 - the second instancetrue if the instances are equal; otherwise
falseCopyright © 2018. All rights reserved.