Edit seconds with RichFaces rich:calendar

Unfortunatelly, RichFaces calendar component doesn’t support editing of seconds in the rich:calendar popup. You can only change hours and minutes, although you specify ss in the date pattern, like in this snippet:

<rich:calendar value="#{bean.datetime}"
    datePattern="yyyy-MM-dd HH:mm:ss" 
    defaultTime="00:00:00" 
    showApplyButton="true"/>

After setting new date and time in the popup, you will get a datetime with ss string instead of default seconds, e.g. 2010-06-01 12:35:ss

To overcome this limitation you must enable the manual field edit mode of the component. Date and hour/minute part of time can still be is edited in the pop-up. Seconds will be adjusted manually. ss will be replaced with JavaScript:

<rich:calendar value="#{bean.datetime}"
    datePattern="yyyy-MM-dd HH:mm:ss" 
    defaultTime="00:00:00" 
    showApplyButton="true"
    enableManualInput="true" 
    onchanged="this.value = this.value.replace('ss', '00')" />
Advertisements

2 thoughts on “Edit seconds with RichFaces rich:calendar

Comments are closed.