Richfaces Calendar Minimum and Maximum Dates

DaTroop picture DaTroop · Dec 16, 2009 · Viewed 13.3k times · Source

My problem is making the RichFaces calendar restricting the dates to be allowed to be chosen by the user.

Let's say I want to allow only the dates of this month and the dates of the next month to be chosen by the user.

I used the preloadDateRangeStart and preloadDateRangeEnd attributes but they did nothing.

I created my own CalendarDataModel which uses the preloadDateRangeStart and preloadDateRangeEnd and enables the items but the calendar on the screen allows only the dates of the current month to be selected. Note that the preloadDateRangeStart is today's date and preloadDateRangeEnd is today's date plus 2 months.

I am missing something here for sure. Can someone help me please?

Answer

Bozho picture Bozho · Dec 16, 2009

Use the isDayEnabled="isDayEnabled" attribute, where the value (isDayEnabled) is a javascript function you should define, in the form

function isDayEnabled(day) {
}

See the richfaces demo for more details.

If you want to add validation on the server side, use a custom JSF Validator, or use Hibernate Validator annotations (see richfaces - bean validator)