Building a Mobile Web Application Using Oracle Application Express 5.0

Overview

Purpose

This tutorial covers how to create a mobile web application using Oracle Application Express 5.0.

Time to Complete

Approximately 45 minutes.

Introduction

Mobile applications are designed to run specifically on smartphone devices and hence they must be built with extremely minimal, semantic HTML that is optimized for mobile connections. Mobile applications developed with Oracle Application Express are browser-based applications that run inside the browser on the mobile device. Therefore, these applications must have a connection in order to communicate with the Oracle Database and cannot operate in a disconnected environment. Mobile devices that have HTML5 capabilities can utilize all of the capabilities that can be built into the applications, including HTML5 date-pickers, sub-types that display different keypads based on field definition, and so. Older devices will still render the application they will offer less advanced features. The major advantage of developing browser-based applications is that you only need to develop them once for the majority of mobile devices.

To support mobile application development, Oracle Application Express incorporates jQuery Mobile. jQuery Mobile-based web pages use a lightweight framework that enables you to create compact and minimalistic web sites that include only a few images and CSS files. Using jQuery Mobile, these applications can run on the following mobile operating systems: iOS, Android, Blackberry, and Windows Mobile.

To test your mobile applications, you can also download and install some of these recommended emulators to view the mobile application.

  • On a Mac, you can use the XCode iPhone Simulator
  • On Windows, you can use the following:
    • Emulator included in the Android SDK
    • Genymotion - which is an Android running in a Virtual Machine
    • Andy

Scenario

In this tutorial, you create a mobile application that is based on the Projects and Departments tables. You will create a List and a Form type of pages for both  Projects and Departments.


Prerequisites

Before starting this tutorial, you should have:

  • Access to Oracle Database 11g or later
  • Installed Oracle Application Express 5.0 into your Oracle Database
  • Downloaded and installed the files.zip into your working directory.
  • Created a workspace and user to perform this tutorial.

Running SQL Script to Load Tables

Before you build the application, you should run the SQL Script that is used to load tables into the database. The mobile application is built using loaded tables.

  1. Log into the Application Express Login page using your login credentials. Enter your login credentials and click Login.


    alt description here


  2. To create the tables, you need to run the SQL Script against the database. Click the down arrow next to SQL Workshop and then select SQL Scripts.

    alt description here
  3. Click Upload.

    alt description here
  4. Click Choose File.

    alt description here

    Locate the OBE.sql file from the files folder that you have downloaded into your working directory.

    alt description here

    Click Upload.
    alt description here
  5. Click Run button.
    alt description here
  6. Click Run in Background.
    alt description here
  7. Click View Results
    alt description here
  8. Your tables have been successfully created and data has been inserted into them.
    alt description here

Creating a Mobile Web Application

