8 Reusing the MAF Application Content

This chapter introduces Feature Archive (FAR) files and describes how you can package application feature content into these files for reuse in one or more MAF applications.

This chapter includes the following sections:

8.1 Introduction to Feature Archive Files

Application features, when packaged into a JAR file known as a Feature Archive file (FAR), provide reusable content that can be consumed by other MAF applications. A MAF application can consume one or more FAR files. A FAR file contains everything that an application feature requires, such as icon images, resource bundles, HTML files, JavaScript files, and other implementation-specific files.

A FAR also contains one maf-feature.xml file, which identifies each of the packaged application features by a unique ID. You can edit this file to update application feature properties, such as content implementation (MAF AMX, Local HTML, Remote URL), display properties based on such factors as user roles and privileges, or device properties.

You can add a FAR as either an application library or as a view controller project. You cannot customize the FAR's contents when you add it as project library, nor can you reuse its individual artifacts. A MAF application consumes the FAR in its entirety when it is added as a library file. For example, a FAR's task flow cannot be the target of a task flow call activity.

8.2 Using FAR Content in a MAF Application

You can import a FAR to make its features accessible to your MAF application.

Before you begin:

Deploy the application feature as a Feature Archive file, as described in Section 27.6.2, "How to Deploy the Feature Archive.".

How to add application feature content to a MAF application:

  1. In the Project Explorer, expand the folder for the top-level assembly project, then expand the MAF folder.

  2. Double-click MAF Application Editor to open it.

  3. Right-click on the Feature Archives folder and choose New > Feature Archive.

  4. Click the Browse button for the URI field to open the Mobile Feature Archive Location dialog, then type in the URI at which the FAR can be located. OEPE verifies that the selected file contains feature definitions, and that the location is accessible.

  5. When you have specified the URI and OEPE has verified it, click OK.

8.3 What Happens When You Add a FAR

After you add a FAR to a MAF application:

  • The FAR appears in the MAF Application Editor, as shown in Figure 8-1.

    Figure 8-1 Feature Archive Imported into MAF Application

    This image is described in the surrounding text
  • Every application feature declared in the maf-feature.xml files included in the JARs becomes available to the consuming application, as illustrated by Figure 8-2 where the dropdown lists IDs of the available application features in the JAR in addition to one that has already been defined in the application.

    Figure 8-2 FAR Features Available

    This image is described in the surrounding text
  • The information in the connections.xml file located in the Feature Archive JAR is merged into the consuming application's connections.xml file. If there are any conflicts, these are displayed in the Log window.

8.4 What You May Need to Know About Enabling the Reuse of Feature Archive Resources

To ensure that the resources of a FAR can be used by an application, both the name of the FAR and its feature reference IDs must be globally unique; ensure there are no duplicate feature reference IDs in the maf-application.xml file. Within the FAR itself, the DataControl.dcx file must be in a unique package directory. Rather than accepting the default names for these package directories, you should instead create a unique package hierarchy for the project. You should likewise use a similar package naming system for the feature reference IDs.