Fusion Middleware Documentation
Advanced Search


Developing Mobile Applications with Oracle Mobile Application Framework
Close Window

Table of Contents

Show All | Collapse

11 Customizing MAF AMX Application Feature Artifacts

This chapter describes how to preform customization of existing MAF AMX pages, task flows, and page definition files.

This chapter includes the following sections:

11.1 Introduction to Customizing MAF AMX Pages and Artifacts

You can use the standard customization mechanism provided by JDeveloper and Oracle Metadata Service (MDS) to customize your existing MAF AMX application feature artifacts and metadata files, including the following:

  • MAF AMX files (.amx)

  • Task flow files, such as ViewController-task-flow.xml

  • Page definition files (<page name>.PageDef.xml)

  • Data control XML file—a package file that contains a data control structure file (that is, a package file named for a data control and prepended with persdef.). For more information, see Section 7.8, "Configuring Data Controls."

The customization changes that you make at design time are applied to your files during deployment and become visible at runtime. MAF AMX supports the static seeded customization, where the final version for a specific customization context is seeded during deployment and work statically at runtime for that customization context. For each customization context you have to deploy a separate MAF application.

Note:

MAF AMX does not support the user customization that both creates and applies customization at runtime.

11.2 Customizing MAF AMX Pages and Artifacts

You customize your MAF AMX pages and artifacts as follows:

  1. Define customization layers and layer values by modifying the jdev_install/jdeveloper/jdev/CustomizationLayerValues.xml file, as Example 11-1 shows.

    Example 11-1 Defining Customization Layers

    <cust-layers xmlns="http://xmlns.oracle.com/mds/dt">
       <cust-layer name="site" id-prefix="s">
          <!-- Generated id-prefix would be "s1" and "s2"
           for values "site1" and "site2" -->
          <cust-layer-value value="headquarter"
                            display-name="Headquarter" 
                            id-prefix="1" />
          <cust-layer-value value="remoteoffices"
                            display-name="Remote Office"
                            id-prefix="2" />
       </cust-layer>
    </cust-layers>
    

    For more information, see Section 11.4, "Configuring Customization Layers."

  2. Create a customization class—a POJO class that extends oracle.mds.cust.CustomizationClass. For more information, see Section 11.3, "What You May Need to Know About Customization Classes."

    Note:

    The customization class can be created with a separate Java application.

  3. Enable the JDeveloper design time to access the customization as follows:

    1. Package the customization class (a .java file) as a JAR file.

    2. Add the JAR file to one of the projects of the MAF application.

      For more information, see Section 11.5.1, "How to Make Customization Classes Available to JDeveloper at Design Time."

  4. Register the customization class with the MAF application's adf-config.xml file by adding that class to the cust-config section, as Example 11-2 shows.

    Example 11-2 Registering the Customization Class

    <?xml version="1.0" encoding="windows-1252" ?>
    <adf-config xmlns="http://xmlns.oracle.com/adf/config">
       <adf-mds-config xmlns="http://xmlns.oracle.com/adf/mds/config">
          <mds-config xmlns="http://xmlns.oracle.com/mds/config" version="11.1.1.000">
             <cust-config>
                <match path="/">
                   <customization-class name="customclass.SiteCC"/>
                </match>
             </cust-config>
          </mds-config>
       </adf-mds-config>
    </adf-config>
    

    For information, see Section 11.6, "Configuring the adf-config.xml File."

  5. Restart JDeveloper in the Customization Developer role. For more information, see the "Working with JDeveloper Roles" section in Oracle Fusion Middleware User's Guide for Oracle JDeveloper and Section 11.7, "What You May Need to Know About the Customization Developer Role."

    Note:

    The Customization Developer role enables you to change files, but not add them.

  6. Perform the required modifications to the files. Your changes are recorded by MDS in the mdssys directory of the ViewController project:

    This image is described in the surrounding text
  7. Deploy the application to a mobile device, emulator, or as a platform-specific application package.

    Note:

    During deployment, the current customization context is picked up and the customized content that you declared in your MAF AMX pages in the deployed application is included in the new deployment artifacts. The customized content is grouped by the deployment profile name and may extend across multiple pages within the MAF AMX application feature.

    You can deploy a customized application in the Studio Developer role or in Customization Developer role. To deploy in the Customization Developer role:

    1. Launch the application the application in the Customization Developer role.

    2. In the Customization Context window, shown in Figure 11-1, select the layer and value for which you want to implement customizations.

      Figure 11-1 Selecting a Customization Context for Deployment

      This image is described in the surrounding text
    3. Select from among the deployment options (accessed by choosing Application > Deploy, and then by selecting the deployment profile). For more information, see Chapter 19, "Deploying Mobile Applications."

    4. Perform a separate deployment for each customization context.

    During deployment, the base file and the delta files are merged to create the customized version of the application at runtime. The deployed application has no MDS dependencies.

    Tip:

    You can deploy the customized application as a MAF Application Archive (.maa) file and then import it into an application to perform additional customization and upgrades. The delta files included in the .maa file are merged with the base files after deployment. For more information, see Section 4.14.7, "Upgrading a Mobile Application with Customizations."

