Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在JQuery中获取richfaces日历的选定日期_Jquery_Jsf_Richfaces - Fatal编程技术网

在JQuery中获取richfaces日历的选定日期

在JQuery中获取richfaces日历的选定日期,jquery,jsf,richfaces,Jquery,Jsf,Richfaces,我有两个相同格式的日历,都是rich:calendar。一个是开始日期(或激活日期),另一个是结束日期(或停用日期) 我试图实现的是在结束日期日历中标记所选的开始日期 例如: 此处7月14日(红色)为开始日期,7月16日为当前选定的结束日期 我的问题似乎是,我无法通过JQuery获得开始日期的值。我尝试在页面上的某个位置“隐藏”该值,以便使用$('#myForm\\\:hiddenActivationDate').val()访问它而且几乎成功了。。但后来一切都停止了 以下是我编写的脚本函数:

我有两个相同格式的日历,都是
rich:calendar
。一个是开始日期(或激活日期),另一个是结束日期(或停用日期)

我试图实现的是在结束日期日历中标记所选的开始日期

例如:

此处7月14日(红色)为开始日期,7月16日为当前选定的结束日期

我的问题似乎是,我无法通过JQuery获得开始日期的值。我尝试在页面上的某个位置“隐藏”该值,以便使用
$('#myForm\\\:hiddenActivationDate').val()访问它而且几乎成功了。。但后来一切都停止了

以下是我编写的脚本函数:

var currentDate = new Date();
function activationDateDisablementFunction(day) {
    return currentDate.getDate() <= day.date.getDate();
}
function activationDateClassProv(day) {
    if (currentDate.getDate() > day.date.getDate()) {
        return "disabledDay";
    }
}
function deactivationDateDisablementFunction(day) {
    var hiddenActivationDate = $('#myForm\\:hiddenActivationDate').val();
    var activationDate = new Date(Date.parse(hiddenActivationDate));
    return day.date.getDate() >= activationDate.getDate(); // true = enabled, false =disabled
}
function deactivationDateClassProv(day) {
    var hiddenActivationDate = $('#myForm\\:hiddenActivationDate').val();
    var activationDate = new Date(Date.parse(hiddenActivationDate));
    if (day.date.getDate() < activationDate.getDate()) {
        return "disabledDay";
    }
    if (day.date.getDate() === activationDate.getDate()) {
        return "activatedDay";
    }
}
var currentDate=新日期();
功能激活日期禁用功能(天){
返回currentDate.getDate()天.date.getDate()){
返回“disabledDay”;
}
}
函数deactivationDateDisablementFunction(天){
var hiddenActivationDate=$('#myForm\\:hiddenActivationDate').val();
var activationDate=新日期(Date.parse(hiddenActivationDate));
返回日期.date.getDate()>=activationDate.getDate();//true=已启用,false=已禁用
}
功能停用DateClassProv(天){
var hiddenActivationDate=$('#myForm\\:hiddenActivationDate').val();
var activationDate=新日期(Date.parse(hiddenActivationDate));
if(day.date.getDate()
这是两个日历:

<!-- start date -->
<a4j:outputPanel id="activationDateCalendar" layout="block" >
    <rich:calendar value="#{myBean.activationDate}"
                   popup="true"     
                   datePattern="#{myBean.dateFormat}"     
                   boundaryDatesMode="scroll"    
                   jointPoint="bottomAuto"
                   showWeeksBar="false"
                   showApplyButton="false" 
                   dayClassFunction="activationDateClassProv" 
                   dayDisableFunction="activationDateDisablementFunction"
                   style="width:320px">
        <a4j:ajax render="@this, hiddenActivationDate, deactivationDateCalendar,  activationDatePreview, deactivationDatePreview, durationPreview" />
    </rich:calendar>
</a4j:outputPanel>

<!-- my hidden date -->
<h:inputHidden id="hiddenActivationDate" value="#{myBean.activationDate}" />

<!-- end date -->
<a4j:outputPanel id="deactivationDateCalendar" layout="block" >
    <rich:calendar value="#{myBean.deactivationDate}"
                   popup="true"     
                   datePattern="#{myBean.dateFormat}"     
                   boundaryDatesMode="scroll"    
                   jointPoint="bottomAuto"
                   showWeeksBar="false"
                   showApplyButton="false"
                   dayClassFunction="activationDateClassProv" 
                   dayDisableFunction="activationDateDisablementFunction"
                   style="width:320px">
        <a4j:ajax render="@this, activationDatePreview, deactivationDatePreview, durationPreview" />                           
    </rich:calendar>
</a4j:outputPanel>

简而言之
我要做的是直接从JQuery函数
deactivationDateClassProv
中访问开始日期值,而不从隐藏字段获取它


这可能吗?还是有“Richfaces方式”?

Richfaces组件有JS API,请阅读

在您的情况下,您只需通过以下方式访问日期:

function deactivationDateClassProv(day) {
    var hiddenActivationDate = #{rich:component('firstCalendarId')}.getValue();
    …
}

请注意,该函数仅在需要时调用,如果您只是关闭并打开日历,它将不会再次调用(除非您切换月份或将
isRendered
设置为false)。

非常感谢,这正是我需要的!感谢您指出,该函数将不再被调用。我很好奇这是否会带来任何问题。。