Invoking a bean using a Javascript Birt Expression

I am attempting to display the contact number (GetExtension) of the current user logged in and generating a report.

The following code successfully displays the name of the logged-in user when placed within Birt's Expression Builder (Dynamic text field):

`var result = "USERID";
try {
result = Packages.uk.co.blah.session.Session.getUserID();
} catch (error) {
Packages.java.lang.System.err.println(error);
}
result;`

However, I have not been able to get the Extension method to display using the same code adjusted for 'getExtension':

`var result = "EXTENSION"; 
try { 
result = Packages.uk.co.blah.session.Session.getExtension(); 
} catch (error) {
Packages.java.lang.System.err.println(error); result;`

After trying a different approach by directly accessing the package path instead of session.Session:

`var result = "EXTENSION";
try {
result = Packages.uk.co.blah.systemmanagement.personnel.getExtension();
} catch (error) {
Packages.java.lang.System.err.println(error);
}
result;`

Unfortunately, this only returns the word ‘EXTENSION’.

Is there a way to utilize getExtension based on the logged-in person obtained through getUserID?

Answer №1

Have you double-checked your error handling technique?

Here's what I suggest to troubleshoot this issue:

  • Try removing the try-catch block.
  • Add some debug output to display the type of result and its value.
  • Insert calls to Java's System.err before any code execution, just to ensure that the program is running and output can be directed to System.err.

Keep in mind that writing to System.err might not always work as expected in Java. For example, javaw.exe may not show any output from System.out or System.err. On the other hand, eclipsec.exe will display System.out and System.err messages on the console.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

EnhancedGreen 5.2.7 - database transition to mysql

Hey there! I am currently using the latest version of Broadleaf (5.2.7) and everything is running smoothly with HSQL. However, I am facing an issue while trying to migrate to MySQL. I have been referring to the tutorials here and here. The problem arises ...

Struggling with creating and exporting TailwindCSS and NextJS

I'm encountering challenges in constructing and exporting my TailwindCSS and NextJS project. While everything works smoothly when running `npm run dev` with all Tailwind classes functioning properly, I face an issue when executing `npm run build && np ...

What is the procedure for iterating through the square brackets of a JSON array?

Here's the data I have: $json_data_array = '[ { "id": 1, "value": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="bfd7cdffcbdacccb91dcd0d2">[email protected]</a>", ...

Turn off a feature on older buttons

For my project, I am looking to dynamically add specific elements like buttons. However, every time a new button is added, the function call for the old button gets duplicated. var btnElem ='<button type="button"class="doSomething">Button< ...

Utilizing AJAX requests to retrieve JSON data and populate Datatables

Trying to figure this out, but all I'm getting is [Object object]. Can anyone assist me with this issue? I've been following the Datatables documentation, but still can't seem to get it right. Any help would be greatly appreciated... thanks ...

How can we use jQuery to hide a selected option from a dropdown menu and move it to another dropdown menu?

<select> <option value = "volvo" > Volvo < /option> <option value = "saab" > Saab < /option> <option value = "vw" > VW < /option> <option value = "audi"> Audi < /option> </select> ...

Tips for keeping a reading item in place while scrolling

To enhance the user experience, I would like to improve readability without affecting the scroll position. Question: Is there a way to fix the scrolling item at a specific position (item with the .active class)? I am looking to maintain a consistent read ...

Tips for transferring information from a promise into an array

I'm trying to populate an array (coursesArray) with data from a promise and then use these values elsewhere. I am using the node-fetch library to make API queries. The issue I'm facing is that when I log the array inside the promise, it contains ...

Issue with Material-UI: Unforeseen TypeError arises while toggling between two Drawer elements

Note: I am utilizing material-ui 3.3.0 My goal is to have two <Drawer> components displayed on a page, with one sliding in from the left and the other from the right. In an <AppBar>, there are two <Button> components that toggle the visi ...

Bypass validation during re-render and enforce it exclusively during form submission

When a user enters a product name into an input field, specific details of the product should appear. I am using AJAX to retrieve the product from a data source based on the entered name and dynamically show the product details. Currently, the product deta ...

Optimal Ways to Share Service Data Among Components in Angular 2

I am looking to develop a service that retrieves data from a .json file once and distributes it to multiple subscribers. However, my current solution results in the same number of requests to fetch data as the number of subscribers for my service. getconf ...

PhoneGap's Ajax Integration

Is it possible to load content from separate files for a menu on a page, with each menu option having its own content file (.txt)? I want only the <div> for the content area to change. I have written code declaring an xmlHttp variable, which is a bro ...

Is it possible to have background animation within an irregularly shaped Canvas or SVG?

I am looking to create a unique and dynamic, animated background using either JavaScript or CSS for a non-rectangular shape in Canvas or SVG. Check out this example animation: https://codepen.io/tmrDevelops/pen/NPMGjE Here's the shape along with my ...

The location of errors is not displayed in VueJS stack traces

My Current VueJS Setup Check out the Source Code here I am working on a project using VueJS with webpack. I have chosen not to use the vue-loader plugin or .vue files. My project structure resembles a typical Javascript webpack project where I import vu ...

Is it possible to include a visible comment in an ajax call that can be viewed in Fiddler when analyzing the outgoing data?

Here is an example of the code I am working with: $.ajax({ cache: false, url: "/xx" }).done(onAjaxDone).fail(function (jqXHR, textStatus, errorThrown) { Dialog.Alerts.ajaxOnFailure(jqXHR, textStatus, err ...

The type 'SVGPathSeg' cannot be assigned to type 'EnterElement' because the property 'ownerDocument' is not present in type 'SVGPathSeg'

I'm attempting to replicate this example using the d3-ng2-service service on Angular 5. Component: OnInit code: let d3 = this.d3; let d3ParentElement: Selection<HTMLElement, any, null, undefined>; let d3Svg: Selection<SVGSVGElement, any, n ...

Executing a function from a JavaScript include within TypeScript code - what's the best way to go about it

I am currently utilizing stacktrace.js as an include in my code base. Within this include, there is a method available for retrieving the stacktrace by invoking StaceTrace.get() I am struggling to figure out how I can call this method from TypeScript. I ...

Can you explain the meaning of `suppressed_by_user` in Google One Tap?

When the user clicks sign in, I want the one tap to appear. The code below works fine when it runs as soon as the page loads. However, if I try to run it on click, I get the error suppressed_by_user. I do not have an ad blocking plugin enabled and I am uns ...

How can I detect Mongoose events through syntax?

Is there a way to detect the open event in Mongoose based on their documentation located here? According to the documentation, once connected, the open event is fired on the Connection instance. If you're using mongoose.connect, the Connection is m ...

Ways to regain control of the iframe window once a popup has been launched

I have a question regarding managing windows in Javascript. In my application, when I click on a link within an iframe, it opens a popup window where I enter my login credentials. After entering the credentials, I am able to close the popup window using a ...