Reputation: 10595
I am using the following XML to get a Birthdate calendar:
<p:calendar pattern="MM-dd-yyyy" value="#{registration.birthDate}"
navigator="true" required="true" label="Birth Date"
id="birthDateCal" yearRange="c-100:c-17" />
The calendar is having some problems though. Seems like the year will change in a funny way when I open the calendar:
Anyone ever seen this?
Upvotes: 2
Views: 3556
Reputation: 10463
Well it seems this is already a bug listed in Primefaces.
http://code.google.com/p/primefaces/issues/detail?id=2737
It was marked as Won't Fix with the reasoning that it is an underlying bug with the jQuery UI calendar component and has nothing to do with Primefaces.
The following discussion here discusses this issue on the jQuery side in greater detail.
http://forum.jquery.com/topic/datepicker-yearrange-bug
Essentially the yearRange attributes don't work as one would assume. It will set the year range NOT on todays date but the currently selected date as of the rendering of the calendar component.
EDIT:
One possible way to work around this would be to write an algorithm that determines a dynamic yearRange from a managed bean method, and base it on the difference between todays date and the birthdate. You can set yearRange="#{managedBean.dynamicYearRange()}"
to call it dynamically.
Upvotes: 2