2.8 and Primefaces 6.0 And i want to retrieve the value of a date from my xhtml to make specific treatments Before submitting my form.
But the value of the date is always null in the bean Before submitting.
Here is my XHTML
<p:outputLabel for="dateDebut" value="Date Debut"/>
<p:calendar id="dateDebut" value="#{etpBean.dateDebut}" required="true">
<p:ajax listener="#{etpBean.listenerDateDebut}" event="change"/>
</p:calendar>
And here is my function in my bean
public Date listenerDateDebut(){
return dateDebut;
}
From the PrimeFaces 6 documentation :
Ajax Behavior Events
Calendar provides a
dateSelect
ajax behavior event to execute an instant ajax selection whenever a date is selected. If you define a method as a listener, it will be invoked by passing anorg.primefaces.event.SelectEvent
instance.<p:calendar value="#{calendarBean.date}"> <p:ajax event="dateSelect" listener="#{bean.handleDateSelect}" update="msg" /> </p:calendar> <p:messages id="msg" />
public void handleDateSelect(SelectEvent event) { Date date = (Date) event.getObject(); //Add facesmessage }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.