Primefaces日历 - 使用EL禁用特定日期 [英] Primefaces Calendar - disabling specific dates using EL
问题描述
所以从我之前的问题来看,在p:日历上禁用特定日期,我知道我可以使用这样的Javascript禁用特定日期:
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"/>
但是,我的问题是如何在中存储日期disabledDays
使用EL表达式的数组?我需要这样做,因为我需要禁用的日期各不相同。禁用日期需要是动态的。如果我不能用EL表达式做这个,有没有使用一个有动态数据的数组?
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?
谢谢
推荐答案
一种可能性就是转换bean中的值( [5-15-2013,6-23-2013]
),并将其直接放在Javascript代码中:
One possibility is just converting the value in a bean (["5-15-2013", "6-23-2013"]
), and put it directly in the Javascript code:
var disabledDays = #{myBean.disabledDays};
这不是最干净的,但最简单的。另一种可能性就是在bean中使用字符串列表并使用< ui:repeat>
将其打印为逗号分隔列表。
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.
这篇关于Primefaces日历 - 使用EL禁用特定日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!