so from my previous question, Disable specific dates on p:calendar, i know that i can disable specific dates using Javascript like this:
var disabledDays = ["5-15-2013", "6-23-2013"];
function disableAllTheseDays(date) {
var m = date.getMonth(), d = date.getDate(), y = date.getFullYear();
for (i = 0; i < disabledDays.length; i++) {
if($.inArray((m+1) + '-' + d + '-' + y,disabledDays) != -1) {
return [false];
}
}
return [true];
}
with:
<p:calendar id="pfdate" navigator="true" pattern="MM-dd-yyyy"
value="#{day}" BeforeShowDay="disableAllTheseDays" showOn="button"/>
However, my question is that how can i store dates in disabledDays
array using EL expressions? I need to do this because the dates that i need to disable varies. Disabling dates needs to be dynamic. If i can't do this with EL expressions, is there anyways to use an array that will have dynamic data?
Thanks
One possibility is just converting the value in a bean (
["5-15-2013", "6-23-2013"]
), and put it directly in the Javascript code:It's not the cleanest one, but the easiest. Another possibility is just having the list of strings in the bean and use
<ui:repeat>
to print it as a comma separated list.