×
Namespaces

Variants
Actions
(Difference between revisions)

Listing calendars in Symbian Web Runtime

From Nokia Developer Wiki
Jump to: navigation, search
Forum Nokia KB (Talk | contribs)
Forum Nokia KB (Talk | contribs)
Line 3: Line 3:
 
{{KBCS}}
 
{{KBCS}}
 
{{CodeSnippet
 
{{CodeSnippet
|id= 
+
|id=CS001278
 
|platform=S60 5th Edition
 
|platform=S60 5th Edition
 
|devices=Nokia 5800 XpressMusic
 
|devices=Nokia 5800 XpressMusic
 
|category=Web Runtime (WRT)
 
|category=Web Runtime (WRT)
 
|subcategory=PIM
 
|subcategory=PIM
|creationdate=January 14, 2009
+
|creationdate=January 20, 2009
 
|keywords=device.getServiceObject(), Service.Calendar.GetList()
 
|keywords=device.getServiceObject(), Service.Calendar.GetList()
 
}}
 
}}
Line 16: Line 16:
 
This code snippet shows how to list calendars by using the Calendar Platform Service for S60 Web Runtime introduced in S60 5th Edition.
 
This code snippet shows how to list calendars by using the Calendar Platform Service for S60 Web Runtime introduced in S60 5th Edition.
  
To obtain access to the service object for the Calendar Service API, the <tt>device.getServiceObject("Service.Calendar", "IDataSource")</tt> method is used.
+
The <tt>device.getServiceObject("Service.Calendar", "IDataSource")</tt> method is used to obtain access to the service object for the Calendar Service API.
  
 
==Source: Relevant HTML components==
 
==Source: Relevant HTML components==
Line 96: Line 96:
 
==See also==
 
==See also==
  
[[Listing calendar entries]]
+
[[CS001244 - Listing calendar entries in WRT]]
  
 
[[Category:Web Runtime (WRT)]][[Category:Code Examples]][[Category:PIM]][[Category:S60 5th Edition]]
 
[[Category:Web Runtime (WRT)]][[Category:Code Examples]][[Category:PIM]][[Category:S60 5th Edition]]

Revision as of 11:18, 20 January 2009


Template:KBCS

Article Metadata
Tested with
Devices(s): Nokia 5800 XpressMusic
Compatibility
Platform(s): S60 5th Edition
S60 5th Edition
Article
Keywords: device.getServiceObject(), Service.Calendar.GetList()
Created: (20 Jan 2009)
Last edited: Forum Nokia KB (20 Jan 2009)

Overview

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.

Source: Relevant HTML components

<label for="calendarList">Calendars:</label><br />
<select size="2" id="calendarList" onclick="showEvents();"></select>

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;
}
 
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);
}
}

Postconditions

Available calendars are displayed.

See also

CS001244 - Listing calendar entries in WRT

88 page views in the last 30 days.
×