JasperReports: report parameter as an argument for message bundle lookup - jasper-reports

How to look up a particular internationalized property based on a report parameter?
This works, but is static:
$R{some_literal_string}
This works too, but is not internationalized:
$P{key_to_parameters_map_element}
What I need is:
$R{$P{key_to_parameters_map_element}}
Unfortunately, I get a pile of error messages:
Caused by: net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:
1. Syntax error on token "}", delete this token
value = str("$P{key_to_parameters_map_element")}; //$JR_EXPR_ID=13$
This doesn't change anything:
$R{$P{key_to_parameters_map_element}.toString()}
Is this possible at all?

It's
str($P{key_to_parameters_map_element})
Quite intuitive, isn't it?

Related

How to correct use $X in jasper??. Problem with parameters and IN clause in JSS

I have a report made with Jaspersoft Studio and in the dataset query I need to use an IN clause, for that I am using the expression "$X{IN ..."
Question # 1: What is the correct type to use for the parameter?
I'm using the following format:
Question # 2: How do I test in the preview?
Parameters screen:
To help, follow the excerpt of where with the parameter being used:
"...Where (($X{IN, db.empresa, paramIdEmpresa}) OR $ P!{ParamIdEmpresa} IS NULL) and (db_view ... "
Error that appears in the preview with the above parameters:
net.sf.jasperreports.engine.JRException: Error executing SQL statement
for: unit1. at com.jaspersoft.studio.editor.preview.view.control.ReportController.fillReport
(ReportController.java:551) at com.jaspersoft.studio.editor.preview.view.control.ReportController.access
(BaseFillHandle.java:135) at java.lang.Thread.run (Thread.java:748)
Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at
or near "["   Position: 199 at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse
(QueryExecutorImpl.java:2440) at
org.postgresql.core.v3.QueryExecutorImpl.processResults
the problem was in the query and not in jasper...
the correct query is:
where
(($X{IN,db.idempresa, paramIdEmpresa}) OR db.idempresa IS NULL )
thanks to GP...
The best possible way to solve it is simple:
create a parameter called $P!{paramWhere}. of your application
pass the complete where clause with this parameter, e.g. "id = 200"
In your query inside jasper, you put it like this: "... select * from <anywhere> where $P!{paramWhere} ..." and it will magically work.

Error message from filter array

So I have tried to get the error message from a filter array in a logic app workflow, this is what i have tried:
#body('Filter_array')['error']
#actions('Filter_array')['outputs']['body']['error']
Am I missing something or doing something wrong here?
Thanks.
UPDATE:
It says: "cannot be evaluated because property 'error' cannot be selected. ".
But i can clearly see the "error" in the body object in the output.
Ok so i managed to figure it out, i missed the fact that the array doesnt give me a single object as i thought i set it up to. so the solution was this:
#string(actions('Filter_array')['outputs']['body'][0]['error'])
Thanks for the help! :)
Can you try with #actions('Filter_array')['error'] ?
You have to distinguish 2 types of errors.
First error can occur during execution of your connector. Eg. The filter did not match. In this case, the connector executed and returns an output with an error-message.
Second error is a runtime error that can occur on the connector. For example if the input of your connector is invalid and the executing of the connector can't be triggered. In this case, the connector does not generate an output or result. In that case, you have to catch the exception with #actions('Filter_array')['error']

Talend component tPivotToColumnsDelimited generates error "The method parseObject(String) is undefined for the type Object"

I am using the component tPivotToColumnsDelimited in Talend 6.1.1. When I try to run the job I get the error message "The method parseObject(String) is undefined for the type Object".
In code view I can see the error relates to this line of Talend-generated code:
sumtPivotToColumnsDelimited_1 = Object.parseObject(row3.Amount + "")
As you can see from the process flow above, the data comes from an SQL query. The schema flowing into the tPivotToColumnsDelimited looks like this:
The tPivotToColumnsDelimited component settings look like this:
Any suggestion how to fix it?
Its clear that Talend cannot parse an Object typed variable, You need to change the type of column Ammount to other type like int, float.

