This tutorial walks you through the process of developing an on-device MAF application using JDeveloper Studio Edition. In this tutorial, you deploy the application to an iPhone simulator. However, the developed application can also be deployed to an actual iOS device.

If you are interested in the setup and deployment to an Android emulator start with Part 2: Setup and Configure an Android Environment.

show more or lessRead more...

MAF enables you to create an application that can house different types of content that runs on mobile devices powered by Apple iOS platforms or Android devices. In this tutorial we'll work with an iOS simulator. Within the framework of the application, the contained content areas are referred to as features and represent a specific piece of the application’s functionality. End users can access features from either the navigation bar or the springboard on the iOS devices. The icons that represent the application features can be grouped together by functionality and aligned by permissions, as well as implementation considerations.

The following types of application features can coexist within the same MAF application:
- Local MAF XML file—although you are not required to develop the application features that reside within the MAF application, this implementation approach allows you to define an application feature that utilizes many of the device's functionality through embedded components, with the metadata represented by an XML file. This application feature implementation, which is generated into HTML or JavaScript on a mobile device and which uses ADF data bindings, is developed declaratively using a set of MAF-specific components in JDeveloper.
- Local HTML files or remote URL—this implementation approach allows you to employ an HTML file that embeds existing technologies, such as JavaScript and Java. Or you can simply point to a resource on the Web by specifying a URL end point. You can use JDeveloper to implement this type of feature.

A MAF application enables integration of its features with such native device utilities as phone, camera, GPS, and so on. You can define the contract for accessing and controlling each feature, as well as supply constraints to determine the display of a feature at run time (such as, for example, Role, OS, Version). The mobile device utilities can be accessed from the local HTML, local MAF XML, Java, and remote Web applications.

The images below show you what your simulator will look like if you successfully complete the tutorial.

hello world app in simulatorhello world app in simulator

Step 1: Download and Install the Required Components
  1. Get access to a Mac that is running operating system 10.11.5 (El Capitan) or above.

  2. Download and install XCode version 8.1.x, (included with this version of Xcode is iOS 10 and SDK. It is recommended that you remove any older versions of the Xcode and only have the 8.1.x version installed on your machine).

    The Xcode and iOS SDK are available from Apple. Show more or lessRead more...

    You can purchase/download Xcode and iOS SDK from the Apple App Store for Mac, or by participating in the iOS Developer Program. The download includes the Xcode IDE, Instruments, iOS Simulator, and the latest iOS SDK. You can compile and test the application with just Xcode and iOS SDK, but you must participate in the iOS Developer program if you want to deploy the application to an actual device. It is necessary when Xcode has just been installed for the first time to run it at least once, otherwise users will hit an error code 69.

  3. Install the MAF extension by using the JDeveloper Update Center. Start JDeveloper Studio Edition (version 12.2.1.0), then select the menu item Help > Check for Updates.

    check for updates

  4. Ensure the Search Update Center radio button is selected and click Next.

  5. step 1 in check for updates
  6. Click Available Updates select the check box by the Mobile Application Framework extension.

    Then click Next.


    step 1 in check for updates

  7. Accept the license agreement by clicking I Agree.

    Then, click Next and the download will start. Once the download completes, click Finish.

    step 1 in check for updates

  8. JDeveloper needs to restart. Click Yes to shut down and restart JDeveloper.
    Might take a minute or two, be patient.

    restart jdevloper message

  9. Once JDeveloper has started, you can confirm the extension was installed by examining the Extension tab in the About pane (Help > About menu options).

    preferences menu

  10. Next, you need to set preferences in JDeveloper to use the SDK provided by XCode 7.

    Select the menu item JDeveloper > Preferences.

    preferences menu

  11. On the left side of the Preferences screen, click and expand the Mobile Application Framework node. If you are using the Mobile Application Framework extension for the first time, you may need to click the Load Extension button.

    mobile preferences

  12. Next, expand the Mobile Application Framework node, and select iOS Platform.

    In previous versions you needed to update the SDK and xcodebuild directory locations. This is no longer required. You only have the opportunity to update the iTunes location and should be populated by default.

    This is also the place where you may specify any device signing certificates. The screen shot shows a selected profile.

    platform sdk location

    Click OK to dismiss the Preferences pane.


