Proposed API changes for the schedule component
bleathem Nov 2, 2012 4:21 PMWe are hoping to include the RichFaces Sandbox schedule component in RichFaces 4.3. To this end, I've taken a close look at the component, and have been tracking suggested changes via the RFXBOX jira issue: RFSBOX-67.
In particular, I would like to discuss RFSBOX-94 which is proposing a significant change to the Schedule component API.
Currently the schedule component (as I understand it) works like a dataTable, where one specifies the var/value attribute of the schedule component, mapping it to a back end data structure (List, ExtendedDataModel etc.) On then uses the var attribute to populate the attributes of scheduleItem components. The facelet code ends up looking like:
<schedule:schedule value="#{myBean.lazyDataModel}" var="event"> <schedule:scheduleItem eventId="#{event.id}" startDate="#{event.startDate}" title="#{event.title}" endDate="#{event.endDate}" allDay="#{event.allDay}" styleClass="#{event.id == 1 ? 'first' : null}" data="#{event.data}" color="#{event.color}"/> </schedule:schedule>
My proposal is to change the approach to model the select/selectItems approach to defining the list of schedule items. The above example would then look something like:
<schedule:schedule> <schedule:scheduleItems value="#{myBean.lazyDataModel}"/> </schedule:schedule>
Where <schedule:scheduleItems> returns a list of ScheduleItem objects. This could be expanded to allow dynamic creation of the ScheduleItem objects, and maintain the flexibility of the current approach, as in:
<schedule:schedule> <schedule:scheduleItems value="#{myBean.someObjectList}" var="event"> <schedule:scheduleItem title="#{event.mapsToTitle}" startDate="#{event.mapsToDate}" /> </schedule:scheduleItems> </schedule:schedule>
One advantage of this approach is it would allow one to create a static schedule component, as in:
<schedule:schedule> <schedule:scheduleItem eventId="1" title="My Event" allDay="true" startDate="2012-11-02" /> </schedule:schedule
In summary I don't think the dataTable approach is required, as we don't need the ability to control the scheduleItem markup/layout the way we do with columns. Rather we are simply interested in populating a list of ScheduleItem objects so we can create the JSON data the fullcalendar plugin is looking for.
WDYT? Would a change to this API make the component use more intuitive and flexible for JSF developers?