When the customization process is complete, JDeveloper creates a metadata file for the customizations and a subpackage for storing them. The metadata file contains the customizations for the customized object, which are applied over the base metadata at runtime. JDeveloper gives the new metadata file the same name as the base file for the object, but includes an additional .xml extension, as Figure 11-2, Figure 11-3, Figure 11-4, and Figure 11-5 show.

Figure 11-2 Customization File for MAF AMX Page

This image is described in the surrounding text
Description of "Figure 11-2 Customization File for MAF AMX Page"

Figure 11-3 Customization File for Task Flow

This image is described in the surrounding text
Description of "Figure 11-3 Customization File for Task Flow"

Figure 11-4 Customization File for Page Definition

This image is described in the surrounding text
Description of "Figure 11-4 Customization File for Page Definition"

Figure 11-5 Customization File for Data Control XML File

This image is described in the surrounding text
Description of "Figure 11-5 Customization File for Data Control XML File"

For additional information about customizing web service data controls, see Section 4.14.4, "What You May Need to Know About Web Service Data Controls and Customized Application Deployments."

For information about customizing MAF application-level artifacts, see Section 4.14, "Customizing MAF Files Using Oracle Metadata Services."

11.3 What You May Need to Know About Customization Classes

A customization class evaluates the current context and returns a String result. This String result is used to locate the customization layer.

The customization class provides the following information:

  • A name that represents the name of the layer.

  • An IDPrefix, for objects created in the layer. When new objects are created in a customization layer, they need a unique ID. The IDPrefix is added to the autogenerated identifier for the object to create an ID for the newly added object. Each layer needs a unique IDPrefix so that objects created at different customization layers have unique IDs.

  • A cache hint (CacheHint), for the layer defined by the customization class. In MAF, the cache hint defines a static customization layer and the getCacheHint method always returns ALL_USERS which means the customization is applied globally (unconditionally) for a given deployment.

Note:

Since customization classes are likely to be executed frequently, once for each document being accessed to get the layer name and layer value, you should ensure their efficiency.

Customizations can be used to tailor MAF AMX application feature to suit a specific industry domain (verticalization). Each such domain denotes a customization layer and is depicted using a customization class.

11.3.1 What You May Need to Know About the Static Customization Content

Static customizations have only one layer value in effect for all executions of the application. A static customization has the same value for all users executing the application.

In the customization class used in a MAF application, the getCacheHint method always returns ALL_USERS meaning that the customization layer is always static. For more information about CacheHint values, see Section 11.3, "What You May Need to Know About Customization Classes."

All objects could have a static customization layer, depending on how the customization classes are implemented.

11.4 Configuring Customization Layers

To customize an application, you must specify the customization layers and their values in the CustomizationLayerValues.xml file so that they are recognized by JDeveloper.

When you open a customizable application in the Customization Developer role, JDeveloper reads the adf-config.xml file to determine the customization classes to use and their order of precedence. JDeveloper also reads the CustomizationLayerValues.xml file to determine the layer values to make available in the Customization Context window. If there are layer values defined in the CustomizationLayerValues.xml file that are not defined in the customization classes listed in the adf-config.xml file, they are not displayed in the Customization Context window.

