Rocket Modern Experience (formerly LegaSuite)

 View Only
  • 1.  Using Qooxdoo Events - Collecting and presenting data

    Posted 03-25-2022 16:10
    Edited by Anand Rajamani 03-25-2022 16:10
    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
    ------------------------------


  • 2.  RE: Using Qooxdoo Events - Collecting and presenting data

    ROCKETEER
    Posted 03-28-2022 03:50
    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:
    Workbench Rocket MX Script function

    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. 
    JavaScript exampleNext 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:
    Adding the JavaScript function as event to a command button
    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:
    Example properties
    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:
    Example output

    Hope this clarifies and helps,
    Best regards,

    ------------------------------
    Roger van Valen
    Senior manager, software engineering
    Rocket Software
    Dordrecht, The Netherlands
    ------------------------------



  • 3.  RE: Using Qooxdoo Events - Collecting and presenting data

    Posted 03-30-2022 14:29
    Hi Roger,

    I tried using this in one of my earlier program to collect data from a grid - but as JavaScript is asynchronous, the callback function was being executed even before ScriptFunctionCall was executed and subfile data was collected. I had to change the program to revert back to MX Script.

    How can I have the program to wait for ScriptFunctionCall to end before the callback is executed?

    Thanks,
    Anand.

    ------------------------------
    Anand Rajamani
    ------------------------------



  • 4.  RE: Using Qooxdoo Events - Collecting and presenting data

    ROCKETEER
    Posted 03-31-2022 02:46
    Hi Anand,

    The callback of the scriptFunctionCall should only be called at the moment the function called has completed and returns the variables.
    I validated this again in the provided example and in our test sets, where this seems to work correct.

    You may have encountered a specific situation where this mechanism fails. Can you please create a support ticket with the project attached and steps to reproduce so we can replay your precise scenario and analyze what may be wrong?

    Regards,
    Roger.

    ------------------------------
    Roger van Valen
    Senior manager, software engineering
    Rocket Software
    Dordrecht, The Netherlands
    ------------------------------



  • 5.  RE: Using Qooxdoo Events - Collecting and presenting data

    PARTNER
    Posted 03-31-2022 10:43

    We ran into that issue when integrating with Fusion Charts.
    The team member that worked on that used setInterval to loop until a callback variable is populated.
    https://developer.mozilla.org/en-US/docs/Web/API/setInterval

    Where that person was more of a Javascript programmer, I'd rather do the bulk of my coding in Seagull Script...

    Use the scriptwindow control's javascript to host api call a Seagull function you create that will return the data.
    The callback variable has always been populated and ready for further javascript processing in this scenario.



    ------------------------------
    Leon Brown
    Gui Developer
    Vormittag Associates Inc
    Ronkonkoma NY US
    ------------------------------