Following on from my previous blog, today I am going to take a look at the REST enabled form improvements first introduced in APEX 19.1. It is now possible to declaratively create an APEX form based on Web Service using a Web Source Module. I will also take the opportunity to demonstrate REST enabled objects, which allow you to easily REST enable tables, views, packages, procedures and functions.
For this demonstration I will be using APEX version 20.1 on an apex.oracle.com workspace and the OEHR_JOBS table from the HR Data sample dataset.
Before starting you will need to complete the following prerequisite tasks.
Before we can create a REST enabled form, we need to create a RESTful Web Service over a data source. One of the simplest ways to do this is to use the REST Enabled Object feature which can be accessed via the SQL Workshop.
|REST Enabled Object||Yes|
You will see a success message meaning that the table has been REST enabled, complete with HTTP methods for GET, PUT, POST and DELETE.
The RESTful URI will now be displayed.
The GET Web Service is called and data from OEHR_JOBS is returned to the browser in JSON format. In the above example the JSON text has been formatted using a browser extension. If you are not using one there are many free online formatting tools available.
You will see objects that the table have been enabled for REST, which in this example is just the table OEHR_JOBS.
Now we have a suitable Web Service we can use for a REST Enabled Form we can create the Web Source Module.
|Web Source Type||Oracle REST Data Service|
|URL Endpoint||The RESTful URI you copied|
We can select the Oracle REST Data Service option because we are using a Web Service generated by REST enabling a table, so we know it follows the Oracle REST standard and has GET, PUT POST and DELETE operations.
The Web Source Module has now been created.Click on the newly created Web Source Module to open the details and scroll down to Operations.
You can see that the operations we required for the REST Enabled form have all been added automatically.
We can now create a linked report and form using the Jobs Web Source Module.
|Report Type||Interactive Report|
|Report Page Name||Jobs|
|Form Page Name||Job Details|
|For Page Mode||Modal Dialog|
|Data Source||Web Source|
|Web Source Module||Jobs|
|Report Columns||Keep the default of all columns selected|
|Form Columns||Keep the default of all columns selected|
|Primary Key Column||JOB_ID|
If you take a look at the Job Details region you will see it is a Form Region with the data source set to the Jobs Web Source we created.
Take a look at the processing APEX has created and you will see it uses the Form Automated Row Processing (DML) type.
Author: Colin Archer
Job Title: Senior Oracle APEX Development Consultant
Bio: Colin is a Senior Development Consultant at DSP-Explorer with 20 years’ experience of analysis, design, and development of bespoke Oracle applications for a wide variety of business functions. Building on his previous experience of Forms and PL/SQL he is now focusing on developing high quality fit for purpose solutions using APEX.