Sup Tutorial Windowsmobile Native Application Development
Sup Tutorial Windowsmobile Native Application Development
DOCUMENT ID: DC01285-01-0210-01 LAST REVISED: December 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 Installing Microsoft Synchronization Software ................6 Starting Sybase Unwired WorkSpace ............................7 Connecting to Sybase Control Center ............................7 Learning the Basics ........................................................8 Developing a Windows Mobile Device Application ..........11 Generating C# Object API Code ...................................12 Creating the User Interface for the Windows Mobile Device Application ....................................................13 Creating the Customers Form .............................14 Creating the Customer Details Form ...................19 Creating the Main Program File ...........................23 Deploying and Running the Device Application ............25 Learn More about Sybase Unwired Platform ....................31 Index ..................................................................................33
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
Sybase Unwired WorkSpace Eclipse tutorials explain how to develop, deploy, and run a mobile application. Table 1. Eclipse tutorials Task
Getting Started
Goals
Install all required WorkSpace components and external resources. Start Unwired Server, then use Sybase Control Center to connect to the server. Open the Mobile Development perspective, and become familiar with the views of the perspective, and the Mobile Application Diagram.
Installing Sybase Unwired Platform on page 5 Installing Microsoft Synchronization Software on page 6 Starting Sybase Unwired WorkSpace on page 7 Connecting to Sybase Control Center on page 7 Learning the Basics on page 8
Note: These steps are prerequisites for the rest of this tutorial. You need to perform them only once.
Complete the Tutorial: Mobile Business Create a mobile application project and a connection to the Object Development. database. Create two mobile business objects, and create a relationship between them. Deploy the mobile business objects to Unwired Server. Generate code for the Windows Mobile platform, code a Windows Mobile device applica tion, and run it on an emulator.
Generating C# Object API Code on page 12 Creating the User Interface for the Windows Mobile Device Application on page 13 Deploying and Running the Device Application on page 25
Task Flow
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. 1. Installing Sybase Unwired Platform Install Sybase Unwired Platform. 2. Installing Microsoft Synchronization Software Install and configure Microsoft synchronization software so you can deploy and run a mobile application on a Windows Mobile emulator. 3. Starting Sybase Unwired WorkSpace Start Unwired WorkSpace. 4. Connecting to Sybase Control Center Open the Web-based Sybase Control Center administration console to manage Unwired Server and its components. 5. Learning the Basics Learn about Sybase Unwired WorkSpace and how to access help (optional).
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
Getting Started
8. Click OK.
For information on configuring, managing, and monitoring Unwired Server, click Help > Online Documentation. 1. Click Start > Programs > Sybase > Sybase Control Center. Note: If the Sybase Control Center service does not open, make sure that the Sybase Control Center service is started. See the Installation Guide for Runtime. 2. In Sybase Control Center, log in by entering the credentials set during installation. Logging in to Sybase Control Center gives you access to the Unwired Platform administration features that you are authorized to use.
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
10
Getting Started on page 5 Install Visual Studio 2008. Install Microsoft .NET Compact Framework 3.5 from http://www.microsoft.com/ downloads/en/details.aspx? FamilyID=e3821449-3c6b-42f1-9fd9-0041345b3385&displaylang=en, if it was not installed with Visual Studio. Tutorial: Mobile Business Objects Development, which provides the foundation tasks for this tutorial. In Unwired WorkSpace, open the SUP101 mobile application project. In WorkSpace Navigator, right-click the SUP101 folder and select Open in Diagram Editor.
Task The device application communicates with the database mobile business objects that are deployed to Unwired Server. 1. Generating C# Object API Code Generate Object API code for Windows Mobile devices. 2. Creating the User Interface for the Windows Mobile Device Application Import the SUP101 project in to Visual Studio 2008, configure the project, then download the tutorial code snippets from Product Documentation so you can create the application user interface. 3. Deploying and Running the Device Application Deploy the device application to a Windows Mobile device emulator, and test its functionality.
11
Description
Select C#. Select NET Compact Framework 3.5 for Windows Mobile. Select My Unwired Server. Select default. Leave blank. Enter SUP101. Accept the default. The default location for generated code is \SUP101\Generated Code.
Replication-based
5. Click Finish.
12
Creating the User Interface for the Windows Mobile Device Application
Import the SUP101 project in to Visual Studio 2008, configure the project, then download the tutorial code snippets from Product Documentation so you can create the application user interface. Prerequisites Install Windows Mobile 6 SDK from http://www.microsoft.com/downloads/en/
details.aspx?FamilyID=06111a3a-a651-4745-88ef-3d48091a390b&displaylang=en. Obtain the text files that contain the code snippets you need to build the user interface from the SUP_WM_Custom_Dev_Tutorial_code.zip file. The code snippets are used to create the CustomerSample, CustomerList, and CustomerSampleScreen C# files. If you are viewing this guide as a PDF, you can obtain the text files from 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. Select the appropriate version, navigate to this topic in the tutorial, then click the link for the zip file to save the files locally. If you are viewing this guide online from the Sybase Product Documentation Web site, click SUP_WM_Custom_Dev_Tutorial_code.zip to access the text files.
Task If needed, install the following: 1. In Visual Studio 2008, open SUP101.csproj. 2. Edit the project properties. a) In Solution Explorer, right-click SUP101, then select Change Target Platform. Select Windows Mobile 6 Professional SDK, then OK. b) Right-click SUP101, then select Properties. c) In the Application tab, select Console Application for Output type. d) In the Devices tab, select Windows Mobile 6 Professional Emulator for the Target device. e) Select File > Save All, then save the solution as SUP101.sln. See also Deploying and Running the Device Application on page 25
13
An empty form, Customers, displays on the Customer.cs [Design] tab. 3. From the Toolbox, drag and drop three buttons on to the form. 4. Select each button, and in the Properties view, change the Text of the buttons to: button1 Sync button2 Refresh button3 Update 5. In the Toolbox, select ListView from Common Device Controls, and drag and drop it to the Customers form.
14
6. In the Toolbox, select Textbox from Common Device Controls, and drag and drop it to the Customers form. 7. In the Customers form, click the ListView, then in the Properties pane, set FullRowSelect to True.
8. In Customers, select the Textbox, then in the Properties pane, set these properties: Multi-line True Read-only True Scrollbars Vertical
15
9. Arrange the controls on the Customers form so they look like this:
10. Save the Customers.cs form. 11. In Solution Explorer, in the SUP101 project, right-click Customers.cs, then select View Code. 12. Replace the code with the source code from the Customers.cs file you downloaded from the Sybase Product Documentation Web site:
16
namespace SUP101 { public partial class Customers : Form { public Customers() { InitializeComponent(); } //Click event for Sync button in Customers screen private void button1_Click(object sender, EventArgs e) { if (!SUP101DB.DatabaseExists()) { //This creates the database. SUP101DB.CreateDatabase(); } try { //This calls SUP101, the package database, user name and password to connect to the Unwired Server. //If your login name and password is different, then the changes must be reflected here. //The default is used below. SUP101DB.LoginToSync("supAdmin", "s3pAdmin"); SUP101DB.SubmitPendingOperations(); SUP101DB.Synchronize(); AddString("Synchronization completed."); } catch (Exception ex) { List<LogRecordImpl> lrs = LogRecordImpl.FindWithQuery(new Sybase.Persistence.Query()); AddString("log record count=" + lrs.Count); for (int i = 0; i < lrs.Count; i++) { AddString(lrs[i].Message); } } AddListView(); } private void AddString(String s) { textBox1.Text += s + "\r\n";
17
18
13. Be sure the bolded code line matches the Sybase Unwired Platform Admin login and password you indicated during installation. SUP101DB.LoginToSync("supAdmin", "s3pAdmin"); 14. Click the Customers.cs[Design] tab to go back to the Customers form design view to add event handlers to the buttons. a) Click the Sync button on the form. b) In the Properties view for the button, click the Event icon (lightning bolt), c) Next to the Click databinding, select button1_Click . d) Repeat these steps for each button, selecting these events for each Click databinding. Refresh refresh_Click Update update_Click 15. Save your changes.
19
Developing a Windows Mobile Device Application In the Properties view, in the Text field, rename the labels First Name, Last Name, and City. 4. From the Toolbox, drag and drop three text boxes onto the Customer_details form and align them to the right of each of the three labels. 5. Set the properties for each text box. For First Name, use tbFName. For Last Name, use tbLName. For City, use tbCity.
6. From the Toolbox, drag and drop two buttons from Common Device Controls to the Customer_details form below the labels and text boxes. a) In the Properties view, in the Text field, rename the button on the left to Cancel. b) In the Properties view, in the Text field, rename the button on the right to Submit. The form looks like this:
20
7. Save the Customer_details.cs form. 8. In Solution Explorer, in the SUP101 project, right-click Customer_details.cs, then select View Code. 9. Replace the existing code with the code from the Customer_details.cs file you downloaded from the Sybase Product Documentation Web site:
using using using using using using using using using System; System.Linq; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Text; System.Windows.Forms; SUP101;
namespace SUP101
21
22
Developing a Windows Mobile Device Application 10. In the the Customer_details.cs[Design] view, click the Submit button, then in the Properties view, add the Submit_Click event to the Submit button, and the Cancel_Click event to the Cancel button. 11. Add events to the Customer_details.cs. a) b) c) d) e) Click the Customer_details.cs [Design] tab. In Properties view, select Customer_details System.Windows.Forms.Form. Click the Events icon (lightning bolt). In Load, add the Customer_Details_Load event. In Paint, add the Customer_Details_paint event.
23
Developing a Windows Mobile Device Application 4. Right-click Program.cs, then select View Code. 5. Replace the existing code with the code from the Program.cs file you downloaded from the Sybase Product Documentation Web site:
using System; using SUP101; using System.Windows.Forms; namespace SUP101 { static class Program { private static Customers _form1 = new Customers(); private static Customer_details _form2 = new Customer_details(); private static string _custid; public static string getCustomer() { return _custid; } public static void setCustomer(string custid) { _custid = custid; } //Customer list screen public static Customers getForm1() { return _form1; } //Customer detail screen public static Customer_details getForm2() { return _form2; } static void Main(string[] args) { Application.Run(_form1); } } }
24
25
26
27
11. Make changes, then click Submit to return to the Customers List screen. 12. Click Sync. The change is reflected in the backend database. 13. Click Refresh and scroll to the bottom of the list view to see the local cache of the changed data.
28
You have now successfully completed the replication-based sample tutorial for Windows Mobile. See also Creating the User Interface for the Windows Mobile Device Application on page 13
29
30
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.
31
32
Index
Index
A
ActiveSync, installing and configuring 6 articles 31 synchronization software 6 iOS 1
M
Microsoft .NET Compact Framework 3.5 11 Microsoft ActiveSync, installing and configuring 6 Mobile Application Diagram, defined 8
B
basics, learning 8 BlackBerry 1
C
C# object API code generation 12 Customer_details form 19 Customers form 14
O
online help, accessing 8
P
Palette, defined 8 program.cs 23 Properties view, defined 8
D
deploying configuring ActiveSync for 6
S
samples 31 starting Sybase Unwired WorkSpace 7 Sybase Control Center connecting to 7 Sybase Unwired Platform getting started 5 installing 5 learning more about 31 Sybase Unwired WorkSpace getting started 8 starting 7 synchronization software installing 6
E
Eclipse Studio Edition Sybase Unwired WorkSpace 7 Enterprise Explorer, defined 8
G
getting started Sybase Unwired Platform 5 Sybase Unwired WorkSpace 8 tutorial projects 1 tutorials 1
H
help, online 8
T
tutorial projects 31 tutorials 31
I
installing Microsoft ActiveSync 6 Sybase Unwired Platform 5
V
Visual Studio 2008 11
33
Index
Windows Mobile 6.5 Professional Developer Tool Kit 11 WorkSpace Navigator, defined 8
W
Windows Mobile 1
34