Therefore, you can have a comprehensive list of layer values for all of your customization projects in the CustomizationLayerValues.xml file, and only those appropriate for the current application are available in the Customization Context window. Conversely, you could have a comprehensive list of customization classes for a MAF AMX application feature in the adf-config.xml file, and only the subset of layer values on which you would work in your CustomizationLayerValues.xml file.

Note:

At design time, JDeveloper retrieves customization layer values from the CustomizationLayerValues.xml file. However, at runtime the layer values are retrieved from the customization class.

The names of the layers and layer values that you enter in the CustomizationLayerValues.xml file must be consistent with those specified in your customization classes. Example 11-3 shows the contents of a sample CustomizationLayerValues.xml file.

Example 11-3 Layers and Layer Values Defined in CustomizationLayerValues.xml

<cust-layers  xmlns="http://xmlns.oracle.com/mds/dt">
   <cust-layer name="industry" id-prefix="i">
      <cust-layer-value value="financial"
                        display-name="Financial"
                        id-prefix="f"/>
      <cust-layer-value value="healthcare"
                        display-name="Healthcare"
                        id-prefix="h"/>
   </cust-layer>
   <cust-layer name="site" id-prefix="s">
      <cust-layer-value value="headquarters"
                        display-name="HQ"
                        id-prefix="hq"/>
      <cust-layer-value value="remoteoffices"
                        display-name="Remote"
                        id-prefix="rm"/>
   </cust-layer>
</cust-layers>

For each layer and layer value, you can add an id-prefix token. This helps to ensure the uniqueness of the id, so that customizations are applied accurately. When you add a new element (such as a commandButton) to a MAF AMX page during customization, JDeveloper adds the id-prefix of the layer and layer value (determined by the selected tip layer) to the autogenerated identifier for the element to create an id for the newly added element in the customization metadata file. In the preceding example, the site layer has an id-prefix of " s " and the headquarters layer value has an id-prefix of " hq ". So, when you select site/headquarters as the tip layer and add a Button component to a page, the commandButton element will have an id of " shqcb1 " in the metadata customization file.

For each layer value, you can also add a display-name token to provide a human-readable name for the layer value. When you are working in the Customization Developer role, the value of the display-name token is shown in the Customization Context window for that layer value.

For each layer, you can optionally provide a value-set-size token that defines the size of the value set for the customization layer. This can be useful, for example, when using a design-time, application-specific CustomizationLayerValues.xml file. By setting value-set-size to no_values you can exclude runtime-only layers at design time.

<cust-layer name="runtime_only_layer" value-set-size="no_values"/>

You can define the customization layer values either globally for JDeveloper or in an application-specific file. If you use an application-specific file, it takes precedence over the global file. For more information on configuring layer values globally for JDeveloper, see Section 11.4.1, "How to Configure Layer Values Globally." For more information on configuring application-specific layer values, see Section 11.4.2.1, "Using the Studio Developer Role."

11.4.1 How to Configure Layer Values Globally

Before you begin:

To configure design time customization layer values globally for JDeveloper:

  1. Open the CustomizationLayerValues.xml file located in the jdev subdirectory of your JDeveloper installation directory (jdev_install\jdev\CustomizationLayerValues.xml).

  2. For each layer, enter a cust-layer element, as shown in Example 11-3, "Layers and Layer Values Defined in CustomizationLayerValues.xml".

  3. For each layer value, enter a cust-layer-value element, as shown in Example 11-3, "Layers and Layer Values Defined in CustomizationLayerValues.xml".

  4. Save and close the CustomizationLayerValues.xmlfile.

  5. After you have made changes to the global CustomizationLayerValues.xml file, restart JDeveloper.

11.4.2 How to Configure Workspace-Level Layer Values

When configuring layer values for an application, you can use either the Studio Developer role (see Section 11.4.2.1, "Using the Studio Developer Role") or the Customization Developer role (see Section 11.4.2.2, "Using the Customization Developer Role"). Note that when you configure an application-specific CustomizationLayerValues.xml file, you can create and modify layer values, but you cannot create additional customization layers. It is not necessary to restart JDeveloper to pick up changes made to the application-specific layer values.

