[#13676] - Datetimevalidator uses wrong Format

Category:
Bug report
Priority:
Urgent
Status:
New
Project: Severity:
Critical
Resolution:
Open
Component: Reproducibility:
Always
Assigned to:
0

I upgraded form v7.2 to v7.8.

All Reports with java.sql.timestamp in parameters stopped working

The server uses german local and displays all values as configured in jasperserver/WEB-INF/bundles/jasperserver_config_de.properties

After changing the value of timestamp parameter there is an invalid value error message and all depending input controls lose there values.

I found out that the expression for validating the paramter is wrong:

ateTimeFormatValidationRule: {errorMessage: "Geben Sie einen gültigen Datums-/Uhrzeitwert an.", format: "yyyy-MM-dd'T'HH:mm:ss"}
errorMessage: "Geben Sie einen gültigen Datums-/Uhrzeitwert an."
format: "yyyy-MM-dd'T'HH:mm:ss"

After that i did some research in source code and found out that these values are hardcodes in file:
package com.jaspersoft.jasperserver.inputcontrols.util;

import com.jaspersoft.jasperserver.inputcontrols.util.DefaultCalendarFormatProvider;

/**
* <p></p>
*
* @author yaroslav.kovalchyk
* @version $Id$
*/
public class IsoCalendarFormatProvider extends DefaultCalendarFormatProvider {
@Override
protected String getDatetimeFormatPattern() {
return "yyyy-MM-dd'T'HH:mm:ss";
}

@Override
protected String getTimeFormatPattern() {
return "HH:mm:ss";
}

@Override
protected String getDateFormatPattern() {
return "yyyy-MM-dd";
}
}

So there is no chance for the validator to check if the value looks like configured.

v7.8
Input Controls
christian.philipp's picture
Joined: Apr 15 2014 - 7:43am
Last seen: 1 day 14 hours ago

9 Comments:

#1

Have you installed sample data? Can you provide step to reproduce this issue? However, I know com.jaspersoft.jasperserver.inputcontrols.util.DefaultCalendarFormatProvider supports locale. Btw, if you want, you can change isoCalendarFormatProvider bean to point to other class in applicationContext.xml.

#2

And there is also com.jaspersoft.jasperserver.inputcontrols.util.MessagesCalendarFormatProvider which uses the same interface, so you can configure bean to use it instead. And ISO calendar is supposed to be a fixed format. Thanks.

#3

No i have not installed sample data. I had a look at the sample reports but they have no parameters and are very simple.

I have downloaded the current configuration from our old Jasperserver version 7.2 and imported it to the new 7.8 version.

Setps the reproduce are very easy.

on jasperserver 7.2

create a datetime datatype

create a inputcontorl using this datatype

add a report which is using this datatype.

Export the configuration form jasperserver 7.2.

I installed jasperserver 7.8 with default options and without sample data.

Security.validation.sql.on=false

restart services

A report running on jasperserver 7.2 is now causing an errormessage for datetimeinput on first change of the paramter.
The report can be executed but all depended parameters have an error on first change of the datetimeparameter.

#4

could you please provide detailed information how to change the configurtion to get it working?
what should i change in which line of which file.

#5

I finally found a easy way to reproduce the error on a new bank system

1. I created a report called test with following content and published it to jasperserver 7.8:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.9.0.final using JasperReports Library version 6.9.0-cb8f9004be492ccc537180b49c026951f4220bf3 -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="test" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="d5594521-0fa8-49a9-acf3-785d578e3857">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<property name="ireport.jasperserver.url" value="http://192.168.0.60:8080/jasperserver/"/>
<property name="ireport.jasperserver.user" value="jasperadmin"/>
<property name="ireport.jasperserver.report.resource" value="/Reports/test_files/main_jrxml"/>
<property name="ireport.jasperserver.reportUnit" value="/Reports/test"/>
<parameter name="startdatetime" class="java.sql.Timestamp">
<parameterDescription><![CDATA[test]]></parameterDescription>
<defaultValueExpression><![CDATA[java.sql.Timestamp.valueOf(java.time.LocalDateTime.now().minusDays(10).withMinute(0).withHour(0).withSecond(0))]]></defaultValueExpression>
</parameter>
<parameter name="enddatetime" class="java.sql.Timestamp">
<parameterDescription><![CDATA[test]]></parameterDescription>
<defaultValueExpression><![CDATA[$P{startdatetime}]]></defaultValueExpression>
</parameter>
<parameter name="sadfg" class="java.lang.String"/>
<queryString>
<![CDATA[]]>
</queryString>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="83" splitType="Stretch">
<textField>
<reportElement x="50" y="30" width="100" height="30" uuid="18626603-af7d-4a47-98de-c6f28c2e0e7b"/>
<textFieldExpression><![CDATA[$P{startdatetime}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="210" y="20" width="100" height="30" uuid="0c5d4a61-fcfc-4cfc-9cfd-d63e0237a097"/>
<textFieldExpression><![CDATA[$P{enddatetime}]]></textFieldExpression>
</textField>
</band>
</title>
<pageHeader>
<band height="35" splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="61" splitType="Stretch"/>
</columnHeader>
<detail>
<band height="125" splitType="Stretch"/>
</detail>
<columnFooter>
<band height="45" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport>

2. i created a new parameter on server which uses the 2 parameters from the report in it sql and added it to the report without using it anywhere in the reportfile.

The query of the new parameter is:

select
comp_shop.id as shopid,
comp_shop.nr as shopnr,
crm_address.city as city
from
comp_shop
join crm_address on comp_shop.address_id=crm_address.id
join comp_shop_region as shopregion on shopregion.shop_id=comp_shop.id
join comp_region as region on shopregion.region_id=region.id and region.parent_region_id is not null
join comp_region as area on region.parent_region_id=area.id
where
$P{startdatetime}<ISNULL(comp_shop.close_date,'01.01.2100') and
$P{enddatetime}>comp_shop.open_date
order by
2

when i add the depending parameter the error is shown and when i remove it the error is gone.

#6

if you remove the following line, will it work?
$P{startdatetime}<ISNULL(comp_shop.close_date,'01.01.2100')

Is it because the day constant not in ISO format?

#7

enddatetime And startdatetime seems to be timestamp. Is comp_shop.open_date column also timestamp or just date?

#8

after removing the line error is still the same on enddatetime parameter.
startdatetime is now working because it is missing in the depended parameter
the constant is working on jaspserver 7.2 with german sql server version

#9

startdatetime and enddatetime are timestamp
open and close date are just date

Create Statement for comp_shop table:

create table comp_shop
(
id bigint NOT NULL,
nr int NOT NULL,
name varchar(255) NULL,
address_id bigint NOT NULL,
open_date DATE NULL,
close_date Date NULL,
manager_id bigint NULL,
company_id bigint NOT NULL,
rangeidentifier_invoicenumber int NULL,
PRIMARY KEY(id)
);

Feedback
randomness