使用primefaces的日历组件过滤数据表

时间:2017-07-03 12:20:04

标签: primefaces datatable calendar jsf-2.2

我正在使用jsf 2.2,Primefaces 6.0,我正在尝试使用Primefaces的日历组件对数据表进行排序。问题:当我开始使用特定日期过滤数据表时,数据表的所有值都将消失,而不是显示正确的值。

xhtml代码:

 <p:dataTable value="#{demandeBean.allDemandes}" var="a" id="t1"
                    sortMode="multiple" widgetVar="tt" editable="true" editMode="cell"
                    selectionMode="single" rowKey="#{a.id}"
                    emptyMessage="Aucune demande" rows="10" paginator="true"
                    paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                    rowsPerPageTemplate="10,15,25" draggableColumns="true"
                    scrollable="true" scrollHeight="250" paginatorPosition="bottom">
    <p:ajax event="rowSelect" listener="#{demandeBean.onRowSelect}"
        oncomplete="PF('d2').show()" update=":form:d2" />

    <p:ajax event="cellEdit" listener="#{demandeBean.onCellEdit}"
        update=":form:t1" />

    <p:column headerText="Date dépot" sortBy="#{a.dateDeDepot}" filterBy="#{a.dateDeDepot}" filterMatchMode="contains">
        <f:facet name="filter">
            <p:calendar id="cal1" pattern="dd/MM/yyyy">
                <p:ajax event="dateSelect" oncomplete="PF('tt').filter()" update="t1" />
                <p:ajax event="change" execute="@this" oncomplete="PF('tt').filter()" update="t1" />
            </p:calendar>
        </f:facet>
        <h:outputText value="#{a.dateDeDepot}">
            <f:convertDateTime pattern="dd/MM/yyyy HH:mm:ss"
                timeZone="GMT+1:00" />
        </h:outputText>
    </p:column>

这里是javaBean代码:

@ManagedBean
@ViewScoped
public class DemandeBean {
    private List<String> images = new ArrayList<>();
    private String matriculeForAdminToAdd;
    private List<DetailDemande> detailDemandesTMP = new ArrayList<>();
    private ActeMedical acteMedical = new ActeMedical();
    private List<ActeMedical> acteMedicalsToAdd = new ArrayList<>();
    private Integer idOf;
    private List<Demande> allDemandes = new ArrayList<>();
    private List<Demande> allDemandesParAssures = new ArrayList<>();
    private List<Demande> allDemandesParEmployer = new ArrayList<>();
    private Demande demande = new Demande();
    private Demande demandeSelectionnee = new Demande();
    private List<String> etats = new ArrayList<>();
    private List<String> etatsDemande = new ArrayList<>();
    private String etatChoisi = "";
    private Date dateActe;
    private Double montant;
    private ActeMedical acteMedicalSelection = new ActeMedical();
    private List<ActeMedical> acteMedicals = new ArrayList<>();
    private List<Assure> assuresParEmployee = new ArrayList<>();
    private Map<String, String> parentes = new HashMap<String, String>();
    private int sizeDemands;
    private int sizeDemandsCollaborateur;
    private int sizeDemandsAssure;
    @EJB
    private DemandeServicesLocal demandeServicesLocal;
    @EJB
    private UserServicesLocal userServicesLocal;
    @ManagedProperty(value = "#{identity}")
    private Identity identity;
    @ManagedProperty(value = "#{demandeTMP}")
    private DemandeTMP demandeTMP;

    @PostConstruct
    public void init() {
        etats.add("ENCOURS");
        etats.add("ACCEPTE");
        etats.add("AMODIFIER");
        parentes = new HashMap<String, String>();
        parentes.put("Enfant", "Enfant");
        parentes.put("Conjoint", "Conjoint");
        etatsDemande.add("ENCOURS");
        etatsDemande.add("TRANSMISE");
        etatsDemande.add("AMODIFIER");

    }





    public List<Demande> getAllDemandes() {
        allDemandes = demandeServicesLocal.findAllDemandes();
        sizeDemands = allDemandes.size();
        Collections.sort(allDemandes, new Comparator<Demande>() {
            @Override
            public int compare(Demande d1, Demande d2) {
                return d2.getDateDeDepot().compareTo(d1.getDateDeDepot());
            }
        });
        return allDemandes;

    }

0 个答案:

没有答案