Skip to main content
RSS feed Subscribe to feed

 

Web Player: Open File

This example shows how to add a reference to the JavaScript API, and how to load an analysis. An open parameter block is used to set a parameter in the information link and to run a bookmark.

The procedure can be used to load an analyses containing information links, but to configure the parameters at runtime, for instance by retrieving them from a web portal.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>API Scenario</title>

    <script type="text/javascript" src="../GetJavaScriptApi.ashx?Version=1.0"></script>

    <script type="text/javascript">
        window.onload = function()
        {
            var customization = new spotfire.webPlayer.Customization();
            customization.showTopHeader = false;
            customization.showToolBar = false;

            var app = new spotfire.webPlayer.Application("../SpotfireWeb/", customization);
            
            // Register an error handler to catch errors.
            app.onError(errorCallback);
            
            // Register event handler for document opened event.
            app.onOpened(onOpenedCallback);
            
            // Register event handler for document closed event.
            app.onClosed(onDocumentClosedCallback);
            
            // Open an analysis.
            app.open(
                "TIBCO Spotfire Example Files/StoreSales/StoreSales", 
                "webPlayer", 
                'Parameter.BusinessLocation = {Boston, Seattle}; ApplyBookmark(bookmarkName = "All");');
        }
        
        function errorCallback(errorCode, description) {
            // Displays an error message if something goes wrong in the Web Player.
            alert(errorCode + ": " + description);
        }

        function onOpenedCallback(analysisDocument)
        {
            // Document is now opened and ready for interactions.
        }
        
        function onDocumentClosedCallback(analysisPath)
        {
            // Document is now closed.
        }
    </script>

</head>
<body>
    <div id="webPlayer" style="width: 800px; height: 600px;"></div>
</body>
</html>