Despicable
Despicable

Reputation: 3957

primefaces calender: how to set dynamically mindate

I have two primefaces calender controls.I want that when I select a date from the first calender then next calender mindate should be start from 1st calender's selected date.For instance, I have selected 7/5/2013 then next calender should disable all dates before 8/5/2013
This is what I have tried so far but it is not working

   <p:calendar id="fromD" value="#{requestController.from}" yearRange="2013:2015" pattern="dd/MM/yyyy" mindate="#{requestController.today}"/>

<p:calendar id="toD" value="#{requestController.to}" yearRange="2013:2015" pattern="dd/MM/yyyy" mindate="#{requestController.from}"/>

Any suggestions?

Upvotes: 3

Views: 9741

Answers (2)

w35l3y
w35l3y

Reputation: 8783

I would recommend you to do the following:

<p:ajax event="dateSelect" update="toD" global="false" />
<p:ajax event="change" update="toD" global="false" />

It will reset the mindate on both events.

Upvotes: 0

Freak
Freak

Reputation: 6883

From change event , you can't submit the value of date.You need to change the event to dateSelect
Just do

<p:ajax event="dateSelect" update="toD"/>

It will reset the mindate for your next calender/component

Upvotes: 7

Related Questions