Tuesday, January 15, 2013

Disable holidays in af:inputDate

How to Disable holidays in af:inputDate?



Case: Need to disable all holidays from user selection. In our case, we have of list business declared holidays for the year were stored in a table as given below. When business user choosing the future dates, the holidays were from selection.


This can be achieved multiple ways, here is an approach to disable days from af:inputDate input component.

Step 1: Create a EO and VO object for HOLIDAYS table as given below.

Step 2: Generate Application Module Class for your application.

Step 3: Create a custom method (Example: getHolidays) in your application module class. Below custom method return list of holidays from HOLIDAYS table.


Step 4: Expose the above method as client interface.



 Step 5As shown below In your page add this getHolidays as Binding.




 Step 6: Create a backing bean to implement DateListProvider to provide getDateList for list of disable days.
             You need to import org.apache.myfaces.trinidad.model.DateListProvider;

-



 Step 7: In your af:inputDate component, you should call the backing bean for list of disable days. You can call this backing bean; By setting the value for DisabledDays under Data section as given below. 


By following the above 7 steps you can disable your desired list of days from user selection. 

Hope these above steps are helpful to you. Let me know if you need any more inputs.

Thank you.