为什么在 JasperServer 6.0.1 上出现调度程序无效日期错误?
Why do I get scheduler Invalid Date error on JasperServer 6.0.1?
我正在将 jasperserver 从 3.7 迁移到 jasperserver 6.0.1,现在在新的 jasperserver 中我希望日期格式为 dd/mm/yyyy 但默认情况下日期格式为 yyyy-mm-dd。
为此,我在
处更改了 jasperserver_config.properties 文件
apache-tomcat-7.0.65\webapps\jasperserver\WEB-INF\bundles\jasperserver_config.properties
我改成了
# Used for parsing and formatting dates by server
date.format=dd/MM/yyyy
datetime.format=dd/MM/yyyy HH:mm:ss
time.format=HH:mm:ss
# Used for parsing and formatting dates by calendar component (UI).
# Pattern for date should match appropriated pattern from server properties.
# The format for calendar component can be combinations of the following:
# d - day of month (no leading zero)
# dd - day of month (two digit)
# o - day of year (no leading zeros)
# oo - day of year (three digit)
# D - day name short
# DD - day name long
# m - month of year (no leading zero)
# mm - month of year (two digit)
# M - month name short
# MM - month name long
# y - year (two digit)
# yy - year (four digit)
calendar.date.format=dd/mm/yyyy
calendar.datetime.format=dd/mm/yyyy HH:mm:ss
calendar.time.format=HH:mm:ss
它更改了日期格式,但是当我要安排任何报告时,日期字段显示为无效日期(见下文)。有人可以帮助我更改在整个 jasperserver
上正常工作的日期格式吗
JasperReports Server 6.10 版之前存在一个错误,请参阅 bug report。我当时不得不使用解决方案#2。
解决方案#1
如果可能,更新到版本 6.10。
解决方案#2
此解决方案有点冗长,但如果两个步骤(更改源、生成优化的 js 文件)都完成,则可以正常工作:
您必须编辑 js 文件才能正常工作。使用您需要的模式。
in file /opt/jasperreports-server-cp-5.5.0a/apache-tomcat/webapps/jasperserver/scripts/scheduler/model/job.js
you have to change this:
row 5
from:
var UI_DATE_PATTERN = "YYYY-MM-DD HH:mm";
to:
var UI_DATE_PATTERN = "DD.MM.YYYY HH:mm";
row 766
from:
data.trigger.startDate = moment(data.trigger.startDate).format(SERVICE_DATE_PATTERN);
to:
data.trigger.startDate = moment(data.trigger.startDate,UI_DATE_PATTERN).format(SERVICE_DATE_PATTERN);
优化Java脚本
注意: 由于优化了 Java 脚本文件(据我所知这不是编辑过的文件),请记住您可能需要重新创建优化的 js 文件 - 因为优化的文件是 JRS 使用的文件。第 5 版就是这种情况。6.x 至少:
- Create a working directory where you can copy JavaScript files and install and run the required scripts. In
this example, the directory is called Working.
- Create a subdirectory for a copy of the JavaScript files from JasperReports Server. This directory is called
jssources
.
Copy the following directories from the JasperReports Server directory, <js-webapp>
, to js-sources
:
• Copy <js-webapp>/scripts
to js-sources/scripts
.
• Copy <js-webapp>/fusion
to js-sources/fusion
(optional, Pro version only)
- Back up your
js-sources
directory.
- Create a
js-optimization-output
directory for the output of the optimization process.
- Download and install
node.js
from http://nodejs.org/. Place the nodejs
folder directly in your Working folder.
- Download
r.js
, a requirejs optimization file, from http://requirejs.org and place it directly in the Working folder.
- Make your changes to the JavaScript files in
Working/js-sources
.
Open a command line tool and run the commands to optimize the JavaScript. The following example is for Windows, it places the output in the Working/js-optimization-output folder:
% cd Working
% nodejs\node r.js -o js-sources\scripts\build.js appDir=js-sources\scripts baseUrl=. optimize=uglify2 dir=js-optimization-output
- Copy the optimized scripts from
js-optimization-output
to <webapp>/optimized-scripts
(where webapp is the location of your JRS)
- Reload the web app in the app server to see the changes.
注意:如果在执行所有这些操作后出现问题,请记住清除浏览器缓存。
我正在将 jasperserver 从 3.7 迁移到 jasperserver 6.0.1,现在在新的 jasperserver 中我希望日期格式为 dd/mm/yyyy 但默认情况下日期格式为 yyyy-mm-dd。 为此,我在
处更改了 jasperserver_config.properties 文件apache-tomcat-7.0.65\webapps\jasperserver\WEB-INF\bundles\jasperserver_config.properties
我改成了
# Used for parsing and formatting dates by server
date.format=dd/MM/yyyy
datetime.format=dd/MM/yyyy HH:mm:ss
time.format=HH:mm:ss
# Used for parsing and formatting dates by calendar component (UI).
# Pattern for date should match appropriated pattern from server properties.
# The format for calendar component can be combinations of the following:
# d - day of month (no leading zero)
# dd - day of month (two digit)
# o - day of year (no leading zeros)
# oo - day of year (three digit)
# D - day name short
# DD - day name long
# m - month of year (no leading zero)
# mm - month of year (two digit)
# M - month name short
# MM - month name long
# y - year (two digit)
# yy - year (four digit)
calendar.date.format=dd/mm/yyyy
calendar.datetime.format=dd/mm/yyyy HH:mm:ss
calendar.time.format=HH:mm:ss
它更改了日期格式,但是当我要安排任何报告时,日期字段显示为无效日期(见下文)。有人可以帮助我更改在整个 jasperserver
上正常工作的日期格式吗JasperReports Server 6.10 版之前存在一个错误,请参阅 bug report。我当时不得不使用解决方案#2。
解决方案#1
如果可能,更新到版本 6.10。
解决方案#2
此解决方案有点冗长,但如果两个步骤(更改源、生成优化的 js 文件)都完成,则可以正常工作:
您必须编辑 js 文件才能正常工作。使用您需要的模式。
in file
/opt/jasperreports-server-cp-5.5.0a/apache-tomcat/webapps/jasperserver/scripts/scheduler/model/job.js
you have to change this:row 5
from:
var UI_DATE_PATTERN = "YYYY-MM-DD HH:mm";
to:
var UI_DATE_PATTERN = "DD.MM.YYYY HH:mm";
row 766
from:
data.trigger.startDate = moment(data.trigger.startDate).format(SERVICE_DATE_PATTERN);
to:
data.trigger.startDate = moment(data.trigger.startDate,UI_DATE_PATTERN).format(SERVICE_DATE_PATTERN);
优化Java脚本
注意: 由于优化了 Java 脚本文件(据我所知这不是编辑过的文件),请记住您可能需要重新创建优化的 js 文件 - 因为优化的文件是 JRS 使用的文件。第 5 版就是这种情况。6.x 至少:
- Create a working directory where you can copy JavaScript files and install and run the required scripts. In this example, the directory is called Working.
- Create a subdirectory for a copy of the JavaScript files from JasperReports Server. This directory is called
jssources
.Copy the following directories from the JasperReports Server directory,
<js-webapp>
, tojs-sources
:• Copy
<js-webapp>/scripts
tojs-sources/scripts
.• Copy
<js-webapp>/fusion
tojs-sources/fusion
(optional, Pro version only)- Back up your
js-sources
directory.- Create a
js-optimization-output
directory for the output of the optimization process.- Download and install
node.js
from http://nodejs.org/. Place thenodejs
folder directly in your Working folder.- Download
r.js
, a requirejs optimization file, from http://requirejs.org and place it directly in the Working folder.- Make your changes to the JavaScript files in
Working/js-sources
.Open a command line tool and run the commands to optimize the JavaScript. The following example is for Windows, it places the output in the Working/js-optimization-output folder:
% cd Working
% nodejs\node r.js -o js-sources\scripts\build.js appDir=js-sources\scripts baseUrl=. optimize=uglify2 dir=js-optimization-output
- Copy the optimized scripts from
js-optimization-output
to<webapp>/optimized-scripts
(where webapp is the location of your JRS)- Reload the web app in the app server to see the changes.
注意:如果在执行所有这些操作后出现问题,请记住清除浏览器缓存。