我需要比较两个日历日期。我也写了javascript函数。但是,如何在从datePicker中选择一个日期时执行此函数(哪个事件?)?查看我的JSF代码

<h:outputText value="From Date" />
<p:calendar id="fDate" value="#{backingBean.fDate}" mode="popup"
    showOn="button" pattern="dd/MM/yyyy">

</p:calendar>
<p:message id="fId" for="fDate" />

<h:outputText value="To Date" />
<p:calendar id="tDate" value="#{backingBean.tDate}" mode="popup"
    showOn="button" pattern="dd/MM/yyyy" ondateselected="compareDate();" />
<p:message id="tId" for="tDate" />


我猜ondateselected="compareDate();根本没有执行,这是错误的。
我在JSF2中使用primefaces-3.0.M3。

最佳答案

不知道何时将它们更改为使用p:ajax,但可能是在3.0M3之前

所以这样尝试

<p:calendar value="#{backingBean.tDate}">
    <p:ajax event=”dateSelect” oncomplete="compareDate();return false;" />
</p:calendar>


现在,当我再次考虑时,我认为您可以将js函数放在onsuccess =“”中并删除return false;。

关于java - 在datePicker上选择日期的事件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8879167/

10-11 02:28
查看更多