In this topic, you create a Mobile application and add list and form pages to the application.


  1. Click Application Builder.


    alt description here


  2. Click Create.


    alt description here


  3. Click Mobile.


    alt description here


  4. Enter Mobile App for Name. Click the up arrow to select the Theme for the mobile application. APEX 5.0 ships with a new mobile theme called Theme 51, which includes a choice of theme styles. Theme styles provide different color schemes and styling.


    alt description here


  5. The two types of Mobile themes that are available are jQuery Mobile Smartphone Theme 50 and Theme 51. The difference between these two theme styles is that Theme 51 uses a List template type and Theme 50 uses a Tab template type. Click jQuery Mobile Smartphone of ID 51.


    alt description here
  6. Click the Theme Style select list to view the available theme colors. Blue and Red are the two Theme Styles that a re available. Select Blue and click Next.
    alt description here


  7. Click Add Page to add pages in the application.


    alt description here


  8. Select List View and Form page type. List View is optimized to display data and provide easy navigation on Smartphones. This page type builds a two page List View and Form combination of pages. On the first page, you can select a row to update from the List View. On the second page, you can add a new record, and update or delete the selected record.
    Select Home(1) for Subordinate to Page, OBE_DEPARTMENTS for Table Name, and DEPARTMENT_NAME for Display Column. Click Add Page.


    alt description here


  9. Click Add Page again to add more pages to the application.


    alt description here


  10. Select List View and Form. Select Home(1) for Subordinate to Page, OBE_PROJECTS for Table Name, and PROJECT_NAME for Display Column. Click Add Page.


    alt description here
  11. Click Add Page to add another report page type.


    alt description here
  12. You want to add a Column Toggle Report. A column Toggle Report hides less important columns at narrower widths and surfaces a button to open a menu allowing the user to choose the columns to be viewed. Click Column Toggle Report. Select OBE_EMPLOYEES for Table Name. Click Add Page.


    alt description here
  13. You want to add another report page type. Click Add Page.


    alt description here
  14. A Reflow report collapses the table columns into a stacked presentation. Click Reflow Report. Select Home (1) for Subordinate to Page. Select OBE_EMPLOYEES for Table Name. Click Add Page.


    alt description here
  15. The pages in your application have been created. You want to edit the names of some pages in your application. Click the Edit icon against ID 6 of the Obe Employees of Column Toggle Report page type.


    alt description here
  16. Change the Name as Employees Column Toggle Report and click Apply Changes.


    alt description here
  17. You also want to edit the Name of the Obe Employees (7) Reflow Report. Click the Edit icon against this page type.


    alt description here
  18. Change the Name as Employees Reflow Report and click Apply Changes.


    alt description here
  19. Click Next.


    alt description here


  20. Accept the default and click Next.


    alt description here


  21. Click Next.


    alt description here


  22. Click Create Application.


    alt description here


  23. Your application has been successfully created. The application definition is displayed with the various pages that you added using the Create Application wizard.


    alt description here


  24. To view your application, click Run Application.


    alt description here


  25. In the new tab, enter your login credentials and click Login.


    alt description here


  26. The Navigation List shows the two pages that were created under the Home page. 


    alt description here
  27. Click the panel button icon on the left corner to view the panel that contains the top level pages that were added at the time of creating the application.

    alt description here
  28. A panel that contains the top level pages is displayed. Clicking any of the top level pages will display its associated subordinate pages.

    alt description here
  29. Click Home.
    alt description here
  30. The subordinate pages Obe Departments and Obe Projects are listed in the list under the Home page are displayed.

    alt description here
  31. Click Obe Departments.

    alt description here
  32. A List View containing the Department Names is displayed. The Create button is available to create a new record. Click Administration to view the Administration department details.


    alt description here


  33. The Department details such as the Department Name and Location Id are displayed. The Save and Delete buttons are available to save the modified record and delete the selected record.


    alt description here


  34. Similarly, to view the Projects list view and Projects form details, click the panel icon.


    alt description here


  35. Click the right arrow next to Home.


    alt description here


  36. Click Obe Projects.


    alt description here


  37. A list view of Projects is displayed. The Create button is available to create a new record. Click one of the Project Names to view the Project Details. In this case, click Maintain Support Systems.


    alt description here


  38. The Project Details pertaining to that particular project is displayed. The Save and Delete buttons are available to save the modified record and delete the selected record.


    alt description here


  39. Click the Application Builder tab to navigate back to the application and modify the application pages.


    alt description here


Adding a New Page to the Panel Menu

In this section, you add a new page of type chart to the Panel menu using the Create Page wizard.

  1. In the Application Builder Home page, click Create Page.

    alt description here
  2. Click Chart.

    alt description here
  3. Select Pie & Doughnut and click Next.

    alt description here
  4. Select 3D Pie and click Next.

    alt description here
  5. Enter EmpDept Chart for Page Name and Region Name. Click Configure.

    alt description here
  6. You want to add this page to the Navigation List. Enter EmpDept Chart for Top Level List Item Label, select Yes for Add Page Link to Navigation List and enter EmpDept Chart for List Item Label. Click Submit.

    alt description here
  7. Click Next.

    alt description here
  8. Enter Employees per Department for Chart Title. Click Next.

    alt description here
  9. Copy and paste the following query into the query field. Click Next.
    select null link, d.dname label, e.emp_count value from (select deptno, count(*) emp_count
    from emp group by deptno) e, dept d where e.deptno = d.deptno

    alt description here
  10. Click Create.

    alt description here
  11. Click Run Application.

    alt description here
  12. Click the panel list button icon.

    alt description here
  13. Notice that the EmpDept Chart list entry is listed in the navigation list along with page link to the navigation list. Click EmpDept Chart page link in the navigation list.

    alt description here
  14. The Employees per Department chart is displayed.

    alt description here

