SPEAK, Part 9: Data Sources

This blog post describes how to use data sources in SPEAK.

A central concept in SPEAK is a Data Source. A data sources provides data to other components.

SPEAK does not impose any restriction on what can be a data source.

Data sources are usually used in data-binding scenarios where other components bind properties to a property on the data source. Whenever the data source is updated, the components respond to the event by updating themselves.

A classic example is the search scenario which consists of a text box, a data source and a list control. The controls are data-bound in such a way that the data source listen for changes in the text box and the list control listen for updates to the data source. The user changes the text box which makes the data source update, which in turn makes the list control update.

Currently SPEAK contains 2 data sources; SearchDataSource and QueryDataSource. Both these data sources expose Sitecore items, but a data source can expose any kind of data. The important point is that the components that bind to the data source understands that data that is exposed.

For instance it is possible to implement a data source that exposes data from a SQL Table on a server. Such a data source could call a web service to retrieve that data from the SQL Table and expose the records as a Json data structure.

Many common SPEAK components can by default bind to an item-based data source.

Implementing a data source

A data source is a standard SPEAK Component, meaning that it has a View rendering and a JavaScript component. As a data source usually has no visual representation, the view rendering often renders a script tag with the appropriate parameters in the Page.Body place holder. It is however entirely possible to choose another approach. If the data source has no visual representation, it should inherit from ComponentModel.

The data source component should expose a property that represents the current data. This property should be read-only.

SPEAK provides no guidelines on the actual implementation of the data source.

Implementing an item-based data source

An item-based data source is a special kind of data source that exposes Sitecore items. An item-based data source is implemented in the same way as a generic data source.

By convention the property that exposes the items is called Items.

SPEAK provides no special base classes or API for implementing item-based data source.

(This blog post is an extract from the internal developer documentation that was generated during the development of SPEAK 1.0. It has been written by the developers who designed SPEAK and wrote the code.)

  • Hi Jakob,  I am trying to implement Sitecore Analytics Reporting using SPEAK Charting application. Do you have any example that explains the implementation of datasource that exposes data from SQL Table?