iOS App Tutorial for CA Plex / CM WebClient

Introduction

Developers that have started using CM WebClient 1.8 Mobile’s touch optimized templates usually find that creating a mobile web app deployment is straightforward. But while deployment as a web app is acceptable for some, other developers creating commercial and specialized applications often benefit from native deployment. For example, you may need to use the camera to capture pictures or scan documents, implement a signature capability, or access the phone contact database. CM WebClient supports this style of native application using Adobe/Apache PhoneGap. There is a Camera and Signature template available, and you are encouraged to create your own device templates and share on the WebClient Mobile Google Code project.

This tutorial is for Apple devices (iPhone / iPad), and also requires use of a Mac to run Xcode and to meet Apple licensing requirements. If you are targeting Android or Blackberry devices, you will need to follow a similar but different procedure for each device platform. I.e. your core code remains the same, but the PhoneGap native wrapper is different for each technology. PhoneGap has tutorials available for every supported platform.

Download and Install Software

For this part you need access to an Apple Mac. Point the browser from your mac to the Apple developer website, http://developer.apple.com. Download the latest version of Xcode and the iOS SDK’s. It is over three gigabytes, so you may want to have a couple coffees at this point. You may also want to take some time to sign up as a developer, either individually or within an organization. Organizational approvals can take weeks to process by Apple, so it is always better to do this well in advance of needing to upload your app for public distribution.

After you have installed Xcode, download the PhoneGap distribution from http://phonegap.com. This example is using version 1.3.

Run the installer

NewImage

Follow the steps on the installer wizard

NewImage

Create Your Xcode Project

Open Xcode and select “Create a new Xcode project”

New Project

Choose PhoneGap as the template for your new project

NewImage

Give your project a name and identify your company. Typically your organization / company id will be your domain name in reverse word order. It is important to deselect Automatic Reference Counting – otherwise build errors will result.

NewImage

Select a directory location for your project. A subfolder will be created beneath the directory you select to contain your project. It is recommended to also create a local repository for source code changes – that way you can easily revert if you make a mistake.

SelFolder

Next, enter project information. You can drag and drop application icons if you wish (you can do this later if you don’t have any  icons prepared).

NewImage

Keep scrolling down and enter iPad information as well as application launch images (splash screens). Do not enter Entitlements unless you know what to fill in.

NewImage

Hit the validate setting button to make sure all is ok

NewImage

You may get a window like this. Accept this recommendation.

NewImage

It is recommended to select the automatic snapshot option

NewImage

Configure and Run

You will now see the Xcode workbench. First we have to run the application once in order to create a “www” folder that contains the Phonegap startup code and resources. Select a simulator target and hit the run (play) button.

NewImage

You will see this error in the simulator – this is expected and is not an issue. It means that your app cannot find a start page.

NewImage

This next step is very important and must be done exactly as described. We need to create a folder reference in Xcode to our www and javascript resources. You do this by opening Finder and dragging the “www” folder beneath the project onto the Xcode project work space. You will see a green plus sign indicating the drag target is accepted. You will then be prompted to create a reference to this folder.

NewImage

Use the following settings

NewImage

Run your project again, and you should see that PhoneGap is now working. The HTML5 and JavaScript you see are running directly on the device, not served up by a web server.

NewImage

Connect your application

The next step is to connect your CM WebClient pages to PhoneGap. There are two parts to this.

First we need to add a whitelist entry to allow your app to access external resources. You do this in the PhoneGap.plist file.

NewImage

Next, add some JavaScript in the index.html file to access your dynamic content. For production applications, you will want to create some static web pages and a mechanism to check the online status. This is straightforward but beyond the scope of this tutorial.

NewImage

Run your app again from Xcode and you should be rewarded with your app on your device emulator!

NewImage

Congratulations, You Are Deployed!

You need some further steps to deploy your app to physical devices and to iTunes. Stay tuned for more blog posts, or contact us at CM FIrst for assistance if you are on one of our support plans.

 

Running CA Plex Java on (virtually) any platform

Is Java truly write once run everywhere? In years past, it was often not the case but in the modern day it is more or less true. And you can run your Plex Java apps on many platforms with good performance, given a supported database and JRE. This is a very nice situation for the ISV or corporate developer who needs to rehost.

In practice is is advisable and desirable to run and debug a CA Plex java app on a Windows or another platform during the development process, such as Mac OS, Linux, iOS, Unix (Aix), or zOS. By far the easiest way to accomplish this is by using the free Eclipse IDE, or if you already have IBM Rational – then you can use this version. The Eclipse (Rational) product runs on virtually every major computing platform, from PC’s to the big iron iOS or zOS. If you do purchase a Rational version, you will have the added benefit of being able to debug not only Java, but RPG and COBOL as well. This is nice if you are trying to debug a full featured multitiered web app, running both in the web container and back end server. WebClient supports this style of application architecture.