Step 2: Create an MAF Application
  1. In this part, you first create a “Hello World” MAF application, and then deploy this starter application to the iPhone simulator.

    Preparing Mobile Application Framework applications for deployment is primarily comprised of creating platform-specific deployment profiles. Show more or lessRead more...

    A deployment profile defines how an application is packaged into the archive that will be deployed to either an iOS device or emulator. The deployment profile:

    - Specifies the format and contents of the archive.
    - Lists the source files, deployment descriptors, and other auxiliary files that will be packaged into the archive file.
    - Describes the type and name of the archive file to be created.
    - Highlights dependency information, platform-specific instructions, and other information.


    In the Applications Window click New Application to start the New Gallery dialog box.

    New Application

  2. In the New Gallery expand the General - Applications nodes and select Mobile Application Framework Application
    Then click OK.

    new gallery mobile application item


  3. In the Name your application page, enter MyMobileApp in the Application Name field, and click Next.

    name mobile application

  4. Examine the Project Features for your first project, the ApplicationController.

    features of application controller  project

  5. Click Next twice and in the Name your project page, leave the default project name. Examine the Project Features for the ViewController project. Notice that the project uses Mobile Application Framework, HTML and CSS, Java, and JavaScript project features.

    project features in view controller project

  6. Click Next and Finish. You should see a new MAF application created in Applications window.

    application navigator files after mobile app creation

  7. Right-click on the ViewController project and select New > From Gallery
    In the New Gallery, select Web Tier - HTML and then the HTML Page item.
    Then click OK.

    application navigator files after mobile app creation

  8. Accept the default File Name and Directory, then click OK.

    application navigator files after mobile app creation

  9. Using the Editor, in the body of the document, enter the following text "Deployment Successful".

    application navigator files after mobile app creation

  10. Save all your work.

  11. In the Structure Window, select the body component.
    Then in the Properties Window, expand the Style node and set the Font Size to xx-large.

    application navigator files after mobile app creation

    application navigator files after mobile app creation

    application navigator files after mobile app creation


Step 3: Add UI Access to the Pages
  1. In this section, you configure a new feature so the user can access the newly defined AMX pages from the native application container. You will need to perform this task when ever you add pages or task flows to your application.

    After you complete an Mobile Application Framework application project, JDeveloper adds both project and application level artifacts.Show more or lessRead more...

    Among these artifacts is an MAF framework model project and the view-controller project (with the default name, ViewController) that has the MAF framework feature application resources. These resources include the configuration file for applications features, maf-feature.xml. The configuration file is a stub XML descriptor file that enables you to define feature applications that will be seen when the application runs. The maf-feature.xml defines details of each feature - for example, its icon, content type, starting point, etc.This file is configured with a default application, Hello, that you ran earlier.

    The maf-application.xml file defines the details of the application itself, including reference to features. These feature applications, when packaged into a JAR file known as a Feature Archive file (FAR), provide the reusable content that can be consumed by other MAF applications. One reason for this distinction is to allow developers to create feature archives (which may contain one or more features referenced in the maf-feature.xml), and then create applications by simply pulling in feature archives.  Of course each app would only have one maf-application.xml.

    A FAR is essentially a self-contained collection of everything that a feature requires, such as icon images, resource bundles, HTML, JavaScript, or other implementation-specific files. The FAR includes a single maf-feature.xml file, which identifies each of the packaged feature applications by a unique ID. You can edit this file to update feature properties. For example, you can specify the content implementation (local or remote HTML files, AMX pages, or a native application written in platform-specific language). You can also control the display of content based on such factors as user roles and privileges, or device properties. A mobile application can reference one FAR, several of them, or none at all.

    In the Application Navigator, expand the ViewController project. Locate and expand the Application Sources folder. Then expand the META-INF folder. You will see the maf-feature.xml file as shown.

    adfmf-feature,xml selected in the applications navigator

  2. Double click on the maf-feature.xml file to open the Feature editor.

    adfmf-feature.xml in editor

  3. Add a new feature by clicking the green plus sign on the Features table near top of the editor. If you cannot see the plus sign, scroll the Feature editor to the right (the plus sign is on the far right side of the Feature editor).

    adfmf-feature.xml with create adf mobile feature pane displayed with default values

  4. In the Create MAF Feature dialog, modify the following values:

    - Feature Name: Success
    - Feature ID: oracle.success
    - Confirm the Add a corresponding feature reference to maf-application.xml check box is selected, and then click OK.

    adfmf-feature.xml with create adf mobile feature pane displayed with correct values

  5. In the Features table, select the newly created feature oracle.success. Under the Features table, click the Content tab, and locate the Content table. Notice that the content item oracle.success.1 is created by default.

    adfmf-feature.xml with content tab displayed with correct values

  6. Confirm the Id field of the content item is set to oracle.success.1.

    content tab with correct id displayed

  7. In the Content area, ensure the Type property is set to Local HTML .

    content tab with correct type displayed

  8. In the Content section, find the URL text box.

    On the right side of the URL text box, click the magnifying glass icon.

    task flow selected when green plus sign is clicked

  9. In the Open window, select the html page you created earlier. In this case, untitled1.html. Then click Open.

    view controller rask flow option selected in content tab

  10. The resulting definition should look like the image below.

    Save all your work.

    completed feature displayed in the editor



