Time for action – using Calendar with a date range
Let us see how we can use the mindate
and maxdate
values from backing beans.
- Create a Calendar component with a date selection range using the
mindate
andmaxdate
attributes:<p:calendar value="#{userController.registeredUser.dob}" pattern="dd-MM-yyyy" mindate="#{userController.dobMinDate}" maxdate="#{userController.dobMaxDate}" showButtonPanel="true" showWeek="true" showOtherMonths="true" selectOtherMonths="false" effect="slideDown" />
- Implement the
getMinDate()
andgetMaxDate()
methods to return minimum and maximum dates:@ManagedBean @RequestScoped public class UserController { public Date getDobMinDate() throws ParseException { return new SimpleDateFormat("dd-MM-yyyy").parse("01-06-2013"); } public Date getDobMaxDate() throws ParseException ...