O'Reilly logo

PrimeFaces Beginner's Guide by K. Siva Prasad Reddy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – using Calendar with a date range

Let us see how we can use the mindate and maxdate values from backing beans.

  1. Create a Calendar component with a date selection range using the mindate and maxdate 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"
          />
  2. Implement the getMinDate() and getMaxDate() 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required