Step 4: Deploy and Test the Page
  1. In the Application menu, select Deploy - New Deployment Profile to start the Create Deployment Profile dialog box.

    There are three other predefined deployment profiles you can use. One for an default iOS deployment, another for a default Android deployment. The third type is used to create a mobile application archive. This archive includes everything, files, icons, reference links but not any signing certificates. It would be used if you wanted to transport an application and install and deploy it using different credentials.

    For our purposes, lets examine what we get when we go through the whole process.

    deploy - new deployment profile menu option

  2. In the Profile Type drop-down list, ensure MAF for iOS is selected and then click OK. Leave the Profile Name at the default value.

    name of deployment profile

  3. In the MAF for iOS Deployment Profile Properties dialog box, examine the deployment options.

    deployment profile properties

  4. Select the iOS Options node and confirm the Simulator Target Version is set to 7.0.

    Then, select the target simulator you wish to use. This must be done in all deployment profiles to determine which simulator to run when the application is deployed. At runtime, you can still switch to view the application in a different device simulator.

    This tutorial uses the iPhone 5 simulator, but feel free to select any simulator you like.

    setting simulator target version to 5.0

    Click OK, and then save all your work.

  5. Before deploying the application, confirm the iOS Simulator is working correctly.

    Run the Simulator by launching Xcode and selecting Xcode > Open Developer Tool > iOS Simulator.
    Once it has started, you can leave it alone.


    deploy menu option

    If at anytime you need to return to the simulator's home page, select Hardware > Home.

    deploy menu option

  6. In the Application menu, select Deploy > iOS2 deployment profile.

    deploy menu option

    In the subsequent dialog box, select Deploy application to simulator, and click Finish.

    deploy profile to simulator window

    There are two approaches to testing an MAF application: Show more or lessRead more...

    1. Testing on a mobile device: This method always provides the most accurate behavior, and is also necessary to gauge the performance of your application. However, you may not have access to all the devices on which you wish to test, making device testing impractical.

    2. Testing on a mobile device emulator or simulator: This method usually offers better performance and faster deployment, as well as convenience. However, even though a device emulator or simulator closely approximates the corresponding physical device, there might be differences in behavior and limitations on the capabilities that can be emulated.

    Typically, a combination of both approaches yields the best results.


  7. In the Deployment Log the Cordova plugman will be installed to support the Cordova plugins. If the Log window is not viewable, select Window > Log from the JDeveloper menu.

    Watch the Deployment Log window for any errors. If the compilation and deployment process completes as expected, you should see the Deployment Log window as shown below.

    The next step in the process is to start the iOS Simulator.


    deployment log window - deployment finished

  8. After the simulator is started, you'll be taken right into the application .A popup notification will appear asking if you would like send notifications. Click OK.

    The MyMobileApp application currently contains your HTML page running inside the MAF application. Because there is only one feature in the application currently, you'll only see one option at the bottom of the page.
    .

    hello world application in simulatorhello world application in simulator

  9. To clear out the application from the simulator, select iOS Simulator - Reset Content and Settings... from the menu. Then click Reset to confirm.

    quit ios simulator menu option

    To clear the settings, click OK in this pane.

    quit ios simulator menu option

  10. Shut down the iPhone simulator by clicking the iOS Simulator menu item (on the top of the Mac desktop), and selecting Quit iOS Simulator.

    quit ios simulator menu option

Back to top
Copyright © 2015, Oracle. All rights reserved.