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

public class LoadingService<T> extends javafx.concurrent.Service<PagingLoadResponse<T>>
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

    Properties
    Type
    Property
    Description
    final javafx.beans.property.LongProperty
    The 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.IntegerProperty
    The index of the currently showing page.
    final javafx.beans.property.IntegerProperty
    The 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
    Modifier and Type
    Field
    Description
    static int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected javafx.concurrent.Task<PagingLoadResponse<T>>
     
    final long
    Gets the value of the loadDelayInMillis property.
    final javafx.util.Callback<PagingLoadRequest, PagingLoadResponse<T>>
    Gets the value of the loader property.
    final int
    Gets the value of the page property.
    final int
    Gets the value of the pageSize property.
    final javafx.beans.property.LongProperty
    The 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.IntegerProperty
    The index of the currently showing page.
    final javafx.beans.property.IntegerProperty
    The number of items shown per page of the control that is being controlled by the pagination control.
    final void
    setLoadDelayInMillis(long loadDelayInMillis)
    Sets the value of the loadDelayInMillis property.

    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

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Property Details

    • page

      public final javafx.beans.property.IntegerProperty pageProperty
      The index of the currently showing page.
      See Also:
    • pageSize

      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.
      See Also:
    • loadDelayInMillis

      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.
      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

      protected javafx.concurrent.Task<PagingLoadResponse<T>> createTask()
      Specified by:
      createTask in class javafx.concurrent.Service<PagingLoadResponse<T>>
    • getPage

      public final int getPage()
      Gets the value of the page property.
      Property description:
      The index of the currently showing page.
      Returns:
      the value of the page property
      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 the pageSize property.
      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 pageSize property
      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 the loadDelayInMillis property.
      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 loadDelayInMillis property
      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 the loadDelayInMillis property.
      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 the loadDelayInMillis property
      See Also:
    • getLoader

      public final javafx.util.Callback<PagingLoadRequest, PagingLoadResponse<T>> getLoader()
      Gets the value of the loader property.
      Property description:
      Returns:
      the value of the loader property
      See Also:
    • loaderProperty

      public final javafx.beans.property.ObjectProperty<javafx.util.Callback<PagingLoadRequest, PagingLoadResponse<T>>> loaderProperty()
      Returns:
      the loader property
      See Also: