Javascript Release

Options
Jenkinsj5
edited February 11, 2022 in Analytics #1
What version of Javascript is supported by BIRT 4.2.1? I can't find any reference to supported JS version, (not even in the help 'JavaScript Development Guide'). I would think that 4.2.1 would be fairly current (2012 release), but the 'for each ... in' iterator does not function and it was part of Javascript 1.7 (2006 release). <a class='bbc_url' href='http://www.birt-exchange.org/org/forum/public/style_emoticons/'>http://www.birt-exchange.org/org/forum/public/style_emoticons/</a><#EMO_DIR#>/confused.gif
Warning No formatter is installed for the format ipb

Comments

  • CBR
    CBR
    edited December 31, 1969 #2
    Options
    BIRT is using Mozilla Rhino 1.7R2 or later as javascript implementation. It also implements Javascript 1.7 spec. To enable the interpreter to run 1.7 compliant scripts a certain parameter needs to be set in Rhino. This parameter is not beeing set in the BIRT source code. Not sure if the dev team is willing to adapt it in future releases.

    I m assuming that i mean something like that:
    for each(let expr1 in expr2) statement
  • Jenkinsj5
    edited December 31, 1969 #3
    Options
    Excerpt from:

    JavaScript Step by Step,
    Second Edition
    Steve Suehring

    var star = new Object;
    star.name = "Polaris";
    star.type = "Double/Cepheid";
    star.constellation = "Ursa Minor";

    for each (var starValue in star) {
    alert(starValue + " is in the star object.");
    }

    When open the above with the appropriate html in an .html file with the BIRT web Browser, nothing happens. When I open the same file with FireFox it gives alert as expected, when I run just this code in the Firebug Console, it gives the alerts as expected.

    The below also only works on firefox, forEach is a 1.6 release

    excerpt from https://developer.mozilla.org/en-US/docs/JavaScript/Guide/Predefined_Core_Objects

    var colors = ['red','green','blue'];
    colors.forEach(function(color){
    alert(color);
    });

    My problem is when using BIRT to test my code, how do I tell if something is not working because I wrote it wrong, or because BIRT does not recognize it?
    Warning No formatter is installed for the format ipb
  • CBR
    CBR
    edited January 11, 2013 #4
    Options
    Sorry but i m confused now are you relating to BIRT javascript that is beeing used in BIRT expressions (e.g to calculate another field) or do you mean client side javascript that runs within a browser to give you alert messages and stuff like that?<br />
    Both are implementation of the javascript spec but are totally different from each other. BIRT is using Rhino as a <strong class='bbc'>server side</strong> javascript implementation which means that it isn't run in a web browser but on the server. Rhino is interpreted to Java at runtime, so you can pretty much compare it to Java itself.<br />
    Client side javascript is run within the client browser at viewtime.<br />
    With client side javascript you can add interactivity and you have access to the dom representation of your html document. Server side javascript is not related to html.<br />
    <br />
    Would you mind uploading a sample report that demonstrates the problem? Perhaps it is just a confusion between client and server side javascript?
  • Jenkinsj5
    edited December 31, 1969 #5
    Options
    This is all server side, I am using the JavaScript perspective to create and edit JavaScript using the 'HTML editor'. This works fine creating the HTML file (<em class='bbc'>other then some words don't get the correct highlights</em>). When I run the HTML file with 'Web Browser' that is part of the BIRT JavaScript perspective, the files do not work correctly. <br />
    <br />
    The forEach method (JS 1.6) and the 'for each ... in' (JS 1.7) don't work. I know my JS is OK because the HTML files behave as they should with Firefox. I have attached the files (copyright as noted above) <br />
    <br />
    I am just learning JS. JS or Java (<em class='bbc'>don't know Java</em>) is pretty much a requirement for any thing past generic drag and drop reporting with BIRT. <br />
    <br />
    When testing how do I tell; what is not working because I made an scripting error, what is not working because BIRT/Rhino is not current, what will work when deployed to HTML via IE8, PDF via Tomcat & IE8, Excel xlsx via Tomcat & IE8?
    Warning No formatter is installed for the format ipb
  • Jenkinsj5
    edited December 31, 1969 #6
    Options
    Here <a class='bbc_url' href='https://developer.mozilla.org/en-US/docs/New_in_Rhino_1.7R1'>https://developer.mozilla.org/en-US/docs/New_in_Rhino_1.7R1</a&gt; it says "<strong class='bbc'>As of Rhino1.7R1, Rhino now supports the features of JavaScript 1.7</strong>" <br />
    <br />
    So, Rhino 1.7R2 should support both 'forEach' method (JS 1.6) and the 'for each ... in' (JS 1.7). <br />
    <br />
    I am not sure what the disconect is. My goal would be to find a resource that identifies what JS is going to work dependably in 'off the shelf' BIRT.
    Warning No formatter is installed for the format ipb
  • Clement Wong
    Clement Wong E mod
    edited January 11, 2013 #7
    Options
    Hi Jenkinsj5,<br />
    <br />
    First, on the client side, please note that "<strong class='bbc'>for each</strong>" is "<em class='bbc'>...is not widely supported by non-Mozilla browsers...</em>" (reference: <a class='bbc_url' href='https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Statements/for_each...in'>https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Statements/for_each...in</a>)<br />
    <br />
    Second, on the client side, when using the default Eclipse's internal web browser on Windows, it will be Internet Explorer. So, if you had the "<strong class='bbc'>for each</strong>" on the client side, it will not be interpreted properly. Try the code outside of your BIRT design, and the "for each" code will not run in Internet Explorer.<br />
    <br />
    Now, in my attached example, I am using your Javascript 1.7 code snippet on both the server side, and on the client side.<br />
    <br />
    On the server side, I have populated the right hand column with your star names and output the string out -- see the expression in the yellow colored data control.<br />
    <br />
    On the client side, I have used your original Javascript code. The output presents the three alert dialogs (in Firefox) after the report is run and rendered. I changed the default Eclipse web browser to Firefox by changing the two settings:<br />
    <em class='bbc'><br />
    <ul class='bbc'><li> Window > Preferences > Report Design > Preview > (check) Always use external browsers<br />
    </li><li> Window > Preferences > General > Web Browser > (select) Use external web browser</li><li> Window > Preferences > General > Web Browser > (select) Firefox</li></ul></em><br />
    <br />
    On the client side, you may want to look into another Javascript function other than "<strong class='bbc'>for each</strong>" that is supported by all browsers.
    Warning No formatter is installed for the format ipb
  • Jenkinsj5
    edited January 14, 2013 #8
    Options
    Thank you Clement!

    It all just came together for me. BIRT 4.2.1 is current through Javascript 1.7, but when I was testing with the 'Web Browser' that is part of the BIRT Javascript perspective it was defaulting to IE settings, which are not as current.

    Now that I have it put together in my brain it makes perfect sense. As the majority of my consumers will be on IE, it is better if I leave the default setting to IE. I can use 'for each' on the server side, but I should probably not, as it will have disappointing behavior for most other applications.

    Again thank you. :)
    Warning No formatter is installed for the format ipb
  • Clement Wong
    Clement Wong E mod
    edited December 31, 1969 #9
    Options
    <blockquote class='ipsBlockquote' data-author="'Jenkinsj5'" data-cid="113221" data-time="1358166221" data-date="14 January 2013 - 05:23 AM"><p>
    .. .As the majority of my consumers will be on IE, it is better if I leave the default setting to IE. I can use 'for each' on the server side, but I should probably not, as it will have disappointing behavior for most other applications.<br /></p></blockquote>
    <br />
    You're welcome!<br />
    <br />
    By the way, in the last sentence you wrote above, did you mean <em class='bbc'>client</em> side? You will not have unexpected behavior on the <strong class='bbc'>server</strong> side because the type of browser will not matter during the generation phase.
    Warning No formatter is installed for the format ipb
  • Jenkinsj5
    edited December 31, 1969 #10
    Options
    <blockquote class='ipsBlockquote' data-author="'Clement Wong'" data-cid="113239" data-time="1358190811" data-date="14 January 2013 - 12:13 PM"><p>
    <br />
    By the way, in the last sentence you wrote above, did you mean <em class='bbc'>client</em> side?</p></blockquote>
    <br />
    No; I intend not to use it on the server or client side. I am just learning JS and if I make use of a solution in one place, and it won't work else where... It just seems simpler at this point to only use solutions that will work in all of my environments. <br />
    <br />
    Thanks again
    Warning No formatter is installed for the format ipb