You are on page 1of 14

This article is Introduction to APEX. What is Application Express?

It is formerly called HTML-DB, a web-based RAD tool which resides in Oracle database. Using browser based user interface and limited programming experience; you can build a complete data-centric web application in a very fast development cycle. From the end users perspective, the deployed applications require only a browser and access to an Oracle database running Application Express. What are the uses of APEX? 1. Builds professional looking web applications that are both fast and secure. 2. Runs on and lives in Oracle database. APEX framework and Meta data are stored in Oracle tables. 3. It is FREE. No licensing required. 4. Fast learning curve for developers to build application. 5. Deployment of application is as simple as 'Export and Import' if hard coded references of values that change between environments are avoided. 6. Lot of scope for customization of application look and feel. 7. Scalable for high user volume. AskTom, former Oracle Metalink (before migrated to Flash version) and many applications are built using APEX. 8. Can be configured to use Oracle SSO and EBS fnd user repository. Who uses APEX? If you are running on oracle database and you want to build rich web application with reports, forms, charts, drill downs and dashboards with limited Java experienced developers in a short time frame, Oracle APEX is the most likely candidate for consideration. How APEX Architecture works? APEX is installed on Oracle database (above 9.2 version), starting from Oracle 11g it comes preinstalled with the database. It is comprised of meta data in tables, pl/sql code and extensive JavaScript APIs. The URL request from the browser is translated into appropriate APEX PL/SQL call by either Oracle HTTP Server (Apache) with mod_plsql plugin or Embedded PL/SQL Gateway. This varies by the type of APEX installation on oracle database. After the data is processed, results are relayed back to browser as HTML. This cycle happens each time user request or submit a page. The application session state is maintained in database tables. APEX installation can be done in two ways. DBAs are more concerned about it than developers. But this determines how the URL is translated.

Oracle HTTP Server In this three-tier configuration, mod_plsql in Oracle HTTP Server acts a broker between client web browser and server database.

For each URL that is processed, mod_plsql either uses a database session from its connection pool, or creates a new session on the fly and pools it. For mod_plsql to invoke the appropriate database PL/SQL procedure in a URL-processing session, you must first configure a virtual path and associate that path with a Database Access Descriptor (DAD). A DAD is a named set of configuration values that specify the information necessary to create a session for a specific database and a specific database user/password. This includes the database service name and the Globalization Support setting (for example, language) for the session. Embedded PL/SQL Gateway this is a classic client-server architecture where embedded PL/SQL gateway provides the Oracle database with a Web server and also the necessary infrastructure to create dynamic applications. The embedded PL/SQL gateway runs in the XML DB HTTP server in the Oracle database and includes the core features of mod_plsql, but does not require the Oracle HTTP Server powered by Apache. Inclusion of the embedded PL/SQL gateway simplifies the architecture and eliminates the middle tier entirely.

Oracle HTTP Server is known and proven technology; it has been used for Self Service applications. Does APEX works with non-Oracle databases? No. What is current version available? APEX 3.2 is released a couple of weeks back. What are skills required for APEX Developers? SQL, PL/SQL is essential. HTML, CSS and JavaScript are good to have skills to understand and customize look and feel (themes, templates,). Where to learn and get hands on APEX? There are multitudes of sites dedicated to APEX. apex.oracle.com allows anyone to request for free APEX account to build applications or run packaged applications. Follow the below steps for creating account in apex.oracle.com

Go to apex.oracle.com and click 'sign up for account' link below Login button. Fill administrator information. This user will have all rights to create new users and manage their accounts. Enter workspace name (For Ex: XX-APEX). Workspace is dedicated area where you develop applications. A workspace is attached to one or more database schemas. In a typical development environment, you might create a single workspace for all your developers to share.

Enter name of database schema and its space allocation. Fill justification and complete by confirming the request. You will get email once the request is approved. Oracle administrator do great job to approve your request as soon as they can. (Usually few hours ... latest a day). After clicking on approval link, you get another email with userid/password. Then you are set on login on apex.oracle.com and run sample application under Application Builder.

Finally APEX or OAF or ADF? Some healthy debates are going on choice of these existing new technologies. APEX embeds business logic and presentation together in oracle database. It has bunch of bugs to be fixed ... for that matter every technology evolves over time. APEX is fast growing platform for RAD. The number of OTN threads and APEX developers in APEX OTN discussion forum gives a fair idea of amount of work going in APEX. Though a quarter of them use APEX with EBS. If you want to follow Model-View-Controller (MVC) design pattern and have Java / J2EE resources at hand, OAF or ADF is a better choice. With OAF, you can use EBS security model, DFFs etc. APEX doesn't replace OAF, it's highly productive, wizard driven development and deployment and easy to use navigation cannot go unnoticed.

Oracle Application Express (APEX) is a rapid web application development tool for Oracle database. Before building or running apex application, there are few concepts and terminology you need to familiarize with. The outline of this article is to cover

Understanding User roles Components in Application Express Useful Terminology in APEX Running Sample application Understanding APEX URL Syntax

