javascripttibcoliveviewstreambase

JavaScript and LiveView (TIBCO Live Datamart)


I have a StreamBase app that queries data and put it into a .lvconf table. Is there a way to get the data from this .lvconf table and have it available in my JavaScript for me to do things with the data?


Solution

  • Assuming that .lvconf table means a data table in a LiveView server (also known as Live Datamart), the way to access data from the table in a JavaScript application is to use the LiveView JavaScript Client API. (There is API reference documentation as well.)

    Here is a short example of using the API to query a Live Datamart table called ItemsInventory:

    <script src="/lv-web/api/lib/jquery.min.js"></script>
    <script src="/lv-web/api/lib/jquery.atmosphere.min.js"></script>
    <script src="/lv-web/api/liveview.min.js"></script>
    <script>
      LiveView.connect({url: '/lv/client/'}).then(
        function(connection){
          connection.subscribe(
            new LiveView.Query('SELECT * FROM ItemsInventory'),
            {
              onInsert: function(result){
                console.log('Got new tuple: ' + JSON.stringify(result.tuple));            
              }
            }
          );
        }
      );
    </script>
    

    The Creating web applications with JavaScript sample shipped with LiveView further illustrates the use of the JavaScript Client API for table querying.

    To load this sample in StreamBase Studio:

    1. Select File → Load StreamBase Sample from Studio's top-level menu.
    2. Enter "javasc" in the filter field to narrow the selection.
    3. Select the sample whose description is Creating web applications with JavaScript from the TIBCO LiveView category.
    4. Click OK.

    Follow the instructions in the sample's README.txt file to run the sample project as a LiveView Project.

    Since this question and answer was created in April 2015, there is a new version of the Dashboard sample that provides a very small framework for creating JavaScript visualizations of Live Datamart query results that uses Highcharts.JS rather than D3. There is also a document called TIBCO Live Datamart JavaScript Dashboard Sample: A Best Practices Guide explaining how that Dashboard sample is structured and how to add visualizations to it.

    Disclosure/Disclaimer: I am an employee of TIBCO Software, Inc. Opinions expressed here are my own and not TIBCO's.