From XPages to Web App Part Fourteen: Calendar View

  |   Blog   |   1 Comment

Table of Contents
Part One – The Application
Part Two – XPages Advanced 1
Part Three: XPages Advanced Database Separation
Part Four: XPages Advanced Document Wrapper
Part Five: XPages Advanced MVC Controller
Part Six: Use of OpenNTF Domino API
Part Seven: OSGi Application Development Introduction
Part Eight: OSGi JAX-RS REST Access with ODA
Part Nine: OsgiWorlds
Part Ten: Vaadin
Part Eleven: OsgiWorlds Document Wrapper
Part Twelve: Key Date Page
Part Thirteen: Application Structure
Part Fourteen: “Views”

To complete the investigation of the OSGiWorlds version of our application, I’ll cover the “views” – the Calendar page and the Key Dates page. I will cover the Calendar page first, class, because that is actually the simpler of the two.

Adding the calendar layout to the page is extremely simple. Vaadin has a built-in rich-functioning component, com.vaadin.ui.Calendar. (In previous versions this was just an add-on, but has now been integrated into the core product). At line 98 of the CalendarView class, an eventHandler is added to the calendar and the eventHandler is an instance of the class, which extends org.openntf.osgiworlds.model.AbstractDominoCalendarEventClickHandler. This is a simple class that allows the developer to pass in the constructor the page to navigate to when clicking the link, in this case KeyDateView.VIEW_NAME – the “KeyDate” page. The eventClick() method of the handler builds the URL, getting the note ID from the current calendar entry being clicked.

The code then defines some settings for the calendar and sets a provider for the data, Again, this extends an abstract class that any implementation can use as a basis, org.openntf.osgiworlds.model.AbstractCalendarEventProvider, and that extends a standard Vaadin CalendarEventProvider. The abstract class should work with a normal Domino calendar view, though bear in mind I’ve not really tested it. The dataProviders for a Vaadin Calendar automatically pass the start date and end date to the dataProvider based on the range being displayed. So, with quite basic code, in the standard Vaadin getEvents() method we can create a ViewEntryCollection from a Domino view based on a DateRange using the start date and end date passed. The ViewEntries are parsed out to org.openntf.osgiworlds.model.BasicDominoEvent objects – basically just a wrapper for each ViewEntry to store the relevant values needed by the calendar.

So the code to add a calendar to a page and bind it to Domino is extremely simple. The most complex part is actually the bit above the calendar, the buttons for selecting and navigating dates, This is my own extension of code from the sample for the original Vaadin aa-on calendar. It adds Next, Previous, Month and Week buttons. The Month button is only available if the calendar is displaying a week or a day, the Week button is only available if the calendar is displaying a day. The calendar itself provides links for drilling down to a week or a day – week links show on the left, day links above each day.


In the next part I’ll conclude the OsgiWorlds app by covering the Key Dates filterable view.

AUTHOR - Paul Withers

Paul Withers has been an IBM Champion since 2011, has been an OpenNTF Board Member since 2013, has worked with XPages since 2009, co-authored XPages Extension Library and was technical editor for Mastering XPages 2nd Edition. He is one of the developers on OpenNTF Domino API as well as contributor to a variety of other OpenNTF projects.


Post A Comment