Modifying the List on the Home Page

In this section, you modify the Name and Title of the Navigation List in the Home page.

  1. In the Application Builder Home page, click Home.

    alt description here
  2. In the Rendering section of the Page Designer, click Navigation.

    alt description here
  3. In the Property Editor - Region section of the Page Designer, notice that the region type is a List. To modify the list, click Shared Components icon.

    alt description here
  4. In the Shared Components, under the Navigation section, select Lists.

    alt description here
  5. Select Navigation.

    alt description here
  6. Click Obe Departments.

    alt description here
  7. Modify the List Entry Label to Departments and click Next icon.

    alt description here
  8. Modify the List Entry Label to Projects and click Apply Changes.

    alt description here
  9. Notice the changes in the Navigation List names. Click Edit Page 1 icon.

    alt description here

Modifying Departments List View and Departments Form pages

In this section, you modify the Name, Title, Region, and Query definitions of the Departments List View and Departments Form pages appropriately. You can make use of the settings available in the List View attributes to display the report based on your requirement. The List View supports the following features:

Advanced Formatting: This feature allows you to include text formatting conventions for common list patterns like header/descriptions, secondary information and counts through semantic HTML markup.

Show Image:You can add an image inside a list item as the first child element.

Show List Divider: This feature allows List items to be turned into dividers to organize and group the list items.

Has Split Button: In cases where there is more than one possible action per list item, you can use a split button to offer two independently clickable items - the list item and a small arrow icon in the far right.

Enable Search: jQuery Mobile provides a very easy way to filter a list with a simple client side search feature. The framework will have a search box above the list to filter out list items that do not contain the current search string as the user types.

Is Nested List View: This feature can be used to populate a new page with the title of the parent in the header and the list of child elements when a list item with a child list is clicked.

Inset List: You can use this feature if lists are embedded in a page with other types of content. An inset list packages the list into a block that sits inside the content area with a bit of margin and rounded corners.


  1. Click the Go To Page icon.

    alt description here

    Select Page 2 (Obe Departments) page from the Popup List of Values of Page Finder.

    alt description here
  2. Under the Identification heading of the Property Editor - Page section in the Page Designer, change the Name and Title as Departments.

    alt description here
  3. Click Save.

    alt description here
  4. Click the OBE_DEPARTMENTS List View region in the Rendering section of the Page Designer.

    alt description here
  5. In the Property Editor - Region section of the Page Designer, change the Title as Departments, and replace the SQL Statement with the query provided below.

    select department_name, department_id, (select count(*) from OBE_PROJECTS p where p.project_dept = d.department_id) Projects from OBE_DEPARTMENTS d
    alt description here
  6. Click Save.

    alt description here
  7. Next, click Attributes to modify the Settings for this region.

    alt description here
  8. In the Property Editor - Attributes section of the Paqe Designer, under Settings, uncheck the Enable Search feature. In the Counter Column, select Projects. In the Number of Rows textbox, enter 10 and click Save.

    alt description here
  9. Next,you want to modify the Departments Form page. Click Go to Page icon.

    alt description here
  10. In the Popup List of Values of Page Finder, select Page Number 3 - Obe Departments.

    alt description here
  11. In the Property Editor - Page section of the Page Designer of Page 3, change the Name and Title to Maintain Departments and click Save.

    alt description here
  12. Next, you will modify the Items in the Page. Currently, the item Department_Id is a hidden item and you want to change it to a Number field so that you can add a new Department Id in the form. In the Rendering section of the Page Designer, click P3_DEPARTMENT_ID

    alt description here
  13. In the Property Editor - Page Item section of the Page Designer, change the Type as Number Field and Label as Department Id. Click Save.

    alt description here
  14. Next, select P3_LOCATION_ID in the Rendering section of the Page Designer.

    alt description here
  15. In the Property Editor - Page Item section of the Page Designer, notice that the Type is Number Field. However, you can change it to a Select List where you can select the Location Names from the locations table to be displayed in the form. To do this, change the Number Field to Select List in the Type property. Change the Label to Locations. In the List of Values property, select SQL Query for Type and enter the below given SQL Statement. Click Save.
    select city d, location_id r from mob_locations

    alt description here
  16. Next, you want to view the changes you made to the pages. Navigate to the Home page that is already available in a different tab.

    alt description here
  17. Notice that the Navigation items in the Home page have now been changed to Departments and Projects.

    alt description here
  18. Click Departments.

    alt description here
  19. Notice that the Label has been changed to Departments and a counter column with the number of projects associated with each Department is displayed.

    alt description here
  20. Click Administration.

    alt description here
  21. You will be taken to the Maintain Departments page where the Department Details of the department that you have selected is displayed. Notice that the Department Id (which was a Hidden item, but later changed to a Number Field) is displayed and also notice that the Location item is a Select List. You can modify the Department Details by changing any of these items. Click the down arrow in the Select List of the Location field and change the location to Bombay. Click Save.

    alt description here
  22. The changes have been applied. Click Administration again to view the changes you made to the Location of that department.

    alt description here
  23. Notice that the modified record is displayed. Click the panel list button icon to navigate back to the Home page.

    alt description here
  24. Select the right arrow next to Home.

    alt description here
  25. Select Departments.

    alt description here
  26. You now want to create a new Department. Click Create.

    alt description here
  27. Enter 50 for Department Id, IT for Department Name, and select South San Francisco for Location. Click Create.

    alt description here
  28. Notice that a new department IT has been added.

    alt description here

