×
Namespaces

Variants
Actions

Display error text in WRT

From Nokia Developer Wiki
Jump to: navigation, search


Article Metadata
Tested with
Devices(s): Nokia 5800 XpressMusic
Compatibility
Platform(s): S60 5th Edition
Article
Keywords: widget.setNavigationEnabled(), device.getServiceObject(), Service.IAppManager.LaunchDoc()
Created: ivruban (28 Jan 2009)
Last edited: hamishwillee (05 Jul 2012)


Contents

Overview

This code snippet shows how to use methods Java Script for displaying error text using widget.
To obtain error used IAppManager.LaunchDoc(). Error appears because of there was not set correct value for loCriteria.Document.DocumentPath.
To use IAppManager.LaunchDoc() correctly, please see MIME type handling in WRT snippet.

To obtain access to service object for the AppManagement Service API, method getServiceObject("Service.AppManager", "IAppManager") used.

After used function IAppManager.LaunchDoc().

Source file: Relevant HTML components

<input type="button" value = "Get error" 
onclick = "getError();"></input>

Source file: JavaScript file

//Object available through a Service API. Declare service object, that is
//used to access the services.
var serviceObject = null;
 
window.onload = init;
 
// Initializes the widget
function init() {
try {
//Disabling navigation, cursor will not be shown.
widget.setNavigationEnabled(false);
//Getting service object.
serviceObject = device.getServiceObject("Service.Messaging",
"IMessaging");
} catch(exception) {
alert("exception: " + exception);
}
}
 
 
function launchDocument() {
try {
//Getting service object for application managment.
var lo = device.getServiceObject("Service.AppManager", "IAppManager");
} catch (ex) {
alert("exception: " + ex);
}
//Criteria for application managment's launch document function
var loCriteria = new Object();
//Object for Document memmber of criteria
loCriteria.Document = new Object();
//Opening the file in standalone application
try {
var res = lo.IAppManager.LaunchDoc(loCriteria);
document.getElementById("result").innerHTML = res.ErrorMessage;
} catch(ex){
alert("exception: " + ex);
}
}
 
function getError() {
launchDocument();
}

Postconditions

Snippet shows error in text area. Click "Get error" button to apper a error.

Supplementary material

  • You can test the displaying error text in action in a simple, executable application into which this code snippet has been patched. The executables and source files are available for download at: Media:DisplayErrorText.zip.
  • You can examine all the changes that are required to implement the above mentioned features in an application. The changes are provided in unified diff and color-coded diff formats: link_to_patchs
This page was last modified on 5 July 2012, at 05:42.
47 page views in the last 30 days.
×