Exporting and importing calendar events in Symbian Web Runtime
hamishwillee
(Talk | contribs) m (Hamishwillee - Add Abstract. Tidy wiki text) |
|||
| (14 intermediate revisions by 5 users not shown) | |||
| Line 1: | Line 1: | ||
| − | + | [[Category:Symbian Web Runtime]][[Category:Code Examples]][[Category:PIM]][[Category:S60 5th Edition]] | |
| − | + | {{Abstract|This code example demonstrates how to export and import calendar entries in Symbian Web Runtime, using the Calendar Platform Service (introduced in S60 5th Edition).}} | |
| − | {{ | + | |
| − | | | + | {{ArticleMetaData <!-- v1.2 --> |
| − | | | + | |sourcecode= [[Media:Listing calendars and events in WRT.zip]] |
| − | |devices=Nokia 5800 XpressMusic | + | |installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) --> |
| − | | | + | |devices= Nokia 5800 XpressMusic |
| − | | | + | |sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) --> |
| − | | | + | |platform= S60 5th Edition |
| − | | | + | |devicecompatability= <!-- Compatible devices (e.g.: All* (must have GPS) ) --> |
| − | + | |dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 --> | |
| + | |signing= <!-- Empty or one of Self-Signed, DevCert, Manufacturer --> | ||
| + | |capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. --> | ||
| + | |keywords= device.getServiceObject(), Service.Calendar.Import(), Service.Calendar.Export() | ||
| + | |language= <!-- Language category code for non-English topics - e.g. Lang-Chinese --> | ||
| + | |translated-by= <!-- [[User:XXXX]] --> | ||
| + | |translated-from-title= <!-- Title only --> | ||
| + | |translated-from-id= <!-- Id of translated revision --> | ||
| + | |review-by= <!-- After re-review: [[User:username]] --> | ||
| + | |review-timestamp= <!-- After re-review: YYYYMMDD --> | ||
| + | |update-by= <!-- After significant update: [[User:username]]--> | ||
| + | |update-timestamp= <!-- After significant update: YYYYMMDD --> | ||
| + | |creationdate= 20081210 | ||
| + | |author= [[User:Dekuykin]] | ||
| + | <!-- The following are not in current metadata --> | ||
| + | |id= CS001237 | ||
}} | }} | ||
| − | |||
==Overview== | ==Overview== | ||
| − | + | The {{Icode|device.getServiceObject("Service.Calendar", "IDataSource")}} method is used to obtain access to the service object for the Calendar Service API. | |
| − | + | The "Export" button handler uses the {{Icode|IDataSource.Export(criteria, callback)}} method from the Calendar Service API to export the selected calendar entries to the file. | |
| − | + | ||
| − | + | The "Import" button handler uses the {{Icode|IDataSource.Import(criteria, callback)}} method from the Calendar Service API to import calendar events from the file. | |
| − | + | The methods used for exporting and importing calendar entries are asynchronous. | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | To interrupt the execution of the asynchronous exporting or importing process, the method {{Icode|IDataSource.Cancel(criteria)}} is used. | |
| − | + | Its {{Icode|criteria}} parameter specifies the transaction ID of the asynchronous method to be canceled. | |
| − | + | ||
| − | + | ||
| − | + | ==Source: Relevant HTML components== | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | ==Source | + | |
<code xml> | <code xml> | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
<input type="radio" name="eventType" id="meeting" checked | <input type="radio" name="eventType" id="meeting" checked | ||
| − | + | onclick="showEntries();" /> | |
| − | + | <label for="meeting">Meetings</label><br /> | |
| + | |||
<input type="radio" name="eventType" id="anniversary" | <input type="radio" name="eventType" id="anniversary" | ||
| − | + | onclick="showEntries();" /> | |
| − | + | <label for="anniversary">Anniversaries</label><br /> | |
| − | <input type="radio" name="eventType" id="dayEvent" | + | |
| − | + | <input type="radio" name="eventType" id="dayEvent" | |
| − | + | onclick="showEntries();" /> | |
| + | <label for="dayEvent">Day Events</label><br /> | ||
| + | |||
<input type="radio" name="eventType" id="reminder" | <input type="radio" name="eventType" id="reminder" | ||
| − | + | onclick="showEntries();" /> | |
| − | + | <label for="reminder">Reminders</label><br /> | |
| + | |||
<input type="radio" name="eventType" id="toDo" | <input type="radio" name="eventType" id="toDo" | ||
| − | + | onclick="showEntries();" /> | |
| − | + | <label for="toDo">ToDos</label><br /> | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | < | + | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | </ | + | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | <br | + | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | = | + | <label for="entriesList">Entries:</label><br /> |
| + | <select size="2" id="entriesList"></select><br /> | ||
| − | < | + | <label for="fileSelection">File:</label><br /> |
| − | + | <p id="fileSelection"> | |
| − | + | C:\Data\Others\<input type="text" size="20" id="file" /> | |
| − | + | </p> | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | <p>File Type:</p> | |
| − | + | <input type="radio" name="fileType" id="iCal" checked /> | |
| − | + | <label for="iCal">ICal</label><br /> | |
| + | <input type="radio" name="fileType" id="vCal"> | ||
| + | <label for="vCal">VCal</label><br /> | ||
| + | |||
| + | <input type="button" id="export" onclick="exportEntry();" value="Export"> | ||
| + | <input type="button" id="import" onclick="importEntry();" value="Import"> | ||
| + | <input type="button" id="cancel" onclick="cancelAction();" value="Cancel"> | ||
| + | <br /> | ||
| + | <p id="state"></p><br /> | ||
</code> | </code> | ||
| − | ==Source | + | ==Source: JavaScript file== |
<code javascript> | <code javascript> | ||
| − | + | var serviceObj = null; | |
| − | + | ||
| − | var | + | // Contains current export or import transaction id value |
| − | // | + | |
var currentTransactionId = 0; | var currentTransactionId = 0; | ||
| − | + | 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() { | |
| − | + | // Showing entries is omitted here for brevity. Refer to the See also | |
| − | + | // section of the code snippet for more information. | |
| − | + | // ... | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | / | + | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
} | } | ||
/** | /** | ||
| − | + | * Imports all entries from the specified file to the calendar. | |
| − | + | */ | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | * Imports all entries from specified file to the calendar. | + | |
| − | */ | + | |
function importEntry() { | function importEntry() { | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
var criteria = new Object(); | var criteria = new Object(); | ||
| − | |||
criteria.Type = "CalendarEntry"; | criteria.Type = "CalendarEntry"; | ||
criteria.Data = new Object(); | criteria.Data = new Object(); | ||
| − | |||
| − | |||
| − | |||
| − | |||
| + | // Name of the file from which calendar events will be imported | ||
| + | var fileName = "C:\\Data\\Others" + document.getElementById("file").value; | ||
criteria.Data.FileName = fileName; | criteria.Data.FileName = fileName; | ||
// Get format of the file. | // Get format of the file. | ||
| − | if (document.getElementById( | + | if (document.getElementById("iCal").checked) { |
criteria.Data.Format = "ICal"; | criteria.Data.Format = "ICal"; | ||
} else { | } else { | ||
criteria.Data.Format = "VCal"; | criteria.Data.Format = "VCal"; | ||
} | } | ||
| − | + | ||
| + | // Import the data | ||
try { | try { | ||
| − | + | var result = serviceObj.IDataSource.Import(criteria, importCallback); | |
| − | var result = | + | |
| − | + | ||
// Store current transaction id to global variable | // Store current transaction id to global variable | ||
currentTransactionId = result.TransactionID; | currentTransactionId = result.TransactionID; | ||
| − | document.getElementById( | + | document.getElementById("state").innerHTML = "Importing..."; |
| − | + | } catch (ex) { | |
| − | + | alert("Error in importing entries: " + ex); | |
| − | + | ||
| − | } catch ( | + | |
| − | alert (" | + | |
} | } | ||
} | } | ||
| + | |||
/** | /** | ||
| − | * | + | * Callback function for import asynchronous call. |
| − | * | + | * @param transId A number representing the transaction that called the |
| − | */ | + | * callback handler. |
| − | function | + | * @param eventCode A number representing the callback return status. |
| − | + | * @param result An object for holding the callback return value | |
| − | + | */ | |
| − | // | + | function importCallback(transId, eventCode, result) { |
| − | + | // Check result of importing | |
| − | + | if (result.ErrorCode != 0) { | |
| − | + | alert("Error in importing: " + result.ErrorMessage); | |
| − | + | } else { | |
| + | alert("Data was imported successfully!"); | ||
} | } | ||
| − | // Get name of the selected | + | |
| − | var | + | document.getElementById("state").innerHTML = ""; |
| − | + | showEntries(); | |
| + | } | ||
| + | |||
| + | /** | ||
| + | * Exports the selected entries from calendar to file. | ||
| + | */ | ||
| + | function exportEntry() { | ||
| + | // Get the name of the selected entry | ||
| + | var entriesList = document.getElementById("entriesList"); | ||
var entryList = new Array(); | var entryList = new Array(); | ||
| − | for (var i = 0; i < | + | for (var i = 0; i < entriesList.length; i++) { |
| − | if ( | + | if (entriesList.options[i].selected) { |
| − | entryList[i] = | + | entryList[i] = entriesList.options[i].value; |
break; | break; | ||
} | } | ||
} | } | ||
| − | + | ||
| − | // Criteria indicating data to be exported and the destination file | + | // Criteria indicating the data to be exported and the destination file |
var criteria = new Object(); | var criteria = new Object(); | ||
criteria.Type = "CalendarEntry"; | criteria.Type = "CalendarEntry"; | ||
criteria.Data = new Object(); | criteria.Data = new Object(); | ||
| − | |||
criteria.Data.LocalIdList = entryList; | criteria.Data.LocalIdList = entryList; | ||
// Destination file name | // Destination file name | ||
| − | var fileLocalName = document.getElementById( | + | var fileLocalName = document.getElementById("file").value; |
// Check the file name correctness | // Check the file name correctness | ||
var regPattern = new RegExp("^[a-zA-Z]+\.?[a-zA-Z]+$"); | var regPattern = new RegExp("^[a-zA-Z]+\.?[a-zA-Z]+$"); | ||
| Line 378: | Line 188: | ||
} | } | ||
// Create full destination file name | // Create full destination file name | ||
| − | var fileName = "C:\\Data\\" + fileLocalName; | + | var fileName = "C:\\Data\\Others\\" + fileLocalName; |
criteria.Data.FileName = fileName; | criteria.Data.FileName = fileName; | ||
| − | // Set format of destination file. | + | // Set the format of the destination file. |
| − | if (document.getElementById( | + | if (document.getElementById("iCal").checked) { |
criteria.Data.Format = "ICal"; | criteria.Data.Format = "ICal"; | ||
} else { | } else { | ||
criteria.Data.Format = "VCal"; | criteria.Data.Format = "VCal"; | ||
} | } | ||
| − | + | ||
try { | try { | ||
| − | // Export the entries | + | // Export the selected entries |
| − | alert("Export | + | alert("Export begins"); |
| − | var result = | + | var result = serviceObj.IDataSource.Export(criteria, exportCallback); |
| − | + | ||
currentTransactionId = result.TransactionID; | currentTransactionId = result.TransactionID; | ||
| − | document.getElementById( | + | document.getElementById("state").innerHTML = "Exporting..."; |
| − | + | } catch (ex) { | |
| − | + | alert ("Error in exporting entries: " + ex); | |
| − | } catch ( | + | |
| − | alert (" | + | |
} | } | ||
} | } | ||
| + | |||
/** | /** | ||
| − | * | + | * Callback function for export asynchronous call. |
| + | * @param transId A number representing the transaction that called the | ||
| + | * callback handler. | ||
| + | * @param eventCode A number representing the callback return status. | ||
| + | * @param result An object for holding the callback return value | ||
| + | */ | ||
| + | function exportCallback(transId, eventCode, result) { | ||
| + | // Check result of exporting | ||
| + | if (result.ErrorCode != 0) { | ||
| + | alert("Error in exporting: " + result.ErrorMessage); | ||
| + | } else { | ||
| + | alert("Data was exported successfully!"); | ||
| + | } | ||
| + | |||
| + | document.getElementById("state").innerHTML = ""; | ||
| + | showEntries(); | ||
| + | } | ||
| + | |||
| + | /** | ||
| + | * Cancels the current action (exporting or importing). | ||
*/ | */ | ||
function cancelAction() { | function cancelAction() { | ||
| − | // Criteria determining transaction which to be canceled | + | // Criteria determining the transaction which is to be canceled |
var criteria = new Object(); | var criteria = new Object(); | ||
| − | // Get transaction id for transaction which to be canceled | + | // Get transaction id for the transaction which is to be canceled |
var transactionId = currentTransactionId; | var transactionId = currentTransactionId; | ||
if (transactionId == undefined) { | if (transactionId == undefined) { | ||
| − | + | return; | |
} | } | ||
criteria.TransactionID = transactionId; | criteria.TransactionID = transactionId; | ||
| − | // Cancel current action | + | // Cancel the current action |
var result = calendarServiceObject.Cancel(criteria); | var result = calendarServiceObject.Cancel(criteria); | ||
if (result.ErrorCode !== 0) { | if (result.ErrorCode !== 0) { | ||
alert("Cancel error: " + result.ErrorMessage); | alert("Cancel error: " + result.ErrorMessage); | ||
} | } | ||
| − | + | showEntries(); | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
} | } | ||
</code> | </code> | ||
| − | |||
==Postconditions== | ==Postconditions== | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| + | The selected calendar entries are exported into or imported from the file specified by the user. | ||
==Supplementary material== | ==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]] | ||
Latest revision as of 09:22, 5 October 2012
This code example demonstrates how to export and import calendar entries in Symbian Web Runtime, using the Calendar Platform Service (introduced in S60 5th Edition).
Article Metadata
Code Example
Tested with
Compatibility
Article
Contents |
Overview
The device.getServiceObject("Service.Calendar", "IDataSource") method is used to obtain access to the service object for the Calendar Service API.
The "Export" button handler uses the IDataSource.Export(criteria, callback) method from the Calendar Service API to export the selected calendar entries to the file.
The "Import" button handler uses the IDataSource.Import(criteria, callback) method from the Calendar Service API to import calendar events from the file.
The methods used for exporting and importing calendar entries are asynchronous.
To interrupt the execution of the asynchronous exporting or importing process, the method IDataSource.Cancel(criteria) is used. Its criteria parameter specifies the transaction ID of the asynchronous method to be canceled.
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 />
<label for="fileSelection">File:</label><br />
<p id="fileSelection">
C:\Data\Others\<input type="text" size="20" id="file" />
</p>
<p>File Type:</p>
<input type="radio" name="fileType" id="iCal" checked />
<label for="iCal">ICal</label><br />
<input type="radio" name="fileType" id="vCal">
<label for="vCal">VCal</label><br />
<input type="button" id="export" onclick="exportEntry();" value="Export">
<input type="button" id="import" onclick="importEntry();" value="Import">
<input type="button" id="cancel" onclick="cancelAction();" value="Cancel">
<br />
<p id="state"></p><br />
Source: JavaScript file
var serviceObj = null;
// Contains current export or import transaction id value
var currentTransactionId = 0;
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() {
// Showing entries is omitted here for brevity. Refer to the See also
// section of the code snippet for more information.
// ...
}
/**
* Imports all entries from the specified file to the calendar.
*/
function importEntry() {
var criteria = new Object();
criteria.Type = "CalendarEntry";
criteria.Data = new Object();
// Name of the file from which calendar events will be imported
var fileName = "C:\\Data\\Others" + document.getElementById("file").value;
criteria.Data.FileName = fileName;
// Get format of the file.
if (document.getElementById("iCal").checked) {
criteria.Data.Format = "ICal";
} else {
criteria.Data.Format = "VCal";
}
// Import the data
try {
var result = serviceObj.IDataSource.Import(criteria, importCallback);
// Store current transaction id to global variable
currentTransactionId = result.TransactionID;
document.getElementById("state").innerHTML = "Importing...";
} catch (ex) {
alert("Error in importing entries: " + ex);
}
}
/**
* Callback function for import asynchronous call.
* @param transId A number representing the transaction that called the
* callback handler.
* @param eventCode A number representing the callback return status.
* @param result An object for holding the callback return value
*/
function importCallback(transId, eventCode, result) {
// Check result of importing
if (result.ErrorCode != 0) {
alert("Error in importing: " + result.ErrorMessage);
} else {
alert("Data was imported successfully!");
}
document.getElementById("state").innerHTML = "";
showEntries();
}
/**
* Exports the selected entries from calendar to file.
*/
function exportEntry() {
// Get the name of the selected entry
var entriesList = document.getElementById("entriesList");
var entryList = new Array();
for (var i = 0; i < entriesList.length; i++) {
if (entriesList.options[i].selected) {
entryList[i] = entriesList.options[i].value;
break;
}
}
// Criteria indicating the data to be exported and the destination file
var criteria = new Object();
criteria.Type = "CalendarEntry";
criteria.Data = new Object();
criteria.Data.LocalIdList = entryList;
// Destination file name
var fileLocalName = document.getElementById("file").value;
// Check the file name correctness
var regPattern = new RegExp("^[a-zA-Z]+\.?[a-zA-Z]+$");
if (!(regPattern.test(fileLocalName))) {
alert("Incorrect file name: " + fileLocalName);
return;
}
// Create full destination file name
var fileName = "C:\\Data\\Others\\" + fileLocalName;
criteria.Data.FileName = fileName;
// Set the format of the destination file.
if (document.getElementById("iCal").checked) {
criteria.Data.Format = "ICal";
} else {
criteria.Data.Format = "VCal";
}
try {
// Export the selected entries
alert("Export begins");
var result = serviceObj.IDataSource.Export(criteria, exportCallback);
currentTransactionId = result.TransactionID;
document.getElementById("state").innerHTML = "Exporting...";
} catch (ex) {
alert ("Error in exporting entries: " + ex);
}
}
/**
* Callback function for export asynchronous call.
* @param transId A number representing the transaction that called the
* callback handler.
* @param eventCode A number representing the callback return status.
* @param result An object for holding the callback return value
*/
function exportCallback(transId, eventCode, result) {
// Check result of exporting
if (result.ErrorCode != 0) {
alert("Error in exporting: " + result.ErrorMessage);
} else {
alert("Data was exported successfully!");
}
document.getElementById("state").innerHTML = "";
showEntries();
}
/**
* Cancels the current action (exporting or importing).
*/
function cancelAction() {
// Criteria determining the transaction which is to be canceled
var criteria = new Object();
// Get transaction id for the transaction which is to be canceled
var transactionId = currentTransactionId;
if (transactionId == undefined) {
return;
}
criteria.TransactionID = transactionId;
// Cancel the current action
var result = calendarServiceObject.Cancel(criteria);
if (result.ErrorCode !== 0) {
alert("Cancel error: " + result.ErrorMessage);
}
showEntries();
}
Postconditions
The selected calendar entries are exported into or imported from the file specified by the user.
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.

