Sup Tutorial Blackberry Native Application Development
Sup Tutorial Blackberry Native Application Development
DOCUMENT ID: DC01214-01-0210-01 LAST REVISED: November 2011 Copyright 2011 by Sybase, Inc. All rights reserved. This publication pertains to Sybase software and to any subsequent release until otherwise indicated in new editions or technical notes. Information in this document is subject to change without notice. The software described herein is furnished under a license agreement, and it may be used or copied only in accordance with the terms of that agreement. To order additional documents, U.S. and Canadian customers should call Customer Fulfillment at (800) 685-8225, fax (617) 229-9845. Customers in other countries with a U.S. license agreement may contact Customer Fulfillment via the above fax number. All other international customers should contact their Sybase subsidiary or local distributor. Upgrades are provided only at regularly scheduled software release dates. No part of this publication may be reproduced, transmitted, or translated in any form or by any means, electronic, mechanical, manual, optical, or otherwise, without the prior written permission of Sybase, Inc. Sybase trademarks can be viewed at the Sybase trademarks page at http://www.sybase.com/detail?id=1011207. Sybase and the marks listed are trademarks of Sybase, Inc. indicates registration in the United States of America. SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. Unicode and the Unicode Logo are registered trademarks of Unicode, Inc. All other company and product names mentioned may be trademarks of the respective companies with which they are associated. Use, duplication, or disclosure by the government is subject to the restrictions set forth in subparagraph (c)(1)(ii) of DFARS 52.227-7013 for the DOD and as set forth in FAR 52.227-19(a)-(d) for civilian agencies. Sybase, Inc., One Sybase Drive, Dublin, CA 94568.
Contents
Sybase Unwired Platform Tutorials ......................................1 Task Flow ................................................................................3 Getting Started .......................................................................5 Installing Sybase Unwired Platform ................................5 Starting Sybase Unwired WorkSpace ............................5 Learning the Basics ........................................................6 Developing a BlackBerry Application ..................................9 Installing the BlackBerry Java Plug-in for Eclipse ...........9 Generating Java Object API Code ..................................9 Creating the BlackBerry Project ....................................11 Configuring BlackBerry Application Properties ....13 Copy Unwired Platform Files to Sample Project .........................................................................13 Creating the User Interface ...........................................13 Creating a Launch Configuration for the Project ...........18 Testing the Device Application on the BlackBerry Simulator ..................................................................19 Learn More about Sybase Unwired Platform ....................25 Index ..................................................................................27
iii
Contents
iv
The tutorials demonstrate a cross section of basic functionality, which includes creating MBOs, and using various Sybase Unwired WorkSpace development tools, independent development environments, and device types. Tutorial projects are available if you want the finished tutorial without going through the steps.
Task Flow
Task Flow
Use this tutorial to develop a BlackBerry device application using replication-based synchronization and custom coding. Test the application on a simulator. Table 1. Eclipse tutorials Task
Getting Started
Goals
Install all required Unwired WorkSpace components and external resources. Start Unwired Server and other platform services, if not already started. Open the Mobile Development perspective, and become familiar with the views of the perspective, and the Mobile Application Diagram. Create a mobile application project and a connection to the database. Create a mobile business object and deploy it to Unwired Server.
Installing Sybase Unwired Platform on page 5 Starting Sybase Unwired WorkSpace on page 5 (Optional) Learning the Basics on page 6
Note: These steps are prerequisites for the rest of this tutorial. You need to perform them only once.
Complete the Tutorial: Mobile Business Object Development. Note: This tutorial is a prerequisite for the remaining steps. You need to perform it only once.
Goals
Generate Java code for the BlackBerry platform, create the user interface for the application, and run it on the simulator.
Installing the BlackBerry Java Plugin for Eclipse on page 9 Generating Java Object API Code on page 9 Creating the BlackBerry Project on page 11 Creating the User Interface on page 13 Creating a Launch Configuration for the Project on page 18 Testing the Device Application on the BlackBerry Simulator on page 19
Getting Started
Getting Started
Install and learn about Sybase Unwired Platform and its associated components. Complete the following tasks for all tutorials, but you need to perform them only once.
Release Bulletin for Sybase Mobile SDK Installation Guide for Sybase Mobile SDK Release Bulletin for Runtime Installation Guide for Runtime
Install Sybase Mobile SDK, which includes: Development support for Native Object API applications, HTML5/JS Hybrid (Mobile Workflow) applications, and OData SDK applications. Sybase Unwired WorkSpace, the Eclipse-based development environment for MBOs and Mobile Workflows. Install Unwired Platform Runtime: Data Tier (included with single-server installation) Unwired Server
Getting Started
Description
A view of mobile application projects. Each project folder includes resources and data source references to which the MBOs are bound, personalization keys, and so on. Use this view to review and modify MBO-related properties.
Enterprise Explorer
A view of enterprise back-end resources, such as database servers, SAP servers, and Sybase Unwired Server.
Description
A graphical editor for designing mobile business objects. A Mobile Application Diagrem is associated with each project. Use the Mobile Application Diagram to create MBOs (including attributes and operations), then define relationships with other MBOs. You can: Create MBOs in the Mobile Application Diagram using Palette icons and menu selections. Either bind to a data source now or or defer binding. For example, using a top-down approach, you might model your MBOs before creating the data sources to which they bind. Drag items from Enterprise Explorer and drop them onto the Mobile Application Diagram to create the MBO quickly creates the operations and attributes automatically based on the data source of the items.
Palette
A view from which you can drag controls onto an open Mobile Application Diagram and define their attributes, operations, and relationships to your application. A view that shows the properties of the object currently selected in the Mobile Application Diagram, and lets you edit them. You cannot create an MBO from the Properties view, but generally, most development and configuration is performed here. An outline of the file that is currently open in an editor, listing structural elements. The contents are editor-specific. The error log captures Eclipse warnings and errors, including stack traces. A view that displays problems, errors, or warnings.
Properties
Outline
Error Log
Problem
3. To access the online help, click Help > Help Contents in the main menu bar. 4. Expand any of the documents that appear in the left pane. Some documents are for Sybase Unwired Platform, while others are for the Eclipse development environment.
Getting Started
Task The device application communicates with the database mobile business objects that are deployed to Unwired Server.
Developing a BlackBerry Application Task 1. In Unwired WorkSpace, open the SUP101 mobile application project. In WorkSpace Navigator, right-click the SUP101 folder and select Open in Diagram Editor. Note: If you do not see the SUP101 project in Workspace Navigator, you must first complete the Tutorial: Developing Mobile Business Objects, which is a prerequisite for this tutorial. 2. If you are performing other tutorials, optionally add a new folder to the project in which to generate code for each device platform. For example, in WorkSpace Navigator, expand SUP101 and add a RIM folder under Generated Code. 3. Right-click the SUP101 Mobile Application Diagram and select Generate Code. 4. Click Next to continue without a configuration. 5. Make sure the Customer MBO is selected, then click Next. 6. Specify the following configuration options: Option
Language Platform Unwired Server Server domain Page size Package
Description
Select Java. Select Java ME for BlackBerry. Select My Unwired Server. Select default. Select 1024. Optionally enter a unique name for the Java package.
Destination
/SUP101/Generated Code, or another folder that you created for this device platform in Step 3.
Unselect for this tutorial.
Generate JavaDoc
7. Click Finish. You can ignore the error icons that appear in WorkSpace Navigator under Generated Code/ src/SUP101, and the error, net cannot be resolved, in the Problems view. The error occurs because the package java file called by SUP101DB.jar is not yet in the project build path. The errors will be resolved later, when you build the application in the BlackBerry Java Plug-in for Eclipse. 8. Click OK in the Success dialog.
10
11
4. In the Java Settings page, modify the build path to point to the correct location for sup_client_rim.jar and UltraLiteJ.jar. a) Click the Libraries tab. b) Click Add External Jars. c) Browse to <UnwiredPlatform_InstallDir\UnwiredPlatform \ClientAPI\RBS\BB. d) Select all the JAR files (for example, by pressing Ctrl + A), then click Open. e) Click Finish.
12
13
Developing a BlackBerry Application create these classes: CustomerSample, CustomerList, and CustomerSampleScreen. If you are viewing this guide online from the Sybase Product Documention web site, click SUP_BB_Custom_Dev_Tutorial_code.zip to access the zip archive containing the text files. If you are viewing this guide as a PDF, go to the Sybase Product Documentation Web site at
http://sybooks.sybase.com/nav/summary.do?prod=1289&lang=en&submit=%A0Go %A0&prodName=Sybase+Unwired+Platform&archive=0. Click the link for the Sybase Unwired Platform version that you want. Then, navigate to this topic in the tutorial, and click the link for the zip file to access the text files.
Task 1. In Package Explorer, right-click SUP101Sample, and select New > Package. 2. For the Name, enter com.sybase.sup.samples.objectapi and click Finish. 3. Right-click the com.sybase.sup.samples.objectapi package and select New > Class. 4. For the Name, enter CustomerSample, and click Finish.
14
5. In the CustomerSample.java file, copy and paste the code from the provided CustomerSample.java text file. Overwrite any existing contents. The provided code creates the main Customer application.
15
6. Save the CustomerSample.java file. The package contains errors until you create the two other classes. Ignore these errors and continue. 7. Right-click the com.sybase.sup.samples.objectapi package, and select New > Class. 8. For Name, enter CustomerList, and click Finish. 9. In the CustomerList.java file, copy and paste the code from the provided CustomerList.java text file. Overwrite any existing contents.
16
10. Save the CustomerList.java file. Ignore the errors, which resolve once you create the next class. 11. Right-click the com.sybase.sup.samples.objectapi package, and select New > Class. 12. For Name, enter CustomerSampleScreen, and click Finish. 13. In the CustomerSampleScreen.java file, copy and paste the code from the provided CustomerSampleScreen.java text file. Overwrite any existing contents.
17
Developing a BlackBerry Application 14. Save the CustomerSampleScreen.java file. Notice that the compilation errors in other java files are resolved.
3. In Name, enter SUP101Sample. 4. In the JRE tab, select the JRE to use, in this case, BlackBerry JRE 6.0.0. 5. In the Simulator tab, select Launch Mobile Data System Connection Service (MDSCS) with simulator, then select BlackBerry-SDK - 9800 as the device.
18
19
20
Developing a BlackBerry Application 2. On the main window, click All to access the applications screen, then scroll until you see the SUP101Sample application.
3. Click to launch the SUP101Sample application. 4. Click the BlackBerry menu button, then select Synchronize. The customer list appears.
21
5. Focus on the customer list and enter dal in the Search bar. The customer list is filtered and only customers with a first or last name beginning with 'dal' are shown, in this case, Daljit Sinnot. 6. Select the customer, Daljit Sinnot, and click the trackball. The detail screen for Daljit Sinnot appears.
22
7. In the customer detail screen, change the first name of the customer to abc and click Submit. The Submit button on the Customer Detail screen is mapped to the update operation of the customer mobile business object. When the application is synchronized, any pending operations are uploaded to Unwired Server. 8. To upload the new record to the back-end database sampledb, click the Menu key, and select Synchronize.
23
24
Developer Guide: BlackBerry Native Applications Developer Guide: iOS Native Applications Developer Guide: Windows and Windows Mobile Native Applications Developer Guide: Mobile Workflow Packages
Developer Guide for Unwired Server Management API customize and automate system
administration features.
Developer Guide: Unwired Server customize and automate server-side implementations for device applications, and administration, such as data handling.
25
26
Index
Index
.cod files adding to the simulator directory 13 CommonClient.cod 13 sup-client-rim.cod 13 UltraLiteJ.cod 13 Sybase Unwired WorkSpace 6 tutorial projects 1 tutorials 1 goals 3
H
help, online 6
A
application properties 13 articles 25
I
installing Sybase Unwired Platform 5 iOS 1
B
basics, learning 6 BlackBerry 1 BlackBerry application description 13 BlackBerry Java Plug-in for Eclipse installing 9 BlackBerry project, creating 11 BlackBerry Simulator 19 build path 11
J
JAR files adding 11 sup-client-rim.jar 11 UltraLiteJ.jar 11 Java class, creating 13 Java Object API code, generating 9 Java perspective 13
C
code generation 9 CustomerList 13 CustomerSample 13 CustomerSampleScreen 13
L
launch configuration 18
D
descriptor file 11
M
Mobile Application Diagram, defined 6
E
Eclipse Studio Edition Sybase Unwired WorkSpace 5 Enterprise Explorer, defined 6
O
online help, accessing 6
P
Palette, defined 6 project build path 11 Properties view, defined 6
G
getting started Sybase Unwired Platform 5
27
Index
S
samples 25 starting Sybase Unwired WorkSpace 5 sup-client-rim.cod 13 sup-client-rim.jar 11 SUP101Sample application running 19 testing 19 updating data 19 viewing data 19 Sybase Unwired Platform getting started 5 installing 5 learning more about 25 Sybase Unwired WorkSpace getting started 6 starting 5
T
task flow 3 testing 19 tutorial projects 25 tutorials 25
U
UltraLiteJ.cod 13 UltraLiteJ.jar 11 user interface creating 13
W
Windows Mobile 1 WorkSpace Navigator, defined 6
28