| ID | CS001278 | Creation date | January 20, 2009 |
| Platform | S60 5th Edition | Tested on devices | Nokia 5800 XpressMusic |
| Category | Web Runtime (WRT) | Subcategory | PIM |
| Keywords (APIs, classes, methods, functions): device.getServiceObject(), Service.Calendar.GetList() |
This code snippet shows how to list calendars by using the Calendar Platform Service for S60 Web Runtime introduced in S60 5th Edition.
The device.getServiceObject("Service.Calendar", "IDataSource") method is used to obtain access to the service object for the Calendar Service API.
<label for="calendarList">Calendars:</label><br />
<select size="2" id="calendarList" onclick="showEvents();"></select>
var serviceObj = null;
window.onload = init;
// Initializes the widget
function init() {
// Obtain the service object
try {
serviceObj = device.getServiceObject("Service.Calendar",
"IDataSource");
} catch (ex) {
alert("Service object cannot be found.");
return;
}
listCalendars();
}
function listCalendars() {
try {
var filter = new Object();
// Not using the default calendar
filter.DefaultCalendar = false;
// Criteria for fetching calendars
var criteria = new Object();
criteria.Type = "Calendar";
criteria.Filter = filter;
// Get the list of calendars
result = serviceObj.IDataSource.GetList(criteria);
if (result.ErrorCode == 0) {
showCalendars(result.ReturnValue);
} else {
alert("Error in getting calendars");
}
} catch( exception ) {
alert("initialize error: " + exception);
}
}
function showCalendars(iterator) {
var calendarList = document.getElementById("calendarList");
// Empty the calendar list
while (calendarList.length != 0) {
calendarList.remove(0);
}
// Set the pointer to the first element
iterator.reset();
var item;
while ((item = iterator.getNext()) != undefined) {
var node = document.createElement("option");
node.value = item;
node.appendChild(document.createTextNode(item));
calendarList.appendChild(node);
}
}
Available calendars are displayed.
No related wiki articles found