显示两个日期之间的结果jsf ajax

时间:2018-09-30 11:58:31

标签: jsf primefaces

我从jsf和ajax开始,无法显示两个日期之间的结果,我尝试显示所有具有两个日期的过滤器(日期日历)之间的日期的购买,但我不知道如何通过在ajax中的结果是我的代码

我使用fetchresult方法尝试控制日期,但我不知道如何返回结果,以便被ajax读取

jsf.xhtml

<p:outputLabel for="startDate1" value="De:" />
<p:calendar id="startDate1" value="#{calendarView.startDate1}"
popupIconOnly="false" pattern ="EEE, dd MMM, yyyy" locale="en">

<p:ajax update="endDate1" event="dateSelect" listener="#{calendarView.fetchResults}" render="dt"/>
</p:calendar>



<p:outputLabel for="endDate1" value="A:" />
<p:calendar id="endDate1" value="#{calendarView.endDate1}"
mindate="#{calendarView.startDate1}" popupIconOnly="false" pattern="EEE, dd MMM, yyyy"
locale="en">

<!--<p:ajax listener="#{calendarView.fetchResults}" render="dt"/>-->
</p:calendar>


</h:form>

<p:dataTable
id="dt"
value="#{instanceController.procInstList}"
var="procInst" paginator="true"
paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="10,50,100">
<p:column headerText="N° DA" width="15%" filterBy="#{procInst.executionId}"
filterMatchMode="contains">
<p:outputLabel value="#{procInst.id}"></p:outputLabel>
</p:column>



<p:column headerText="Tache" width="15%">
<p:outputLabel value="#{procInst.name}"></p:outputLabel>
</p:column>


<p:column headerText="Demandeur" width="15%">
<p:outputLabel
value="#{instanceController.getVariableProcess(procInst,'form_1453749085252')}"></p:outputLabel>
</p:column>


<p:column headerText="Acheteur" width="15%">
<p:outputLabel
value="#{instanceController.getAcheteurFromProcessInstance(procInst,'ListeAcheteurs')}"></p:outputLabel>
</p:column>




<p:column headerText="Montant Estimatif de la DA " width="15%">
<p:outputLabel
value="#{instanceController.getVariableProcess(procInst,'FormBuilder_budgetEstimatifAchat')}"></p:outputLabel>
</p:column>

<p:column headerText="Date DA " width="15%">
<p:outputLabel id="dateDa"
value="#{instanceController.getVariableProcess(procInst,'form_1448539361458')}"></p:outputLabel>
</p:column>

controller.java

public class CalendarView  {



    private Date startDate1;
    private Date endDate1;
    private Date startDate;
    private Date endDate;

    public void onDateSelect(SelectEvent event) {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM, yyyy");
        facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Date Selected", format.format(event.getObject())));
    }

    public void click() {
        PrimeFaces.current().ajax().update("form:display");
        PrimeFaces.current().executeScript("PF('dlg').show()");
    }






    public Date getStartDate1() {
        return startDate1;
    }

    public Date getEndDate1() {
        return endDate1;
    }

    public Date getStartDate() {
        return startDate;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setStartDate1(Date startDate1) {
        this.startDate1 = startDate1;
    }

    public void setEndDate1(Date endDate1) {
        this.endDate1 = endDate1;
    }

    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }


    public void fetchResults(SelectEvent event) {

        Date date1 = (Date) event.getComponent().getAttributes().get("dateDa");
        if ((date1.compareTo(startDate1) > 0) && (date1.compareTo(endDate1) < 0)){


        }

    }

0 个答案:

没有答案