widget element

Supported platforms

  • yes BlackBerry OS: 5.0 - 7.0
  • yes BlackBerry PlayBook OS: 2.0+
  • yes BlackBerry 10 OS

Syntax

<widget xmlns="http://www.w3.org/ns/widgets"
        xmlns:rim="http://www.blackberry.com/ns/widgets"
        version="string" 
        id="string"
        xml:lang="string"
        rim:header="string"
        rim:userAgent="string">
</widget>

Description

The <widget> element provides a container for all other elements, and it's the root element in the configuration document for a BlackBerry WebWorks application.

Parent elements

None

Child elements

Many. For a list of elements, see the Elements in config.xml table.

Occurrences

One, at the root of the configuration document.

Attributes

You can use the following attributes in the <widget> element:

Attribute Platform

xmlns="http://www.w3.org/ns/widgets"

Defines the namespace for the BlackBerry WebWorks application. If this namespace is missing, the application archive is not valid.

Required

  • BB OS 5.0 - 7.0
  • PB 2.0+
  • BB10

xmlns:rim="http://www.blackberry.com/ns/widgets"

Defines the namespace for the BlackBerry WebWorks extensions.

Required

  • BB OS 5.0 - 7.0
  • PB 2.0+
  • BB10

version

Specifies a valid version for the app, in one of the following formats:

For BlackBerry PlayBook OS and BlackBerry 10 OS use the following:
  • x.x.x
  • x.x.x.x
For OS 5.0 - 7.0, use the following:
  • x.x
  • x.x.x
  • x.x.x.x

If you specify a version number that is not valid, the application archive is not valid.

Required

  • BB OS 5.0 - 7.0
  • PB 2.0+
  • BB10

rim:header

Specifies an HTTP header value that precedes every request for data that the application sends. This attribute allows you to distinguish between requests sent from your BlackBerry WebWorks application and those coming from the BlackBerry Browser. The attribute value can be any string.

Optional

  • BB OS 5.0 - 7.0
  • BB10

rim:userAgent

Specifies the value for the user agent. The value that you specify is sent as the value of the User-Agent header, which is included with every HTTP request. You can use this string to identify requests coming from your app. The attribute value can be any string.

Optional

  • BB10

rim:backButton

Specifies the behavior for the Back button on the BlackBerry smartphone. If you specify this attribute with a value of exit, the Back button exits the application.

By default, the Back button displays the previous screen.

Optional

  • BB OS 5.0 - 7.0

id

Specifies a unique identifier for the application.

Unless you are repackaging an app from another platform, you should use a reverse DNS format for all platforms, for example, id="com.somedomain.HelloWorld".

BlackBerry 10 OS

The id attribute is required. If you resubmit an application to BlackBerry World that was initially packaged using a previous version of the BlackBerry WebWorks SDK, the value you specify for this attribute must be the same as the value for the Package-Name in your existing application's .bar MANIFEST file (for example, sampleApp6d5d8d2973ab439a52d274dffa2b018). You can access the MANIFEST file by unzipping the .bar file and viewing it in any text editor.

BlackBerry PlayBook OS

The id attribute specifies a unique identifier for the application. If you are resubmitting your application to BlackBerry World with a different archive file name, the value you specify for the id attribute must match the name of the archive file (without the file extension) that you previously submitted. The id attribute is optional if the archive file name matches the name of the previously submitted archive file.

BlackBerry OS 5.0 - 7.0

For BlackBerry smartphone applications running BlackBerry 7 or earlier, this attribute is informational only. Applications you resubmit to BlackBerry World must use a file name that matches the archive file that you previously submitted.

  • BB OS 5.0 - 7.0
  • PB 2.0+
  • BB10

xml:lang

Specifies the language that is used in the element. For more information about this attribute, visit www.w3.org.

Optional

  • BB OS 5.0 - 7.0
  • PB 2.0+
  • BB10

Examples

For BlackBerry 10:

<widget xmlns="http://www.w3.org/ns/widgets"
        xmlns:rim="http://www.blackberry.com/ns/widgets"
        version="2.0.0.0" 
        id="sampleapp"
        rim:header="RIM-Widget:rim/widget"
        rim:userAgent="BlackBerry10/MyWebWorksApp">
</widget>

For BlackBerry PlayBook OS:

<widget xmlns="http://www.w3.org/ns/widgets"
        xmlns:rim="http://www.blackberry.com/ns/widgets"
        version="2.0.0.0"
        xml:lang="en">
</widget>

For BlackBerry 7 or earlier:

<widget xmlns="http://www.w3.org/ns/widgets"
        xmlns:rim="http://www.blackberry.com/ns/widgets"
        version="2.0"
        rim:header="RIM-Widget:rim/widget">
</widget>

Last modified: 2013-05-06