Jasper Reports: how to add own Functions to Expression Editor - jasper-reports

I am using Jaspersoft Studio 6.6 and try to add own functions to the Expression Editor.
Therefore i follow the tutorial Jaspersoft Studio Expression Editor: how to extend it and contribute your own functions (part 2) - updated for version 5.5 (i was not able to find a more current version so i guess this one should be still correct)
All works fine but i had to replace the language of the generated report (SampleFunctionsReport.jrxml) from groovy to java to get rid of class not found exceptions
Finally the following Errors are remaining:
Description Resource Path Location Type
The method HELLO_WORLD_MSG() is undefined for the type SampleFunctions_1541665022158_603382 SampleFunctionsReport.jrxml /MyFunctions line 37 JRXML Problem
The method HELLO_WORLD_MSG() is undefined for the type SampleFunctions_1541665022158_603382 value = HELLO_WORLD_MSG( ); SampleFunctionsReport.jrxml /MyFunctions line 0 JRXML Problem
The method REPEAT_MSG(String, int, boolean) is undefined for the type SampleFunctions_1541665022158_603382 SampleFunctionsReport.jrxml /MyFunctions line 52 JRXML Problem
The method REPEAT_MSG(String, int, boolean) is undefined for the type SampleFunctions_1541665022158_603382 value = REPEAT_MSG("A message that will be probably repeated",5,true); SampleFunctionsReport.jrxml /MyFunctions line 0 JRXML Problem
I checked the points of the tutorial a couple of times...
can someone reproduce my problem?
What am i missing?

<import value="test.customfunctions.*"/>
this is the code from my jrxml, which is fine.
when i tried to enter the full class name - i got an error, that the package cannot be added.
today i tried the same again - and its working. even the resulting XML is identical!

Related

How to solve om.google.zxing.client.j2se.MatrixToImageWriter cannot be resolved to a type?

