Table update and Primefaces ScheduleEvent
<p>Hello i would like to ask your help to solve a  difficult i meet in my project.
I am using primefaces Schedule to do a task and for that i store all events in a MySQL table named agenda.
My difficult concerns the table update. When i update for the first time all things perfectly work but  other attempts fail because mySQL does not find the primary Key for updating the line concerned in the table.
This is my backing bean code</p>

<pre><code>public class AgendaBean implements Serializable{
private Agenda agenda;
private String title;
private Date dateDbt;
private Date dateFin;
private ScheduleModel eventModel;
private ScheduleEvent event;
@EJB
private AgendaDao agendaDao;
public AgendaBean(){
    agenda=new Agenda();
    event= new DefaultScheduleEvent(nom, dateDbt, dateFin, agenda) ;
}
@PostConstruct
public void init() {
    eventModel=new DefaultScheduleModel();
    agendas=agendaDao.listAgenda();
    for(Agenda agendItem:agendas){
        String title=agendItem.getTitle();
        Date dtDbt=new java.util.Date(agendItem.getDateDbt().getTime());
        Date dtFin=new java.util.Date(agendItem.getDateFin().getTime());
        event=(ScheduleEvent) new DefaultScheduleEvent(title, dtDbt, dtFin,agendItem);
        eventModel.addEvent(event);
    }
}
public void addEvent(ActionEvent actionEvent){
    if(event.getId() == null)
    {
        agenda.setDateDbt(new java.sql.Timestamp(event.getStartDate().getTime()));
        agenda.setDateFin(new java.sql.Timestamp(event.getEndDate().getTime()));
        agenda.setTitle(event.getTitle());
        agendaDao.creer(agenda);
     }
    else{
        eventModel.updateEvent(event);
        agenda.setDateDbt(new java.sql.Timestamp(event.getStartDate().getTime()));
        agenda.setDateFin(new java.sql.Timestamp(event.getEndDate().getTime()));
        agenda.setTitle(event.getTitle());
        agendaDao.modifier(agenda);
    }
    init();
}

public void onEventSelect(SelectEvent selectEvent) {
    event = (ScheduleEvent) selectEvent.getObject();
    Agenda agendaFound=(Agenda)event.getData();
    agenda.setDescription(agendaFound.getDescription());
    agenda.setLieu(agendaFound.getLieu());
    agenda.setPkIdag(agendaFound.getPkIdag());
}

public void onDateSelect(SelectEvent selectEvent) {
    event = (ScheduleEvent) new DefaultScheduleEvent("", (Date) selectEvent.getObject(), (Date) selectEvent.getObject(),new Agenda());
}
</code></pre>

<p>}</p>

<p>My view code is below</p>

<pre><code>&lt;h:panelGrid columnClasses="value"&gt;
    &lt;p:schedule id="schedule" value="#{agendaBean.eventModel}" widgetVar="myschedule" timeZone="GMT"  process="@form" axisFormat="HH:mm" &gt;
        &lt;p:ajax event="dateSelect" listener="#{agendaBean.onDateSelect}" update="eventDetails" oncomplete="PF('eventDialog').show();" /&gt;
        &lt;p:ajax event="eventSelect" listener="#{agendaBean.onEventSelect}" update="eventDetails" oncomplete="PF('eventDialog').show();" /&gt;
    &lt;/p:schedule&gt;
&lt;/h:panelGrid&gt;
&lt;p:dialog widgetVar="eventDialog" header="Event" showEffect="clip" hideEffect="clip" height="400" width="400" id="eventDetails" resizable="false" &gt;
    &lt;h:outputLabel for="idCleAg"&gt;REF &lt;span class="requis"&gt;*&lt;/span&gt;&lt;/h:outputLabel&gt;
    &lt;h:inputText id="idCleAg" value="#{agendaBean.agenda.pkIdag}"/&gt;
    &lt;br/&gt;
    &lt;h:outputLabel for="title"&gt;title &lt;span class="requis"&gt;*&lt;/span&gt;&lt;/h:outputLabel&gt;
    &lt;p:inputText id="title" value="#{agendaBean.event.title}" required="true" maxlength="60" style="background:#fff;width:370px;margin-left:-4px;"/&gt;
    &lt;h:message id="titleMessage" for="title" errorClass="erreur" /&gt;
    &lt;br/&gt;
    &lt;h:outputLabel for="place"&gt;Place&lt;span class="requis"&gt;*&lt;/span&gt;&lt;/h:outputLabel&gt;
    &lt;p:inputText id="place" value="#{agendaBean.agenda.place}" required="true" maxlength="60" style="background:#fff;width:370px;margin-left:-4px;"/&gt;
    &lt;h:message id="placeMessage" for="place" errorClass="erreur" /&gt;
    &lt;br/&gt;
    &lt;h:outputLabel for="description"&gt;Description&lt;span class="requis"&gt;*&lt;/span&gt;&lt;/h:outputLabel&gt;
    &lt;p:inputTextarea id="description" value="#{agendaBean.agenda.description}" rows="10" cols="50" queryDelay="750" minQueryLength="4" required="true"/&gt;
    &lt;h:message id="descriptionMessage" for="description" errorClass="erreur" /&gt;
    &lt;br/&gt;
    &lt;p:outputLabel for="from" value="From:" /&gt;
    &lt;p:calendar  id="from" value="#{agendaBean.event.startDate}" pattern="yyyy-MM-dd HH:mm:ss"/&gt;
    &lt;br/&gt;
    &lt;p:outputLabel for="to" value="To:" /&gt;
    &lt;p:calendar id="to" value="#{agendaBean.event.endDate}" pattern="yyyy-MM-dd HH:mm:ss"/&gt;
    &lt;br/&gt;
    &lt;p:commandButton id="addButton" value="Save" actionListener="#{agendaBean.addEvent}" update="@form" ajax="true" /&gt; 
&lt;/p:dialog&gt;
</code></pre>

<p>Any help would be welcome!Thank you</p>