The examples below use Eclipse for Mac and CA Plex 7.0, but the steps are the same regardless of platform or version. Mac OS is particularly useful for mobile device development, for example you can run your CA Plex WebClient apps on iOS devices such as iPhone and iPad by using Xcode and Phonegap.

First Step – Install the Eclipse or Rational IDE

Before installing, download and install a matching JDK from Oracle using this link. The JavaSE version is appropriate for most cases.

Next, download and install Eclipse or Rational IDE. You can download a open source version of Eclipse from this link to match your target platform, or go to IBM for a version that runs on an IBM host (PowerSystems, zOS) (warning, fees may apply). We recommend downloading the J2EE version so you get most necessary tooling included.

Second Step – Create a Java Project and Link your Plex source

Go to menu File / New, select other, then select Java project

FileNew

NewJavaProject

Give it a name of your choosing

NewProject2

Perspective

Third Step – Add ObRun and JDBC / Third Party Jars

Copy and paste any external jar files you may need into the project root. This includes both CA Plex product jars and JDBC jars for database access. Note – you can leave the jar files in place and add to the class path or reference by path. However, if you do this the resulting Java project is easily not portable between machines.

If you are not using WebClient, you will need to make sure the ObRun.jar is copied from the Plex product files. If you are using WebClient, then this will happen automatically when you add the WebClient nature to the project. See the WebClient user manual

After you copy and paste the jars into the project, you need to configure the build path to use the jars.

Jars

BuildPath

Select the jars you copied from the first step

BuildPath

Final Result

NewImage

Fourth Step – Link to your CA Plex generated source

In this step simply link to the CA Plex generated source directory (under your model GEN folder). First remove the src directory from the build path and from the project. Next you will  link the Src subdirectory (with an exclusion to Res), and then link the Res directory.

Go to the build path and start with an empty screen. If you see a src folder, first remove from this screen then go back and delete the directory from the project itself.

NewImage

If you get the message “directory exists with a different case” later it is because you need to remove the default src directory first!

Next, add a source folder for Plex bitmaps / GIFs. Copy the Plex BMP3 files into this directory

NewImage

Next, use the link button to link to your CA Plex Gen/Src directory, where your Java source resides

NewImage

Add an exclusion pattern to exclude the Res source directory (it will be added in the next step)

NewImage

Link the Res directory in the same manner as Src

NewImage

Your final build path for source should look like this:

NewImage

Fifth Step – Compile and check for errors

Eclipse will automatically and incrementally build your CA Plex source as you generate – and will do so much faster that you can generate!

Check the “Problems” tab for any errors. Usually these errors are the result of C++ code injected into the java code. You will need to variant / clean up any native C++.

NewImage

Sixth Step – Set up a run configuration

Click on the green “Play” button drop down to access the “Configurations” menu. Select this.

NewImage

Type in the Name, Project (or browse), and the main class “ObRun.ObPanel.ObLaunch”

NewImage

Click on the arguments tab

Type in the package.class name followed by “path= “, e.g. MobileApp.ConfMenu “path= “. Note the space between the = and final quote.

NewImage

Congratulations, you are running Plex Java natively (in this case on Mac OSX Lion accessing MySQL)

NewImage

HTML5 Mobile Reference Site Launches

NewImage

From time to time CM First gets asked if the Sencha Touch / PhoneGap technology behind CM WebClient 1.8 Mobile for CA Plex can produce a first class touch-optimized mobile experience. Although HTML5′s promise of single code base across devices is highly attractive, there is often some skepticism expressed. Is this a technology can handle produce an experience equivalent to the native device alternative, laboriously crafted by hand multiple times for iOS Objective C, Android SDK, and BlackBerry?

We invite you to research the question yourself by checking out this HTML5 web site. NOTE: Must be accessed from an Android, Apple, or Blackberry mobile device, or Safari/Chrome from a desktop browser.

