primefaces 日历时间选择器中的错误? [英] bug in primefaces calendar timepicker?

查看:32
本文介绍了primefaces 日历时间选择器中的错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的页面上有这个带有时间选择器的日历:

I have this calendar with time picker on my page:

 <p:calendar value="#{addTaskBacking.currentTask.deadline}" mode="inline" 
  pattern="dd-MM-yyyy HH:mm" mindate="01-09-2013 00:00"/>

当我设置模式时:dd-MM-yyyy 没有正确添加所有内容,但是当我更改为:dd-MM-yyyy HH:mm 时出现此错误:

When I set the pattern: dd-MM-yyyy without the time everything is added correctly, but when I change to: dd-MM-yyyy HH:mm I get this error:

j_idt10:j_idt12: '9-04-2014' 无法理解为日期和时间.

j_idt10:j_idt12: '9-04-2014' could not be understood as a date and time.

这是我设置内联模式的时候,我设置弹窗的时候就ok了.

This is when I set the inline mode, when I set the popup is all ok.

我有 primefaces_v4.jar.我检查这边 http://forum.primefaces.org/viewtopic.php?f=3&t=22982 但我找不到任何解决方案

I have primefaces_v4.jar. I check this side http://forum.primefaces.org/viewtopic.php?f=3&t=22982 but i can't find any solution

看起来所有依赖于 p:calendarmode 属性.如果我有默认的 popup 模式一切都很好(例如 http://primefaces.org/showcase/ui/calendarTime.jsf.但是当我更改为内联模式时,我收到此错误:cal:inlineCal: '13-04-2014' 无法理解为日期和时间.示例:13-04-2014 15:16

It look like all depends of mode atribute of p:calendar. If i have default popup mode everything it's fine (like in example on http://primefaces.org/showcase/ui/calendarTime.jsf. But when I change to inline mode i get this error: cal:inlineCal: '13-04-2014' could not be understood as a date and time. Example: 13-04-2014 15:16

推荐答案

PrimeFaces 默认使用 SimpleDateFormat,除非您覆盖格式化程序.http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html

PrimeFaces uses SimpleDateFormat by default unless you override the formatter. http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html

编辑如果您将 mindate 属性更改为与您的模式相同,您的模式将起作用.IE:当你有一个 mindate="01/09/2013" 时,你不能有一个模式 dd-MM-yyyy HH:mm改变你的想法到 - 01-09-2013

EDIT Your pattern will work if you change your mindate attribute to be the same as your pattern.. IE: You can't have a pattern dd-MM-yyyy HH:mm when you have a mindate="01/09/2013" Change your mindate to - 01-09-2013

编辑 2在调试了一些你是对的之后,在 POST 中将 inputValue 字段发送到服务器之前,在 javascript 中设置 inputValue 字段时似乎存在错误,甚至可以使用模式转换器......

EDIT 2 AFter debugging a fair bit you're right, there seems to be a bug when setting the inputValue field in javascript prior to being sent in the POST to the server to even use the pattern converters...

我通过以下更改重新编译了代码:calendar.js 中的第 129 行(合并到 primefaces.js) var newDate = this.value;

I got it all working recompiling the code with the following changes: Line 129 in calendar.js (gets merged into primefaces.js) var newDate = this.value;

基本上目前它尝试在输入上执行 formatDate,这很好,因为它的日期格式拆分相同,即 dd/mm/yy 等.但它完全跳过了附加的时间"不能使用 parseDatetime因为它完成了整个对象时间,这应该在您刚刚构建对象时在 java 端进行.

Basically at the moment it tries to do a formatDate on the input which is fine cause its the same date format split ie, dd/mm/yy etc.. but it totally skips 'time' being attached can't use parseDatetime as it does an entire object time, which should be don eon the java side as you just build the object.

this.value 是您想要的,无论是否在帖子中发回,这就是它为 _self.cfg.popup 所做的(它甚至没有设置输入 val,因为它已经存在!...我会提出一个关于 PF 的问题

this.value is what you want regardless to be sent back in the post which is what it does for _self.cfg.popup (it doesn't even set the input val because its already there!... I'll raise an issue with PF

PrimeFaces 问题跟踪器"

这篇关于primefaces 日历时间选择器中的错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