Class ComponentEvent<T extends Component>
- Type Parameters:
T- the event source type
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
AbstractAttachDetachEvent,AbstractDnDEvent,AbstractField.ComponentValueChangeEvent,AbstractLogin.ForgotPasswordEvent,AbstractLogin.LoginEvent,Accordion.OpenedChangeEvent,AllFinishedEvent,BlurNotifier.BlurEvent,CellFocusEvent,ChartAddSeriesEvent,ChartAfterPrintEvent,ChartBeforePrintEvent,ChartClickEvent,ChartDrillupAllEvent,ChartDrillupEvent,ChartLoadEvent,ChartRedrawEvent,ChartSelectionEvent,ClickEvent,ClientItemToggleEvent,CollapseEvent,ColumnReorderEvent,ColumnResizeEvent,ComboBoxBase.CustomValueSetEvent,CompositionEvent,ConfirmDialog.CancelEvent,ConfirmDialog.ClosedEvent,ConfirmDialog.ConfirmEvent,ConfirmDialog.OpenedChangeEvent,ConfirmDialog.RejectEvent,ContextMenuBase.OpenedChangeEvent,Crud.CancelEvent,Crud.DeleteEvent,Crud.EditEvent,Crud.NewEvent,Crud.SaveEvent,CrudI18nUpdatedEvent,DashboardItemMovedEvent,DashboardItemMoveModeChangedEvent,DashboardItemRemovedEvent,DashboardItemResizedEvent,DashboardItemResizeModeChangedEvent,DashboardItemSelectedChangedEvent,DatePicker.InvalidChangeEvent,DatePicker.OpenedChangeEvent,Details.OpenedChangeEvent,Dialog.ClosedEvent,Dialog.DialogCloseActionEvent,Dialog.DialogDraggedEvent,Dialog.DialogResizeEvent,Dialog.OpenedChangeEvent,DrilldownEvent,ExpandEvent,FileRejectedEvent,FileRemovedEvent,FinishedEvent,FocusNotifier.FocusEvent,GridContextMenu.GridContextMenuItemClickEvent,GridDragEndEvent,GridDragStartEvent,GridDropEvent,GridPro.CellEditStartedEvent,GridPro.ItemPropertyChangedEvent,IdentifierProviderChangeEvent,InputEvent,ItemCountChangeEvent,KeyboardEvent,MapClickEvent,MapClusterClickEvent,MapFeatureClickEvent,MapFeatureDropEvent,MapViewMoveEndEvent,MasterDetailLayout.BackdropClickEvent,MasterDetailLayout.DetailEscapePressEvent,MessageInput.SubmitEvent,MessageList.AttachmentClickEvent,NativeDetails.ToggleEvent,Notification.OpenedChangeEvent,PointClickEvent,PointDragEvent,PointDragStartEvent,PointDropEvent,PointLegendItemClickEvent,PointMouseOutEvent,PointMouseOverEvent,PointRemoveEvent,PointSelectEvent,PointUnselectEvent,PointUpdateEvent,PollEvent,Popover.OpenedChangeEvent,ProgressUpdateEvent,Select.InvalidChangeEvent,Select.OpenedChangeEvent,SeriesAfterAnimateEvent,SeriesCheckboxClickEvent,SeriesClickEvent,SeriesHideEvent,SeriesLegendItemClickEvent,SeriesMouseOutEvent,SeriesMouseOverEvent,SeriesShowEvent,SortEvent,SplitLayout.SplitterDragEndEvent,StartedEvent,Tabs.SelectedChangeEvent,TabSheet.SelectedChangeEvent,TimePicker.InvalidChangeEvent,UI.BrowserLeaveNavigationEvent,UI.BrowserNavigateEvent,UI.BrowserRefreshEvent,UploadCompleteEvent,UploadManager.AllFinishedEvent,UploadManager.FileRejectedEvent,UploadManager.FileRemovedEvent,UploadStartEvent,WebComponentUI.WebComponentConnectEvent,XAxesExtremesSetEvent,YAxesExtremesSetEvent
Component.
Typically used together with ComponentEventBus.
- Since:
- 1.0
- Author:
- Vaadin Ltd
- See Also:
-
Field Summary
Fields inherited from class java.util.EventObject
source -
Constructor Summary
ConstructorsConstructorDescriptionComponentEvent(T source, boolean fromClient) Creates a new event using the given source and indicator whether the event originated from the client side or the server side. -
Method Summary
Modifier and TypeMethodDescriptiongetUI()Gets the UI the source component is attached to.booleanChecks if this event originated from the client side.voidUnregisters the event listener currently being invoked.Methods inherited from class java.util.EventObject
toString
-
Constructor Details
-
ComponentEvent
Creates a new event using the given source and indicator whether the event originated from the client side or the server side.- Parameters:
source- the source componentfromClient-trueif the event originated from the client side,falseotherwise
-
-
Method Details
-
getSource
- Overrides:
getSourcein classEventObject
-
getUI
Gets the UI the source component is attached to.This is a convenience for
getSource().getUI().get()when the event is fired while the source is attached to a UI, which is the common case.If the source component is not currently attached to a UI, this method throws an
IllegalStateException. This can happen, for example, when an initial value is set on a field before it is added to the UI and a value-change listener is invoked. If your listener can run while the source is detached, usegetSource().getUI()instead, which returns anOptionaland lets you handle the detached case explicitly.- Returns:
- the UI the source component is attached to, never
null - Throws:
IllegalStateException- if the source component is not currently attached to a UI
-
isFromClient
public boolean isFromClient()Checks if this event originated from the client side.- Returns:
trueif the event originated from the client side,falseotherwise
-
unregisterListener
public void unregisterListener()Unregisters the event listener currently being invoked.This method can only be called from within an event listener. Calling it will remove the current event listener so no further events are passed to it.
-