Given a report with a parameter, say foo
with value bar
, I'd expect the following to either print bar
if it supported parameters, or $P{foo}
if it only supported static text.
AutoText showBatchAutoText = new AutoText("$P{foo}",
AutoText.POSITION_HEADER,
HorizontalBandAlignment.CENTER);
Instead it prints ((java.lang.String)parameter_foo.getValue())
, implying it does some kind of logic on the field...
Is it supposed to work? Am I misusing the "message" type AutoText?
DynamicJasper wraps the string in quotes before sending it to Jasper. So, sql injection attack style, you can bypass it with escaped quotes.
AutoText showBatchAutoText = new AutoText("\" + $P{foo} + \"",
AutoText.POSITION_HEADER,
HorizontalBandAlignment.CENTER);
A hack, but... it does the trick.