Class LoadingService<T>
java.lang.Object
javafx.concurrent.Service<PagingLoadResponse<T>>
com.dlsc.gemsfx.paging.LoadingService<T>
- Type Parameters:
T- the type of items to be shown by the UI
- All Implemented Interfaces:
javafx.concurrent.Worker<PagingLoadResponse<T>>, javafx.event.EventTarget
A service that performs the actual loading of items for a paging control such as the
PagingListView or the
PagingGridTableView. The service delays the actual loading by a couple of milliseconds so that it can be
restarted (cancel and start) when the user changes the page index quickly. This avoids redundant updates and heavy
query operations. The service binds all of its properties to the paging control that uses it.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface javafx.concurrent.Worker
javafx.concurrent.Worker.State -
Property Summary
PropertiesTypePropertyDescriptionfinal javafx.beans.property.LongPropertyThe delay in milliseconds before the loading service will actually try to retrieve the data from (for example) a backend.final javafx.beans.property.ObjectProperty<javafx.util.Callback<PagingLoadRequest, PagingLoadResponse<T>>> final javafx.beans.property.IntegerPropertyThe index of the currently showing page.final javafx.beans.property.IntegerPropertyThe number of items shown per page of the control that is being controlled by the pagination control.Properties inherited from class javafx.concurrent.Service
exception, executor, message, onCancelled, onFailed, onReady, onRunning, onScheduled, onSucceeded, progress, running, state, title, totalWork, value, workDone -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected javafx.concurrent.Task<PagingLoadResponse<T>> final longGets the value of theloadDelayInMillisproperty.final javafx.util.Callback<PagingLoadRequest, PagingLoadResponse<T>> Gets the value of theloaderproperty.final intgetPage()Gets the value of thepageproperty.final intGets the value of thepageSizeproperty.final javafx.beans.property.LongPropertyThe delay in milliseconds before the loading service will actually try to retrieve the data from (for example) a backend.final javafx.beans.property.ObjectProperty<javafx.util.Callback<PagingLoadRequest, PagingLoadResponse<T>>> final javafx.beans.property.IntegerPropertyThe index of the currently showing page.final javafx.beans.property.IntegerPropertyThe number of items shown per page of the control that is being controlled by the pagination control.final voidsetLoadDelayInMillis(long loadDelayInMillis) Sets the value of theloadDelayInMillisproperty.Methods inherited from class javafx.concurrent.Service
addEventFilter, addEventHandler, buildEventDispatchChain, cancel, cancelled, exceptionProperty, executeTask, executorProperty, failed, fireEvent, getException, getExecutor, getMessage, getOnCancelled, getOnFailed, getOnReady, getOnRunning, getOnScheduled, getOnSucceeded, getProgress, getState, getTitle, getTotalWork, getValue, getWorkDone, isRunning, messageProperty, onCancelledProperty, onFailedProperty, onReadyProperty, onRunningProperty, onScheduledProperty, onSucceededProperty, progressProperty, ready, removeEventFilter, removeEventHandler, reset, restart, running, runningProperty, scheduled, setEventHandler, setExecutor, setOnCancelled, setOnFailed, setOnReady, setOnRunning, setOnScheduled, setOnSucceeded, start, stateProperty, succeeded, titleProperty, totalWorkProperty, valueProperty, workDoneProperty
-
Property Details
-
page
public final javafx.beans.property.IntegerProperty pagePropertyThe index of the currently showing page.- See Also:
-
pageSize
public final javafx.beans.property.IntegerProperty pageSizePropertyThe number of items shown per page of the control that is being controlled by the pagination control.- See Also:
-
loadDelayInMillis
public final javafx.beans.property.LongProperty loadDelayInMillisPropertyThe delay in milliseconds before the loading service will actually try to retrieve the data from (for example) a backend. This delay is around a few hundred milliseconds by default. Delaying the loading has the advantage that sudden property changes will not trigger multiple backend queries but will get batched together in a single reload operation.- See Also:
-
loader
public final javafx.beans.property.ObjectProperty<javafx.util.Callback<PagingLoadRequest, PagingLoadResponse<T>>> loaderProperty- See Also:
-
-
Field Details
-
UNDEFINED
public static int UNDEFINED
-
-
Constructor Details
-
LoadingService
public LoadingService()
-
-
Method Details
-
createTask
- Specified by:
createTaskin classjavafx.concurrent.Service<PagingLoadResponse<T>>
-
getPage
public final int getPage()Gets the value of thepageproperty.- Property description:
- The index of the currently showing page.
- Returns:
- the value of the
pageproperty - See Also:
-
pageProperty
public final javafx.beans.property.IntegerProperty pageProperty()The index of the currently showing page.- Returns:
- the number of the currently showing page
- See Also:
-
getPageSize
public final int getPageSize()Gets the value of thepageSizeproperty.- Property description:
- The number of items shown per page of the control that is being controlled by the pagination control.
- Returns:
- the value of the
pageSizeproperty - See Also:
-
pageSizeProperty
public final javafx.beans.property.IntegerProperty pageSizeProperty()The number of items shown per page of the control that is being controlled by the pagination control.- Returns:
- the number of items per page
- See Also:
-
getLoadDelayInMillis
public final long getLoadDelayInMillis()Gets the value of theloadDelayInMillisproperty.- Property description:
- The delay in milliseconds before the loading service will actually try to retrieve the data from (for example) a backend. This delay is around a few hundred milliseconds by default. Delaying the loading has the advantage that sudden property changes will not trigger multiple backend queries but will get batched together in a single reload operation.
- Returns:
- the value of the
loadDelayInMillisproperty - See Also:
-
loadDelayInMillisProperty
public final javafx.beans.property.LongProperty loadDelayInMillisProperty()The delay in milliseconds before the loading service will actually try to retrieve the data from (for example) a backend. This delay is around a few hundred milliseconds by default. Delaying the loading has the advantage that sudden property changes will not trigger multiple backend queries but will get batched together in a single reload operation.- Returns:
- the delay before data will actually be loaded
- See Also:
-
setLoadDelayInMillis
public final void setLoadDelayInMillis(long loadDelayInMillis) Sets the value of theloadDelayInMillisproperty.- Property description:
- The delay in milliseconds before the loading service will actually try to retrieve the data from (for example) a backend. This delay is around a few hundred milliseconds by default. Delaying the loading has the advantage that sudden property changes will not trigger multiple backend queries but will get batched together in a single reload operation.
- Parameters:
loadDelayInMillis- the value for theloadDelayInMillisproperty- See Also:
-
getLoader
Gets the value of theloaderproperty.- Property description:
- Returns:
- the value of the
loaderproperty - See Also:
-
loaderProperty
public final javafx.beans.property.ObjectProperty<javafx.util.Callback<PagingLoadRequest, PagingLoadResponse<T>>> loaderProperty()- Returns:
- the
loaderproperty - See Also:
-