I have two Datepicker
/Calendar
(Primefaces) , what I want to do is when I'll click on the second Calendar I'll call a Listener that will caclulate the days between the two dates. So this is what I've did:
Web Page
<a:column span="4" >
<a:label value="Begining Date" span="4" required="true" ></a:label>
<a:column span="8">
<p:calendar id="idBegDate" value="#{addController.enti.begDate}"
pattern="dd/MM/yyyy" label="Begining Date"
readonlyInput="true" locale="fr" navigator="true"
required="true" >
</p:calendar>
</a:column>
</a:column>
<a:column span="4" >
<a:label value="End Date" span="4" required="true" ></a:label>
<a:column span="8">
<p:calendar id="idDateFin" value="#{addController.enti.dateFinAbsAgt}"
pattern="dd/MM/yyyy" label="End Date"
readonlyInput="true" locale="fr" navigator="true"
required="true" >
<p:ajax event="dateSelect" listener="#{addController.doCalculate()}" update="jourCalendaire" />
</p:calendar>
</a:column>
</a:column>
Backing Bean
public void doCalculate()
{
//..Some Stuffs
}
The problem is that when the listener is called it says that the dateOfBegining
is NULL
while it shouldn't be.
I found the solution to this issue by adding an empty listener
to the first calendar
:
public void emptyListener()
{
}
I think this is not logical, so I want to know why the webpage/backingBean had this behavior ? Is there a way in which I can use only the listener of the second calendar ?
Thanks