|
How to implement an iCalendar feed to emebed into your Notes calendar with XPages
Julian Buss, March 19th, 2010 09:56:33
Tags: XPages
I just had the idea to implement an iCalendar feed in some application. And guess what? It's really piece of cake!
Create a XPage, set all properties -> rendered to "false", add some code like this into the afterRenderResponse event: (don't copy and paste my code, it contains specific stuff for my app...) --- var exCon = facesContext.getExternalContext(); var writer = facesContext.getResponseWriter(); var response = exCon.getResponse(); var nview:NotesView = database.getView("($plans)"); nview.setAutoUpdate(false); var vc:NotesViewEntryCollection = nview.getAllEntriesByKey(@UserName(), false); var ve:NotesViewEntry = vc.getFirstEntry(); var values; var date; var body; var period; var i = 0; response.setContentType("text/calendar"); response.setHeader("Cache-Control", "no-cache"); writer.write("BEGIN:VCALENDAR\n"); writer.write("VERSION:2.0\n"); writer.write("X-LOTUS-CHARSET:UTF-8\n"); while (ve) { values = ve.getColumnValues(); date = values.elementAt(5); body = values.elementAt(6); period = values.elementAt(2); writer.write("BEGIN:VEVENT\n"); writer.write("DTSTART:"+date+"T080000\n"); writer.write("DTEND:"+date+"T080000\n"); writer.write("TRANSP:OPAQUE\n"); writer.write("DESCRIPTION:"+body+"\n"); if (period == "d") writer.write("SUMMARY:Plan für heute\n"); if (period == "w") writer.write("SUMMARY:Plan für die Woche\n"); if (period == "m") writer.write("SUMMARY:Plan für den Monat\n"); writer.write("UID:"+values.elementAt(1)+"-ynplan\n"); writer.write("END:VEVENT\n"); ve = vc.getNextEntry(ve); } writer.write("END:VCALENDAR\n"); writer.endDocument(); --- You can subscribe to that feed with your Notes calendar, just click "add calendar", select "iCalendar" as format and set the URL to your XPage. There is a lot of more stuff in the iCalendar format... if you need it, just export some calendar entry of your Notes calendar to iCal and have a look at the file. |
|