When you create an application-specific CustomizationLayerValues.xml file, JDeveloper stores it in an application-level directory (for example, workspace-directory\.mds\dt\customizationLayerValues\CustomizationLayerValues.xml). You can access this file in the Application Resources window of the Applications window, under the MDS DT node.

11.4.2.1 Using the Studio Developer Role

The following procedure describes how to configure the CustomizationLayerValues.xml file for a specific application from the Studio Developer role.

Before you begin:

To configure design-time customization layer values at the workspace level from the Studio Developer role:

  1. In the Application Resources window, expand the Descriptors > ADF META-INF node, and then double-click adf-config.xml.

  2. In the Overview editor, click the MDS Configuration navigation tab.

  3. On the MDS Configuration page, below the table of customization classes, click Configure Design Time Customization Layer Values to open the workspace-level CustomizationLayerValues.xml file in the Source editor.

    Note:

    If the override file does not exist, JDeveloper displays a confirmation dialog. Click Yes to create and open a copy of the global file.

  4. In the file, specify layer values as necessary, as described in Section 11.4, "Configuring Customization Layers."

  5. Save your changes.

11.4.2.2 Using the Customization Developer Role

The following procedure describes how to configure the CustomizationLayerValues.xml file for a specific application from the Customization Developer role.

Before you begin:

To configure design-time customization layer values at the workspace level from the Customization Developer role:

  1. In the Customization Context window, click Configure application layer values to open the CustomizationLayerValues.xml file in the Source editor.

    Note:

    If the override file does not exist, JDeveloper displays a confirmation dialog. Click Yes to create and open a copy of the global file.

  2. In the file, specify layer values as necessary, as described in Section 11.4, "Configuring Customization Layers."

  3. Save your changes.

After you make changes to the application-specific CustomizationLayerValues.xml file while you are in the Customization Developer role, any tip layer you have selected in the Customization Context window is deselected. You can then select the desired tip layer.

11.5 Consuming Customization Classes

After you have created your customization classes, you can use them at design time in the Customization Developer role, as well as at runtime in the application. To be consumed in an application or in JDeveloper, the classes must be packaged appropriately.

11.5.1 How to Make Customization Classes Available to JDeveloper at Design Time

After you create the customization classes, you must make them available to JDeveloper so that you can use them when implementing customizations while working in the Customization Developer role.

Because the customization classes are reusable components, you can create a separate project to contain them and package them into their own JAR file. You can then import the JAR into the consuming application, which makes the customization classes available to JDeveloper.

Note:

This procedure is not required if you created your customization classes in the data model project of the consuming application.

Use the following procedure to make the customization classes visible to the application, and then add the customization classes to the cust-config section of the adf-config.xml file, as described in Section 11.6, "Configuring the adf-config.xml File."

Before you begin:

  • Create your customization classes in an external project, as described in Section 11.2, "Customizing MAF AMX Pages and Artifacts."

  • Create a JAR file that includes the customization classes.

  • Launch JDeveloper using the Studio Developer role, and open the application that you want to customize.

To use customization classes from an external project:

  1. In the Applications window, click the Application Menu icon and select Application Properties.

  2. In the Application Properties dialog, select Libraries and Classpath, and click Add JAR/Directory.

  3. In the Add Archive or Directory dialog, select the JAR file you created that contains the customization classes, and click Open.

  4. Click OK.

Upon completion, the customization classes are available to JDeveloper for customization and for running your project locally in JDeveloper. They will also be packaged to the EAR class path when you package the application.

11.6 Configuring the adf-config.xml File

The application's adf-config.xml file must have an appropriate cust-config element in the mds-config section. The cust-config element allows clients to define an ordered and named list of customization classes. You use the Overview editor for the adf-config.xml file to add customization classes (see Figure 11-6).

Before you begin:

