This tutorial shows you how to use and built plug-ins in Oracle Application Express 4.0.
Approximately 60 minutes.
What are Plugins?
Plug-ins enable developers to enhance the existing built-in functionality with new item types, region types, process types and dynamic actions to enhance and customize their application.
In this tutorial, you import the Star Rating Plug-in and then add it to your page as shown below.
In addition, you create a Masked Text Field Plug-in from scratch and then use it for your Phone Number item as shown below.
Before starting this tutorial, you should:
You want to create a new database application that will demonstrate the plug-in functionality.. Perform the following steps:
1 . |
Enter the following URL in your browser to log in to Oracle Application Express. http://<yourhostname>:8080/apex
|
---|---|
2 . |
To log in to Oracle Application Express, enter the following details,
and click Login.
|
3 . |
Select Application Builder > Database Applications.
|
4 . |
Click Create.
|
5 . |
Make sure the Database Application Type is selected and click Next.
|
6 . |
Make sure From Scratch is selected and click Next.
|
7 . |
Enter Plug-in Application for Name and click Next.
|
8 . |
Enter Home for Page Name and click Add Page.
|
9 . |
Select the Report and Form Page Type, select Home (1) for Subordinate to Page, enter DEMO_PRODUCT INFO or select it from the list of tables and click Add Page.
|
10 . |
Click Create to accept the default values for the rest of the wizard pages.
|
11 . |
Click Create to confirm.
|
12 . |
Your application was created successfully. Click Run Application.
|
13 . |
Enter obe for Username and Password and click Login.
|
14 . |
The Home page is displayed. Select the Demo Product Info link.
|
15 . |
The report is displayed. Select the edit icon for one of the products.
|
16 . |
The Product Form is displayed. You want to add a rating for the product. In the next topic you add the column to the table. Click the Home link in the developer toolbar.
|
You will add a Star Rating Plugin to your page. You want to store the rating selected so you need to add a column to the table where you want to store the value. Perform the following steps:
1 . |
Select SQL Workshop > Object Browser.
|
---|---|
2 . |
Enter demo in the search area and select the DEMO_PRODUCT_INFO table in the list.
|
3 . |
Select Add Column.
|
4 . |
Enter RATING for Add Column, make sure NUMBER is selected for Type, enter 2 for Precision and click Next.
|
5 . |
Click Finish.
|
6 . |
The rating column was added successfully. Now you are ready to import the plug-in you will use in your application.
|
In order to use a plugin, you either need to create your plugin or import one from the repository or an export file. In this section you will import a file that contains the plug for a star rating. Perform the following steps:
1 . |
Select Application Builder > Database Applications.
|
---|---|
2 . |
Select your Plug-in Application.
|
3 . |
Select Shared Components.
|
4 . |
Under User Interface, select Plug-ins.
|
5 . |
There are currently no plug-ins. You will import the Star Rating plug-in which has been supplied in your files directory. Click Import.
|
6 . |
Click Browse...
|
7 . |
Select the item_type_plugin_com_oracle_star_rating.sql file from the directory where your files for this tutorial are located and click Open. Click Next.
|
8 . |
Click Next.
|
9 . |
Make sure your Plug-in Application is selected for Install into Application and click Install Plug-in. In the next section, you will add the plugin to your page.
|
You want to add a rating item to the Product form page in your Plug-in Application. Perform the following steps:
1 . |
Click the Application <n> breadcrumb.
|
---|---|
2 . |
Select the 3-Demo Product Info form icon.
|
3 . |
Under the Edit DEMO_PRODUCT_INFO Region, right-click Items and select Create Page Item.
|
4 . |
Select the Item Type Plug-ins and click Next. Note that if there are no plug-ins contained under Shared Components > Plug-ins then this Item Type will not be shown on this page.
|
5 . |
Select the Star Rating radio button and click Next. Note that only the Plug-ins that have been imported for this application are displayed.
|
6 . |
Enter P3_RATING for Item Name and click Next.
|
7 . |
Accept the defaults and click Next.
|
8 . |
Accept the default to have 5 # of stars for the Rating and click Next.
|
9 . |
Select Database Column for Source Type, enter RATING for Database Column Name and click Create Item.
|
10 . |
The Rating item was created successfully. Click Run.
|
11 . |
The Star Rating item is displayed. When you put your cursor over one of the stars you see the stars change colors. Select the number of stars you want.
|
12 . |
Click Apply Changes.
|
13 . |
Your Star Rating was added to the database. In the next section, you will create a plug-in from scratch and then use it in your application. Select Application <n> in the developer toolbar.
|
You may at some point want to create a plug-in to perform a function that is not currently available in Oracle Application Express. In this section you will create a item plug-in that allows a user to enter a fixed width input and enter data in a certain format such as a phone number. Perform the following steps:
1 . |
Select the Shared Components icon.
|
||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2 . |
Under User Interface, select Plug-ins.
|
||||||||||||
3 . |
You want to create a new plug-in. Click Create.
|
||||||||||||
4 . |
Enter Masked Text Field for Name, COM.ORACLE.APEX.MASKED_TEXT_FIELD for Internal Name, make sure Item is selected for Type and click Create. Note that the internal name should be changed to your own domain name but for this example, you will use ORACLE.
|
||||||||||||
5 . |
You need to add a file that contains the javascript needed for this plug-in. Select the Files subtab.
|
||||||||||||
6 . |
Click Upload New File.
|
||||||||||||
7 . |
Click Browse...
|
||||||||||||
8 . |
Select the jquery.maskedinput-1.2.2.min.js file from the directory where your files for this tutorial are located and click Open. Then click Upload.
|
||||||||||||
9 . |
Your file was added. Click the Custom Attributes tab.
|
||||||||||||
10 . |
Click Add Attribute.
|
||||||||||||
11 . |
Enter the following and click Create and Create Another.
|
||||||||||||
12 . |
Enter the following and click Create.
|
||||||||||||
13 . |
You need to specify the code that will execute for this plug-in. Click the Source subtab.
|
||||||||||||
14 . |
Copy and paste the code in the mask_plugin.txt file into the PL/SQL Code field and then click the Callbacks subtab.
|
||||||||||||
15 . |
Make sure render_mask is set for Render Function Name and validate_mask is set for Validation Function Name and click Apply Changes.
|
||||||||||||
16 . |
The Masked Text Field plug-in was created successfully. Now you want to create a new page where you can apply the plug-in. Click the Application <n> breadcrumb.
|
You will create 2 new pages (Report and Form) to maintain Customer information. Perform the following steps:
1 . |
Click Create Page.
|
---|---|
2 . |
Select Form and click Next.
|
3 . |
Select Form on a Table with Report and click Next.
|
4 . |
Accept the default and click Next.
|
5 . |
Enter DEMO_CUSTOMERS for Table/View Name and click Next.
|
6 . |
Enter Customer List for Page Name and Region Title, select Breadcrumb for Breadcrump, select Home for the Parent Entry and click Next.
|
7 . |
Accept the default and click Next.
|
8 . |
Shift+select CUST_FIRST_NAME, CUST_LAST_NAME and CUST_EMAIL and click Next.
|
9 . |
Accept the default and click Next.
|
10 . |
Enter Maintain Customers for Page Name, Region Title and Entry Name and click Next.
|
11 . |
Accept the default and click Next.
|
12 . |
Accept the default and click Next.
|
13 . |
Shift+select all the columns and click Next.
|
14 . |
Accept the default and click Next.
|
15 . |
Click Finish.
|
16 . |
Click Run Page.
|
17 . |
The report is displayed. Select the edit icon in front of one row.
|
18 . |
The form is displayed. Notice that Phone Number 1 is formatted however this number is not based on the plug-in. Change the number to something else.
|
19 . |
After you make your change, click Apply Changes to see that it was accepted..
|
20 . |
Click the edit icon again.
|
21 . |
Your change was accepted because there is no validation and the plug-in was not applied. In the next topic, you apply the Masked Text Plug-in to the Phone Number 1 item. Select the Edit Page link in the developer toolbar.
|
Now that your masked text field plugin is imported and your customer form is created, you can use it for the Phone Number 1 item. Perform the following steps:
1 . |
Right click P5_PHONE_NUMBER1 and select Edit.
|
---|---|
2 . |
Select Masked Text Field [Plug-in] for Display As.
|
3 . |
Notice the Settings area is displayed which contains the Custom Attributes you specified when you created the plug-in. Accept the defaults and click Apply Changes.
|
4 . |
Click Run.
|
5 . |
The form is displayed. Notice the phone number looks the same as it did before. Delete the current contents of that field.
|
6 . |
Notice that the format of the field is displayed with the placeholder of a '_'. Change the '_' with a different number.
|
7 . |
The numbers for Phone Number are displayed in the format specified by the plug-in. Enter something in the Alt Phone Number field. Notice that the numbers do not have the same format applied. This is because this item is still a text item and the plug-in has not been applied.
|
In this tutorial, you have learned how to:
![]() |
About
Oracle |Oracle and Sun | ![]() |