Complete Bill Buchan Article on Mobilizing Domino Applications onto BlackBerry Handsets


The LotusUserGroup.org Developer Tips Newsletter is written by two world-class Lotus develoment experts, Jessica Stratton and Thomas "Duffbert" Duff. The newsletter provides you with valuable code, tips, techniques, time-savers, insights, and more to make your job easier, improve your skills, and brighten your career. As a special feature invited guest author Bill Buchan, of HADSL (and the famed Wild Bill Buchan Blog) has been contributing an article on mobilizing Domino applications onto BlackBerry handsets. If you're not a subscriber to the Development Tips Newsletter, update your profile to include the monthly newsletter.

Check out each part of the article below to get the fundamentals of publishing Domino data onto a BlackBerry handset, capitalize on the BlackBerry MDS Studio, discover tips for enhancing applications, learn the process of deploying applications to your corporate BlackBerries, and dive into the more advanced BlackBerry development tool - the JDE.




Part 2
Mobilizing Domino Applications onto Blackberry Devices

September/2007

  
Mobilizing Domino Applications onto Blackberry Devices
Part 2: Advanced MDS Programming
by Bill Buchan

Table of contents

  1. Introduction


  2. Advanced MDS Applications
    1. Web Services and Complex Return Structures
    2. Displaying Collections
    3. Chaining Requests
    4. More GUI work
    5. Creating a Style
    6. Assigning a Style
    7. Some Thoughts on Architecture

  3. Deploying MDS Applications
    1. Deploying the MDS Runtime environment
    2. Deploying MDS Applications

  4. Appendix A - Some Notes on Making Management Simpler


  5. Appendix B - Using the Simulator Against A Live BES Server

Download Bill's original .pdf version of this article here!
(850 kb)



 
 1. Introduction
  

In the previous article we covered:

  • BlackBerry architecture


  • Web service basics with Domino


  • Basic BlackBerry MDS applications

In this article, we'll take our very basic BlackBerry application and make it far more useful, as well as improve the user interface. We'll also discuss how to deploy BlackBerry MDS applications to your live BES servers, and ultimately to your handsets.

The final article in this series will deal with building applications using the far more comprehensive (but more difficult) Java Development Environment (JDE).

Return to Top
 
SPONSORED BY BLACKBERRY
 
Read this new white paper for an overview on effectively creating BlackBerry® applications that interact with Domino databases. If you have experience developing for Domino, you've already got all the skills you need! This overview document includes a sample application to help you get started quickly and easily. Download now at http://www.blackberry.com/go/techbrief.
 
2. Advanced MDS Applications
  

In the previous article, we discussed using very simple Web services - Web services that would only return primitive data structures such as a single string, number, and so forth.

If we had to build all our applications only using simple return structures such as this, the applications would not be that useful. Let's now discuss returning far more interesting information from our Web service.

2.1 Web Services and Complex Return Structures

A limitation with LotusScript (and the Basic language in general) is that we can only return one "thing" at a time. That thing might be:

  • A simple (or primitive) data item such as a string, number, or so forth


  • A variant containing just about anything


  • An instance of a class

A limitation of Web services is that the Variant data type is not supported - hardly surprising as it would be an almost impossible exercise to come up with data structures that deal with all possible variant contents.

This leaves us with our last option, which is returning an instance of a class.

As you recall from the last article, a class is a LotusScript construct that allows you to bind data and functions together. In terms of classes that are exposed to Web services (within the "Web service" design type in Notes/Domino 7), all public functions are exposed to Web services.

For example, our simple class:

As this class is exposed to Web services, we have a very simple Web service that exposes a single function that, in turn, returns a single string. This isn't very useful at this point in time.

The next function we shall implement is to list all users in our database. This will return zero or more user names in a string array.

But as previously discussed, we cannot return collections (such as arrays or lists) directly from a LotusScript function, and we cannot put them into a Variant data type.

The solution is to construct another class:

As you can see, this class contains just one public member - the String array "S." (In terms of best practices, this is a pretty horrible naming strategy I know, but it does keep the code examples readable.)

Now, within our new function in our "Contact" class, we can have the function:

This will then be returned by the Web service as class returnStringArray, which in turn just contains an array of strings. Most Web service consumers (and certainly the BlackBerry MDS toolkit) will immediately resolve this to a string array

All we now have to do is populate this string array:

And that's it. We've populated a string array with a value from each document in our view, and returned that function. That wasn't as hard as it sounded!

If we take this one step further, instead of passing back just a string array, we can pass back a more detailed structure. For instance, consider the "Contact" class

We could then return this as a Web service return result by:

2.2. Displaying Collections

Now that our Web service has been updated, we can refresh our BlackBerry application. This will then recognize these new methods, and add in relevant screens and data definitions.

Now that we have our new Web service functions in place, let's go off and refresh our BlackBerry MDS application to incorporate these functions.

  1. Open the BlackBerry MDS Studio and expand our project. Expand the "Data Sources" entry, and select the entry for the Web service. Right click the Web service and select "Data Source Update."
  1. You will be prompted to confirm the Web site address
  1. Our new operations are updated. On this dialog box, select the entry in the "Action for MDS Components" column and change it from "Ignore" to "Bind with QuickStart"

    Click the "Finish" button to complete this operation.
  1. We should now find a number of new screens in our application that we can now work with. As before, the screens have been built using a standard graphical look and feel and need to be updated. Use the actions in the previous article to refresh the following screens:
  • scrLISTUsersResponse


  • scrGETUSERDETAILSResponse
 
  1. Let's open screen scrLISTUSERResponse.
  1. As you can see, a radio button has been added automatically to this screen, and has the initial value "@gLISTUSERResponseArray[]." Basically this means that the results of the Web service "List Users" function will then populate this radio button.
 

2.3 Chaining Requests

I use the phrase "Chaining Requests" in order to indicate that the user should use the results of one operation - perhaps searching for a user in order to get a username - in order to execute a second operation, such as requesting more information on that user.

The BlackBerry MDS toolkit makes this very simple for us by holding the parameters and the results for all Web service operations in global variables within the application. This means that we can easily direct the output of one operation to the input of the next.

We'd like to link the user selection from the button on the LISTUsersResponse screen to the GetUserDetails operation. How can we do that?

It's simply a case of mapping the output of the radio button to a global variable, and then changing the button to run the "GetUsersDetails" operation.

  1. Open the scrLISTUsersResponse screen.
 
  1. Click the radio button, and then click the button on the mapping field in the properties box.

    We can now select a global variable to put the output into.

    As you can see, global variables have already been defined as part of the process of importing the Web service definition, and each operation input and output is defined using a naming convention.

    In this case, we shall select gGETUSERDETAILSRequest - "g" for Global, the name of the operation, and "Request" for an input.
  1. Lastly, let's change the "Done" button to "Select," and change the button action from opening a screen to running a script. Select the "Done" button and in the properties window:

    1. Change the caption.


    2. Click the On Click event, and change the event from a screen transition to run a script. In the Script drop-down box, choose the script GETUSERDETAILSRequest


2.4 More GUI work

So far, we've restricted ourselves to using the standard fonts and colors in our applications, which doesn't give our application the required feel.

One good thing about the MDS Studio is that it allows you to define a style for a piece of text, and apply that style throughout the application. This means that if you have to change your font, size, color, etc., you won't have to go hunting through all the screens to update them.

2.4.1 Creating a Style

In order to create a style:

  1. Expand your application browser on the left hand pane, and right click "Styles."
  1. Assign this style a name. In this case, let's define how our label text will appear.

    Enter "Labels" in the name field, and click on "Finish."
  1. In this case, we're going to change the foreground color of the text from black to dark-grey.

2.4.2 Assigning a Style

To assign a style, we need to select a screen element.

  1. Open screen scrFINDUSERRequest and click the "SEARCHSTRING" label element.
  1. On the right-hand property box, click the Style property and select "Labels" from the drop-down list.
  1. You can now choose one of the styles you created earlier.

And that's all there is to it!

2.5 Some Thoughts on Architecture

You are not restricted to a single Notes database in terms of the reach of the code you put behind your Web service.

Remember that we can write a Web service server in Notes and have it execute any piece of LotusScript, which can include opening other databases. This means that you may wish to write one Web service that consolidates information for one set of Web service requests from many databases, thus simplifying the Web service output.

Or you may wish to write your Web service in a separate database, in order to take advantage of a different ACL, or because you may not be able to update the application itself.


Return to Top
 
3. Deploying MDS Applications application
  

Deploying your MDS application requires quite a bit of work. In order to deploy MDS applications, the MDS Runtime must be installed on each handset.

