Sharing data between a Javascript applet and a webpage: strategies for sending results from the applet back to

When it comes to calling a method in an applet from JavaScript, I am facing a challenge. Both the applet and the JavaScript code are running on the same webpage. I am aware of how to call applet methods from JavaScript and vice versa using techniques like

MyAppletID.appletMethodName(args)
and JSObject. However, these approaches only allow one-way communication and do not support the passing of return values from one language to the other.

My goal is to achieve something like this...

var result = 0;
callAppletMethod( JSON.stringify(args), function(r) { result = r; } )

...in order to invoke an applet method and capture the return value in the variable result.

I am seeking advice on any technique, library, or toolkit that facilitates this type of two-way communication between JavaScript and an applet.

Should I explore the use of a remote procedure call protocol such as JSON-RPC? Or is there a more effective approach available?

(As someone new to JavaScript and web programming, I appreciate any guidance.)

Answer №1

let outcome = myApp.appletFunction(input)

... can be used to successfully retrieve data from Java and pass it to JavaScript.

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

What is causing the reluctance of my Angular test to accept my custom form validation function?

I'm currently facing an issue with testing an angular component called "FooComponent" using Karma/Jasmine. Snippet of code from foo.component.spec.ts file: describe('FooComponent', () => { let component: FooComponent let fixture ...

Are there any aesthetically pleasing CSS themes available for GWT integration?

This inquiry has been raised in the past... GWT 2.0 Themes? GWT Themes and Component Libraries ...however, two years have elapsed. Previously, the response was mainly negative unless utilizing a widget library. I am on the lookout for an appealing CSS ...

What causes the circular progress bar to disappear when hovering over the MUI React table?

My goal was to create a table with a CircularProgressBar that changes its background color from orange to dark blue when hovering over the row. However, despite my efforts, I couldn't get it to work as intended. Additionally, I wanted the progressBar ...

Error: The reduce function cannot be applied to $scope.array as it is not a

I am currently facing an issue with a section of my code that involves loading attributes related to a page using drop-down lists. These attributes, namely instruments, style, and scoring, are fetched through a service call. For instance, when retrieving ...

Using hooks for conditional rendering

Background Information : My current project involves creating a form using hooks and rendering components based on the step. Challenge Encountered : I received this error message: "Error: UserFormHooks(...): Nothing was returned from render. This usually ...

What is the best way to connect input values with ngFor and ngModel?

I am facing an issue with binding input values to a component in Angular. I have used ngFor on multiple inputs, but the input fields are not showing up, so I am unable to push the data to subQuestionsAnswertext. Here is the code snippet from app.component ...

Using JavaScript to transform base64 encoded strings into images

I'm currently working on an app using Titanium and I have a base64 string that I need to convert into an image from JSON data. Any assistance you can provide would be much appreciated. Thank you! ...

Troubleshooting regex validation issues in a JSFiddle form

Link to JSFiddle I encountered an issue with JSFiddle and I am having trouble figuring out the root cause. My aim is to validate an input using a regex pattern for a person's name. $("document").ready(function() { function validateForm() { var ...

Using Vue's $emit method within a Promise

I am currently working on an image upload feature that is based on a Promise. Within the "then" callback, I am attempting to $emit an event named 'success'. Although my VueDevTools shows me that the success event has been triggered, the associate ...

Sending data in chunks using Vue.js

I'm interested in sending the data in chunks. Currently, what I send to the server looks like this: for loop - 1, 2, 3. However, the server receives it asynchronously as 3, 1, 2 and I need it to be received synchronously in the order of my for loop: 1 ...

What are the best practices for utilizing createHash('sha1') effectively in node.js?

Exploring the intricacies of a login system using React, MySQL, and Node.JS has been an interesting journey. Here's a glimpse of what I've accomplished so far: Presenting my router setup: const express = require('express') const app = ...

Encountering issues when trying to upload a video to a Facebook page using the Graph

Trying to publish a video to a specific Facebook page using the guidelines provided by Facebook's documentation at this link, but encountering persistent errors. Below is the code snippet: try { let mediaPostParams = new URLSearchParams() ...

Using the index of a v-for loop as the value for v-model

I am facing a challenge in setting the index of a v-for loop to a dynamic v-model. I have tried a method that works, but it is not elegant and results in errors in the console: Here is my template section: <div v-for="(ob, index) in $v.especifications ...

What could be causing the misalignment between the desired output and the response from the AJAX request

Below is a basic JavaScript file I am working with: $.ajax({ url: "is_complete.php", type: "post", success: function (data) { if(data == 1) { } alert("ok") } }) The message "ok" will only be di ...

Unable to create a flawless circle using Canvas

No matter how hard I try, drawing a perfect circle seems impossible for me. Every time I attempt it, all I manage to create is an ellipse. Check out this code snippet I put together as an example: function canvasClicked(number) { var c = "canvas" + nu ...

Running a function exclusively within a single div using Angular 2

I am currently using *ngFor to group items, and it's functioning correctly. However, I am having trouble displaying the "listofGroup" in the view even though it works in the console. Specifically, I need to run a function within a specific div in Angu ...

Using javascript to filter an array of JSON data

I'm contemplating how to streamline my filter code below. It's designed to filter out all JSON strings from a JSON array that contain specified values in one of three specific JSON string keys. My Visual Studio seems to be laughing at me, questio ...

Tips for transferring information from the isolate scope to the parent scope

As a newcomer to AngularJS, I am exploring the creation of directives and how to invoke functions from the parent scope within them. While I have successfully achieved this, I am now grappling with the challenge of passing data from the isolate scope via a ...

Is jQuery AJAX returning improperly formatted JSON when using the jsonp type?

$('#rn_s').keyup(function() { var rn = $('#rn_s').val(); if(rn.length == 9) { $.ajax({ url: 'http://routingnumbers.info/api/data.json?rn=' + rn, type: 'GET', dataT ...

Could someone provide clarification on this particular line of Apex code for me?

I'm completely new to Oracle Apex and I could use some guidance in understanding the code snippet I came across in a tutorial about app creation. After digging around, I suspect it might be JavaScript, but I'm not entirely certain. The scenario ...