primefaces schedule with parameter in jsf

1.8k Views Asked by At

Hello I am here to ask your help following a difficult i meet in my project .Your different point of vue are welcome. I am using primefaces Schedule to perform a given task but I don't know how I can pass a parameter to my backing bean.I would like to use this parameter in backing bean when a schedule event triggered like SelectEvent or dateSelect . For example if I have a parameter personeID I would pass this parameter to the bean so that when actionListener will activate this setting can be initialized in the bean so that I can use. that my code

<p:schedule id="schedule" value="#{inscrireAgendaBean.eventModel}" widgetVar="myschedule"  process="@form" axisFormat="HH:mm"  columnFormat="dddd D/MM" firstHour="08" locale="fr" timeZone="GMT+1"  timeFormat="HH:mm">

  <p:ajax event="dateSelect" listener="#{inscrireAgendaBean.onDateSelect}" update="eventDetails" oncomplete="PF('eventDialog').show();" />

  <p:ajax event="eventSelect" listener="#{inscrireAgendaBean.onEventSelect}" update="eventDetails" oncomplete="PF('eventDialog').show();" />

 </p:schedule>

I just want to know if there is a possibility to add a parameter to my bean when eventSelect or dateSelect triggered Thank you !!!

1

There are 1 best solutions below

8
Bilal Dekar On BEST ANSWER

I understand from your question that you want to triger a listener when you select an event, so you have to add a p:ajax with a eventSelect event :

<p:schedule id="scheduleLocale"  value="#{managedBean.schedule}" draggable="false" resizable="false" axisFormat="HH:mm"  columnFormat="dddd D/MM" firstHour="08" locale="fr" timeZone="GMT+1"  timeFormat="HH:mm" >
    <p:ajax event="eventSelect" listener="#{managedBean.onEventSelect}" update="eventDetails" oncomplete="PF('eventDialog').show();" />
</p:schedule>

and on you managedBean the onEventSelect method will be as follows:

public void onEventSelect(SelectEvent selectEvent) {
    event = (ScheduleEvent) selectEvent.getObject();
}

so getObject() will allow you to retrieve informations like personeID, and depends if you actually put personelID when you first created the event with event = new DefaultScheduleEvent()

to add an event by selecting a date on a schedule, you use p:ajax with dateSelect event:

<p:ajax event="dateSelect" listener="#{managedBean.onDateSelect}" update="eventDetails" oncomplete="PF('eventDialog').show();" />

this will show up a dialog, you can put any information you want to add to the event, the user will enter it, so no need to pass any parameters.