Skip to page content
Secretary of Labor Hilda L. Solis

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.

Select Workspace


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.

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

Create BlackBerrt Project


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.

Add SDK File,Import SDK files into Project

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

Import SDK using General > File System option

Choose the root path and click ok.

Choose root path


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.

Add Service Reference


For the DOL Service Operation sample please use http://api.dol.gov/V1/SummerJobs

Locate Dataset Location path from Dataset, for Summer Job Plus 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.

Add Button Code

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

Add Button Code




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 :

Add Button Code to place DOL Data Request logic


For DOL service operation :

Add Button Code to place DOL Data Request logic 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 :

Add Button Code to  iterated through results of the DOL Data API and create label for each item in result list.

For DOL service operation:

Add Button Code to  iterated through results of the DOL Service API and create label for each item in result list.

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

Add Button Code to handle 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.

Configure SDK

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 :

Run application and screen should display list of Agencies

For DOL service operation :

Run application and screen should display list of jobs