Assuming that you already have account in apex.oracle.com (If you don't, please follow instructions from APEX Introduction article), go to login page of apex.oracle.com and enter workspace name, user name and password.

Once you login successfully, home page shows different components of APEX depending upon user role assigned to you. Users are divided into four primary roles:

Developers are users who create or edit applications Workspace Administrators are users who perform administration tasks specific to workspace like managing user accounts, services and monitoring workspace activity Oracle APEX Administrators are super users that manage an entire hosted instance using the Application Express Administration Services application. End Users have no development privileges

You are given Workspace Administrator role for oracle.apex.com account. Once you login successfully, home page looks similar to below screenshot.

You are presented with different icons, navigation tabs and regions on the right which shows useful information about your workspace. Region at the bottom of the home page shows Apex Version (v3.2.0.00.27 for oracle apex site), apex workspace and user name. Workspace Schema (in my case 'BT_APEX') is database schema attached to your apex workspace. Four components which are of interest to us are Application Builder, SQL Workshop, Utilities and Administration.

Application Builder is where you build apex applications. You can also import / export applications from sql files. SQL Workshop is like web version of SQL Developer. You can browse database objects in your schema, run SQL commands, create SQL scripts and use Query Builder to create a sql query using its GUI. Utilities has numerous useful tools for monitoring database, viewing meta data about APEX. Administration is used to manage sessions, caching, users and monitor activity.

Most part of development time is spent in Application Builder building pages, applications or SQL Workshop running queries. SQL Workshop is self explanatory if you use SQL Developer or any SQL, PL/SQL interface tool. I will focus mainly on Application Builder. Application Builder Concepts Application Builder has collection of apex applications. Your oracle.apex.com account comes with a sample application. You can run or modify this application.

The following terminology is important to know when working with Application Builder:

Workspace: A workspace allows multiple developers to work within the same Oracle Application Express installation. It can be based on one or more database schemas. As a rule workspaces should be organized such that they contain applications that are related to each other. Application: It is a collection of pages and branches connecting them. Its attributes include authentication scheme, default UI templates. Application is synonymous to project in JDeveloper. Page: A page is the basic building block of an application. When you build an application in Application Builder, you create pages that contain user interface elements, such as tabs, lists, buttons, items, and regions.

Region: Content is displayed in regions, which are logical subsections of a page. Each page can have any number of regions of several different types. These types include: HTML text, SQL Queries, PL/SQL-generated HTML, and charts. Each region is rendered using a region template. Regions are positioned on the page using display points defined in the page template. Item: An item can be a text field, text area, password, select list, check box, and so on. Item attributes affect the display and behavior of items on a page. For example, these attributes can impact where a label displays, how large an item is, and whether or not the item is displayed next to, or below the previous item. The value of an item is automatically stored into the application's session state, which can be referenced at any point within the user's session.

Running sample application by default you have a sample application in your workspace. It can be used to demonstrate various features offered by Application Express like charts, reports, forms, etc., run the sample application by clicking on 'Run Application' icon as shown in above screenshot. In the login name, enter user name as demo (or) admin with password as your workspace name in lower case.

Sample application shows an easy-to-use interface for viewing, updating, and searching order and customer information for electronic and computer products. Users can navigate among the pages using the Home, Customers, Products, Orders and Charts tabs.

Home page alone shows a lot of information about Application Express features. The following are the pointers from the above screenshot. 1. URL of the page. Every page in apex is accessed through browser URL, but authorization schemes control user access. Authorization schemes can be specified for an entire application, a page, or a specific page control such a region, item or button. For example, you could use an authorization scheme to selectively determine which tabs, regions, or navigation bar entries a user sees. URL of the home page was http://apex.oracle.com/pls/otn/f?p=44970:1:1618122951801106::NO it includes important information about application, page, session and few more. 2. Company logo/text is an attribute of Application definition. It appears on all pages in application. You can use an image or text. 3. Navigation tabs simplifies navigation to specific pages. Type of tabs (One-Level /Two-Level / None) is defined while creating application. Sample application is using One-Level tabs.

Graphical representation can be used when defining tabs. Tabs can be conditionally displayed as well. 4. Navigation bar entries provide hypertext based navigation. By default it has Print and Logout entries. Placement (right / left) is determined by page templates. 5. Breadcrumb provides hierarchical navigation to any number of levels. Clicking on breadcrumb entry is associated with a page and also a parent page. Breadcrumb builds up with breadcrumb entries the deeper the user navigates to the pages. Try navigating to Add/Modify customers page by clicking on create button in Customers page, breadcrumb now shows 'Home > Customers > Add/Modify Customers' with hyper links to parent breadcrumb entries i.e. Home, Customers. Breadcrumb adds another level for easy navigation between pages. You are familiar with it in Oracle EBS Self-Service modules. 6,7,8,9. Home page has four regions (My Quota, My Orders, Sample Application and Tasks). Each region uses different region type. My Quota demonstrates the use of Flash Dial Chart. My Orders is an interactive report which is a feature introduced in Apex 3.1. Both of these regions are based of SQL query. Sample Application region is HTML with simple text. Tasks is a list region using navigation list to branch on other pages in the application. Interactive report gives users a plethora of personalization options like adding filters, computations, highlight columns based on conditions, save report, search by column values etc. You can play around with Sample application to get a feel of APEX's rich features. One of the prominent feature is ease of navigation for end users using breadcrumbs, navigation tabs, drill down column links, navigation lists etc. Once you get a hang of pages and navigation, you can look at how a page is defined by clicking 'Edit Page 1' link at the bottom of the page (or) navigating from Application Builder > Sample Application > 1 - Sample Application page. Page Definition: The page definition is divided into three main sections:

Page Rendering lists user interface controls and logic that are executed when a page is rendered. Page Rendering is the process of generating a page from the database. Page Processing lists logic controls like computations, processes that are evaluated or executed when page is processed. Shared Components lists common components that are used by one or more pages within the application.

The Application Express engine dynamically renders and processes pages based on data stored in Oracle database tables. To view a rendered version of your application, you request it from the Application Express engine. When you run an application, the Application Express engine relies on two processes.

Show Page is the page rendering process. It assembles all the page attributes (including regions, items, and buttons) into a viewable HTML page. Accept Page performs page processing. It performs any computations, validations, processes, and branching.

When you request a page using a URL, the engine is running Show Page. When you submit a page, the Application Express engine is running Accept Page or performing page processing during which it saves the submitted values in the session cache and then performs any computations, validations, or processes.

Page Rendering: Each page is associated with attributes such as name, title, template, etc. In the above screenshot page template used is 'Application Default'. It is the default page template attached to application. You can check template name by going to Shared Components (second icon on top right navigation) > Application Definition > Template Defaults (section). Application Default is substituted with One Level Tabs template. Page template defines how header, body and footer sections of the page are displayed. It has bunch of HTML tags with Substitution Strings. When the page is rendered, Application Engine replaces substitution string with actual value. Substitution strings alone takes an article to explain them in detail. Regions are the actual containers of items in a page. Region type determines the source of the region whether it is flash chart, form, report, HTML etc. Source field of the region has either SQL query or HTML depending on region type. Region Display point determines where a region is displayed on the page. They are available depending on the page template. Items are basic building blocks of a page. They are variety of item types to choose from such as check box, text box, radio button, display item, hidden item, etc. Computations and Processes can have PL/SQL block for assigning values to items in the page. You can also specify at what point the logic should be executed like On Page Load, Before header. These are like triggers in Forms 6i. Page Processing: Validations can be item-level or page-level. Branches define the navigation to other pages depending on a event like a button click or Enter key etc. Shared Components: Shared components are reusable components which are used by one or more pages. Shared components section on the page shows all the shared components that are referenced in that page. Global Page (Page Zero): When an application is created, page zero is created by default. Page zero components are rendered on every page. You can define regions, items and buttons on page 0. Below screen shot of page zero in Sample Application shows breadcrumb menu entry and chart list regions appear on every page. Chart list is conditionally displayed. A condition is a small unit of logic that helps you control the display of regions, items, buttons, and tabs as well as the execution of processes, computations and validations.

Understanding APEX URL Syntax The URL that displays for each page identifies the location of Oracle Application Express, the address of Oracle Application Express, the application ID, the page number, and the session ID. For Example, take the URL of Home page in Sample Application http://apex.oracle.com/pls/otn/f?p=44970:1:1618122951801106::NO this example indicates:

apex.oracle.com is URL of server. It could like: when run in your environment. pls indicates apex is using mod_plsql cartridge. If your apex installation is based of pl/sql gateway otn is database access descriptor (DAD) name. DAD describes how HTTP Server connects to the database server so that it can fulfill an HTTP request. The default value is apex. f?p= is a prefix used by Oracle Application Express 44970 is application being called. You can also use Application alias rather than application id. 1 is the page within the application to be displayed 1618122951801106 is session number. NO is debug mode.

Understanding URL syntax is useful when defining navigation to pages using navigation lists or hypertext links. I will cover more on this in coming article. There is so much ground to cover in

Application Express, once you start building applications apex is mostly wizard driven and really simple. Firebug - Essential tool for APEX/Web Developers Firebug is Firefox browser add-on, which is a must have APEX or web developers. It can be downloaded from http://getfirebug.com/. Some of firebug features at a glance.

View and edit HTML Source and CSS (Cascading Style Sheet). Javascript debugging Explore DOM (Document Object Model) Execute JavaScript in command line JavaScript logging using console command Monitor network activity

Enough said ... why do APEX developers care about? At the end of the day Oracle Application Express Engine has to produce HTML output to the browsers to present it to the users. APEX engine uses PL/SQL code and HTML in templates to generate HTML output with data. Viewing HTML source in a readable format will help when you customize templates and themes to change look and feel of application. As you see changes on the fly, before modifying templates you can choose the best look for your application. These changes does not effect application used by other users. Firebug also provides the most effective debugging for JavaScripts. If you ask me to close my eyes and pick one firebug feature that saved my day that would definitely be ... seeing the version of CSS and JavaScripts currently loaded or used by my application. There were few scenarios where my changes to CSS/JavaScripts are not seen in the versions used by browser. It was due to browser cache or unknown issue that caused duplicate records in APEX_WORSPACE_FILES table.

You might also like