To identify customization classes in the adf-config.xml file:

  1. In the Application Resources window, expand the Descriptors > ADF META-INF nodes, and then double-click adf-config.xml.

  2. In the Overview editor, select MDS navigation tab and then click the Add ( + ).

  3. In the Edit Customization Class dialog, search for or navigate to the customization classes you have already created.

  4. Select the appropriate classes and click OK.

  5. After you have added all of the customization classes, you can use the arrow icons to arrange them in the appropriate order.

Figure 11-6 shows the Overview editor for the adf-config.xml file with two customization classes added.

Figure 11-6 adf-config.xml Overview Editor

This image is described in the surrounding text

The order of the customization-class elements defines the precedence of customization layers. For example, in the code shown in Example 11-4, the IndustryCC class is listed before the SiteCC class. This means that customizations at the industry layer are applied to the base application, and then customizations at the site layer are applied.

Example 11-4 Customization Class Order in the adf-config.xml File

<adf-config xmlns="http://xmlns.oracle.com/adf/config"> 
   <adf-mds-config xmlns="http://xmlns.oracle.com/adf/mds/config"> 
      <mds-config xmlns="http://xmlns.oracle.com/mds/config" version="11.1.1.000">
         <cust-config> 
            <match path="/">
               <customization-class name="com.mycompany.IndustryCC"/>
               <customization-class name="com.mycompany.SiteCC"/>
            </match> 
         </cust-config>
      </mds-config>
   </adf-mds-config>
</adf-config>

11.7 What You May Need to Know About the Customization Developer Role

In JDeveloper, the Customization Developer role is used to customize the metadata in a project. Customization features are available only in this role. When working in a Customization Developer role, you can do the following:

  • Create and update customizations.

  • Select and edit the tip layer of a customized application.

  • Remove existing customizations.

When you use JDeveloper in the Customization Developer role, the Source editor is read-only and the following JDeveloper features are disabled:

  • Workspace migration.

  • Creation, deletion, and modification of application and IDE connections. You must configure connections in Default role before opening an application in Customization Developer role.

When working with an application in the Customization Developer role, new objects cannot be created, and noncustomizable objects cannot be modified. In addition, you cannot edit noncustomizable files, such as Java classes, resource bundles, security policies, deployment descriptors, and configuration files.

Note:

Noncustomizable files are indicated by a lock icon when you are working in the Customization Developer role.

You are also restricted from modifying project settings and customizing certain ADF Business Components features, including service interfaces and business event definitions. Additionally, you cannot refactor, or make changes to customizable files that would, in turn, necessitate changes in noncustomizable files.

11.7.1 How to Switch to the Customization Developer Role in JDeveloper

The customization features of JDeveloper are available to you in the Customization Developer role. To work in this role, you can either choose it when you start JDeveloper or, if JDeveloper is already running, you can use the Switch Roles menu to switch to the Customization Developer role.

To switch to the Customization Developer role in JDeveloper:

From the main menu in JDeveloper, choose Tools > Switch Roles > Customization Developer.

Optionally, you can toggle the Tools > Switch Roles > Always Prompt for Role Selection at Startup menu to specify whether or not you want to choose the role when JDeveloper is launched. If deselected, JDeveloper launches in the role in which it was when you last closed it.

11.7.2 What You May Need to Know About the Tip Layer

When working in the Customization Developer role, the layer and layer value combination that is selected in the Customization Context window is called the tip layer. The changes you make while in the Customization Developer role are applied to this layer.

Note:

When working in the Customization Developer role, if the Customization Context window is not displayed, you can access it from JDeveloper's Window menu.

The metadata displayed in the JDeveloper editors is a combination of the base metadata and the customization layers up to and including the tip layer, according to the precedence set in adf-config.xml, with the values specified in the Customization Context window for each layer.

When working in the Customization Developer role, you can also see the noncustomized state of the application. When you select View without Customizations in the Customization Context window, there is no current tip layer. Therefore, what you see is the noncustomized state. While you are in this view, all customizable files show the lock icon (in the Applications window), indicating that these files are read-only.

When you make customizations in a tip layer, these customizations are indicated by an orange icon in the Properties window. A green icon indicates non-tip layer customizations. When you see an orange icon beside a property, you have the option of deleting that customization by choosing Remove Customization from the dropdown menu for that property.