2 Replies Latest reply on Nov 6, 2012 10:40 AM by bleathem

    Proposed API changes for the schedule component

    bleathem

      We 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?

        • 1. Re: Proposed API changes for the schedule component
          lfryc

          Hey Brian,

           

          could we use <a4j:repeat /> instead of scheduleItems?

          We did some modifications to allow dynamic subtree creation we could leverage here, right?

          • 2. Re: Proposed API changes for the schedule component
            bleathem

            The thing that separates this from the tab/tableetc. approach, is we don't want to manipulate the markup of the scheduleItem components, rather we just want to build up a list of objects, in an analogous way to what we do with selectItems.

             

            As such, I'll adjust my initial use cases above as:

             

            selectEvent list built in javacode:

            <schedule:schedule>
                 <schedule:scheduleItems value="#{myBean.lazyDataModel}"/>
            </schedule:schedule>
            

             

            selectEvents list build in the facelet, looping over a collection:

            <schedule:schedule>
                 <schedule:scheduleItems value="#{myBean.someObjectList}" var="event" title="#{event.mapsToTitle}" startDate="#{event.mapsToDate}" />
            </schedule:schedule>
            

             

            Individual "static" selectItem:

            <schedule:schedule>
                <schedule:scheduleItem eventId="1" title="My Event" allDay="true" startDate="2012-11-02" />
            </schedule:schedule>
            

             

            In this modified proposal, UIScheduletems could inherit from UIScheduleItem, introducing only the var and value attributes.