Member-only story
Integrating Vaadin Java Code with PowerBI JavaScript Code
3 min readJul 14, 2023
Integrating PowerBI dashboards and reports into a Vaadin application can provide powerful data visualization capabilities. PowerBI offers a JavaScript API that allows embedding reports and interacting with them programmatically. In this article, we will explore how to integrate Vaadin Java code with PowerBI JavaScript code by separating the JavaScript code into a separate file.
Prerequisites
Before proceeding, make sure you have the following prerequisites in place:
- Vaadin development environment set up.
- PowerBI account and a workspace with the desired reports.
Step 1: Create the JavaScript File
- In your Vaadin project, navigate to the
frontend
directory. This directory is typically located at the same level assrc
directory in your Vaadin project. - Create a new JavaScript file named
powerbi.js
in thefrontend
directory. - Open the
powerbi.js
file and add the following PowerBI JavaScript code:
// powerbi.js
function initPowerBIReport(reportContainer, embedUrl, embedToken) {
var reportLoadConfig = {
type: 'report',
tokenType: 'Embed',
accessToken: embedToken,
embedUrl: embedUrl,
settings: {…