I am using primefaces p:schedule component to display events as shown here
.
p:schedule
These events can be draggable if we set property draggable=”true” and
with event ‘eventMove’.I have two type of events, which I can differntiate by using their
‘title’
I want type1 events to be draggable and type 2 not to be draggable.
How can I achieve it? As we provide syntax to become draggable events in this way.
<p:schedule value="#{scheduleController.eventModel}" widgetVar="myschedule" draggable="true">
<p:ajax event="dateSelect" listener="#{scheduleController.onDateSelect}" update="eventDetails" oncomplete="eventDialog.show()" />
<p:ajax event="eventSelect" listener="#{scheduleController.onEventSelect}" update="eventDetails" oncomplete="eventDialog.show()" />
<p:ajax event="eventMove" listener="#{scheduleController.onEventMove}" update="messages" />
</p:schedule>
You have to dive into the fullcalendar plugin to make it. check these SO questions:
FullCalendar: How to stop dragging custom events?
How do I disable drag and drop in fullcalendar
http://code.google.com/p/fullcalendar/issues/detail?id=1243
http://arshaw.com/fullcalendar/docs/event_data/Event_Object/
Maybe if you can edit the response of the JSF server before it goes out, try using a filter.
The events have this general structure when draggable is ON:
notice the classes of the main div:
You need then to unregister the DOM events of the scheduled-events you want, BUT…
Schedule re-renders every time, and it re-registers the events and the classes back. You have little control over the items, since primefaces forwards the data to the jQuery schedule plugin.
So you would need to mark your events as un-draggable every time it re-renders.
the PF response on the ajax code is a javascript object with the data the plugin needs to re-render the schedule, so I don’t think that anything server-side would help you.
Here is the server response on a event drag:
I think you have to use some javascript to unregister the events from the elements you want. But since they are loaded from the server with only data, you have to identify them by name, by date or something else.
See this question for info on how to unregister events: jquery override event
So the path is:
As an added bonus, here goes the source I tested on:
You have to bind the draggable property of the
<p:schedule>to a managed bean boolean property, and then use a control (in the example below, a selectbooleancheckbox:notice the ajax tag to communicate with the server:
the whole JSF code:
the managed bean:
If you look closely to the managed bean, it has some other changes from the primefaces showcase example, for one, all events are snapped to 15 minutes intervals, and other stuff.