JasperReports: java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Date

I try to use a report on my JasperServer, which I created with the help of iReport. In iReport my report works fine and there are no errors. But when I tried to deploy the report it gives me following error in short:
java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Date
and the complete Error:
The server has encountered an error. Please excuse the inconvenience.
Error Message
java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Date
Error Trace
java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Date
at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.setDate(JRJdbcQueryExecuter.java:649)
at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.setStatementParameter(JRJdbcQueryExecuter.java:577)
at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.setStatementParameter(JRJdbcQueryExecuter.java:399)
at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter$1.visit(JRJdbcQueryExecuter.java:332)
at net.sf.jasperreports.engine.query.JRAbstractQueryExecuter$QueryParameter.accept(JRAbstractQueryExecuter.java:157)
at net.sf.jasperreports.engine.query.JRAbstractQueryExecuter.visitQueryParameters(JRAbstractQueryExecuter.java:646)
at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.createStatement(JRJdbcQueryExecuter.java:317)
at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.createDatasource(JRJdbcQueryExecuter.java:196)
at com.jaspersoft.jasperserver.api.engine.jasperreports.util.JRTimezoneJdbcQueryExecuter.createDatasource(JRTimezoneJdbcQueryExecuter.java:168)
at net.sf.jasperreports.engine.fill.JRFillDataset.createQueryDatasource(JRFillDataset.java:1087)
at net.sf.jasperreports.engine.fill.JRFillDataset.initDatasource(JRFillDataset.java:668)
at net.sf.jasperreports.engine.fill.JRBaseFiller.setParameters(JRBaseFiller.java:1258)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:877)
at net.sf.jasperreports.engine.fill.BaseFillHandle$ReportFiller.run(BaseFillHandle.java:120)
at com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl$SynchronousExecutor.execute(EngineServiceImpl.java:875)
at net.sf.jasperreports.engine.fill.BaseFillHandle.startFill(BaseFillHandle.java:165)
at com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl$AsynchronousReportFiller.fillReport(EngineServiceImpl.java:831)
at com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl.fillReport(EngineServiceImpl.java:1658)
at com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl$ReportFill.runReport(EngineServiceImpl.java:1022)
at com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl$ReportRunnable.run(EngineServiceImpl.java:897)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
I uploaded the report, got the right data source (I tested it with another report already) and imported my Resources (Subreports) and input controls. I don't know whether I missed a step or so, but I am pretty sure that I did everything required. Importing every Subreport, setting input controls declare the right path repo:mySubreports.jrxml. If you need more information please tell me ! I think I added all information required and I don't want to spam SO with useless information because I don't know which information could be useful by now as well :)
I think this has something to do with date parameters/variables in your report.
Please ensure the input control you made for the date parameters in Jasperserver are java.util.date
Also one common error i have seen myself repeating is putting a default value expresion like an empty string may be ("") for the date parameters/variables where they are declared .In this case i have seen the report works in ireport also gets upload in the server without any error but it would throw
java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Date Error Trace
Please check the above two points with all the date parameters of your report and update here if that works
Thanks
chandra

JasperReports Server: Input Controls error

My question relates to an error when generating a report.
In JasperReports Server created a Single Input Control Value but when you try to generate a report I get the error:
The server has encountered an error. Please excuse the inconvenience.
Error Message
net.sf.jasperreports.engine.JRRuntimeException: Invalid type java.lang.String for parameter SelectAsset used in an IN clause; the value must be an array or a collection.
In the preview iReport everything works flawlessly. I will put the value and generates a report.
if you mean a single value by "Single Input Control Value" it should not be a collection. So
Change your SelectAsset parameter type from java.util.Collection to java.lang.String
Then redeploy your report to the server then try again.