What is the best way to transfer information from one class to another while also modifying the content of an element?

I am working on two qooxdoo classes:

main.container:

qx.Class.define("main.container",
{
    type: "singleton",
    extend: webfrontend.gui.CustomWindow,

    construct: function() {
        this.base(arguments);
        this.setLayout( new qx.ui.layout.VBox());
        var info = new qx.ui.container.Composite( new qx.ui.layout.VBox());
        this.add(info);
        this.info = info;
    },
    destruct: function(){},
    members: {
        info: null,
        __setInfo: function(array) {
            this.info.removeAll();
            for(var i = 0; i < array.length; i++) {
                var label = new qx.ui.basic.Label(array[i]);
                this.info.add(label);
            }
        }
    }
});

main.widget:

qx.Class.define("main.widget",
{
    type: "singleton",
    extend: qx.ui.core.Widget,

    construct: function() { ... },
    members: {
        __sendData: function(data) {
            var cont = main.container.getInstance();
            var setInfo = cont.__setInfo;
            setInfo(data);
        },
        __onHover: function() {
            var data = ....
            this.__sendData(data);
        }
    }
});

I am trying to retrieve data from the main.widget class and pass it to the main.container class to add labels to the info container.

However, when I execute this code, I encounter an error

TypeError: Cannot call method 'removeAll' of undefined
, but running
main.container.getInstance().__setInfo([...])
in the console works!

What am I doing incorrectly and how can I resolve it?

qooxdoo playground

Answer №1

By using a double underscore prefix in a method like you did with __setInfo, it designates the method as private. This restricts access to only the class itself. qooxdoo enforces this restriction by altering the method names during the build process. To allow access from another class, consider making it a public method without underscores at the start of the name. For more information, refer to the Classes manual page:

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

Why is inner HTML returning input/textbox instead of the value?

I need help extracting the value from an input/textbox within a table cell. Although the rest of my code is functioning correctly, I'm struggling to retrieve the value from this particular input element. I've attempted to access the value using ...

Master the art of linking multiple axios calls together in a single promise

I've been delving into Axios and promises lately, trying to grasp the concept. It seems like I'm on the right track, but there are definitely some mistakes in my approach. My javascript method is supposed to return a promise, within which I have ...

In JavaScript, a "switch statement" retrieves a test value from a "input type text" by accessing the value using getElementByName.value

Attempting to test 7 possible values for the variable 'a' by passing it to a function from user input in seven 'input type text' boxes, then checking each value individually with clicks on 7 'input type image' elements. Howeve ...

The error message thrown states: "Invalid function for Dispatch Action within Redux Toolkit."

Currently, I am in the process of learning the redux toolkit and have encountered a Type Error that I am unable to resolve. Let's Create a Counter Slice! const { createSlice } = require("@reduxjs/toolkit"); const initialState = { count ...

How to wait for the webpage to fully load before executing a script using a Chrome extension

After opening a new website tab, I am attempting to select a DOM element by its class name. The issue I have encountered is not knowing how to effectively wait until the entire page has finished loading. Despite trying various methods such as alarms, setTi ...

How to deactivate a text box within a form that is dynamically generated using Angular

I have encountered an issue with disabling the textbox inside my dynamic form in AngularJS after clicking a button. My code works perfectly fine for disabling textboxes outside the dynamic form, but when I try to target the ID of the textbox within the dyn ...

Suggestions for improving the smoothness of the Bootstrap toggle hide/show feature

Recently completed my bootstrap toggle hide/show feature and everything seems to be functioning correctly, except for the transition between the different contents. The borders appear jagged and not smooth when activating the toggle. I suspect there may b ...

Adding a dynamic css class to an HTML class attribute in AngularJS: A step-by-step guide

I recently encountered a div setup in this way: <div class="row loginCtrl.padding(50)"></div> Here is my corresponding controller code snippet: app.controller("loginController", function(){ this.padding = function(val){ alert('pa ...

How can I access a PHP variable by passing it through JavaScript?

I've been trying to pass my variable through an AJAX request in JavaScript. How can I properly assign the value of this variable to a new one in the tabs.php file? JavaScript code snippet: var build = { m_count : document.getElementById('count& ...

What is the best method for sending a user to a different page when a webhook is triggered by an external API in

In my project using NextJS and the pages router, I encounter a scenario where a user initiates a process through a form that takes approximately 30 seconds to complete. This process is carried out by an external API over which I have no control. Once the p ...

Automatically assigning IDs to all elements on an Angular webpage

We are currently developing an enterprise web application and have brought on board an e2e test engineer to automate tests. The test engineer has requested that we assign IDs to all elements in our pages. Is there a tool or method available to automatical ...

Merge nested arrays while eliminating any redundant elements

Is there a way to merge these array sets while ensuring that duplicate values are removed? I am unsure if lodash provides a solution for this specific scenario where the arrays are nested. Most of the solutions I have come across assume flat arrays. Any ...

`How can I dynamically refresh Laravel @includes using AJAX?`

Incorporating a single page application within my larger application has been a challenge. The issue lies in sending data to the database and displaying it on the table without having to refresh the page. Despite implementing AJAX dynamically, the newly in ...

Reset checkboxes in Material UI data grid

Currently, I am immersed in a React Js project that involves various tabs, each containing a unique data grid table with rows featuring checkboxes. Issue: Whenever I select a row from Table 1 and navigate to Tab 2 before returning to Tab 1, the checkboxes ...

Trigger Element Upon Click

Forgive me in advance for the lack of quality in this question, but I'll proceed anyway: All I want is for an element to slide open when clicked with a mouse! That's all! More specifically, I am looking for a single menu item that, upon clickin ...

How can we update state using the previous state in React?

Every time I click a button <Pressable onPress={() => { this.onPressHandler(); }}> I try to revert the state back to its previous value, but it doesn't work as expected onPressHandler = () => { th ...

Exploring the capabilities of nested WebGL render targets in the three.js library

I am currently developing an application for the Oculus Rift using JavaScript, three.js, and OculusRiftEffect.js. In order to create a transparent portion of a 2D ring for the menu, I am attempting to generate a MeshBasicMaterial.alphaMap texture on a Web ...

How can I retrieve and process a text or .csv file that has been uploaded using Multer?

Just starting out with Multer - I created an application to analyze a .csv file and determine the frequency of each keyword and phrase in the document. However, I have since made adjustments using node and express to analyse the file AFTER it has been subm ...

Useragent-dependent styling conditions

How can I select the appropriate stylesheet based on the useragent? For instance, I would like to display a specific css style for Android and another for iPhone. Is it achievable using only css? Can media queries be utilized? Appreciate any help in ad ...

I am looking to create a unique object by searching for key-value pairs in an array containing 'n' number of objects, using either lodash or typescript

Here is my plan: We have an array of objects retrieved from the database. Let's focus on one item: this.usersObj. @Input() inlinetext: string; <<-- This represents the input field from the UI public usersObj: string[]; <<-- Type definit ...