4 Setting Up the Login Module

This chapter describes how to use the Login Module to manually configure the user login and logout for a mobile application.

This chapter contains the following topics:

4.1 Before You Begin

Before you can set up the Login Module for your mobile application, you have to:

4.2 Setting Up the Login Module

The Login Module is provided in the Login.jar file.

Important:

An Oracle MAF license is required in order to use the Login.jar (Login Module) in production-ready mobile applications.

Setting up the Login Module includes the following tasks:

4.2.1 Pointing to the Login.jar

To point to the Login.jar:

  1. In JDeveloper, click the Application drop-down and select Application Properties.

  2. Select Libraries and Classpath and then click the Add JAR/Directory button to locate the Login.jar file on your local file system.

    The Login.jar is part of the JDE_Mobile_Framework_1.0.0 download.

  3. After you locate the Login.jar, click Open.

  4. Click OK to save the properties.

4.2.2 Making the Login Module the First Feature in Your Mobile Application

To make the Login Module the first feature in your mobile application:

  1. In the Application Resources panel, double-click the maf-application.xml to open it.

  2. Select the Feature References tab, and then click the green plus sign to add a feature reference.

  3. In the Id drop-down menu, select com.oracle.e1.jdemf.login and click OK.

  4. Use the blue arrow to the right to move the login feature to the top of the list.

4.2.3 Verifying the LifeCycleListenerImpl Activation

You must verify that the LifeCycleListenerImpl is activated before setting the defaultFeature or overriding your login values.

To do so:

  1. In the Application Resources panel, under Descriptors > ADF META-INF, double click maf-application.xml.

  2. Select the Application tab and then click the magnifying glass next to Lifecycle Event Listener.

  3. Navigate to LifeCycleListenerImpl in the hierarchy, which should be:

    application.LifeCycleListenerImpl

  4. Click OK.

4.2.4 Setting the defaultFeature

You must set the default feature in your application so that the Login page can successfully navigate to your default page.

To do so:

  1. In the Projects panel, expand ApplicationController > Application Sources > application, and double-click LifeCycleListenrImpl.java.

  2. Locate a method that looks like the following method:

    public void start()
      {
        // Add code here...
      }
    
  3. Replace the code in the method with the following code, where the value in quotes is the Feature ID of your applications main feature:

    public void start()
      {
        LoginConfiguration.setDefaultFeature("myfeatureId");
      }
    

4.2.5 Overriding the Login Values from Your Mobile Application

While developing your mobile application, you typically run the mobile application multiple times for testing. To make the testing process easier, you can override the login values.

To do so:

  1. On the LifeCycleListenrImpl.java page, locate a method that looks like the following method:

    public void start()
      {
        // Add code here...
      }
    
  2. Replace the code in the method with the following code, where the value in quotes is the Feature ID of your applications main feature:

      public void start()
      {
        LoginConfiguration.setCredentials("jde", "jde");
    

    This code will override the user name and password on the login screen. Depending on the values that you need to override, use one of the following parameters to invoke this method:

    • LoginConfiguration.setCredentials(username, password);

    • LoginConfiguration.setCredentials(username, password, environment, role);

    • LoginConfiguration.setCredentials(username, password, environment, role, jasserver);

4.3 Configuring the Logout

This section describes how to manually configure the logout if you are not using the springboard for the logout. The steps on how to use the springboard are located in the section that describes how to create a sample mobile application. See Appendix A, "Creating a Sample Mobile Application" for more information.

To configure the mobile application logout, you call the JDEmfUtilities.logout() method. To enable your mobile application to call it, place this call in a method of your DC class. This method returns the user to the login screen. When the default feature is invoked after logging in again, it will be in a new state.

public static void logout(){
JDEmfUtilities.logout();
}

To place a Logout button on your screen, regenerate your data control from your DC class. You can now drag the item logout() onto your form.