Showing highlighted holiday calendar in af:inputDate date picker (ADF 12.1.3)

Sharing is Caring

Hello All
This post is about showing highlighted holiday in af:inputDate and user must not be able to select these dates
here I am using JDeveloper 12.1.3
According to this post, you can do this using af:calendar
https://blogs.oracle.com/adf/entry/display_holiday_name_in_af
but I have a requirement to show holidays while the user selects date using af:inputDate

So for this requirement first step is easy to do and there is lots of post about disabling specific days in the calendar of af:inputDate

Step 1. Disable specific days –

    • You can see there is property in af:inputDate for setting disabled days, this filed takes a value of type List supported by DateListProvider interface

 

    • For this purpose i have created a bean that implements methods of DateListProvider , in Overridden method i have defined a list that contains dates of holidays that i want to disable in af:inputDate

package holiday.view.bean;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import javax.faces.context.FacesContext;

import org.apache.myfaces.trinidad.model.DateListProvider;

public class HolidayBean implements DateListProvider {
    public HolidayBean() {
    }

    @Override
    public List<Date> getDateList(FacesContext facesContext, Calendar calendar, Date date, Date date2) {
List<java.util.Date> holiDay = new ArrayList();
holiDay.add(new Date("27-July-2014"));
holiDay.add(new Date("29-July-2014"));
holiDay.add(new Date("10-Aug-2014"));
holiDay.add(new Date("25-Dec-2014"));
holiDay.add(new Date("01-Jan-2015"));
holiDay.add(new Date("22-Oct-2014"));
holiDay.add(new Date("23-Oct-2014"));
holiDay.add(new Date("24-Oct-2014"));

        return holiDay;
        //return Collections.emptyList();
    }
}

 

    • Attached this bean to disabledDays property of af:inputDate

 

 

    • Now first part is done we can see all holidays as disabled in the calendar of af:inputDate

 

Step 2. Highlight disabled holidays –

    • But it is not easy to find holidays as all are in grey, so I have to highlight all disabled days, so for this requirement, create a skin in the viewController project and write this

af|chooseDate::regular-day:disabled{
    background-color: red;
    color: ButtonFace;
}

 

  • af:chooseDate is used because internally af:inputDate opens af:chooseDate as date picker so I have to change the property of af:chooseDate, now run your application

 

highlighted holiday

Cheers 🙂 Happy Learning

Related Posts

0 thoughts on “Showing highlighted holiday calendar in af:inputDate date picker (ADF 12.1.3)”

Leave a Reply

Your email address will not be published. Required fields are marked *