Creating a WebWorks project

You can use the BlackBerry 10 WebWorks SDK web tool or command-line interface to create a project.

A new project includes all the basic resources required to function as a complete app. The folder structure of a project includes a www folder. This folder is the working directory for your app. All project resource files should be stored in the www folder, or in the appropriate subfolder. See Folder structure of a WebWorks project for the complete folder structure of a WebWorks project.

By default, your app has no access to any of the Cordova or WebWorks APIs. You need to add plugins to access the functionality you want your app to have. For more information about plugins and how to add them, see Adding and removing plugins.

Create a WebWorks project using the SDK web tool

To create a BlackBerry WebWorks project using the BlackBerry 10 WebWorks SDK web tool:

  1. Open BlackBerry WebWorks <version>. A new browser window opens, displaying the BlackBerry 10 WebWorks SDK web tool.
  2. In the navigation panel, click [+] beside the Projects heading.
  3. In the Project Name field, enter your application's name.
  4. In the Project Path field, enter a project path.
  5. Click Create.

Create a WebWorks project from the command line

If you choose, you can create a WebWorks project from the command line instead of from the BlackBerry 10 WebWorks SDK web tool. If you create a project from the command line, the project is not initially available in the web tool. However, you can import your project into the web tool at any time. For more information, see Importing a WebWorks 2.0 project into the SDK web tool.

To create a WebWorks project:

  1. On the command line, navigate to the folder where you installed the BlackBerry WebWorks SDK.
  2. Run the following command to create a WebWorks project:
    webworks create <path> [<app-id>] [<app-name>]
For example, the following command creates a project called My App in the c:\webworks-apps\myapp folder:
webworks create c:\webworks-apps\MyApp com.mycompany.myapp "My App" 

Check the table below for parameter details:

Parameter Description
<path>

Specifies the home folder for your project. The tool creates this folder for you and does not overwrite an existing folder; if you specify an existing folder, the project is not created.

<app-id>

Specifies a unique identifier for the app. If provided, this value is used to populate the id attribute of the config.xml <widget> element.

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".

This parameter is optional.

<app-name>

Specifies the name for the app. To specify a name with spaces in it, enclose the value in quotation marks ("). If provided, this value is used to populate the <name> element in the config.xml file.

This parameter is optional.

Once your project is created, you may want to edit the configuration information, for example, to specify a particular orientation or background color. For more information, see Modifying your app configuration.

Folder structure of a WebWorks project

A WebWorks 2.0 project has the following folder structure:

Folder Description
project_root/

This folder is the root folder, which you specify when you create your project. This folder contains the master config.xml file.

www/

This folder contains all your project resources, including the index.html file, which is the starting page for your app. It also contains subfolders for various resources, including CSS and JavaScript files, as well as any other resources you might add.

merges/

This folder contains platform-specific resources. It should contain a subfolder for each platform you are creating your app for, which contains a duplicate of the /www folder structure.

For example, you can store a platform-specific JavaScript file in the project_root/merges/blackberry10/www/js subfolder. When you build the app for BlackBerry 10, that JavaScript file is used in place of the JavaScript file of the same name in the project_root/www/js folder.

platforms/

The SDK uses this folder to maintain platform-specific versions of your project.

A blackberry10 folder is automatically created in this folder, and you can add folders for additional platforms, such as Android or iOS.

When you build your app for a specific platform, the contents of the www/ folder are copied to the appropriate platform-specific folder.

plugins/

This folder contains any plugins you add to your project. By default, this folder is empty.

For more information on plugins, see Adding and removing plugins.

.cordova/

This folder contains Cordova-specific configuration files.

Importing a WebWorks 2.0 project into the SDK web tool

There are instances where an existing WebWorks project is not available from within the WebWorks SDK web tool. For example, projects that you create from the command line are not displayed in the web tool. In additions, all WebWorks project content that appears in the tool is stored in browser cookies; deleting these cookies removes the project data from the web tool.

You can import a WebWorks 2.0 project into the web tool at any time. To import an existing project into the web tool:

  1. On the Start menu, click BlackBerry >BlackBerry WebWorks <version>. A new browser window opens, displaying the BlackBerry 10 WebWorks SDK web tool.
  2. In the navigation panel, click the arrow icon beside the Projects heading.
  3. In the Project Path field, enter the complete path to the project.
  4. Click Open.

Last modified: 2014-09-29



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus