Client-side Data Cache Actions

Description

Perform some action on an item in the Client-side Data Cache (e.g. read the data, refresh the data, etc.).

The client-side data cache allows you to retrieve data from the server. Once the data has been loaded into the data cache, you can use the data in your UX component. The data in the client-side data cache can be persisted (either to Local Storage or to the file system in a Cordova application) so that the data is available even when you no longer have a connection.

The Client-side Data Cache Actions action can be used to read, refresh, delete, or list the data items stored in the Client-side data cache.

Client-side Data Cache Action Properties

This section describes properties for configuring a Client-side Data Cache Action action.

  • Action name

    Specify the Client-side Data Cache Action that you want to execute. Available actions include:

    • Refresh Data Item(s)

      Perform an Ajax callback to the server to refresh the data in one or more cached data item(s). You can specify a function to call once data items have been refreshed.

    • Read Data

      Get the data from a cached data item. You can specify a JavaScript function to call after the data has been successfully read. You can also specify a filter and/or order to apply tot he data before the success function is called.

    • Read Multiple Data Items

      Read multiple data items, then call an onComplete JavaScript function once all data items have been read. If the data for a data-item hasn't been fetched from the server, an Ajax callback is made to the server to retrieve the data. The onComplete function will be passed a parameter, obj that contains the data for each data-item read. E.g. obj.customers.data, obj.orders.data, etc.

    • Delete Data Cache Item(s)

      Deletes item in the data cache. Specify the name of each item to delete or use '<all>' to delete everything from the data cache in the Data cache item to delete property. If the item is stored on the file system, the file is deleted. If the item is stored in LocalStorage, the item is deleted from LocalStorage. If you select the '<all>'' option, the folder storing client-side files is removed.

    • List Files in Data Cache

      Lists the data cache files that have been stored in the file system.

  • Data cache items Id(s)

    Specify the data cache items you want to perform an action on. You can enter a comma delimited list of data-items if you want to refresh the data in more than one data-item in a single Ajax callback. This property is available for the "Refresh Data Item(s)" action(s).

  • Data cache items to read

    Data cache items to read property. This property is available for the "Read Multiple Data Items" action(s).

  • Data cache item to delete

    Specify the name of the Data Cache item to delete (or '<all>' to delete all items). If the item is defined to persist (either in LocalStorage or the file system) and it has been persisted, it will be removed (from either LocalStorage or the file system). This property is available for the "Delete Data Cache Item(s)" action(s).

  • Data item

    Specify the name of the data item you want to read. This property is available for the "Read Data" action(s).

  • Refresh cache items (if on-line) before read

    If checked, the data cache items will be refreshed if a connection is available. This property is available for the "Read Data" and "Read Multiple Data Items" actions.

    • Automatically Refreshing Data

      When you read the value in a client-side data cache item using the Read Data or Read Multiple Data Items actions, the value stored on the device is returned, even if more up-to-date data is on the server. If you would like to retrieve the most recent data from the server before reading the item, you can specify that the data should be refreshed if the device is online by checking the Refresh cache items (if on-line) before read property.

      When an item is read with this property enabled, the cache will be updated if the device is online and the Alpha Anywhere server is available. After the cache has been updated, the data in the cache is read and returned. If the device is not online, or the Alpha Anywhere server is not available, the existing data in the cache is read and returned.

      images/csdc3.jpg
      images/csdc1.jpg
  • Filter

    You can specify a filter expression to filter the data in the data item. This property is available for the "Read Data" action(s).

  • Order

    You can specify an order expression to order the data in the data item. This property is available for the "Read Data" action(s).

Javascript Properties

  • onComplete

    The onComplete event is triggered when data items have been refreshed or read from the server. Custom JavaScript can be added to this event to do additional processing or perform other actions. This event is available for the "Refresh Data Item(s)" and "Read Multiple Data Items" actions.

  • onSuccess

    The onSuccess event is triggered when the action completes. You can add your own JavaScript to this event to perform additional tasks, such as populating controls in the UX Component or alerting the user. This event is available for the "Refresh Data Item(s)", "Read Data", "Delete Data Cache Item(s)", and "List Files in Data Cache" actions.

  • onFail

    The onFail event is triggered when the Ajax callback fails to return a response. You can add your own JavaScript to this event to handle the error. This event is available for the "Refresh Data Item(s)", "Read Data", "Delete Data Cache Item(s)", and "List Files in Data Cache" actions.

  • onDeviceOffline

    The onDeviceOffline event is triggered when an Ajax callback needs to be made to retrieve a data item that has not been downloaded to the device yet and the device is offline. JavaScript can be added to this event to handle the case when data cannot be downloaded from the server because the device is offline. This event is available for the "Refresh Data Item(s)", "Read Data" action(s).

  • onServerNotAvailable

    The onServerNotAvailable event is triggered when an Ajax callback is made to server but the server is not available. JavaScript can be added to this event to handle the case when data cannot be downloaded from the server because the server is not available. This event is available for the "Refresh Data Item(s)", "Read Data" action(s).

Limitations

UX Component Only

See Also