Weird behaviour of Calendar (mindate maxdate)

UI Components for JSF
Post Reply
JohnPace
Posts: 2
Joined: 10 Jun 2021, 11:21

10 Jun 2021, 12:01

Hi,

I had to update the dependencies of a rather old project. After update and test everything, we shipped the war-file to our customer, which found some very strange behaviour.

The Calendar from
https://www.primefaces.org/showcase/ui/ ... ndar.xhtml
now has sometimes problems, if mindate or maxdate are set as string. It fails for some dates.

Normally I set mindate and maxdate by the bean.

For example this date works:

Code: Select all

<p:calendar id="cal" mode="inline"
	value="#{data.selectedDate}"
	pattern="dd.MM.yyyy" locale="de"
	mindate="03.06.2021"
	maxdate="09.06.2021">
	<p:ajax event="dateSelect" listener="#{controller.dateSelectListener}" update="controlButtons"/>
</p:calendar>
While this date does not work, I receive the error "Calendar : "cal" minimum date must be less than maximum date.":

Code: Select all

<p:calendar id="cal" mode="inline"
	value="#{data.selectedDate}"
	pattern="dd.MM.yyyy" locale="de"
	mindate="27.05.2021"
	maxdate="10.06.2021">
	<p:ajax event="dateSelect" listener="#{controller.dateSelectListener}" update="controlButtons"/>
</p:calendar>
The program has previously used Primefaces 4.0.13 and didn't had this problem before.

After updating to Primefaces 10, with MyFaces 2.3.9 running on Tomcat 9.4.41 the above problem appears. Since my problem is very urgent, I had to find a solution.

If I use java.util.Date instead of String everything works for all dates again.

I also found some related strange things in the showcase:
https://www.primefaces.org/showcase/ui/ ... ndar.xhtml

Code: Select all

<p:outputLabel for="restricted" value="Restricted:"/>
<p:calendar id="restricted" value="#{calendarView.date6}" mindate="4/1/14" maxdate="7/1/14"/>
"14" is obvious 2014, but this is not used in the showcase. The restriction seems to use some date in 2021.

Melloware
Posts: 3717
Joined: 22 Apr 2013, 15:48

11 Jun 2021, 13:15

You are right if you look at the version 8 of the calenda it works. but V10 has an issue.

Here is V8 calendar: https://www.primefaces.org/showcase-v8/ ... ndar.xhtml

Must be a bug in v10 if you want to report it on GitHub Issues.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

Melloware
Posts: 3717
Joined: 22 Apr 2013, 15:48

11 Jun 2021, 13:19

Also Calendar is no longer recommended DatePicker is the newer more modern calendar in V10: https://www.primefaces.org/showcase/ui/ ... cker.xhtml
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

Melloware
Posts: 3717
Joined: 22 Apr 2013, 15:48

11 Jun 2021, 13:38

OK its a formatting issue. It works if you pass the dates and let them be converted.

Code: Select all

<p:calendar id="restricted" value="#{calendarView.date6}" mindate="#{calendarView.minDate}" maxdate="#{calendarView.maxDate}"/>
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

JohnPace
Posts: 2
Joined: 10 Jun 2021, 11:21

12 Jul 2021, 19:17


Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 49 guests