bug in primefaces calendar timepicker?

試著忘記壹切 提交于 2019-12-02 14:56:04

问题


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"/>

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' could not be understood as a date and time.

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

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

Edit: 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


回答1:


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

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

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...

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;

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 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

"Raised Issue 6790 on the PrimeFaces Issue Tracker"



来源:https://stackoverflow.com/questions/23036356/bug-in-primefaces-calendar-timepicker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!