(http://m.descuentolibre.com)

Descuento Libre is dedicated to serving the Latino community – and those who love the Latino culture – through significant discounts on retail, services, restaurants, entertainment, and recreational activities. Descuento Libre’s deals focus on local businesses and establishments patronized by the Latino community, as well as places that promote Latino culture. The company is also committed to supporting the local Latino community by engaging at the grassroots level and partnering with non-profit organizations. Descuento Libre is active in major metro centers across the USA and Mexico.

CM First developed the transactional mobile web site for Descuento Libre. Stay tuned for appearances on the iTunes, Android, and Blackberry market places.

DL4DL2

 

 

 

 

 

 

 

 

 

 

 

DL1DL3

Interested in a web site like this? Email us at info@cmfirsttech.com for more information.

Movie – Debugging on Devices with Firebug

Movie on how to turn on the iOS device JavaScript console and enable Firebug debugging

Debugging HTML5 Apps on iPhone/iPad

WebClient for CA Plex shields you from much of the need to delve into the internals of HTML5 and JavaScript on the iPhone / iPad platform. However, the fact is that sometime you have to debug the HTML and CSS directly on the device. This is a guide on how to do it.

There are two options available. The first is to turn the JavaScript debug console on. You can do this by visiting the device settings, and moving down to Safari. From Safari select Advanced Settings and turn on the JavaScript Console. This is sufficient for many issues.

NewImage

NewImage

Although the Apple debug console is certainly useful, sometimes you need more. One way is to use the Firebug, a popular JavaScript debugging platform.

You can debug using Firebug on your iOS device.

First, open Safari on your mobile device.

Next, create a bookmark in Safari on your iOS device for any webpage, and name that bookmark “Firebug.”

Following this, launch Safari and edit the Firebug bookmark, replacing the URL with the above text. Hit “Done,” and the bookmarklet should be created and ready to use.

In order to launch the Firebug console, visit a website on your iOS device and, once the website has loaded, open your Bookmarks in Safari and touch Firebug. After a few moments, the console should appear at the bottom of the webpage (as you can see in the above image).

javascript:(function(F,i,r,e,b,u,g,L,I,T,E){if(F.getElementById(b))return;E=F[i+'NS']&&F.documentElement.namespaceURI;E=E?F[i+'NS'](E,’script’):F[i](‘script’);E[r](‘id’,b);E[r](‘src’,I+g+T);E[r](b,u);(F[e](‘head’)[0]||F[e](‘body’)[0]).appendChild(E);E=new%20Image;E[r](‘src’,I+L);})(document,’createElement’,’setAttribute’,’getElementsByTagName’,’FirebugLite’,’4′,’firebug-lite.js’,’releases/lite/latest/skin/xp/sprite.png’,’https://getfirebug.com/’,’#startOpened’);

Following this, launch Safari and edit the Firebug bookmark, replacing the URL with the above text. Hit “Done,” and the bookmarklet should be created and ready to use.

In order to launch the Firebug console, visit a website on your iOS device and, once the website has loaded, open your Bookmarks in Safari and touch Firebug. After a few moments, the console should appear at the bottom of the webpage (as you can see in the image).

NewImage

NewImage

Mobile Device Development Recommended Reading List

Here is a list of ebooks that we have found useful for mobile device development. We will be adding to the list as we come across new valuable resources.

http://www.amazon.com/lm/R19VKG1G2RSJJY/ref=cm_lm_pthnk_view?ie=UTF8&lm_bb=

Enjoy!

Webcast Replay – CA Plex, Mac, and Mobile Development

To view a recording of the webcast, click here:

https://www305.livemeeting.com/cc/cai/view?id=2F7GPS&role=attend&pw=kQ%2CM9%28%2BMg

 

CA Plex on the Apple Mac and iOS

See how CA Plex can be used to generate applications that run 100% on the Apple Mac (Java Swing with MySQL) or run iOS/Android devices using Xcode, Eclipse for Mac, WebClient, and PhoneGap.

 

WebClient 1.8 New Release Information

WebClient 1.8 has been in private beta since November 2011. We are readying a Release Candidate for January 2012, and General Availability February 2012.

There are several new features in the new release:

  • Mobile Touch Optimized Templates
    • iPhone, Android, BB6
    • HTML5 Sencha Touch based, with Adobe/Apache PhoneGap
    • Native capability including Camera templates
  • Core Product Enhancements
    • Accordion control, enabling Outlook style menus
    • New Claro theme, support for creating user defined themes
    • Auto scale CA Plex functions to browser size
    • Enhanced Grid, save placement, export to Excel, and more
    • Intellisense style interactive filtering
    • Initial Cloud Instance Definitions
    • Portlet Generations – Websphere Portal or Apache Pluto
  • Additional Features
    • FileOpen, Progress, Plex 7.0 …
    • New licensing – No more crypkey!

Please view the presentation below for more information:

If you are a current customer and wish to be part of the release candidate process, please drop us an email to info@cmfirsttech.com.

 

Welcome to the new cmWebClient blog

Welcome to the new cmWebClient blog. The old blog url will be retired shortly.

You can expect to see a lot of new posts in the coming days, as version 1.8 is readied for general availability.

Regards from the WebClient team at

 

CMFT Logo SML