A recipe for Turing-complete logic in reports

0

The report environment is obviously not the right place to perform complex logic, but when needs must the lack of lambda support in the available JS and troubles getting java 8+ working make a solution desirable. This technique worked for me, and I thought it might be of interest:

<textFieldExpression><![CDATA[
    (function () {
       var a = new Object($F{top}.get("buss")); 
       var b = ...;
       for (var p in a) {
           b.push(a[p]);
       }
       return ...;
    }
    ).apply()
]]></textFieldExpression>

Notice the use of a "for" loop and temporary "var"s! This works because the "()" around the "function () {}" turns the declaration into an expression, which ".apply()" can run.

Enjoy responsibly...

srhaque's picture
13
Joined: Mar 16 2018 - 1:29pm
Last seen: 6 days 10 hours ago

0 Answers:

No answers yet
Feedback
randomness