|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.vaadin.server.AbstractClientConnector
com.vaadin.ui.AbstractComponent
com.vaadin.ui.CustomComponent
com.vaadin.addon.jpacontainer.fieldfactory.JPAContainerCustomField<T>
public abstract class JPAContainerCustomField<T>
A CustomComponent that implements the Field interface,
enabling the creation of e.g. form fields by composing Vaadin components.
Customization of both the visual presentation and the logic of the field is
possible.
Subclasses must at least implement the method getType() and set the
composition root (typically in the constructor). In addition, other methods
can be overridden to customize the functionality.
Most custom fields can simply compose a user interface that calls the methods
setValue(Object) and getValue().
It is also possible to override commit(),
setPropertyDataSource(Property) and other logic of the field.
Copied from the CustomField add-on.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface com.vaadin.ui.Field |
|---|
com.vaadin.ui.Field.ValueChangeEvent |
| Nested classes/interfaces inherited from interface com.vaadin.data.Buffered |
|---|
com.vaadin.data.Buffered.SourceException |
| Nested classes/interfaces inherited from interface com.vaadin.data.Property |
|---|
com.vaadin.data.Property.Editor, com.vaadin.data.Property.ReadOnlyException, com.vaadin.data.Property.ReadOnlyStatusChangeEvent, com.vaadin.data.Property.ReadOnlyStatusChangeListener, com.vaadin.data.Property.ReadOnlyStatusChangeNotifier, com.vaadin.data.Property.Transactional<T>, com.vaadin.data.Property.ValueChangeListener, com.vaadin.data.Property.ValueChangeNotifier, com.vaadin.data.Property.Viewer |
| Nested classes/interfaces inherited from interface com.vaadin.ui.Component |
|---|
com.vaadin.ui.Component.ErrorEvent, com.vaadin.ui.Component.Event, com.vaadin.ui.Component.Focusable, com.vaadin.ui.Component.Listener |
| Nested classes/interfaces inherited from interface com.vaadin.server.ClientConnector |
|---|
com.vaadin.server.ClientConnector.AttachEvent, com.vaadin.server.ClientConnector.AttachListener, com.vaadin.server.ClientConnector.ConnectorErrorEvent, com.vaadin.server.ClientConnector.DetachEvent, com.vaadin.server.ClientConnector.DetachListener |
| Nested classes/interfaces inherited from interface com.vaadin.server.Sizeable |
|---|
com.vaadin.server.Sizeable.Unit |
| Nested classes/interfaces inherited from interface com.vaadin.ui.HasComponents |
|---|
com.vaadin.ui.HasComponents.ComponentAttachDetachNotifier, com.vaadin.ui.HasComponents.ComponentAttachEvent, com.vaadin.ui.HasComponents.ComponentAttachListener, com.vaadin.ui.HasComponents.ComponentDetachEvent, com.vaadin.ui.HasComponents.ComponentDetachListener |
| Field Summary |
|---|
| Fields inherited from interface com.vaadin.server.Sizeable |
|---|
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS |
| Constructor Summary | |
|---|---|
JPAContainerCustomField()
|
|
| Method Summary | |
|---|---|
void |
addListener(com.vaadin.data.Property.ValueChangeListener listener)
Deprecated. |
void |
addValidator(com.vaadin.data.Validator validator)
|
void |
addValueChangeListener(com.vaadin.data.Property.ValueChangeListener listener)
|
void |
commit()
|
void |
discard()
|
protected void |
fireValueChange(boolean repaintIsNotNeeded)
Emits the value change event. |
void |
focus()
|
com.vaadin.server.ErrorMessage |
getErrorMessage()
Error messages shown by the fields are composites of the error message thrown by the superclasses (that is the component error message), validation errors and buffered source errors. |
com.vaadin.data.Property<T> |
getPropertyDataSource()
|
String |
getRequiredError()
|
int |
getTabIndex()
|
abstract Class<T> |
getType()
|
Collection<com.vaadin.data.Validator> |
getValidators()
Gets the validators of the field. |
T |
getValue()
Gets the current value of the field. |
protected boolean |
isEmpty()
Is the field empty? In general, "empty" state is same as null.. |
boolean |
isInvalidAllowed()
Fields allow invalid values by default. |
boolean |
isInvalidCommitted()
|
boolean |
isModified()
|
boolean |
isReadOnly()
|
boolean |
isReadThrough()
|
boolean |
isRequired()
Is this field required. |
boolean |
isValid()
Tests the current value against all registered validators. |
boolean |
isValidationVisible()
Is automatic, visible validation enabled? If automatic validation is enabled, any validators connected to this component are evaluated while painting the component and potential error messages are sent to client. |
boolean |
isWriteThrough()
|
void |
removeListener(com.vaadin.data.Property.ValueChangeListener listener)
Deprecated. |
void |
removeValidator(com.vaadin.data.Validator validator)
Removes the validator from the field. |
void |
removeValueChangeListener(com.vaadin.data.Property.ValueChangeListener listener)
|
void |
setCurrentBufferedSourceException(com.vaadin.data.Buffered.SourceException currentBufferedSourceException)
|
protected void |
setInternalValue(T newValue)
Sets the internal field value. |
void |
setInvalidAllowed(boolean invalidAllowed)
Fields allow invalid values by default. |
void |
setInvalidCommitted(boolean isCommitted)
|
void |
setPropertyDataSource(com.vaadin.data.Property newDataSource)
Sets the specified Property as the data source for the field. |
void |
setReadThrough(boolean readTrough)
|
void |
setRequired(boolean required)
Sets the field required. |
void |
setRequiredError(String requiredMessage)
Set the error that is show if this field is required, but empty. |
void |
setTabIndex(int tabIndex)
|
void |
setValidationVisible(boolean validateAutomatically)
Enable or disable automatic, visible validation. |
void |
setValue(Object newValue)
|
protected void |
setValue(Object newValue,
boolean repaintIsNotNeeded)
Sets the value of the field. |
void |
setWriteThrough(boolean writeTrough)
|
String |
toString()
Returns the value of the Property in human readable textual format. |
void |
validate()
Checks the validity of the Validatable by validating the field with all attached validators. |
void |
valueChange(com.vaadin.data.Property.ValueChangeEvent event)
This method listens to data source value changes and passes the changes forwards. |
| Methods inherited from class com.vaadin.ui.CustomComponent |
|---|
getComponentCount, getCompositionRoot, iterator, setCompositionRoot |
| Methods inherited from class com.vaadin.ui.AbstractComponent |
|---|
addListener, addShortcutListener, addStyleName, attach, beforeClientResponse, detach, findAncestor, fireComponentErrorEvent, fireComponentEvent, getActionManager, getCaption, getComponentError, getData, getDebugId, getDescription, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getState, getState, getStyleName, getWidth, getWidthUnits, isConnectorEnabled, isEnabled, isImmediate, isVisible, removeListener, removeShortcutListener, removeStyleName, setCaption, setComponentError, setData, setDebugId, setDescription, setEnabled, setHeight, setHeight, setIcon, setId, setImmediate, setLocale, setParent, setPrimaryStyleName, setReadOnly, setSizeFull, setSizeUndefined, setStyleName, setVisible, setWidth, setWidth |
| Methods inherited from class com.vaadin.server.AbstractClientConnector |
|---|
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hasListeners, isAttached, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface com.vaadin.data.Buffered |
|---|
isBuffered, setBuffered |
| Methods inherited from interface com.vaadin.data.Validatable |
|---|
removeAllValidators |
| Methods inherited from interface com.vaadin.data.Property |
|---|
setReadOnly |
| Methods inherited from interface com.vaadin.ui.Component |
|---|
addListener, addStyleName, attach, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isVisible, removeListener, removeStyleName, setCaption, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setReadOnly, setStyleName, setVisible |
| Methods inherited from interface com.vaadin.server.ClientConnector |
|---|
addAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler |
| Methods inherited from interface com.vaadin.shared.Connector |
|---|
getConnectorId |
| Methods inherited from interface com.vaadin.server.Sizeable |
|---|
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setSizeFull, setSizeUndefined, setWidth, setWidth |
| Constructor Detail |
|---|
public JPAContainerCustomField()
| Method Detail |
|---|
public abstract Class<T> getType()
getType in interface com.vaadin.data.Property<T>public boolean isReadOnly()
isReadOnly in interface com.vaadin.data.Property<T>isReadOnly in interface com.vaadin.ui.ComponentisReadOnly in class com.vaadin.ui.AbstractComponentpublic boolean isInvalidCommitted()
isInvalidCommitted in interface com.vaadin.data.BufferedValidatablepublic void setInvalidCommitted(boolean isCommitted)
setInvalidCommitted in interface com.vaadin.data.BufferedValidatable
public void commit()
throws com.vaadin.data.Buffered.SourceException,
com.vaadin.data.Validator.InvalidValueException
commit in interface com.vaadin.data.Bufferedcom.vaadin.data.Buffered.SourceException
com.vaadin.data.Validator.InvalidValueException
public void discard()
throws com.vaadin.data.Buffered.SourceException
discard in interface com.vaadin.data.Bufferedcom.vaadin.data.Buffered.SourceExceptionpublic boolean isModified()
isModified in interface com.vaadin.data.Bufferedpublic boolean isWriteThrough()
public void setWriteThrough(boolean writeTrough)
throws com.vaadin.data.Buffered.SourceException,
com.vaadin.data.Validator.InvalidValueException
com.vaadin.data.Buffered.SourceException
com.vaadin.data.Validator.InvalidValueExceptionpublic boolean isReadThrough()
public void setReadThrough(boolean readTrough)
throws com.vaadin.data.Buffered.SourceException
com.vaadin.data.Buffered.SourceExceptionpublic String toString()
toString in class ObjectObject.toString()public T getValue()
This is the visible, modified and possible invalid value the user have entered to the field. In the read-through mode, the abstract buffer is also updated and validation is performed.
Note that the object returned is compatible with getType(). For example, if the type is String, this returns Strings even when the underlying datasource is of some other type. In order to access the datasources native type, use getPropertyDatasource().getValue() instead.
Note that when you extend CustomField, you must reimplement this method if datasource.getValue() is not assignable to class returned by getType() AND getType() is not String. In case of Strings, getValue() calls datasource.toString() instead of datasource.getValue().
getValue in interface com.vaadin.data.Property<T>
public void setValue(Object newValue)
throws com.vaadin.data.Property.ReadOnlyException
setValue in interface com.vaadin.data.Property<T>com.vaadin.data.Property.ReadOnlyException
protected void setValue(Object newValue,
boolean repaintIsNotNeeded)
throws com.vaadin.data.Property.ReadOnlyException
newValue - the New value of the field.repaintIsNotNeeded - True iff caller is sure that repaint is not needed.
Property.ReadOnlyException
Property.ConversionExceptionpublic com.vaadin.data.Property<T> getPropertyDataSource()
getPropertyDataSource in interface com.vaadin.data.Property.Viewerpublic void setPropertyDataSource(com.vaadin.data.Property newDataSource)
Sets the specified Property as the data source for the field. All uncommitted changes to the field are discarded and the value is refreshed from the new data source.
If the datasource has any validators, the same validators are added to the field. Because the default behavior of the field is to allow invalid values, but not to allow committing them, this only adds visual error messages to fields and do not allow committing them as long as the value is invalid. After the value is valid, the error message is not shown and the commit can be done normally.
setPropertyDataSource in interface com.vaadin.data.Property.ViewernewDataSource - the new data source Property.public void addValidator(com.vaadin.data.Validator validator)
addValidator in interface com.vaadin.data.Validatablepublic Collection<com.vaadin.data.Validator> getValidators()
getValidators in interface com.vaadin.data.Validatablepublic void removeValidator(com.vaadin.data.Validator validator)
removeValidator in interface com.vaadin.data.Validatablevalidator - the validator to remove.public boolean isValid()
isValid in interface com.vaadin.data.Validatabletrue if all registered validators claim that the
current value is valid, false otherwise.
public void validate()
throws com.vaadin.data.Validator.InvalidValueException
validate in interface com.vaadin.data.Validatablecom.vaadin.data.Validator.InvalidValueExceptionValidatable.validate()public boolean isInvalidAllowed()
isInvalidAllowed in interface com.vaadin.data.ValidatableValidatable.isInvalidAllowed()
public void setInvalidAllowed(boolean invalidAllowed)
throws UnsupportedOperationException
In common setting where the user wants to assure the correctness of the datasource, but allow temporarily invalid contents in the field, the user should add the validators to datasource, that should not allow invalid values. The validators are automatically copied to the field when the datasource is set.
setInvalidAllowed in interface com.vaadin.data.ValidatableUnsupportedOperationExceptionValidatable.setInvalidAllowed(boolean)public com.vaadin.server.ErrorMessage getErrorMessage()
getErrorMessage in class com.vaadin.ui.AbstractComponentAbstractComponent.getErrorMessage()@Deprecated public void addListener(com.vaadin.data.Property.ValueChangeListener listener)
addListener in interface com.vaadin.data.Property.ValueChangeNotifierpublic void addValueChangeListener(com.vaadin.data.Property.ValueChangeListener listener)
addValueChangeListener in interface com.vaadin.data.Property.ValueChangeNotifier@Deprecated public void removeListener(com.vaadin.data.Property.ValueChangeListener listener)
removeListener in interface com.vaadin.data.Property.ValueChangeNotifierpublic void removeValueChangeListener(com.vaadin.data.Property.ValueChangeListener listener)
removeValueChangeListener in interface com.vaadin.data.Property.ValueChangeNotifierprotected void fireValueChange(boolean repaintIsNotNeeded)
public void valueChange(com.vaadin.data.Property.ValueChangeEvent event)
valueChange in interface com.vaadin.data.Property.ValueChangeListenerevent - the value change event telling the data source contents have
changed.public void focus()
focus in interface com.vaadin.ui.Component.Focusablefocus in class com.vaadin.ui.AbstractComponentpublic int getTabIndex()
getTabIndex in interface com.vaadin.ui.Component.Focusablepublic void setTabIndex(int tabIndex)
setTabIndex in interface com.vaadin.ui.Component.Focusableprotected void setInternalValue(T newValue)
newValue - the new value to be set.public boolean isRequired()
isRequired in interface com.vaadin.ui.Field<T>true if the field is required .otherwise
false.public void setRequired(boolean required)
setRequired in interface com.vaadin.ui.Field<T>required - Is the field required.public void setRequiredError(String requiredMessage)
setRequiredError in interface com.vaadin.ui.Field<T>requiredMessage - Message to be shown when this field is required, but empty.public String getRequiredError()
getRequiredError in interface com.vaadin.ui.Field<T>protected boolean isEmpty()
public boolean isValidationVisible()
public void setValidationVisible(boolean validateAutomatically)
validateAutomatically - True, if automatic validation is enabled.public void setCurrentBufferedSourceException(com.vaadin.data.Buffered.SourceException currentBufferedSourceException)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||