Book Image

Oracle APEX 4.0 Cookbook

By : Michel Van Zoest, Marcel Van Der Plas
Book Image

Oracle APEX 4.0 Cookbook

By: Michel Van Zoest, Marcel Van Der Plas

Overview of this book

<p>Oracle Application Express 4.0 is a rapid web application development tool that works with the Oracle database. Using features like Plug-ins and Dynamic Actions, APEX helps you build applications with the latest techniques in AJAX and JavaScript.</p> <p>The Oracle Application Express 4.0 Cookbook shows you recipes to develop and deploy reliable, modern web applications using only a web browser and limited programming experience. <br /><br />With recipes covering many different topics, it will show you how to use the many features of APEX 4.0.<br /><br />You will learn how to create simple form and report pages and how to enhance the look of your applications by using stylesheets. You will see how you can integrate things such as Tag Clouds, Google Maps, web services, and much more in your applications. Using Plug-ins, Dynamic Actions, BI Publisher, translations and Websheets, you will be able to enhance your applications to a new level in APEX.</p> <p>This book will show you how to be Agile in the development of your web applications by using Team Development, debugging, and third-party tools.</p> <p>After reading this book, you will be able to create feature-rich web applications in Application Express 4.0 with ease and confidence.</p>
Table of Contents (19 chapters)
Oracle APEX 4.0 Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Implementing an interactive report


In this recipe, we are going to create an interactive report and show you how to use it. An interactive report is a special kind of report, which offers a lot of options to the user for filtering, sorting, publishing, and much more.

Getting ready

It's always a good idea to start by creating a view that already selects all columns you want to show in your report. This simplifies the query required for your report region and separates the logic from presentation in your application architecture.

In this recipe, we are going to base the interactive report on the APP_VW_CONTACTS view that joins the tables for contacts, addresses, and communications. The query for this view is:

select ctt.firstname
     , ctt.lastname
     , ctt.contact_type
     , ads.address_type
     , ads.address_line1
     , ads.address_line2
     , ads.postcode
     , ads.city
     , ads.state
     , ads.country
     , aac.default_yn
     , ctt.id
     , ads.id
  from app_contacts ctt
     , app_addresses ads
     , app_ads_ctt aac
 where aac.ctt_id = ctt.id
   and aac.ads_id = ads.id

[1346_01_01.txt]

We will also need a named LOV later on in the recipe. To create it, follow the next steps:

  1. Go to Shared Components and then to Lists of Values.

  2. Click Create to make a new LOV.

  3. Create it from scratch and call it ADDRESS_TYPE, it should be a dynamic LOV.

  4. The query that it's based on is:

    select rv_meaning display_value
         , rv_low_value return_value
      from app_ref_codes
     where rv_domain = 'ADDRESSES'

[1346_01_02.txt]

How to do it...

The starting point for this recipe is an empty page, so the first thing that we're going to do is create a new region to contain the interactive report.

  1. Create a new region by right-clicking on the Regions label and select Create.

  2. Select Report as the type of region.

  3. Then select Interactive Report as the Report Implementation.

  4. Give the Region a title "Contacts".

  5. Select Region Template APEX 4.0 – Reports Region. Keep the other fields on the default.

  6. As the source for the Region, enter the SQL Query:

    SELECT *
      FROM app_vw_contacts

    [1346_01_03.txt]

  7. Leave the other options on default.

  8. Click Create Region to finish this part of the recipe.

    As you can see in the tree view, we now have a new Region with all columns from the view.

    When we run the page now, we can already see some data. APEX also generated a toolbar above the report that we can use to filter data or change the way it is presented.

    The next step is to alter the report, so we can customize the column labels and change the way some of the data is presented.

  9. In the Page Definition's tree view, right-click on the Contacts Region and select Report Attributes from the pull-down menu.

  10. Change the heading for some of the columns:

    • Firstname -> First Name

    • Lastname -> Last Name

    • Default Yn -> Default Address?

  11. Click Apply Changes to confirm the changes.

    This changes the labels for some of the columns in the report. Next, we will change the presentation of the data inside one of the columns.

  12. Expand the tree view to show the contents of Report Columns of the Contacts Region.

  13. Right-click on ADDRESS_TYPE and click Edit.

  14. Change the item Display Text As to Display as Text (Based on LOV, escape special characters).

  15. Under List of Values, select Use Named List of Values to Filter Exact Match from the pull-down Column Filter List of Values.

  16. Select ADDRESS_TYPE as the Named List of Values.

  17. Click Apply Changes.

When we take a look at the page by clicking Run we can see the changes to the column names and the Address Type no longer shows the abbreviation, but the full text.

There's more...

After the developer is done with creating an interactive report, the user will have a host of possibilities in the action menu to change the way the information is presented and filtered. These possibilities can be granted or revoked by the developer to an extent.

To see these options, right-click on the region and click the option named Edit region attributes. When scrolling down this screen, there are two sections for Search Bar and Download.

The first section holds the options that can be used in the Search Bar. When a user clicks the Action button in the Search Bar, a menu will unfold revealing all the possible options. Data can be filtered, sorted, highlighted, and aggregated for instance. It's also possible for the user to generate a chart.

When a user wants to save the changes he made to the report, this is also possible. He can save it for personal or public use, so other users can benefit as well.

The second section holds the file types that can be used to download the information in the interactive report. These include well-known formats such as CSV, PDF, and XLS.