-1

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;
}
CHARAFI Saad
  • 1,340
  • 3
  • 16
  • 36
  • 1
    Possible duplicate of [Value Change listner not working in primefaces calendar](http://stackoverflow.com/questions/14099478/value-change-listner-not-working-in-primefaces-calendar) – Jasper de Vries Apr 10 '17 at 15:28
  • but DateSelectEvent have been removed in primefaces 6.0 :/ :/ – CHARAFI Saad Apr 10 '17 at 15:36

1 Answers1

2

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 an org.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
}
Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102
  • 3
    I'm going to investigate why the original question does not work. I'd expect it to just work (or the listener is not being called at all due to a wrong method signature – Kukeltje Apr 10 '17 at 15:58
  • 3
    And as a matter of fact, this is also (sort of) in the original link you referred to as a 'single' upvoted answer...., just a different event... All kind of weird AND even more identical as a non-upvoted answer... Maybe we should mark this one as a duplicate and improve the other one – Kukeltje Apr 10 '17 at 16:00
  • 2
    Oh, you modified the answer of the other question... I thought you meant this one.... hahaha... Sorry... – Kukeltje Apr 10 '17 at 17:17