Magazine
 
Quick Review:Ajax
 
Cross-platform programming with Java technology and the IBM Web Services Toolkit for Mobile Devices
 

trackwheel. The user selects the highlighted item by pressing the spacebar or using menu options. For a Multiple-type List on the BlackBerry 5810 Handheld, no selection events are generated when pressing the spacebar to select an item. In addition, choosing Change Option from the menu has the same effect as pressing the spacebar: It changes the selected item but does not generate an event. This behavior is consistent with the MIDP documentation.

For an Exclusive-type List, no selection events are generated when pressing the spacebar to select an item. However, in contrast with the Multiple-type List, there were no menu items to choose from. This behavior is consistent with the MIDP documentation, though inconsistent with the implementation of the Multiple-type List.

For an Implicit-type List, selection events are generated when you choose Select from the menu. Pressing the spacebar has no effect. This behavior is consistent with the MIDP documentation. Differing List controls: Can they be reconciled?

The List control behavior differs from device to device. In addition, its behavior on the Palm device is not consistent with its documented behavior. On the iPAQ device, the List control’s behavior is consistent with the MIDP documentation; however, the fact that the Implicit-type List does not respond to the touchscreen and requires the use of the five-way hardware button is inconsistent and aggravating. The BlackBerry implementation is also consistent with the documentation; however, the menus available under the three types of List are not consistent. The Multiple type contains a Change Option menu item, the Exclusive type contains no menu items, and the Implicit type contains a Select menu item.

Other MIDP implementations may also provide inconsistent behavior; you should not assume that they all have the same limitations described here.

ChoiceGroup: An alternative to List

Because of the problems associated with the List control on the devices I used, I realized that I could not use that control in a cross-platform application. Instead, I use the ChoiceGroup control to display a list of choices to the user. You can create either a Multiple- or an Exclusive-type ChoiceGroup control. Like their corresponding List types, these types should not generate selection events when the user chooses items. For the sample applications, I used an Exclusive-type ChoiceGroup, since I only wanted the user to be able to make one selection from each list. Then, I provided different Command objects that, when selected, would take action based on which item in the ChoiceGroup was selected.

Multithreaded connections

There is one more trick you’ll need to keep in mind in order to have one program execute on all three devices we’re considering here. A device running the BlackBerry OS can only make an HTTP connection from a secondary thread and not on the main thread. Palm OS4 and Pocket PC 2002 devices have no such restriction.

I initially attempted to have my applications dynamically determine which device they were running on and create a secondary thread only when running on the BlackBerry platform. However, this technique itself ran into a problem: the System.getProperty(“os.version”); call returned a null value on the BlackBerry platform. Under the Pocket PC 2002 and Palm OS4 operating systems, this method call returned valid values; however, I did not want to assume that a null return from a System.getProperty(“os.version”); call always implied the need for a secondary thread for HTTP
connections.

June 2008 | Java Jazz Up |37
 
previous
index
next
 
Pages: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,

30
, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,   Download PDF