Nesting Jasper expressions - grails

I have a field ($P{ORDER}.permit) which is Integer (0,1) and I'd like to display it as a String ("No", "Yes"). So I added below keys to ResourceBoundle:
order.permit.0=No
order.permit.1=Yes
I wrote expression $R{order.permit.$P{ORDER}.permit} but it doesn't work. An exception is thrown
net.sf.jasperreports.engine.JRException: Too many groovy classes were
generated. Please make sure that you don't use Groovy features such as
closures that are not supported by this report compiler.
I suspect that this exception is caused by nesting jasper expressions or nesting them in wrong way.
How should I write the expression to achieve desired result?
EDIT: str("order.permit." + $P{ORDER}.permit) is the answer. Details in the below post.

Use str() instead of $R{}.
See also http://jasperforge.org/plugins/espforum/view.php?group_id=102&forumid=103&topicid=54665:
$R{} and str() are largely the same thing. The functional difference
is that $R{} can only be used with fixed/static keys, while str() can
be used with dynamic message keys, e.g. str("message.prefix." +
$P{message}).

Related

What is the effect on using | without a list? [duplicate]

We can make a nested list in erlang by writing something like this:
NL = [[2,3], [1]].
[[2,3],[1]]
But assume we wrote it like this instead:
OL = [[2,3]|1].
[[2,3]|1]
Is OL still a list? Can someone please elaborate more what OL is?
This is called an improper list and should typically not be used. I think most library functions expects proper lists (e.g. length([1|2]) throws bad argument exception). Pattern matching with improper lists works though.
For some use cases, see Practical use of improper lists in Erlang (perhaps all functional languages)
More information about | and building list is given in Functional Programming: what is an "improper list"? .

Using decimal values in FunScript

I'm getting an exception when trying to use a decimal value with FunScript. It can be reproduced simply by using:
Globals.window.alert(Globals.JSON.stringify(3M))
The exception says:
System.Exception was unhandled
Message: An unhandled exception of type 'System.Exception' occurred in FunScript.dll
Additional information: Could not compile expression: Call (None, MakeDecimal,
[Value (13), Value (0), Value (0), Value (false), Value (0uy)])
I suspect this is a FunScript limitation, but I just wanted to check. In that case, How could a decimal value be used in the context of FunScript code? Or How could Funscript be extended in order to fix this?
The decimal primitive is a TODO feature. I guess the best way to tackle it would be reimplementing the System.Decimal structure using the recently open sourced .NET Framework reference source and then add the appropiate expression replacements to the compiler like it's done for other types which do not translate directly from .NET to JavaScript like DateTime, TimeSpan, Regex, F# option or list, etc.
I guess the feature hasn't been prioritized. If you need it, can you please open an issue in the Github page so one of the contributors (maybe myself) can start implementing it? If you think you can do it yourself, please feel free to submit a pull request. Thanks!
It is rather JavaScript limitation because JavaScript has only binary floating point.
One of the solution would be creating your own type containing two integers: for integer part and fractional part

About the | operator in erlang.

We can make a nested list in erlang by writing something like this:
NL = [[2,3], [1]].
[[2,3],[1]]
But assume we wrote it like this instead:
OL = [[2,3]|1].
[[2,3]|1]
Is OL still a list? Can someone please elaborate more what OL is?
This is called an improper list and should typically not be used. I think most library functions expects proper lists (e.g. length([1|2]) throws bad argument exception). Pattern matching with improper lists works though.
For some use cases, see Practical use of improper lists in Erlang (perhaps all functional languages)
More information about | and building list is given in Functional Programming: what is an "improper list"? .

Guessing a code block's language for correct syntax highlighting

I'm quite puzzled how the syntax highlighting feature here on SO works, but I have seen similar somewhere else. How does this work?
Is there one parser which can parse multiple languages at once?
Or, are several passes of different parsers needed and the best parsing result is used?
Or, is only a shallow analysis performed and the language is then guessed based on heuristics?
And if one of these is true, how does it work?
Check out Javascript code prettifier on Google Code.

SnakeYAML: How to disable underscore stripping when parsing?

Here's my problem. I have YAML doc that contains the following pair:
run_ID: 2010_03_31_101
When this get's parsed at
org.yaml.snakeyaml.constructor.SafeConstructor.ConstructYamlInt:159
underscores get stripped and Constructor returns Long 20100331101
instead of unmodified String "2010_03_31_101" that I really need.
QUESTION: How
can I disable this behavior and force parser to use String constructor
instead of Long?
OK. Got answer form their mailing list. Here it is
Hi, according to the spec
(http://yaml.org/type/int.html): Any
“_” characters in the number are
ignored, allowing a readable
representation of large values
You have a few ways to solve it. 1) do
not rely on implicit types, use quotes
(single or double) run_ID:
'2010_03_31_101'
2) Turn off resolver for integers (as
it is done here for floats) link
1 link 2
3) Define your own pattern for int
link 3
Please be aware that when you start to
deviate from the spec other recipients
may fail to parse your YAML document.
Using quotes is safe.
Andrey

Resources