Cloud
Cloud-Dienstleistung für schnelle und effektive Analyse und Visualisierung von Daten für Ihr Business ohne eigene Applikationen zu erstellen oder zu programmieren.
index.jsp, wrapped in a container with a known id:String reportPath = request.getSession().getServletContext().getRealPath("/reports/TwoSimpleLists.mrt");
StiReport report = StiSerializeManager.deserializeReport(new File(reportPath));
report.render();
StiWebViewerOptions options = new StiWebViewerOptions();
pageContext.setAttribute("report", report);
pageContext.setAttribute("options", options);
// <div id="viewerDiv"><stiwebviewer:webviewer report="${report}" options="${options}" /></div>
Add the button to the toolbar. On page load, get the viewer's JavaScript object and insert the button in its onready handler:function loaded() {
var viewer = window["js" + document.getElementById("viewerDiv").childNodes[1]["id"]];
viewer.onready = function () {
var customButton = viewer.SmallButton("customButton", "Custom Button", "emptyImage");
customButton.image.src = "icon.png";
customButton.action = function () {
alert("Custom Button Event");
};
var toolbarTable = viewer.controls.toolbar.firstChild.firstChild;
var buttonsTable = toolbarTable.rows[0].firstChild.firstChild;
var customButtonCell = buttonsTable.rows[0].insertCell(0);
customButtonCell.appendChild(customButton);
};
}
// <body onload="loaded()">
window["js" + viewerId] — the client-side viewer object created by the <stiwebviewer:webviewer> tag.onready — fires when the viewer and its toolbar are built, so the controls are available.SmallButton(name, caption, image) — creates a toolbar-style button; image.src sets its icon and action its click handler.controls.toolbar — the toolbar element; insertCell(0) puts the new button first in the row of buttons.StiWebResourceServlet and StiWebViewerActionServlet registered in web.xml. The custom button lives entirely on the client: it is built with the viewer's own button factory, so it matches the toolbar style, and its action can run any JavaScript — call your own endpoint, open a dialog, or trigger application logic.