Hi Anand,
This is definitely possible. Instead of giving an example I can guide you through the steps here to make this possible.
Best practice it to use a Rocket MX script to retrieve the information to be provided to your JavaScript.
Our client's JavaScript API can also be configured to allow to get any host field value or global variable from JavaScript, but we recommend to create functions to get only the information needed. This to prevent misuse, as opening up the API too much could make your web application vulnerable.
In my example I've created a Rocket MX script function to retrieve a System, SubSystem and DeviceName from the logon screen:
Next, I made a JavaScript function to use the API 'scriptFunctionCall' to call this function, obtain the outcome and just alert() on the outcome.
This is just an example that displays the contents of the fields in an alert, but you can both put and get variables this way to Rocket MX script functions. and use these in JavaScript.
As a function may take some time to complete the call is asynchronous. The scriptFunctionCall will invoke the function and on completion it will call the 'callback function' with the results. You can both capture the return value (in my example called result) as well as the variables passed 'by reference'. Although we call them "by reference" when we return updated arguments, technically these will be copies of the outcome - so changing them in JavaScript will have no effect in the Rocket MX script. To change these and send them back to the session another script function should be made for updating.
Also note that the names of returning values are uppercased, because JavaScript is case sensitive but Rocket MX script is not. To avoid challenges the variable names will always be uppercased.
Next step is to bind the JavaScript to a button.
As example we will bind this to a button on a panel, on the OnCommand event:
And lastly, the API will not be enabled by default.
To do so you can enable the API and the allowed function in the deployment.properties file.
For instance like this:
As explanation:
servlet.host_api=true --> turns on the API
servlet.host_api_access_control_order=deny-allow --> sets the order to first process the denials, then the allowances
servlet.host_api_access_control_deny=* --> deny everything
servlet.host_api_access_control_allow=scriptFunctionCall,RetrieveValues --> except call to scriptFunctionCall and RetrieveValues
This will allow only these two calls in the API, keep all other access closed to avoid any misuse for a safe setup.
When all is configured, my live test gives the following outcome when I click the button:
Hope this clarifies and helps,
Best regards,
------------------------------
Roger van Valen
Senior manager, software engineering
Rocket Software
Dordrecht, The Netherlands
------------------------------
Original Message:
Sent: 03-25-2022 16:09
From: Anand Rajamani
Subject: Using Qooxdoo Events - Collecting and presenting data
Hi,
I would like to use qooxdoo events (button click, radiobox selection change etc.) to collect host data (grid/ texts) and then manipulate the same (calculate totals from detail amounts, change color coding based on host condition, etc.) on the front-end side. Is there any example to achieve this?
Thanks,
Anand Rajamani.
------------------------------
Anand Rajamani
------------------------------