BlackBerry DOL Data SDK Sample
Overview
This sample will provide the steps to create a simple BlackBerry application that can consume DOL Data.
Following these steps in order will allow your application to operate correctly.
Download this project |
Download project for Service Operation.
This solution was built using:
- Eclipse JEE Helio SR2 windows 32
- JDK
- BlackBerry SDK
- BlackBerry JRE 5.0.0 - The BlackBerry JRE is included in the BlackBerry SDK. This is the JRE version this application will need to build correctly.
Download BlackBerry SDK
Installation instructions are provided in detail here to setup a BlackBerry development environment.
After installation it is important to follow the steps for installing plug-in updates and additional components. This page will be visible in the Eclipse startup screen.
Create a New Project
For this sample we are going to create a new BlackBerry application that will consume and list Agency data.
Start by creating a new workspace or selecting a workspace of your choice.
Then open a new project by Clicking File > New Project > BlackBerry Project.

You will need to provide information in order to proceed.
- Choose a project name; this will be displayed as the root item in your project.
For this project, BlackBerry JRE 5.0.0 platform has been used.
Currently BlackBerry JRE 6.0.0 and 7.0.0 are not supported.

Add SDK to Project
All requests require account credentials to be submitted along with the request.
This SDK contains a few classes needed to process service requests.
This package needs to be imported into your project.

Import the BlackBerry_DOLDataSDK into your project using the General > File System option.

Choose the root path and click ok.

Locate the Dataset Path
Each Dataset has a Dataset Location path that gives the URL that will be needed to reach the Dataset on the API. For this sample please see the one circled in red.

For the DOL Service Operation sample please use http://api.dol.gov/V1/SummerJobs
Define the User Interface
BlackBerry allows developers to add UI Components to the main screen programmatically.
By Creating a ButtonField member variable in this application, users will be able to invoke a call to the DOL Data API.
We will implement the FieldChangeListener to handle the button click events.
We will also implement the DOLDataRequestCallBack to handle request made to the DOL Data API.

Implementation for initializing this button is placed in the class constructor to be executed only once.

Implementing the DOL Data Request
DOL Data Request logic has been placed in the fieldChanged method to respond to the button's click event.
The String method variable represents the Dataset and the table portion of the Data location path.
-Format( Dateset/Table) i.e. "DOLAgency/Agencies", "FORMS/AgencyFormsTable", "FAQ/Topics", "FAQ/SubTopics".
*Please Note: these paths are case sensitive, please refer to the corresponding Datasets for the correct formats.
For DOL API dataset :

For DOL service operation :

The results from the request are implemented in the DOLDataResultsCallBack method. The request results of the DOL Data API are iterated through and a label is created for each item in the list.
For DOL API dataset :

For DOL service operation:

Requests resulting in error, are sent to the DOLDataErrorCallBack method with information pertaining to the error.

Configure Security
Secure logins are provided using the following code; we will need to modify both the ApiKey and the SharedSecret members of the DolDataMainScreen class.
Add members to the DolDataMainScreen class within the DolDataMainScreen.java file.
- The ApiKey corresponds to the Token identifier in your token list.
- The SharedSecret created during setup is the same value that is used in the DOLDataUtil class.

Run the Application
If you are not using a BlackBerry device, you will need to run this application in the Simulator.
Press F11 or Run > Debug to run this application in debug mode. You will be prompted to choose either a BlackBerry Device or Simulator.
When the Simulator is fully active, goto the Downloads icon in the menu and click on the application to run.
A list of Agencies should be displayed on the screen.
For DOL API dataset :
For DOL service operation :