在设置开始日期后设置日历结束日期 [英] Setting primefaces calendar end date after setting start date
问题描述
我使用primfaces日历创建一个事件。使用mindate参数我禁用了当天前的天数。我想要这样做,即使在结束日期,禁用在开始日期之前的天。我不知道如何处理这个,因为支持bean只有在整个表单的验证后获得开始日期。
我需要在inputText字段中输入开始日期之后设置支持bean。
HTML:
< p:calendar immediate =truemindate =#{createEventBean.today}id = startingtimevalue =#{createEventBean.current.startingtime}/>
< p:calendar mindat =#{createEventBean.current.startingtime}id =endingtimevalue =#{createEventBean.current.endingtime}/>
这里是支持bean的方法:
public Date getToday(){
return new Date();
}
$ c>< p:ajax> 更新结束日期,以选择开始日期。 < p:calendar>
支持选择日期时触发的ajax事件 dateSelect
>
所以,这应该做:
< p:calendar value = #{bean.startDate}mindate =#{bean.today}>
< p:ajax event =dateSelectupdate =endDate/>
< / p:calendar>
< p:calendar id =endDatevalue =#{bean.endDate}mindate =#{bean.startDate}/>
I'm using primefaces calendar for the creation of an event. With the "mindate" parameter i have disabled the days before the current day. I want to do this even with the end date, disabling the days before the start date. I don't know how to handle this, since the backing bean gets the start date only after the validation of the entire form.
I need the backing bean to be set right after entering the start date on the inputText field.
Here the HTML:
<p:calendar immediate="true" mindate="#{createEventBean.today}" id="startingtime" value="#{createEventBean.current.startingtime}"/>
<p:calendar mindate="#{createEventBean.current.startingtime}" id="endingtime" value="#{createEventBean.current.endingtime}"/>
here the backing bean's method:
public Date getToday(){
return new Date();
}
You can use <p:ajax>
to update the end date on select of start date. The <p:calendar>
supports the ajax event dateSelect
which is fired when a date is selected.
So, this should do:
<p:calendar value="#{bean.startDate}" mindate="#{bean.today}">
<p:ajax event="dateSelect" update="endDate" />
</p:calendar>
<p:calendar id="endDate" value="#{bean.endDate}" mindate="#{bean.startDate}" />
这篇关于在设置开始日期后设置日历结束日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!