0

I am working on a calendar for PrimeFaces and I want to set the minDate as one day after today (which is tomorrow) without going into the backing bean. How do I do so on the minDate in PrimeFaces?

 <p:calendar id="tomorrowDate"
             value="#{calendarView.tomorrowsDate}"
             mindate="#{calendarView.applicationDate} + 1"/>

Help is much appreciated. Thank you.

  • Why? That mean uaers can tamper with it unless you add additional server side checks. And if the page is rendered, the minDate is already set. – Kukeltje Oct 08 '18 at 07:15
  • I have two calendars currently. One show today's date and user can select any date before the date. And another show's tomorrow's date, depending on the user's selection of today date. The minimum date for tomorrow should always be bigger than today. That is why I wanted to cater from the EL – Nik Mohamad Lokman Oct 08 '18 at 07:30
  • Sounds like a XY problem, not the reason why it should be done in EL. – Jasper de Vries Oct 08 '18 at 08:38
  • If it's done in the EL, the calendar will instantly block invalid dates. The invalid dates will be greyed out and unchooseable. – Nik Mohamad Lokman Oct 08 '18 at 09:28
  • Isn't that great? – Kukeltje Oct 08 '18 at 09:40
  • That is why I want to cater it from the EL – Nik Mohamad Lokman Oct 08 '18 at 09:51
  • If you create a bean method mindate="#{calendarView.tomorrowDateMinDate}" that returns users' previously selected date + 1 day it should also be reflected in tomorrowDate component UI. You can add a to the first calender that updates tomorrowDate calender on change, such that tomorrowDate always allows to only select a greater date. – Selaron Oct 10 '18 at 08:27
  • I did so @Selaron. I find no way to cater it from JSF. The only way I found is to set the minDate in the backingBean and later pass it to the JSF layer. Thank you very much by the way for the help ! – Nik Mohamad Lokman Dec 06 '18 at 08:23
  • You could create an EL function to do this. See https://stackoverflow.com/questions/7079978/how-to-create-a-custom-el-function-to-invoke-a-static-method – Jasper de Vries Jun 13 '19 at 06:59
  • Yes, I would say that is the longer workaround version. Thank you for @JasperdeVries ! – Nik Mohamad Lokman Jun 14 '19 at 02:34

1 Answers1

-1

Can't find a possible solution for this, need to specify minDate value in bean and fetch it from JSF.