47,99 €
Developing data-centric web applications can be a real challenge as it is a multi-disciplinary process. There are many technologies involved in the client side (HTML, CSS, JavaScript, and so on); the interaction with the database, on the server side; the typeless nature of the web environment; and above all, the need to put it all together. This needs to be done in a manner that will allow the end users to do their job in the simplest and most efficient way, while enriching their user experience. How often have you wished that developing such applications could be uncomplicated and straightforward? This book will show you that it's possible, and teaches you how to do it, using Oracle Application Express (APEX).With this practical guide to APEX, you'll learn how to easily develop data-centric web applications for the Oracle environment. The book covers the development cycle of an APEX application, reviewing the major APEX principles and building blocks chapter by chapter. It starts with the basic skills you need to get going when developing with APEX. Later, you will learn advanced issues, such as how to build tailor-made forms and reports, using APEX APIs, AJAX, and so on. It not only deals with the "How" but also with the "Why", and before long you will be able to understand APEX concepts, and use them to expand and enhance the built-in features, wizards, and tools.The book starts with the design phase, including building the necessary database objects infrastructure; continues with ways to implement the application logic (on the server side) and the User Interface (on the client side), whilst showing you how to enhance your applications' features and functionality according to your specific needs; and it ends with application deployment.The book emphasizes and clearly documents areas such as Globalization, Localization, and developing multi-lingual applications, and includes a special discussion about Right-To-Left (RTL) support for APEX applications, documented here for the first time.Throughout the book, there are many screenshots and snippets of code, taken from working APEX applications. The book is accompanied by demo APEX applications that you can download and install in your APEX environment, thoroughly analyze, and learn from as you read the book.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 788
Veröffentlichungsjahr: 2010
Copyright © 2010 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: June 2010
Production Reference: 1250510
Published by Packt Publishing Ltd. 32 Lincoln Road Olton Birmingham, B27 6PA, UK.
ISBN 978-1-847194-52-7
www.packtpub.com
Cover Image by Vinayak Chittar (<[email protected]>)
Authors
Arie Geller
Matthew Lyon
Reviewers
Ashish Agarwal
Ben Burrell
Katie McLaughlin
Penny Cookson
Acquisition Editor
James Lumsden
Development Editors
Dhiraj Chandiramani
Rakesh Shejwal
Technical Editor
Pallavi Kachare
Copy Editor
Leonard D'Silva
Editorial Team Leader
Akshara Aware
Project Team Leader
Priya Mukherji
Project Coordinator
Zainab Bagasrawala
Proofreaders
Aaron Nash
Jeff Orloff
Indexer
Hemangini Bari
Graphics
Geetanjali Sawant
Production Coordinator
Aparna Bhagat
Cover Work
Aparna Bhagat
Arie Geller is an independent IT consultant, with more than 30 years of experience with systems analysis, software development, IT infrastructure, etc. He started to use HTML DB 1.6 (the former name of APEX) to develop data centric Web applications in the Oracle environment, and continue doing so, with all the following versions, until today.
Arie has specialized in developing Right-To-Left-oriented applications, and he brings his expertise and experience in this field into the book. Arie is also an active member of the APEX community on OTN, where he assists other members and shares his knowledge and experience as much as he can.
I would like to thank my surrounding family for their great patient and support, and also to my friends and customers for their understanding, during the very demanding period of writing this book.
I would also like to thank Joel Kallman and Scott Spadafore (RIP) from the APEX development team, for their invaluable help and insight on APEX, over the years.
Matthew Lyon is a Senior Consultant at SRA Information Technology in Adelaide, South Australia. His involvement in enterprise software development extends across analysis, design, development, architecture, and project management, giving him a deep appreciation of the effective use of software technology. He has experience with a wide variety of technologies but has a passion for Oracle APEX and Java. Matthew runs APEX training courses for clients and is active in the Oracle community as a presenter and as a committee member of the South Australian Oracle User Group. Matthew has more than 10 years experience in software development and has been using APEX since HTMLDB version 1.6.
I would like to thank my lovely wife Zoe and beautiful baby girl Rose for their help and support while writing this book.
Ashish Agarwal has the distinct privilege of being one of the less than a few hundred Oracle Certified Masters in the world (http://www.oracle.com/technology/ocm/aagarwal.html). He is also a certified Project Management Professional from PMI, USA & Oracle Certified Professional in Oracle 10g, 9i, 8i, and 8. With a total industry experience of more than 12 years in Information Technology Field, exhaustive experience and Knowledge in Managing Oracle Databases and Oracle Applications (ERP and CRM Suites), administration is his expertise. Participating in the design of Infrastructure Architecture for Oracle Products and managing data centre kind of environment with multiple databases and servers are some of his other experience areas.
Ashish has worked with companies like Panasonic, Oracle, Sapient, and Mercer across the geographies of India, Singapore, Malaysia, Canada, and the UK, and is now currently running DBCON - a Database & Oracle APEX consulting company based in Singapore. DBCON leverages on the power of the Internet to provide live online training, application development, management and maintenance, support, and troubleshooting in Oracle technologies to anyone in the world. DBCON also leverages on the power of the Internet to engage the best people in their respective areas from across the globe.
Attracted to Oracle Application Express because of its simplicity and productivity, Ashish regularly conducts live online training in Oracle Application Express through his company DBCON. Anyone from anywhere in the world can attend this training with just a PC and internet connection. To learn more about live online training in Oracle Application Express please visit http://www.dbcon.com or e-mail at <[email protected]>.
Ben Burell is an Oracle developer currently based in the Isle of Man. He is an active contributor to the Oracle APEX forum as 'Munky' and sporadically blogs about APEX related tips and tricks at http://munkyben.wordpress.com.
He enjoys problem solving while listening to music, meaning that he quite enjoys his job!
Katie McLaughlin is a software developer and consultant who has been working with Oracle Apex for many years, developing enterprise applications as well as for smaller business requirements. She currently works for an international software house, developing financial applications for some of the largest companies in the world.
I'd like to thank my partner, Karl, for all his kindness and for bringing many a cup of tea during the time I worked on this book.
Penny Cookson has been working with Oracle products since 1987. Penny is the Managing Director and Principal Consultant for SAGE Computing Services, an Australian company which specializes in providing Oracle education and consulting services. She has written and conducted training courses and provided expert advice in a wide range of products, including Application Express, and is a regular presenter at Oracle and User Group conferences. She was Oracle Magazine's Educator of the Year in 2004 and is an Oracle ACE.
Oracle Application Express — APEX for short, or by its former name, HTML DB, is a declarative, Web-based RAD (Rapid Application Development) tool. APEX runs inside an Oracle database, tightly integrated with its internal resources, and utilize them optimally. Using a Web browser, it allows us to develop, test, and deploy a Web based, data-centric application in a declarative manner, but on the same time it doesn't limit our abilities to manually enter specific and tailored code, both on the client and server side, that will answer our most specific needs and demands.
Developing data centric Web applications can be a real challenge as it's a multi-disciplinary process. There are many technologies involved in the client side (HTML, CSS, JavaScript, etc.); the interaction with the database, in the server side; the typless nature of the Web environment; and above all, the need to put it all together, in a manner that will allow the end users to do their job, in the simplest and most efficient way, while enriching their user experience. If you are working in the Oracle environment, APEX can be your best solution.
With this book, you'll learn how to easily develop data centric Web applications for the Oracle environment, using the APEX RAD tool.
This book is not a recipes book, although it includes many working examples. You will learn to understand the basic principles behind the APEX building blocks, and how they operate. It will allow you to take advantage of existing "APEX recipes" but more importantly to create your own.
The book covers the development cycle of an APEX application. It starts with the design phase, including building your necessary database objects infrastructure; continue with ways to implement the application logic (on the server side) and the User Interface (on the client side), whilst showing you how to enhance your applications features and functionality, according to your specific needs; and it ends with application deployment.
The book includes dedicated chapters that deal with the Globalization and Localization aspects of developing APEX applications, with dedicated chapter for developing Right-To-Left oriented applications.
This book is for developers, in general, and web developers, in particular, who wish to learn how to develop data-centric web applications in the Oracle environment. It is also for novice APEX developers, who wish to learn how to use and best utilize the APEX environment, as well as for more experience APEX developers who wish to improve their knowledge and understanding of APEX and its capabilities and learn from the experiences of others.
Developers who work in a multi-lingual environment, in general, and in a Right-To-Left environment, in particular, will be most beneficial from the dedicated chapters on these subjects, which include issues that we believe are documented for the first time.
The book assumes basic knowledge of HTML, SQL, and PL/SQL. Basic JavaScript understanding is an advantage, and in general, can make your life much easier as an APEX developer. The book includes a dedicated chapter which gives a general review of these issues.
Chapter 1, An Introduction to APEX gives an introduction of APEX architecture and technology, while explains some of the above-mentioned terms in the APEX context.
Chapter 2, What we need to know to effectively use APEX reviews. Some of the basic skills we should have in order to better utilize the Web development aspects of APEX. It talks about HTML, the DOM, CSS, and JavaScript.
Chapter 3, APEX Basic Concepts discusses some of the major APEX concepts and explains how they can help us in our developmental efforts.
Chapter 4, The Application Builder Basic Concepts and Building Blocks explains the major building blocks of the APEX application, and how to create them using the APEX Application Builder.
Chapter 5, APEX Items discusses the major building blocks of the application page — the application items. We'll review application items and page items and learn how they can serve us in our applications.
Chapter 6, APEX Buttons explains different types of buttons that a developer can place on an APEX page, creating/editing them, assigning attributes and using the REQUEST feature
Chapter 7, APEX Computations reviews the computation mechanism and sees how we can use it in our applications.
Chapter 8, APEX Validations discusses APEX validations, which help us to maintain the integrity and consistency of our data by making sure that only correct and consistent data will be used and saved into the database.
Chapter 9, APEX Processes reviews the main concepts of APEX processes and how they can help us to implement our application logic. It includes discussions on application level processes (including on-demand processes), page level processes, and the various types and options APEX provides us with to implement them.
Chapter 10, APEX Branches discusses APEX Branches, which are responsible for the flow of the application.
Chapter 11, APEX SQL Workshop reviews some APEX IDE built-in utilities that will help us define our application database infrastructure, either declaratively or by using DDL commands and scripts.
Chapter 12, APEX Forms reviews the various sources that we can use to create an APEX form. How to use the APEX Create Form wizard to generate a new form and manually create an APEX form.
Chapter 13, APEX Reports discusses how we can create and modify reports in APEX applications.
Chapter 14, Tabular Forms describe the APEX tabular form concept, with a very detailed discussion on how to generate one using an APEX wizard, or in more complex scenarios, doing it manually, using specific APEX APIs.
Chapter 15, Calendars looks at how we can use calendar components in our applications.
Chapter 16, Interactive Reports looks at how we can use Interactive Reports in our applications.
Chapter 17, AJAX with APEX looks at how we can utilize the APEX AJAX framework, both on the client and server side, to integrate and support this important technology in our APEX applications.
Chapter 18, Globalization and Localization With APEX Applications deals with the Globalization and Localization aspects of APEX applications. It include detailed discussion about the APEX built-in translation mechanism and sees how we can develop multi-lingual APEX applications.
Chapter 19, Right-To-Left Support in APEX review the specific actions we need to take in order to generate and support APEX Right-To-Left applications.
Chapter 20, Deploying APEX Applications discuss the means APEX provides us to deploy our developed applications.
Chapter 21, The APEX Runtime Environment explains what the APEX Runtime Environment is all about and how we can manage it.
Chapter 22, Security looks at APEX Security and how it can be used in our applications.
Chapter 23, Application Conversion looks at how we can convert Microsoft Access and Oracle Forms applications to APEX.
Chapter 24, APEX Best Practices looks at the best practices for developing APEX applications.
Appendix deals with APEX installation, upgradation, and configuration issues.
This book assumes basic knowledge in the main technologies and programming languages that we are using while working in APEX. These include, for the client side, HTML/XHTML, CSS, and JavaScript; and for the server side SQL and PL/SQL.
You can practice developing APEX application using the Oracle hosted site on apex.oracle.com. APEX is also included in the free ORACLE XE database version, which can be downloaded from the Oracle OTN site (http://otn.oracle.com). You can also download the latest version of APEX, and use it to upgrade the built-in version in the Oracle XE.
Feedback from our readers is always welcome. Let us know what you think about this book — what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.
To send us general feedback, simply send an e-mail to <[email protected]>, and mention the book title via the subject of your message.
If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or e-mail <[email protected]>.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book on, see our author guide on www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
Downloading the example code for the book
Visit https://www.packtpub.com//sites/default/files/downloads/4527_Code.zip to directly download the example code.
The downloadable files contain instructions on how to use them.
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books — maybe a mistake in the text or the code — we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the let us know link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.
Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <[email protected]> with a link to the suspected pirated material.
We appreciate your help in protecting our authors, and our ability to bring you valuable content.
You can contact us at <[email protected]> if you are having a problem with any aspect of the book, and we will do our best to address it.
Oracle Application Express — APEX for short, or by its former name HTML DB is a declarative, Web-based RAD (Rapid Application development) tool. It is used to develop native Web-based, data centric applications.
Let's clarify some of these terms, and understand what they mean in the APEX context.
The term Web-based appears in the description of both the development tool and its product — the APEX application. We are using a Web browser to both develop and run our applications. The advantages are obvious. Web browsers are installed, almost by default, on most of the workstations we are using, independently of the workstation hardware or operating system. It means that on the client side, we don't need anything else to start developing with APEX, or to run APEX applications. Moreover, it means very easy access to our applications, both internally — using Intranet — or externally, using the Internet If we add all the modern smart phones and other PDAs on the market today, which include built-in Web browsers, we'll come to the conclusion that the range of options to access our APEX applications is very wide.
Another important advantage when using a Web browser is the ability to free us from hardware and local operating system dependencies. As the APEX Application Builder actually generates HTML code, we (as developers) don't have to worry about the hardware specifications, or the local operating system our end users will be using, to run our APEX application. As long as they have access to an HTML supporting Web browser, we are covered.
However, Web based application development can also be a drawback. Unfortunately, not all Web browser manufacturers have fully adopted all the international standards in this field. As a result, there are cases in which different Web browsers will display the same code page differently. The variety of Web browsers in the market today, like Internet Explorer, Firefox, Chrome, Opera and Safari, just to name a few, support and implement HTML, XHTML, CSS and JavaScript versions and levels, in different ways and styles. There are known cases where even the same Web browser brand, but in different versions, or across local operating systems, delivers different results with the same code. We need to be aware of this, and take actions to resolve it — if we want to ensure cross-browser compatibility code for our applications (which will apply to greater numbers of potential users). Sometimes we need to take hard decisions and waive the support of certain web browsers in order to keep our code simple and maintainable.
A list of supported Web browsers can be found in the APEX release notes. For version 3.2, which is the latest APEX version at the time of writing this book, it can be found at http://download.oracle.com/docs/cd/E14373_01/relnotes.32/e13365/toc.htm#BGBCEGBI
APEX, in all its previous forms, was always designed to operate in the Web environment. The final product of the APEX Application Builder is HTML code that can be run directly on any Web browser that supports the HTML 4.0 and above standard. APEX Application Builder also incorporates special features into generated applications, as a direct result of operating in the Web environment. Further on, we will discuss APEX architecture and its main features, but for now we will mention session state and Optimistic Locking, as distinguished Web environment features which help us overcome the stateless nature of this environment.
The APEX Application Builder fully supports CSS (Cascading Style Sheets) and JavaScript, as integrated components of APEX applications. That includes built-in CSS files as part of a wider page layout and format mechanism, which we'll address later in the book, and a JavaScript library. The JavaScript library also includes, among a variety of general and APEX related functions, an AJAX (Asynchronous JavaScript and XML) framework. This allows even novice developers to utilize this advanced technology, and produce high quality applications, compatible with the latest trends in the market like Web 2.0, etc.
APEX was designed to produce applications that store, retrieve, manipulate, and display data, from Oracle Databases. This means that if your application's main logic doesn't revolve around data manipulation, it may be that APEX is not your optimal application development tool. However, if data manipulation is at the heart of your application, APEX could be your best bet.
APEX is actually a collection of PL/SQL packages, which "live" inside the Oracle database. It means that APEX automatically inherits all the outstanding features, often mentioned with regards to the Oracle database environment: high performance, robustness, reliability, enhanced security, scalability, and more. In addition, APEX can natively utilize the very rich SQL and PL/SQL environment, including the built-in packages that the Oracle database has to offer, and use them to manipulate the data in the optimal ways a RDBMS can offer.
Moreover, APEX can utilize special functionality features that are included in the various database versions and editions, like Oracle XML DB, Oracle Text, and Oracle Multimedia.
Another advantage in this context is that, like the client side which relies on Web browsers to gain hardware independence, (alongside operating system independence), the APEX engine relies on the database platform for the same purpose. As long as we have a proper running version of an Oracle database, starting with Oracle database 9.2.0.3 and above (including the free version, Oracle XE), we can ignore the hardware and operating systems aspects of the server.
APEX is a declarative tool. It means that we, as developers, concentrate more on the "What needs to be done", and less on the "How to do it". Think, for example, about SQL. In a SELECT statement, when we are using the ORDER BY clause, we are actually telling the database what we need — a sorted data result set, but we don't tell it how to actually do the sorting. In fact, the entire SELECT statement, just like SQL itself, is a declarative statement. In APEX, we are telling the Application builder that we need to lay out an HTML item on the page, or retrieve certain records from the database, and the APEX engine generates the proper code for doing that, both on the server side and the client side.
Working declaratively in APEX means that we are not generating traditional (3 GL) program code. Instead, we are working with a series of wizards and property sheets, which allows us to define all the metadata we need in order to generate an application page's code. APEX includes sets of pre-defined wizards, supported HTML objects, supported database objects and data types, page rendering options and procedures, after submit processes and DML options, navigation and branching options, and more. We can use all of these to declare our application page's forms, reports, charts, etc., with their layouts and application/business logic. The APEX engine translates it all into an HTML code for the client side, and SQL and PL/SQL code for the server side. Whenever the predefined options don't give us the exact solution we need, APEX allows us to use our own SQL and PL/SQL code for the server side, and HTML/XHTML, CSS, and JavaScript code, for the client side. As mentioned before, it also allows us the use of AJAX technology, within a built-in framework, to query the server side, while running on the client side without submitting the page.
APEX provides us with a full development environment, allowing us to develop, test, and deploy our applications. APEX includes three modules: Application Builder, SQL Workshop, and Utilities.
The Application Builder allows us to develop and test our applications, without leaving the development environment. While working in the Application Builder, it automatically adds a dedicated developer toolbar to every page in our application, making it very easy to toggle between the running page and its code within the Application Builder. The developer toolbar also provides the developer with more options to assist in the development process, like checking session state, running in debug mode, etc. Moreover, the Application Builder allows us to manage, monitor, and control all the application's shared components, supporting objects, and deployment scripts. In addition, the Application Builder includes tools for exporting and importing applications and application components.
Some of these terms might be unfamiliar to you at this stage, but don't be alarmed as we'll cover them all further down this book.
The SQL Workshop includes a series of tools which allow us to create, manage, and inspect our application data infrastructure. This including wizards to create and manipulate database objects, scripts and queries, and the SQL Commands facility, which allows us to run SQL and PL/SQL code in the context of APEX. This can be very useful, as some of the APEX features and APIs are not available outside the APEX context (e.g. SQL*Plus) for security reasons.
The Utilities module includes a number of tools to help us manage the APEX development-surrounding environment, especially regarding the database. It includes tools for the import and export of data into and out of the database, the APEX data dictionary, and several database monitoring and reporting tools.
The APEX environment also includes a special administration module, which allows us to define the APEX working environment, developers, and users.
All these modules include declarative, wizard-based tools, which makes the application development cycle a very rapid one. These development environment allows us to quickly define a prototype of our application, and then expand it with all the finer details.
APEX was designed with globalization, localization, and NLS (National Language Support) in mind. To begin with, the APEX interface is translated into nine languages, other than English. The languages are German, Spanish, French, Italian, Japanese, Korean, Brazilian Portuguese, Simplified Chinese, and Traditional Chinese.
APEX can utilize all the globalization, localization, and NLS features that the Oracle database has to offer, and add some of its own. The Application Builder Shared Components module includes a Globalization section, which allows us to define relevant parameters for globalization, localization, and NLS. It also includes a wizard to guide us through the process of translating our entire application into secondary languages.
APEX takes into account the client side NLS settings when dealing with the import and export of data into and out of the database. It also takes into account the database NLS settings, in order to properly sort data, display dates, number format (e.g. decimal point or comma) and the local currency, among others.
APEX supports the XLIFF (XML Localization Interchange File Format) standard, which allows us to translate an entire APEX application into any language we need, without re-writing the application code. APEX provides a built-in mechanism to simultaneously run the same application in multi language User Interfaces, giving us several options to determine the application language, including the option of matching the APEX application language to the end user's browser language preferences. Moreover, if we need to support a language which is not included in the native supported languages list, this mechanism will allow us to specifically translate the built-in APEX engine strings and messages into that language, allowing us to develop and support APEX application in any language that our database can support.
Since version 2.0, the client side communicates with the server side, using the AL32UTF8 character set, regardless of the database character set. Due to some of the advanced technologies APEX is using (like AJAX), this setting is mandatory. If you are going to work in a multi-language environment, it would be optimal to set your database character set to AL32UFT8. This will ensure a true multi-language environment, while eliminating the need to employ any character set conversions between the client and the server. Oracle is advising users to use AL32UTF8 as their default choice for the database character set.
Throughout this book, we will devote special attention to globalization, localization, and NLS issues in the APEX environment, including RTL (Right-To-Left) support examples.
The core of APEX is a collection of PL/SQL packages, written using the PL/SQL Web Toolkit, and several hundred database tables, in which all the metadata regarding developed applications are stored.
The PL/SQL Web Toolkit is a collection of Oracle supplied database packages, which allow us to produce Web page code, directly in the database, using PL/SQL stored procedures. During run-time, and in real-time, the APEX engine queries the metadata tables and retrieves all the relevant information for a specific application page. Next, it uses the PL/SQL Web Toolkit to generate the application page's HTML code. This page's code also includes the proper linkage to the CSS and JavaScript resources that support proper page functionality, layout, and styles. Some internal tests run by the APEX development team, showed that the APEX engine performs all the real-time rendering processes, with an average overhead of less than 0.04 seconds per page. Pretty impressive in my opinion, and the APEX engine includes a server side caching mechanism, that can help us reduce that further.
It is important to understand that although the final product of APEX Application Builder is an HTML page code, no static files with any related HTML file extensions, are stored on the server. Each page is created upon demand a specific URI request. That, of course, gives us considerable flexibility with constructing the pages, e.g. the same page can be displayed somewhat differently for various users, or include conditioned components, depending on the user's security privileges, or role in the company, etc.
So, on one side we have the APEX engine, a collection of PL/SQL packages, running inside an Oracle database, and on the other side we have the application user, using a Web browser. How can we connect, and communicate between the sides? As we are in a Web environment, we are going to use the HTTP protocol, implemented in two technologies.
The first way is by using the Oracle HTTP Server (OHS) technology. OHS is based on the well-known (open source) Apache HTTP server, in its 1.3 or 2.0 versions. What interests us, for the APEX environment, is the Oracle plug-in module for this HTTP server, called mod_plsql.
OHS, with the mod_plsql module, is located between the client's Web browser and the Oracle database server. The mod_plsql module communicates with the database by mapping the Web browser request into PL/SQL stored procedures in the database. In turn, the PL/SQL stored procedures can manipulate the data in the database tables and generate HTTP responses, which can include HTML code, to be displayed on the client Web browser.
In order to communicate with the database, mod_plsql is using a DAD (Database Access Descriptor) file, which contains configuration parameters on how to connect with the database, which user and password to use, NLS parameters, and others.
The second technology to implement the HTTP communication protocol utilizes the Embedded PL/SQL Gateway running on the XML DB HTTP server, which is an integrated feature of the Oracle Database. Using the DBMS_EPG package, the Embedded PL/SQL Gateway can implement the core functionality of the OHS mod_plsql module, without installing it. This technology was first supported by APEX in the embedded version (2.1) of the Oracle XE database. Today, it's also supported by APEX 3.0 and above versions, running on Oracle 11g databases. APEX 3.0, which uses the embedded PL/SQL gateway, is installed by default as part of the 11g database installation process, and can be upgraded to any higher APEX version.
APEX is a RAD tool, running inside an Oracle database. Using a Web browser, it allows us to develop, test, and deploy a Web based, data centric application, in a declarative manner.
Although APEX is a declarative tool, we need to be familiar with some other programming technologies and resources, in order to optimally utilize it. That's in the next chapter.
APEX is a declarative tool. As such, we are working with wizards and properties/attributes sheets. However, in some cases, the declarative wizards don't support all the technologies, options, and finer details that are available to us in the environment in which APEX operates and are important to achieve the tasks and business logic of our APEX application.
Whenever we want to enhance the generic result of a declarative wizard, such as in some of the following cases:
and more, we need to have some basic skills and a knowledge of relevant programming languages and technologies.
When and where appropriate or needed, whether mandatory or optional, the APEX wizards and property sheets will allow us to use our skills to develop snippets of real code to achieve what we want.
The following are some of the skills and technologies that we believe will help you the most while developing with APEX.
SQL is essential where reports, charts, and calendars are concerned as it defines the scope and the conditions of the fetched data from the database. APEX includes some wizards and tools, such as the Wizard Report and Query Builder, which can greatly assist novice users in creating SQL queries, but basic SQL knowledge is still an advantage. The same can be said about PL/SQL, especially when we want to enhance the APEX built-in wizards and pre-defined processes capabilities, or when we use AJAX (on the server-side). For example, the APEX built-in wizards and the declarative pages natively support working with a composite Primary Key of up to two segments. Working with compound Primary Keys with more than two segments, is possible, but we will have to write our own DML code for that.
In this book, we'll assume that you have the basic skills and knowledge to handle the APEX tasks that involve SQL and PL/SQL.
HTML and CSS skills will help us a lot with enhancing and enriching the APEX built-in wizards and tools that are dealing with the look and feel of our applications. APEX allows us to define our own HTML templates or add our own CSS files, built from scratch or based on the existing HTML and CSS pre-built libraries (Theme in the APEX terminology). This will allow us to create applications with the exact look and feel that we need, for example, to maintain consistency with other Web applications in our environment.
JavaScript can give us the ultimate control over our pages, allowing us to change their layout and content dynamically and in real-time. JavaScript is also the client-side component of AJAX, which is a crucial technology in all the modern Web applications.
However, we must bear in mind that JavaScript can be banned from our client's Web browsers due to strict security policies, for example. JavaScript is also not fully supported on many of the low-end smart phones and PDAs. We should check the target environment for our APEX application and then decide how to use JavaScript.
Mastering JavaScript will make your life as a Web application developer much easier, regardless of which specific development tool you choose to use. Spending time learning it will definitely be worth your while, and the Internet is filled with JavaScript tutorials that can greatly assist in the learning process.
APEX includes a built-in JavaScript library. As of version 3.x, this library is documented in the APEX User's Guide. You should use this documentation to familiarize yourself with that library.
http://download.oracle.com/docs/cd/E14373_01/apirefs.32/e13369/javascript_api.htm#CDEEIGFH
Globalization and National Language Support (NLS) note:
JavaScript is a crucial element for APEX non-native supported language applications, especially in the RTL (Right-To-Left) environment. It's the only technology that allows us to adapt compound built-in APEX components to the NLS and RTL orientation environment. We will elaborate more on these issues, further in the book.
In the following sections I'll explain some specific issues pertaining to HTML, CSS, and JavaScript that I find useful and important to working effectively with APEX. I strongly believe that enhancing your skills and knowledge in these issues will give you a better understanding of how the APEX Application Builder is working and will allow you to develop better APEX applications right from the start.
We already know that the final product of the APEX Application Builder is an HTML code, so the importance of this Hyper Text Markup Language (and its successor, the eXtensible version, XHTML) can't be overrated.
Every element that we are placing on our application page is being translated by the APEX engine, into a combination of HTML, CSS, and in some cases, JavaScript code. As such, all the elements of the page are being arranged in a DOM (Document Object Model) structure — a hierarchical, tree-like model. The DOM standard, formalized by W3C (World Wide Web Consortium), allows us to access and manipulate every node on the tree, whether by direct access or by walking up (or down) the tree.
The main building blocks of the DOM are the DOM objects. Every DOM object has a series of properties and methods, and it can include other objects and even a collection of objects (e.g. an array of all images or links on the page).
The two highest objects in the DOM hierarchy are the DOM window object and the DOM document object.
Every HTML element is represented by a DOM object with its own attributes and methods. Every such object is represented by one or more nodes in the DOM tree.
The DOM document object can include other DOM objects, which represent various HTML tags — e.g.<A>, <INPUT>, <BUTTON>, <IMG>, etc. Each such DOM object has a set of attributes and methods according to its type and functionality.
One of the most useful attributes of the DOM elements is the ID attribute, which uniquely identifies the element, within the document object. Other attributes allow us to name the element (a non-unique attribute), read or set its value, status (e.g. disabled, read-only, checked, etc.), and appearance (e.g. style, class etc.).
The DOM is a hierarchical, tree-like model. As such, by using hierarchical terms like parents, children, and siblings we can walk the DOM up and down, reaching every node on the tree even if it does not contain a means of identifications, such as ID or name. This allows us more direct access. Using some of the specific DOM walking node object properties, such as parentNode, firstChild, lastChild, nextSibling, or previousSibling, can bring us anywhere we need on the DOM.
The DOM also includes several built-in methods for easy access to the DOM elements. In APEX we are usually using these methods in JavaScript code. The following are the most common built-in DOM methods that we will be using:
Bear in mind:
Specific DOM objects can also have methods according to their type and functionality. For example, the window object has a method called print() which allows us to call the local OS (Operating System) print services, or the open() and close() methods, which allow us to open a popup window and in turn, close it. Most of the DOM objects that represent HTML page elements have a method called focus() which allows us to focus the application cursor on the element. Some of them have functionality dependent methods like click() for the DOM checkbox item, which emulates a mouse click on that item. You should familiarize yourself with all these methods as they can make some of your tasks easier.
HTML 4.0 introduced the option of including HTML event handlers as part of the DOM elements. The standard defines a set of events that we can use as attributes of the various HTML tags. The events are fired in the Web browser as a result of the actions performed on the document such as moving the mouse cursor around, using the keyboard, changing the value of an element, navigating across the page, etc. We can trap these events and use them to invoke snippets of code, like JavaScript, in the Web browser.
The following is a list of some common events that we will be using while working with APEX:
The correct syntax for the HTML events is all in lower-case and NOT like onLoad, onChange, etc.