0

I start in jsf and ajax, and I can not display the result between two dates, I try to display all purchase that have a date between the two date of the filter (date calander) but I do not know how to pass the result in ajax here is my code

I use the fetchresult method to try to control the dates but I do not know how to return the results so that it is read by 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)){


        }

    }
Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102

0 Answers0