Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Listing calendar entries in Symbian Web Runtime

From Wiki
Jump to: navigation, search
Article Metadata
Code ExampleTested with
Devices(s): Nokia 5800 XpressMusic
Compatibility
Platform(s): S60 5th Edition
S60 5th Edition
Article
Keywords: device.getServiceObject(), Service.Calendar.GetList()
Created: ivruban (10 Dec 2008)
Last edited: hamishwillee (04 Oct 2012)

Contents

Overview

This code snippet shows how to list calendar entries using the Calendar Platform Service for Symbian Web Runtime. The service was 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.

Source: Relevant HTML components

<input type="radio" name="eventType" id="meeting" checked
onclick="showEntries();">
<label for="meeting">Meetings</label><br />
 
<input type="radio" name="eventType" id="anniversary"
onclick="showEntries();">
<label for="anniversary">Anniversaries</label><br />
 
<input type="radio" name="eventType" id="dayEvent"
onclick="showEntries();">
<label for="dayEvent">Day Events</label><br />
 
<input type="radio" name="eventType" id="reminder"
onclick="showEntries();">
<label for="reminder">Reminders</label><br />
 
<input type="radio" name="eventType" id="toDo"
onclick="showEntries();">
<label for="toDo">ToDos</label><br />
 
<label for="entriesList">Entries:</label><br />
<select size="2" id="entriesList"></select><br />

Source: JavaScript file

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;
}
}
 
function showEntries() {
var criteria = new Object();
var filter = new Object();
if (document.getElementById("meeting").checked) {
filter.Type = "Meeting";
} else if (document.getElementById("anniversary").checked) {
filter.Type = "Anniversary";
} else if (document.getElementById("dayEvent").checked) {
filter.Type = "DayEvent";
} else if (document.getElementById("reminder").checked) {
filter.Type = "Reminder";
} else if (document.getElementById("toDo").checked) {
filter.Type = "ToDo";
}
criteria.Filter = filter;
criteria.Type = "CalendarEntry";
 
// Get the list of entries
try {
var result = serviceObj.IDataSource.GetList(criteria);
if (result.ErrorCode == 0) {
displayEntries(result.ReturnValue);
} else {
alert("Error in getting calendar entries.");
}
} catch(exception) {
alert("Error in getting calendar entries: " + result.ErrorMessage);
}
}
 
function displayEntries(iterator) {
var entriesList = document.getElementById("entriesList");
 
// Empty the entries list
while (entriesList.length != 0) {
entriesList.remove(0);
}
 
// Set the pointer to the first element
iterator.reset();
 
var item;
while ((item = iterator.getNext()) != undefined) {
var msg = "";
msg = msg + "Type: " + item['Type'];
msg = msg + "Summary: " + item['Summary'];
// The commented code shows available fields that can be retrieved
//msg = msg + "StartTime: " + item['StartTime'];
//msg = msg + "EndTime: " + item['EndTime'];
//msg = msg + "Id: " + item['Id'];
//msg = msg + "LocalId: " + item['LocalId'];
var node = document.createElement("option");
node.value = item['LocalId'];
node.appendChild(document.createTextNode(msg));
entriesList.appendChild(node);
}
}

Postconditions

Available calendar entries are displayed.

Supplementary material

You can view the source file and executable application in the attached ZIP archive. The archive is available for download at Media:Listing calendars and events in WRT.zip.

See also

Listing calendars in Symbian Web Runtime

This page was last modified on 4 October 2012, at 05:24.
80 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×