4

I would to disable the dates before the current date in <rich:calendar>. I already Googled about it, but none seems to work so far.

Any idea how to do this in a easy way ?

This is my code so far:

<rich:calendar id="since" popup="false" value="#{c.since}" datePattern="dd/MM/yyyy" firstWeekDay="1" showWeeksBar="false" showApplyButton="false" showFooter="false"  >
    <a4j:ajax event="change" execute="@this" render="_since"/>
</rich:calendar>
Valter Silva
  • 16,446
  • 52
  • 137
  • 218

1 Answers1

6

As shown in the Showcase:

<script type="text/javascript">
    // <![CDATA[
    var curDt = new Date();
    disableBeforeToday = function(day) {
        return (curDt.getTime() - day.date.getTime() < 0);
    }
    // ]]>
</script>
…

<rich:calendar dayDisableFunction="disableBeforeToday" …>

Note that you have to use &lt; because the JSF engine will think < is the beginning of a new tag.

Makhiel
  • 3,874
  • 1
  • 15
  • 21
  • 1
    You can use CDATA section around javascripts to avoid the mess with `&...;` escaping in code. See http://stackoverflow.com/questions/7092236/what-is-cdata-in-html – DRCB May 02 '13 at 08:53
  • I didn't saw this showcase, it's not the same as the current showcase. Thank you for your answer and sorry if I bother you with something that already was explained in the showcase. – Valter Silva May 02 '13 at 12:45
  • 1
    It's not the same but disabling the days before today is part of the showcased code. And you're not bothering, I'm linking to showcase more to show where I got it from than to show you you were not looking hard enough ;) – Makhiel May 02 '13 at 13:19