[To the person that closed my previous question, the links provided have nothing to do with my question]
I'm trying to create a QR code in JasperSoft Studio.
We have a report properly working on production containing a QR code. But after a new installation of JasperSoft Studio, we are unable to run the report.
While compiling the report we are getting the error : com.google.zxing.client.j2se.MatrixToImageWriter cannot be resolved to a type
Details :
net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:
1. com.google.zxing.client.j2se.MatrixToImageWriter cannot be resolved to a type
value = com.google.zxing.client.j2se.MatrixToImageWriter.toBufferedImage( //$JR_EXPR_ID=38$
<---------------------------------------------->
2. com.google.zxing.client.j2se.MatrixToImageWriter cannot be resolved to a type
value = com.google.zxing.client.j2se.MatrixToImageWriter.toBufferedImage( //$JR_EXPR_ID=38$
<---------------------------------------------->
3. com.google.zxing.client.j2se.MatrixToImageWriter cannot be resolved to a type
value = com.google.zxing.client.j2se.MatrixToImageWriter.toBufferedImage( //$JR_EXPR_ID=38$
<---------------------------------------------->
3 errors
.
at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:229)
at net.sf.jasperreports.eclipse.builder.JasperReportCompiler.compileReport(JasperReportCompiler.java:289)
at net.sf.jasperreports.eclipse.builder.JasperReportCompiler.compileReport(JasperReportCompiler.java:141)
at net.sf.jasperreports.eclipse.builder.JasperReportsBuilder.compileJRXML(JasperReportsBuilder.java:212)
at com.jaspersoft.studio.editor.action.CompileAction.actionCompile(CompileAction.java:154)
at com.jaspersoft.studio.editor.action.CompileAction$1.run(CompileAction.java:98)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
We have setup the Java Build Path and added Core and JavaSE jars but the report doesn't compile.
The QR code is inserted in the report using the following expression :
com.google.zxing.client.j2se.MatrixToImageWriter.toBufferedImage(
new com.google.zxing.qrcode.QRCodeWriter().encode(
$F{QRCODE},
com.google.zxing.BarcodeFormat.QR_CODE, 400, 400
)
)
Does anyone know how to solve that please ?
Thanks.
Regards,
[To the person who is closing the question, the question is not about "something cannot be resolved to a type". The question is very specific. And of course I checked the links provided. It just has nothing to do with the question. Every missing type involves specific classes to be added. So sending me a link about : JasperReport org.w3c.tools.codec.Base64Decoder cannot be resolved to a type is just useless. Thank you in advance for your non contribution. You can let other people answer if they are willing to. The most similar question in SO is rather this one. But no answer could be provided]

How to create a QR Code in JasperSoft Studio?

I'm trying to create a QR code in JasperSoft Studio.
We have a report properly working on production containing a QR code. But after a new installation of JasperSoft Studio, we are unable to run the report.
While compiling the report we are getting the error : com.google.zxing.client.j2se.MatrixToImageWriter cannot be resolved to a type
Details :
net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:
1. com.google.zxing.client.j2se.MatrixToImageWriter cannot be resolved to a type
value = com.google.zxing.client.j2se.MatrixToImageWriter.toBufferedImage( //$JR_EXPR_ID=38$
<---------------------------------------------->
2. com.google.zxing.client.j2se.MatrixToImageWriter cannot be resolved to a type
value = com.google.zxing.client.j2se.MatrixToImageWriter.toBufferedImage( //$JR_EXPR_ID=38$
<---------------------------------------------->
3. com.google.zxing.client.j2se.MatrixToImageWriter cannot be resolved to a type
value = com.google.zxing.client.j2se.MatrixToImageWriter.toBufferedImage( //$JR_EXPR_ID=38$
<---------------------------------------------->
3 errors
.
at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:229)
at net.sf.jasperreports.eclipse.builder.JasperReportCompiler.compileReport(JasperReportCompiler.java:289)
at net.sf.jasperreports.eclipse.builder.JasperReportCompiler.compileReport(JasperReportCompiler.java:141)
at net.sf.jasperreports.eclipse.builder.JasperReportsBuilder.compileJRXML(JasperReportsBuilder.java:212)
at com.jaspersoft.studio.editor.action.CompileAction.actionCompile(CompileAction.java:154)
at com.jaspersoft.studio.editor.action.CompileAction$1.run(CompileAction.java:98)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
We have setup the Java Build Path and added Core and JavaSE jars but the report doesn't compile.
The QR code is inserted in the report using the following expression :
com.google.zxing.client.j2se.MatrixToImageWriter.toBufferedImage(
new com.google.zxing.qrcode.QRCodeWriter().encode(
$F{QRCODE},
com.google.zxing.BarcodeFormat.QR_CODE, 400, 400
)
)
Does anyone know how to solve that please ?
Thanks.
Regards,
[To the person who is closing the question, the question is not about "something cannot be resolved to a type". The question is very specific. And of course I checked the links provided. It just has nothing to do with the question. Every missing type involves specific classes to be added. So sending me a link about : JasperReport org.w3c.tools.codec.Base64Decoder cannot be resolved to a type is just useless. Thank you in advance for your non contribution. You can let other people answer if they are willing to. The most similar question in SO is rather this one. But no answer could be provided]

How to hide while fields are empty in i-report

I wanted to hide text fields in jasper i-report when they are empty.
So I put this expression in those field's Print When Expression
$F{field_cashPaymentReceiptMode} != null && !"".equals($F{field_cashPaymentReceiptMode})
But then I got an error while compiling the report.
net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:
1. The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files
value = ((java.lang.String)field_cashPaymentReceiptMode.getValue())!=null &&!"".equals(((java.lang.String)field_cashPaymentReceiptMode.getValue())); //$JR_EXPR_ID=33$
<-------------------------------------------------------------------->
1 errors
Please help me.
Eliminate the Print When Expression altogether.
Check Blank When NULL.
Optionally, check Remove Line When Blank (only use this if you want the field to disappear completely, rather than retain its space on the page but have no content).
Try changing the order:
... && !$F{field_cashPaymentReceiptMode}.equals("")
If that doesn't help:
This could also depend on your JDK (1.7 / 1.8) version as seen in this question. When using 1.8, try downgrading to 1.7 if possible. This happens because of new default methods in interfaces in 1.8.

Why do I get current expression is not valid using JRDataSource?

I am trying to use List into the jasper report using JasperSoft Studio, but while defining dataset the JRDataSource expression is showing as invalid even after casting REPORT_DATA_SOURCE to the JRXmlDataSource(find image below).
Expression
((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("/Header/FileName")
Error
The current expression is not valid. Please verify it!
The error is looking so weird and I am not able understand it what is wrong here.
Do not worry about it, this is a bug in the IDE.
If you can't close the expression editor, edit the expression manually in the xml view.

Compile obfuscated error

when I 'm compiling my project in B4A using the obfuscated option, I get the below error:
Compiling generated Java code. Error
B4A line: 6
Dim ActivityResponse As String: ActivityResponse=\
javac 1.6.0_26
src\adamioan\cinemattica\com\actmovie.java:1192: array dimension missing
_vvvvv3 = BA.__b (new byte[] }, 680010);
^
1 error
This error occures only with the obfuscated option; debug and simple compilation work great.
Why is this happening?
Seems like a bug in the obfuscation feature related to empty strings. It will be fixed for the next update. Note that there is no need to assign empty strings as this is the default value. So for now just remove the assignment.
Thank you both, it was my mistake. In the Process Globals I declared the variable ActivityResponse and in the same line I set this to "".
Dim ActivityResponse as String: ActivityResponse = ""
That was the problem. Thanks again.