p:日历多个日期选择

时间:2012-07-07 12:06:50

标签: jsf-2 primefaces

我正在尝试使用p:calender(primefaces 3.3)实现多个日期功能选择, 就这样。

<p:calendar  id="cal" showButtonPanel="true"  mode="inline"
    value="#{bean.dates}" selection="multiple"/> 

在Backing bean中,我以这种方式将日期作为数组:

private Date[] dates;
public Date[] getDates() {
    return dates;
}

public void setDates(Date[] dates) {
    this.dates = dates;

}

但仍然无法选择多个日期。

根据此博客http://blog.primefaces.org/?p=391,它可以运作。

我试图以同样的方式实施。但是没有奏效。 为什么会这样?

2 个答案:

答案 0 :(得分:2)

你读过的博客文章已经过时了,那时的主要日历依赖于YUI,而现在它基于Jquery UI datepicker(不支持多选)

所以你无法使用primefaces当前日历实现多个日期选择,但你可以谷歌一点并找到其他基于jquery的替代品,

例如jQuery UI Datepicker - Multiple Date Selections

答案 1 :(得分:1)

没有默认的功能,但这是一个使用2个内联日历的解决方案

<p:commandButton id="test" type="button"/>                                  
<p:overlayPanel for="test">
    <p:outputLabel styleClass="ui-grid ui-grid-responsive">
        <div class="ui-grid-row">
            <div class="ui-grid-col-6">
                <p:calendar id="start" value="#{myModel.start}" navigator="true" pattern="dd/MM/yyyy" mode="inline">
                    <p:ajax event="dateSelect" update="end"/>
                </p:calendar>       
            </div>
            <div class="ui-grid-col-6">
                <p:calendar id="end" value="#{myModel.end}" navigator="true" pattern="dd/MM/yyyy" mode="inline" mindate="#{myModel.start}"/>        
            </div>
        </div>
    </p:outputLabel>                                    
</p:overlayPanel>