Modifying Projects List View and Projects Form pages

In this section, you modify the Name, Title, Region, and Query definitions of the Projects List View and Projects Form pages appropriately.

  1. Navigate back to the Page Designer tab of the Application of Page 3.

    alt description here
  2. Click the Go To Page icon.

    alt description here

    Select Page Number 4 (Obe Projects) from the Popup List of Values of Page Finder.

    alt description here
  3. In the Property Editor - Page section of the Page Designer of Page Number 4 (Obe Projects), change the Name and Title as Projects. Click Save.

    alt description here
  4. In the Rendering section of the Page Designer section, click Attributes.

    alt description here
  5. In the Property Editor - Attributes section, expand Settings. Select Advanced Formatting and Show List Divider under Features. Enter the code given below in the Text Formatting text field. Select PROJECT_DEPT in the List Divider Column to divide the Project lists based on the Department.

    <h1>&PROJECT_NAME.</h1>

    <p>Start Date: &PROJECT_START_DATE.</p>

    <p>End Date: &PROJECT_END_DATE.</p>

    alt description here
  6. Further down, change the Search Type as Server: Like and Ignore Case. Select PROJECT_NAME for Search Column and enter Search By Project Name in Search Box Placeholder text field. In the Layout property, enter Number of Rows as 10 and click Save.

    alt description here
  7. Next, you select the Projects form page to make changes to the items. Click the Go To Page icon.

    alt description here

    Select Page Number 5 - Obe Projects in the Popup List of Values of Page Finder.

    alt description here

  8. In the Property Editor - Page section of the Page Designer of Page Number 5 (Obe Projects), change the Name and Title as Maintain Projects. Click Save.

    alt description here
  9. In the Rendering section of the page, select P5_PROJECT_DEPT.

    alt description here
  10. You want to change the Type of this item to be a select list so that you can select the Departments that are available and modify the Projects with a different Department if needed. In the Property Editor - Page Item section of the Page Designer, select the Type to Select List in the Identification property. Select Type as SQL Query in the List of Values property and enter the SQL Statement given below. Click Save.
    select department_name d, department_id r from obe_departments

    alt description here
  11. In the Rendering section of the Page Designer, click P5_STATUS.

    alt description here
  12. You want to have a Select List for the Status of the Projects. In the Property Editor - Page Item section of the Page Designer, change the Type to Select List in the Identification property. Select Type as SQL Query in the List of Values property and enter the SQL Statement given below. Click Save.
    select distinct status d, status r from obe_projects

    alt description here
  13. You now want to run the application to view the changes you made to the Projects List View and Form pages. Select the tab that has the application open and running.

    alt description here
  14. Click the panel list button icon on the page to go back to the Home page.

    alt description here
  15. Click the right arrow icon next to Home.

    alt description here
  16. Click Projects.

    alt description here
  17. Notice that the projects have been divided based on the Department Id. Enter a term in the Search field to search the Projects based on the Search item. Type Maintain in the Search field and press Enter key.

    alt description here
  18. Notice that the Projects are displayed based on the Search field.

    alt description here
  19. Click Maintain Support Systems to view the details of this project.

    alt description here
  20. Change the Status of the project from Open to Planned.

    alt description here
  21. Click Save.

    alt description here
  22. The changes have been saved. To verify the changes, click the Project name.

    alt description here
  23. The changes have been saved. To verify the changes, click the Project name again.

    alt description here
  24. Notice that the Status has changed.

    alt description here

