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.
-
Log into the Application Express Login page using your login credentials. Enter your login credentials and click Login.
-
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.
-
Click Upload.
-
Click Choose File.
Locate the
OBE.sql
file from the files folder that you have downloaded into your working directory.
Click Upload. -
Click Run button.
-
Click Run in Background.
-
Click View Results
-
Your tables have been successfully created and data has been inserted into them.
Creating a Mobile Web Application
In this topic, you create a Mobile application and add list and form pages to the application.
-
Click Application Builder.
-
Click Create.
-
Click Mobile.
-
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.
-
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.
- 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.
-
Click Add Page to add pages in the application.
-
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.
SelectHome(1)
for Subordinate to Page,OBE_DEPARTMENTS
for Table Name, andDEPARTMENT_NAME
for Display Column. Click Add Page.
-
Click Add Page again to add more pages to the application.
-
Select List View and Form. Select
Home(1)
for Subordinate to Page,OBE_PROJECTS
for Table Name, andPROJECT_NAME
for Display Column. Click Add Page.
-
Click Add Page to add another report page type.
-
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.
-
You want to add another report page type. Click Add Page.
-
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.
-
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.
-
Change the Name as Employees Column Toggle Report and click Apply Changes.
-
You also want to edit the Name of the Obe Employees (7) Reflow Report. Click the Edit icon against this page type.
-
Change the Name as Employees Reflow Report and click Apply Changes.
-
Click Next.
-
Accept the default and click Next.
-
Click Next.
-
Click Create Application.
-
Your application has been successfully created. The application definition is displayed with the various pages that you added using the Create Application wizard.
-
To view your application, click Run Application.
-
In the new tab, enter your login credentials and click Login.
-
The Navigation List shows the two pages that were created under the Home page.
-
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.
-
A panel that contains the top level pages is displayed. Clicking any of the top level pages will display its associated subordinate pages.
- Click Home.
-
The subordinate pages Obe Departments and Obe Projects are listed in the list under the Home page are displayed.
-
Click Obe Departments.
-
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.
-
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.
-
Similarly, to view the Projects list view and Projects form details, click the panel icon.
-
Click the right arrow next to Home.
-
Click Obe Projects.
-
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.
-
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.
-
Click the Application Builder tab to navigate back to the application and modify the application pages.
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.
-
In the Application Builder Home page, click Create Page.
-
Click Chart.
-
Select Pie & Doughnut and click Next.
-
Select 3D Pie and click Next.
-
Enter EmpDept Chart for Page Name and Region Name. Click Configure.
-
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.
-
Click Next.
-
Enter Employees per Department for Chart Title. Click Next.
-
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 -
Click Create.
-
Click Run Application.
-
Click the panel list button icon.
-
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.
-
The Employees per Department chart is displayed.
Modifying the List on the Home Page
In this section, you modify the Name and Title of the Navigation List in the Home page.
-
In the Application Builder Home page, click Home.
-
In the Rendering section of the Page Designer, click Navigation.
-
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.
-
In the Shared Components, under the Navigation section, select Lists.
-
Select Navigation.
-
Click Obe Departments.
-
Modify the List Entry Label to Departments and click Next icon.
-
Modify the List Entry Label to Projects and click Apply Changes.
-
Notice the changes in the Navigation List names. Click Edit Page 1 icon.
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.
-
Click the Go To Page icon.
Select Page 2 (Obe Departments) page from the Popup List of Values of Page Finder.
-
Under the Identification heading of the Property Editor - Page section in the Page Designer, change the Name and Title as
Departments
. -
Click Save.
-
Click the
OBE_DEPARTMENTS
List View region in the Rendering section of the Page Designer. -
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
-
Click Save.
-
Next, click Attributes to modify the Settings for this region.
-
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. -
Next,you want to modify the Departments Form page. Click Go to Page icon.
-
In the Popup List of Values of Page Finder, select Page Number 3 - Obe Departments.
-
In the Property Editor - Page section of the Page Designer of Page 3, change the Name and Title to Maintain Departments and click Save.
-
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 newDepartment Id
in the form. In the Rendering section of the Page Designer, clickP3_DEPARTMENT_ID
-
In the Property Editor - Page Item section of the Page Designer, change the Type as Number Field and Label as
Department Id
. Click Save. -
Next, select
P3_LOCATION_ID
in the Rendering section of the Page Designer. -
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
-
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.
-
Notice that the Navigation items in the Home page have now been changed to Departments and Projects.
-
Click Departments.
-
Notice that the Label has been changed to Departments and a counter column with the number of projects associated with each Department is displayed.
-
Click Administration.
-
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 toBombay
. Click Save. -
The changes have been applied. Click Administration again to view the changes you made to the Location of that department.
-
Notice that the modified record is displayed. Click the panel list button icon to navigate back to the Home page.
-
Select the right arrow next to Home.
-
Select Departments.
-
You now want to create a new Department. Click Create.
-
Enter
50
for Department Id,IT
for Department Name, and selectSouth San Francisco
for Location. Click Create. -
Notice that a new department IT has been added.
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.
-
Navigate back to the Page Designer tab of the Application of Page 3.
-
Click the Go To Page icon.
Select Page Number 4 (Obe Projects) from the Popup List of Values of Page Finder.
-
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. -
In the Rendering section of the Page Designer section, click Attributes.
-
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>
-
Further down, change the Search Type as Server: Like and Ignore Case. Select
PROJECT_NAME
for Search Column and enterSearch By Project Name
in Search Box Placeholder text field. In the Layout property, enter Number of Rows as10
and click Save. -
Next, you select the Projects form page to make changes to the items. Click the Go To Page icon.
Select Page Number 5 - Obe Projects in the Popup List of Values of Page Finder.
-
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. -
In the Rendering section of the page, select
P5_PROJECT_DEPT
. -
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
-
In the Rendering section of the Page Designer, click
P5_STATUS
. -
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
-
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.
-
Click the panel list button icon on the page to go back to the Home page.
-
Click the right arrow icon next to Home.
-
Click Projects.
-
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. -
Notice that the Projects are displayed based on the Search field.
-
Click Maintain Support Systems to view the details of this project.
-
Change the Status of the project from Open to Planned.
-
Click Save.
-
The changes have been saved. To verify the changes, click the Project name.
-
The changes have been saved. To verify the changes, click the Project name again.
-
Notice that the Status has changed.
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.
-
Navigate back to the Page Designer tab of the Application by clicking Page Designer tab. page.
-
In the Rendering section of the Maintain Projects page, right-click Items and select Create Page Item.
-
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 selectP5_LOCATION
from the Popup List of Values of Pick Item. Click Save. -
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-clickP5_PROJECT_DEPT
and select Create Dynamic Action. -
In the Property Editor - Dynamic Action section of the Page Designer, enter Name as
Get Location
and click Show All button. -
Navigate to the Rendering section, expand Get Location, select True. Click Show.
-
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)
-
To view the modifications, you have to run the application. Navigate to the Maintain Projects tab in the browser.
-
Click the panel list button icon.
-
Click the right arrow next to Home.
-
Click Projects.
-
Click Maintain Support Systems project. Notice that the Location is being displayed.
-
Change the Project Dept select list to a different department. Select IT from the select list.
-
The Location changes based on the Department Name selected.
-
Click panel list icon.
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.
-
Click Employees Column Toggle Report in the panel list.
-
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...
-
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.
-
Notice that the Employee Id and Email columns are not displayed.
-
A Toggle report can also be used to assign priorities to different columns in the report. Click Page Designer tab.
-
Navigate to the Toggle Report page by clicking the down arrow of the Popup List of Values of page list. Home.
-
Select Employees Column Toggle Report page.
-
In the Rendering section of the Page Designer, click the arrow head aginst Columns to expand the columns available in the report.
-
The available columns are displayed. Click
FIRST_NAME
. -
In the Property Editor - Column section of the Page Designer, select 3 for Priority.
-
In the Rendering section of Page Designer, click
LAST_NAME
. -
In the Property Editor - Column section of the Page Designer, select 3 for Priority.
-
In the Rendering section of Page Designer, click
EMAIL
. -
In the Property Editor - Column section of the Page Designer, select 2 for Priority.
-
In the Rendering section of Page Designer, click
HIRE_DATE
. -
In the Property Editor - Column section of the Page Designer, select 1 - Hide Last for Priority.
-
In the Rendering section of Page Designer, click
EMPLOYEE_ID
. -
In the Property Editor - Column section of the Page Designer, select 1 - Hide Last for Priority. Click Save.
-
Click Save and Run Page.
-
Notice that all the columns are displayed. To view the columns based on priority, resize the browser.
-
Notice that the columns are displayed in the report based on the priority specified.
-
By resizing the browser to the size of a mobile device will display only the columns of highest priority.
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.
-
Resize your browser by clicking the maximize option.
-
Click the panel list button icon.
-
Click Employees Reflow Report from the panel list.
-
Notice that the report is displayed with all the columns available next to each other when displayed on a tablet or desktop.
-
Resize the browser.
-
Notice that the horizontal report reflows to a stacked vertical report as the browser width is resized to accommodate on a smartphone.
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.
-
Click the maximize button of your browser and reduce the width to look like a mobile screen.
-
Click Departments.
-
The Departments page is displayed. Click one of the Departments to view the department details.
-
Notice that the labels have shifted above the items thereby providing a look and feel of a mobile device's browser.
-
Click the panel list button icon.
-
Click Home.
-
Click Projects.
-
Click one of the Projects.
-
Click the arrow head against the Project End Date.
-
A calendar is displayed. Select a different date.
-
Click Save.
-
The date has been updated. Click the panel list button icon.
Summary
- 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
- APEX OTN Home Page
- To learn more about Application Express 4.2, refer to additional OBEs in the Oracle Learning Library
- Oracle Application Express: Developing Web Applications
- Oracle University
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.