T
- the type of the row/item being editedpublic interface Editor<T> extends Serializable
This class contains methods for editor functionality: configure an editor
Binder
, open the editor, save and cancel a row editing.
Modifier and Type | Method and Description |
---|---|
Registration |
addCancelListener(EditorCancelListener<T> listener)
Adds an editor cancel
listener . |
Registration |
addCloseListener(EditorCloseListener<T> listener)
Adds an editor close
listener . |
Registration |
addOpenListener(EditorOpenListener<T> listener)
Adds an editor open
listener . |
Registration |
addSaveListener(EditorSaveListener<T> listener)
Adds an editor save
listener . |
void |
cancel()
Cancel will discard any changes made in editor fields for a buffered
editor.
|
void |
closeEditor()
Closes the editor when in unbuffered mode and fires an
EditorCloseEvent if the edited item is
not null . |
void |
editItem(T item)
Opens the editor component for the provided item and fires an
EditorOpenEvent . |
Binder<T> |
getBinder()
Returns the underlying Binder from Editor.
|
Grid<T> |
getGrid()
Gets the Grid instance which this editor belongs to.
|
T |
getItem()
Gets the current item being edited, if any.
|
boolean |
isBuffered()
Returns whether Editor is buffered or not.
|
boolean |
isOpen()
Returns whether Editor is open or not.
|
void |
refresh()
Refreshes the editor components for the current item being edited.
|
boolean |
save()
In buffered mode calling save will validate bean and will save any
changes made to the Editor fields to the edited bean if all validators
pass.
|
Editor<T> |
setBinder(Binder<T> binder)
Sets the underlying Binder to this Editor.
|
Editor<T> |
setBuffered(boolean buffered)
Sets the Editor buffered mode.
|
Editor<T> setBinder(Binder<T> binder)
binder
- the binder for updating editor fields; not null
Binder<T> getBinder()
null
Editor<T> setBuffered(boolean buffered)
buffered
- true
if editor should be buffered; false
if
notboolean isBuffered()
true
if editor is buffered; false
if notsetBuffered(boolean)
boolean isOpen()
true
if editor is open; false
if notboolean save()
A successful write will fire an EditorSaveEvent
and close the
editor that will fire an EditorCloseEvent
.
If the write fails then there will be no events and the editor will stay open.
Note! For an unbuffered editor calling save will have no effect and
always return false
.
true
if save succeeded; false
if notvoid cancel()
Calling cancel will fire an EditorCancelEvent
and close the
editor that will fire an EditorCloseEvent
if the edited item is
not null
.
void closeEditor()
EditorCloseEvent
if the edited item is
not null
.
For buffered mode calling close editor will throw an UnsupportedOperationException
as either save()
or cancel()
should be used.
UnsupportedOperationException
- thrown if trying to close editor in buffered modevoid editItem(T item)
EditorOpenEvent
.
In case there is an open editor an EditorCloseEvent
will also be
fired.
item
- the edited itemIllegalStateException
- if already editing a different item in buffered modeIllegalArgumentException
- if the item
is not in the backing data providervoid refresh()
This is useful when the state of the item is changed while the editor is open.
isOpen()
T getItem()
The item being edited is always null
while the editor is
closed. The item is not null
during save()
and
cancel()
operations, but become null
as soon as the
editor is closed.
null
if none is being
editededitItem(Object)
Grid<T> getGrid()
Registration addSaveListener(EditorSaveListener<T> listener)
listener
- save listenerRegistration addCancelListener(EditorCancelListener<T> listener)
listener
- cancel listenerRegistration addOpenListener(EditorOpenListener<T> listener)
listener
. EditorOpenEvent
is
fired when the editor is opened through editItem(java.lang.Object)
listener
- open listenerRegistration addCloseListener(EditorCloseListener<T> listener)
listener
. Close events are sent every time
the editor is closed, no matter if it is due to a close, save or to a
cancel operation.
When a successful save()
operation is performed, two listeners
are triggered: save and close listeners. Likewise, when a
cancel()
operation is performed, two listeners are triggered,
cancel and close listeners.
listener
- close listenerCopyright © 2020. All rights reserved.