Enhancing the Projects Form page by Adding a New Page Item and Dynamic Action

In this section, you add a new page item called LOCATION to the Projects form page. You will then associate the P5_PROJECT_DEPT item with a Dynamic Action that will display the Location based on the Department selected. Dynamic Actions are used to define complex client-side behavior declaratively without the need for JavaScript. Using the Dynamic Actions, you specify an action that is performed when a defined set of conditions occur. You can also specify which elements are affected by the action, and when and how they are affected.

  1. Navigate back to the Page Designer tab of the Application by clicking Page Designer tab. page.

    alt description here
  2. In the Rendering section of the Maintain Projects page, right-click Items and select Create Page Item.

    alt description here
  3. In the Property Editor - Page Item section of the Maintain Projects page, enter P5_LOCATION for Name and select Type as Display Only. In the Source property, select Type as Item and select P5_LOCATION from the Popup List of Values of Pick Item. Click Save.

    alt description here
  4. Next, you want to create a Dynamic Action for the P5_PROJECT_DEPT item which will display the appropriate Location of the Department whenever the Department Name is changed. Right-click P5_PROJECT_DEPT and select Create Dynamic Action.

    alt description here
  5. In the Property Editor - Dynamic Action section of the Page Designer, enter Name as Get Location and click Show All button.

    alt description here
  6. Navigate to the Rendering section, expand Get Location, select True. Click Show.

    alt description here
  7. In the Property Editor - Action section, change Action property to Set Value. Expand Settings and select Set Type as SQL Statement and enter the SQL Statement given below. Select P5_PROJECT_DEPT for Page Items to Submit. Note that under the Affected Elements, P5_LOCATION is selected with Selection Type as Item(s). Click Save.
    select city from obe_locations where location_id = (select location_id from obe_departments where department_id = :P5_PROJECT_DEPT)

    alt description here
  8. To view the modifications, you have to run the application. Navigate to the Maintain Projects tab in the browser.

    alt description here
  9. Click the panel list button icon.

    alt description here
  10. Click the right arrow next to Home.

    alt description here
  11. Click Projects.

    alt description here
  12. Click Maintain Support Systems project. Notice that the Location is being displayed.

    alt description here
  13. Change the Project Dept select list to a different department. Select IT from the select list.

    alt description here
  14. The Location changes based on the Department Name selected.

    alt description here
  15. Click panel list icon.

    alt description here

Viewing the Employees Column Toggle Report