It is possible to visit each users desk and manually install the MDS Runtime using the desktop manager application, but that negates the whole "over the air" philosophy of a BlackBerry.

BlackBerry Enterprise server has the ability to deploy applications, including the BlackBerry MDS Runtime application.

Your BlackBerry Administrator may have already set up this facility, in which case it's just a case of bribing him requesting that the MDS Runtime application be deployed.

If this is not the case, then the first section of this chapter will lead you through the process of setting up your BES server to deploy applications.

3.1 Deploying the MDS Runtime environment

The BlackBerry Administrator (or the person who manages the BES server) has to perform a number of operations in order to deploy applications over the air. All of these operations are carried out on the BES server that the user normally connects to, which means that if you have multiple BES servers, then this must be carried out on multiple machines.

You should research this activity in the current BlackBerry Administration manual - You may be running a slightly newer version of BES than I (I'm using BES 4.1.3) and the instructions may have changed. The "Making additional BlackBerry device software and applications available to users" section is a good starting point.

There is also an architectural consideration. As this stage uses a shared drive in order to pick up the software, you may choose to only create a single shared area on one BES server and then point all other BES servers at this area. This keeps the deployment of a consistent set of applications relatively straightforward, but does build in the requirement that this server should always be available. A more robust (but more work-intense) method of performing this is to create a shared area on each BES server, and in this manner, allow a more robust service. In this case, we shall assume that you are creating a shared area on each BES server.

1. The first stage is to create the relevant directory structure and fileshare on the BES server. To do this, start explorer and then:
a. Navigate to the "C:\Program Files\Common Files\Research In Motion" directory. This may be on a different drive letter depending on how your BES server was installed.  
b. Create a "Shared" subdirectory directory and a subdirectory of "Shared" called "Applications."  
c. Create a subdirectory under Applications for the MDS Runtime environment. I used the directory name "MDS."  
d. We should now see a folder:
c:\Program Files\Common Files\Research In Motion \Shared\Applications\MDS
e. Right click the C:\Program Files\Common Files\Research In Motion directory, and choose "Sharing and Security."
f. Enter a Share name - I chose "BlackBerryApps" - and then click the "Permissions" button.
g. In this case, I've left the default share permissions as "Read" for all users. Your network or file server administrator should be able to advise you on the correct share permissions for your environment. Click "OK" to continue.
h. Once you have completed this step, you should see that the "Research in Motion" folder now has a hand sharing icon associated with it, indicating a fileshare
2. Obtain the latest BlackBerry MDS Runtime from the BlackBerry Web site.
a. Extract the downloaded file into our "MDS" directory created in Step 1.  
b. Start a "Cmd" window by clicking the start button, and selecting run. Then enter "cmd."
c. Change the directory to "C:\program files\common files\research in motion\apploader."  
d. Run the command "loader.exe /index"
3. Start the BlackBerry Enterprise Server management application on the BES server.
a. Click the "BlackBerry Domain" top-level element on the left-hand navigator.
b. On the right-hand pane, click the "Software Configurations" tab.
c. On the bottom right hand pane, choose "Add New Configuration."
d. On the pop-up dialog box, enter a name and description for this configuration. Then click the "Change" button.
e. Now you should enter the UNC path to the "c:\Program Files\Common Files\Research In Motion" directory using the share name you created earlier. In my case, my host name is called "Bluewave01", so my UNC would be "\\Bluewave01\BlackBerryApps."
f. The BlackBerry MDS Runtime should now appear on the Application Software list. It's important to enable this software package by selecting the check box, and changing the deployment method from "Wireline" (that is, plugged into USB) to "Wireles" (over the air).
g. Click "OK" to save this software configuration.  
4. Now we should apply this software configuration to one or more devices. This can be done directly to each device or by assigning this software configuration to a policy or group.

In this case, for simplicity, I shall just assign this software configuration to a single device.
a. Select a user to assign this software configuration to.  
b. On the right-hand bottom navigator, choose "Device Management," and then "Assign Software Configuration."
c. You can now choose which software configuration to assign to this user. Choose the software configuration that you chose in the earlier steps.
5. The BES server will now push this application to the selected user. After a period of time, the user should see the MDS Runtime application on their BlackBerry.
a. Note that in some instances I found that the "BlackBerry Policy Service" windows service was not running. If this is the case, start this service.  
b. You can monitor what the policy service is doing by examining the Policy Log file. This is located in the C:\Program Files\Research In Motion\BlackBerry Enterprise Server\Logs\ directory, where is the date of the log file.
c. You should now be able to see the list of MDS-enabled devices in the BlackBerry Manager.

Navigate to the MDS server and examine the "Devices Registered" option.

3.2 Deploying MDS Applications

Phew! We got there. We now have a BES server running MDS, with the correct software installed, and one or more BlackBerry handsets running the MDS Runtime application.

Finally, we can look to deploying our MDS application from our MDS Studio to our MDS server, and then from there to the handsets.

The first stage is to configure BlackBerry MDS Studio to publish our application to the relevant BES/MDS server. Thankfully, this is a one-off configuration exercise

1. Open MDS Studio.  
2. Click on the Options Menu, then Preferences  
3. Choose the "Publishing" option, and then choose "Application Registries."
4. Add a new application registry by clicking the plus icon on the right-hand side.

We can now add a new application registry entry for our MDS server. The dialog box asks for the address of the server and the user name and password of the publishing user that was entered during the BES server MDS installation phase.
5. Once you have filled this in, click the "Test Configuration" button. If everything has been configured correctly, you should see a dialog box with the text "Test Successful" appear.
6. Now click "OK" to save this application registry entry.  

We now repeat this exercise for the File Repository

1. Choose the "Publishing" option, and then choose "File Repositories."
2. Add a new file repository by clicking the plus icon on the right-hand side.

We can now add a new File Repository entry for our MDS server. The dialog box asks for the address of the server and the user name and password of the publishing user that was entered during the BES server MDS installation phase.
3. Once you have filled this in, click the "Test Configuration" button. If everything has been configured correctly, you should see a dialog box with the text "Test Successful" appear.
  • Now click "OK" to save this file repository entry.

So now we have configured our MDS Studio to recognize our BES/MDS server as a publishing target. Let's now take our project and publish it to the server.

1. Right click our project, and choose "Publish," and then choose "Publish Wizard."
2. Enter a description for this application.;
Now choose a publishing target. From the drop-down dialog boxes, choose the BES/MDS server you set up in the previous steps. Choose both the File Repository and the Application Registry from the drop-down dialog boxes. If the server is running, and the MDS studio can connect to it, the traffic lights should show green.
Remember, the MDS server relies on one or more Web services. It'd be a very well planned environment that DIDN'T require the URL for this Web service to be changed. Thankfully, the deployment process allows you to change the Web service URL.
4. Click "Finish" to publish this application to the BES/MDS server.  

Now we have the application on the MDS server. Let's do the last, simple step and deploy this application down to the handsets. In this case, we'll just deploy it directly.

1. Open the BlackBerry Manager.  
2. Navigate to the MDS Server.  
3. Open the "Application Registry" view.  
4. Right click the application and select "Install on Device."  
5. Select one or more devices.

Congratulations! You now have a working MDS application deployment environment. Whilst it's been a long haul, most of the configuration only has to be performed once, and chances are, in a larger environment, your BES Administrator has already done it.

Return to Top
 
Appendix A - Some Notes on Making Management Simpler
 

In order to make the management of your handsets simpler, especially if you have a number of users, leverage the group structures within the BES server to target more than one user at a time.

It's outside the scope of this document to discuss best practices around this area, but I'd heartily recommend that you start with the manual, and visit the BlackBerry Web site and hunt for some white papers.

Return to Top
 
Appendix B - Using the Simulator Against A Live BES Server
  

I thought I'd mention this idea as a discussion point in terms of helping debug a BlackBerry BES/MDS server.

On the BlackBerry Web site, under the developers' area, you can download the BlackBerry simulators. These are built into BlackBerry MDS Studio, and the Java Development Environment (JDE). Why would you wish to install them separately?

If you were to install the BlackBerry simulator, as well as a copy of BlackBerry Desktop software, you could then:

  • Activate a new handset for a test account.
 
  • Configure the Desktop synchronisation and email client to properly point at the target BES and Domino servers.
 
  • On the simulator, select the "Simulate" menu, and choose "Simulate USB Connection."
  • On the desktop manager, choose synchronize, and synchronize the handset with the BES server.
 
  • You will find on the BES server that the simulated BlackBerry now appears to be a live handset on the server.
 

This mimics the activation steps necessary for BES v2, or for the older BlackBerry connect clients.

Return to Top