This article contains information about common issues that developers may encounter while building BlackBerry® WebWorks applications. By raising awareness about the root cause of these problems, developers can introduce habits and best practices into their daily development lives that will help reduce and/or avoid the occurrences of these issues.
- Unable to Access External Domains
- Unable to Access BlackBerry WebWorks API / JavaScript® Extension features
- Dealing with Runtime Errors
- Common JavaScript Language Issues
- Slow / Frozen BlackBerry WebWorks applications on BlackBerry® 6
- Accessing Embedded vs File System Resources
- Resource Name is Not valid
- BlackBerry Smartphone Simulator connection issues
Unable to Access External Domains
You must grant your BlackBerry WebWorks application permission to access any external domains. If you do not, the following error will occur when the application attempts to sent an HTTP request to that domain:
Domains can be white listed individually, or the wildcard * can be used to white list all domains.
HTML example:
1
Clicking this link<a> will cause the above error to occur if the domain "www.blackberry.com" is not white listed.</a>
1 2 3 4
<?xml version="1.0" encoding="UTF-8"?><widget xmlns="http://www.w3.org/ns/widgets" xmlns:rim="http://www.blackberry.com/ns/widgets" version="1.0.0.0"> <name>commonPitfalls</name> <access subdomains="false" uri="http://www.blackberry.com"/> <content src="index.html"/></widget> <a>
Unable to Access BlackBerry WebWorks API / JavaScript Extension Features
TypeError: Cannot convert ‘undefined’ to an object.
1 2 3 4 5 6 7
<a>function showName() { alert('App Name: ' + blackberry.app.name);</a>
<a> // The above example will produce a runtime error if the // "blackberry.app" feature is not whitelisted because the // JavaScript engine will evaluate "blackberry.app" to be // 'undefined' which can then not be used as an object // to evaluate the ".name" property}</a>
<a>
1
2
3
4
</a>
<?xml version="1.0" encoding="UTF-8"?><widget xmlns="http://www.w3.org/ns/widgets" xmlns:rim="http://www.blackberry.com/ns/widgets" version="1.0.0.0"> <name>commonPitfalls</name> <feature id="blackberry.app" required="true" version="1.0.0.0"/> <content src="index.html"/></widget>
Dealing with Runtime Errors
1
2
3
4
5
6
7
<a>function world(){ try { // Do some functionality - what happens if an exception occurs here? return 'World'; } catch { alert("Exception in 'world': " + e); }}function hello(){ try { // Do some functionality - what happens if an exception occurs here return 'Hello ' + world(); } catch { alert("Exception in 'hello': " + e); }}</a>
<a>//In the above example, if an exception occurs within the 'world' method// method, it will not bubble up to the hello method and the developer will // quickly be able to find the source of the problem.</a>
<a>alert(hello());</a>
JavaScript Language Issues
1
2
3
4
5
6
7
<a>function helloWorld(){ alert('hello world');}</a>
<a>//The following will generate an error since no method named "HelloWorld()" //has been defined;</a>
<a>HelloWorld();</a>
1
2
3
4
5
6
7
8
9
10
<a>function doSomething(){ alert(' ... something');</a>
<a>function doSomethingElse(){ alert(' ... something else');}</a>
<a>//The JavaScript engine will not recognize any of this script // since the doSomething() method is missing a closing parentheses</a>
<a>doSomething();doSomethingElse();</a>
1
2
3
4
5
6
7
<a>function notSupported(){ alert(blackberry.doesNotExist.propertyABC);}</a>
<a>//The code above will generate a runtime error when the JavaScript engine// tries to evaluate ".propertyABC". The reason why is because the// "blackberry" object does not have a child object named "doesNotExist".</a>
<a>notSupported();</a>
Slow / Frozen BlackBerry WebWorks Applications on BlackBerry 6
Accessing Embedded vs File System Resources
1
2
3
4
5
</p>
<p style="text-align: center;">This image is an embedded Resource: <img src="local:///embedded_image.png" height="16" width="16" /></p>
<p style="text-align: center;"><a>
1 2 3 4
This image is saved on the file system:<img src="file:///store/home/user/pictures/file_system.jpg" height="16" width="16" /> This image is saved on the removable SD card:<img src="file:///SDCard/BlackBerry/pictures/removable.jpg" height="16" width="16" />
Resource Name Is Not Valid
1
<a>BUILDING commonPitfallscmd.exe /c bbwp C:sandboxweb appscommonPitfallsbuildcommonPitfalls.zip /o C:sandboxweb appscommonPitfallsbuild[INFO] Parsing command line options[INFO] Parsing bbwp.properties[INFO] Validating widget archive[ERROR] Invalid widget archive - resource name is not valid(invalid-name.html)BUILD EXITED WITH 1 ERROR</a>
BlackBerry Smartphone Simulator Connection Problems
http://localhost
http://127.0.0.1
Related posts:




Recent Comments