In this topic, you view the Employees Column Toggle report. In this report, you can toggle the columns and hide the columns which are less important in the report thereby allowing the user to choose the columnms to be viewed.

  1. Click Employees Column Toggle Report in the panel list.

    alt description here
  2. Notice that all the columns in the report are displayed. You can choose to display only columns that are of importance to you by clicking the Columns button on the top right corner of the screen. Click Columns...

    alt description here
  3. All the columns that are available are displayed here. You can uncheck the columns that you do not want in your report. Click Employee Id and Email columns to deselect and not display in the report.

    alt description here
  4. Notice that the Employee Id and Email columns are not displayed.

    alt description here
  5. A Toggle report can also be used to assign priorities to different columns in the report. Click Page Designer tab.

    alt description here
  6. Navigate to the Toggle Report page by clicking the down arrow of the Popup List of Values of page list. Home.

    alt description here
  7. Select Employees Column Toggle Report page.

    alt description here
  8. In the Rendering section of the Page Designer, click the arrow head aginst Columns to expand the columns available in the report.

    alt description here
  9. The available columns are displayed. Click FIRST_NAME.

    alt description here
  10. In the Property Editor - Column section of the Page Designer, select 3 for Priority.

    alt description here
  11. In the Rendering section of Page Designer, click LAST_NAME.

    alt description here
  12. In the Property Editor - Column section of the Page Designer, select 3 for Priority.

    alt description here
  13. In the Rendering section of Page Designer, click EMAIL.

    alt description here
  14. In the Property Editor - Column section of the Page Designer, select 2 for Priority.

    alt description here
  15. In the Rendering section of Page Designer, click HIRE_DATE.

    alt description here
  16. In the Property Editor - Column section of the Page Designer, select 1 - Hide Last for Priority.

    alt description here
  17. In the Rendering section of Page Designer, click EMPLOYEE_ID.

    alt description here
  18. In the Property Editor - Column section of the Page Designer, select 1 - Hide Last for Priority. Click Save.

    alt description here
  19. Click Save and Run Page.

    alt description here
  20. Notice that all the columns are displayed. To view the columns based on priority, resize the browser.

    alt description here
  21. Notice that the columns are displayed in the report based on the priority specified.

    alt description here
  22. By resizing the browser to the size of a mobile device will display only the columns of highest priority.

    alt description here

Viewing the Employees Reflow Report

In this topic, you view the Employees Reflow report. In this report, the table columns are in a stacked presentation that look like block of label/data pair for each row.

  1. Resize your browser by clicking the maximize option.

    alt description here
  2. Click the panel list button icon.

    alt description here
  3. Click Employees Reflow Report from the panel list.

    alt description here
  4. Notice that the report is displayed with all the columns available next to each other when displayed on a tablet or desktop.

    alt description here
  5. Resize the browser.

    alt description here
  6. Notice that the horizontal report reflows to a stacked vertical report as the browser width is resized to accommodate on a smartphone.

    alt description here

Viewing your Mobile Application by Resizing the Browser

In this topic, you resize your browser to experience the look and feel of a mobile screen.

  1. Click the maximize button of your browser and reduce the width to look like a mobile screen.

    alt description here
  2. Click Departments.

    alt description here
  3. The Departments page is displayed. Click one of the Departments to view the department details.

    alt description here
  4. Notice that the labels have shifted above the items thereby providing a look and feel of a mobile device's browser.

    alt description here
  5. Click the panel list button icon.

    alt description here
  6. Click Home.

    alt description here
  7. Click Projects.

    alt description here
  8. Click one of the Projects.

    alt description here
  9. Click the arrow head against the Project End Date.

    alt description here
  10. A calendar is displayed. Select a different date.

    alt description here
  11. Click Save.

    alt description here
  12. The date has been updated. Click the panel list button icon.

    alt description here

Summary

In this tutorial, you learned how to:
  • Run SQL Script and load tables
  • Create a Mobile Web Application
  • Add a new page to the Panel menu
  • Modify List on the Home page
  • Modify the Departments List View and Form pages
  • Modify the Projects List View and Form pages
  • Enhance the Projects form page by adding a new Page Item and Dynamic Action
  • Viewing the Employees Column Toggle report
  • Viewing the Employees Reflow report
  • View your mobile application by resizing the browser

Resources

Credits

  • Lead Curriculum Developer: Anupama Mandya
  • Other Contributors: David Peake, Marc Sewtz

To navigate this Oracle by Example tutorial, note the following:

Topic List:
Click a topic to navigate to that section.
Expand All Topics:
Click the button to show or hide the details for the sections. By default, all topics are collapsed.
Hide All Images:
Click the button to show or hide the screenshots. By default, all images are displayed.
Print:
Click the button to print the content. The content that is currently displayed or hidden is printed.

To navigate to a particular section in this tutorial, select the topic from the list.