This also works if the report is accessed directly via an URL that uses Configuration Blocks.
- Create a Document Property as a boolean and set it to false.
- Tie your script to that Document Property; every time its value changes, the script is triggered
If using the JS mashup page, have a JS script run when the onOpened event is fired and set that property. Make sure that the mashup page runs under the same site as the Web Player on the IIS server, eg: "Add application" under the Spotfire Web Player site.
Mashup page:
<html>
<head>
<title>MySamplePage</title>
<script type="text/javascript" src="PATH_TO/SpotfireWeb/GetJavaScriptApi.ashx?Version=3.1"></script>
<script type="text/javascript" src="PATH_TO/myScript.js"></script>
</head>
<body>
<!-- Whatever -->
<div id="webPlayerDiv"/>
</body>
</html>
Script:
var webPlayer;
var webPlayerRelativePath = "PATH_TO/SpotfireWeb/";
var analysisPath = "PATH_TO/myAnalysis";
<!-- when the page is accessed, include the Web Player analysis via JS -->
window.onload = function()
{
openWebPlayer();
};
var openWebPlayer = function()
{
var webPlayerCustomization = new spotfire.webPlayer.Customization();
<!-- enable/disable toolbar buttons -->
webPlayerCustomization.showCustomizableHeader = true;
webPlayerCustomization.showTopHeader = true;
webPlayerCustomization.showClose = true;
webPlayerCustomization.showAnalysisInfo = true;
webPlayerCustomization.showToolBar = true;
webPlayerCustomization.showExportFile = true;
webPlayerCustomization.showExportVisualization = true;
webPlayerCustomization.showUndoRedo = true;
webPlayerCustomization.showDodPanel = true;
webPlayerCustomization.showFilterPanel = true;
webPlayerCustomization.showPageNavigation = true;
webPlayerCustomization.showStatusBar = true;
webPlayer = new spotfire.webPlayer.Application(webPlayerRelativePath, webPlayerCustomization);
var onError = function(errorCode, description)
{
log('<span style="color: red;">[' + errorCode + "]: " + description + "</span>");
};
<!-- when the report is loaded, set our Document Property to true to trigger the script -->
var onOpened = function(analysisDocument)
{
webPlayer.analysisDocument.setDocumentProperty(
"myProperty",
"true");
};
webPlayer.onError(onError);
webPlayer.onOpened(onOpened);
webPlayer.open(analysisPath, "webPlayerDiv", "");
};
If using the configuration block in the URL instead, add:
&configurationBlock=PROPERTY_NAME=VALUE;
So you'll have something like:
http://myServer:PORT/SpotfireWeb/ViewAnalysis.aspx?file=/PATH_TO/MyAnalysis&configurationBlock=MyDocumentProperty=VALUE;
No comments:
Post a Comment
With great power comes great responsibility