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's advanced customization options

Let us see how we can customize the Calendar component to disable Saturday and Sunday dates and apply a custom style.

  1. Create the JavaScript function disableSatSundays() using the following code:
    function disableSatSunDays(date) 
    {
      var day = date.getDay();
      return [(day != 0 && day != 6), 'myCalendar'];
    }
    Create a new custom style myCalendar.
    <style type="text/css">
      .myCalendar
      {
        font-size: 15px;
        background-color: #D3D3D3;
      }
    </style>
  2. Create a Calendar component and configure the beforeShowDay attribute to invoke the disableSatSundays() callback function:
    <p:calendar value="#{userController.registeredUser.dob}" beforeShowDay="disableSatSunDays"/>

What just happened?

We have customized the ...

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