com.vaadin.flow.component.grid.editor.
Class EditorImpl<T>
Type Parameters:
T
- the grid bean type
All Implemented Interfaces:
Editor<T>
, DataGenerator<T>
, Serializable
Implementation of Editor
interface.
See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddCancelListener
(EditorCancelListener<T> listener) Adds an editor cancel
listener
.addCloseListener
(EditorCloseListener<T> listener) Adds an editor close
listener
.addOpenListener
(EditorOpenListener<T> listener) Adds an editor open
listener
.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
Closes the editor when in unbuffered mode and fires an
EditorCloseEvent
if the edited item is notnull
.void
Opens the editor component for the provided item and fires an
EditorOpenEvent
.void
generateData
(T item, elemental.json.JsonObject jsonObject) Adds custom data for the given item to its serialized
JsonObject
representation.Returns the underlying Binder from Editor.
getGrid()
Gets the Grid this extension extends.
getItem()
Gets the current item being edited, if any.
boolean
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.
Sets the underlying Binder to this Editor.
setBuffered
(boolean buffered) Sets the Editor buffered mode.
Methods inherited from class com.vaadin.flow.component.grid.Grid.AbstractGridExtension
extend, refresh, remove
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.vaadin.flow.data.provider.DataGenerator
destroyAllData, destroyData, refreshData
-
Constructor Details
-
EditorImpl
-
-
Method Details
-
setBinder
Description copied from interface:
Editor
Sets the underlying Binder to this Editor.
-
getBinder
Description copied from interface:
Editor
Returns the underlying Binder from Editor.
-
setBuffered
Description copied from interface:
Editor
Sets the Editor buffered mode. When the editor is in buffered mode, edits are only committed when the user clicks the save button. In unbuffered mode valid changes are automatically committed.
Specified by:
setBuffered
in interfaceEditor<T>
Parameters:
buffered
-true
if editor should be buffered;false
if notReturns:
this editor
-
isBuffered
public boolean isBuffered()Description copied from interface:
Editor
Returns whether Editor is buffered or not.
Specified by:
isBuffered
in interfaceEditor<T>
Returns:
true
if editor is buffered;false
if notSee Also:
-
isOpen
public boolean isOpen()Description copied from interface:
Editor
Returns whether Editor is open or not.
-
save
public boolean save()Description copied from interface:
Editor
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.
A successful write will fire an
EditorSaveEvent
and close the editor that will fire anEditorCloseEvent
.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
. -
cancel
public void cancel()Description copied from interface:
Editor
Cancel will discard any changes made in editor fields for a buffered editor.
Calling cancel will fire an
EditorCancelEvent
and close the editor that will fire anEditorCloseEvent
if the edited item is notnull
. -
closeEditor
public void closeEditor()Description copied from interface:
Editor
Closes the editor when in unbuffered mode and fires an
EditorCloseEvent
if the edited item is notnull
.For buffered mode calling close editor will throw an
UnsupportedOperationException
as eitherEditor.save()
orEditor.cancel()
should be used.Specified by:
closeEditor
in interfaceEditor<T>
-
editItem
Description copied from interface:
Editor
Opens the editor component for the provided item and fires an
EditorOpenEvent
.In case there is an open editor an
EditorCloseEvent
will also be fired. -
refresh
public void refresh()Description copied from interface:
Editor
Refreshes the editor components for the current item being edited. It is a NO-OP if the editor is not opened.
This is useful when the state of the item is changed while the editor is open.
-
getItem
Description copied from interface:
Editor
Gets the current item being edited, if any.
The item being edited is always
null
while the editor is closed. The item is notnull
duringEditor.save()
andEditor.cancel()
operations, but becomenull
as soon as the editor is closed. -
getGrid
Description copied from class:
Grid.AbstractGridExtension
Gets the Grid this extension extends.
-
generateData
Description copied from interface:
DataGenerator
Adds custom data for the given item to its serialized
JsonObject
representation. This JSON object will be sent to client-side DataProvider.Specified by:
generateData
in interfaceDataGenerator<T>
Parameters:
item
- the data item being serializedjsonObject
- the JSON object being sent to the client -
addSaveListener
Description copied from interface:
Editor
Adds an editor save
listener
.EditorSaveEvent
is called whenEditor.save()
is called.Specified by:
addSaveListener
in interfaceEditor<T>
Parameters:
listener
- save listenerReturns:
a registration object for removing the listener
-
addCancelListener
Description copied from interface:
Editor
Adds an editor cancel
listener
.EditorCancelEvent
is fired whenEditor.cancel()
is called.Specified by:
addCancelListener
in interfaceEditor<T>
Parameters:
listener
- cancel listenerReturns:
a registration object for removing the listener
-
addOpenListener
Description copied from interface:
Editor
Adds an editor open
listener
.EditorOpenEvent
is fired when the editor is opened throughEditor.editItem(java.lang.Object)
Specified by:
addOpenListener
in interfaceEditor<T>
Parameters:
listener
- open listenerReturns:
a registration object for removing the listener
-
addCloseListener
Description copied from interface:
Editor
Adds an editor close
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
Editor.save()
operation is performed, two listeners are triggered: save and close listeners. Likewise, when aEditor.cancel()
operation is performed, two listeners are triggered, cancel and close listeners.Specified by:
addCloseListener
in interfaceEditor<T>
Parameters:
listener
- close listenerReturns:
a registration object for removing the listener
-