Class FacadeDataSource

All Implemented Interfaces:
HasHandlers, HasDataChangedHandlers, HasHandleErrorHandlers

public class FacadeDataSource extends DataSource
Extends an arbitrary DataSource with the ability to queue requests made on it and dispatch the queued requests on demand. To use, create a FacadeDataSource instance with the inheritsFrom property set to the DataSource that you wish to extend.

This advanced class is intended to be used for testing data-bound components. This should not be used in production code.

See also the overview of the DataSource Facade pattern.

  • Constructor Details

    • FacadeDataSource

      public FacadeDataSource()
    • FacadeDataSource

      public FacadeDataSource(JavaScriptObject jsObj)
  • Method Details

    • getOrCreateRef

      public static FacadeDataSource getOrCreateRef(JavaScriptObject jsObj)
    • create

      public JavaScriptObject create()
      Overrides:
      create in class DataSource
    • getQueuedRequests

      public DSRequest[] getQueuedRequests() throws IllegalStateException
      An array of derived DS requests that are queued to be executed on the underlying inherited DataSource.

      When a DS request is made on this FacadeDataSource, if queueRequests is true, then a new DS request is created based on the given DS request and added to this queue.

      To clear the queue, set queueRequests to false or call clearQueue().

      Note : This method should be called only after the underlying component has been created.

      Returns:
      Current queuedRequests value. Default value is null
      Throws:
      IllegalStateException - if the underlying component has not yet been created.
    • setQueueRequests

      public FacadeDataSource setQueueRequests(boolean queueRequests)
      Should requests be queued?

      When DS requests are made on the FacadeDataSource, a new, derived DS request on the underlying inherited DataSource is created. If queueRequests is true, then the derived DS request is added to the queuedRequests array. If false, then the derived DS request is executed immediately on the inherited DataSource.

      If this method is called after the component has been drawn/initialized: Setter for queueRequests.

      Parameters:
      queueRequests - New queueRequests value. Default value is false
      Returns:
      FacadeDataSource instance, for chaining setter calls
    • getQueueRequests

      public boolean getQueueRequests()
      Should requests be queued?

      When DS requests are made on the FacadeDataSource, a new, derived DS request on the underlying inherited DataSource is created. If queueRequests is true, then the derived DS request is added to the queuedRequests array. If false, then the derived DS request is executed immediately on the inherited DataSource.

      Returns:
      Current queueRequests value. Default value is false
    • clearQueue

      public void clearQueue()
      Shorthand to clear the request queue without changing the value of queueRequests.
    • setDefaultProperties

      public static void setDefaultProperties(FacadeDataSource facadeDataSourceProperties)
      Class level method to set the default properties of this class. If set, then all existing and subsequently created instances of this class will automatically have default properties corresponding to the properties set on the SmartGWT class instance passed to this function before its underlying SmartClient JS object was created. This is a powerful feature that eliminates the need for users to create a separate hierarchy of subclasses that only alter the default properties of this class. Can also be used for skinning / styling purposes.

      Note: This method is intended for setting default attributes only and will affect all instances of the underlying class (including those automatically generated in JavaScript). This method should not be used to apply standard EventHandlers or override methods for a class - use a custom subclass instead. Calling this method after instances have been created can result in undefined behavior, since it bypasses any setters and a class instance may have already examined a particular property and not be expecting any changes through this route.

      Parameters:
      facadeDataSourceProperties - properties that should be used as new defaults when instances of this class are created
      See Also: