Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Oracle APEX Cookbook : Second Edition

You're reading from   Oracle APEX Cookbook : Second Edition Get straight into developing modern web applications, including mobile, using the recipes in this brilliant cookbook for Oracle Application Express (APEX). From the basics to more advanced features, it's a reference book and guide in one.

Arrow left icon
Product type Paperback
Published in Oct 2013
Publisher
ISBN-13 9781782179672
Length 444 pages
Edition Edition
Languages
Arrow right icon
Toc

Table of Contents (21) Chapters Close

Oracle APEX Cookbook Second Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
1. Creating a Basic APEX Application 2. Themes and Templates FREE CHAPTER 3. Extending APEX 4. Creating Websheet Applications 5. APEX Plug-ins 6. Creating Multilingual APEX Applications 7. APEX APIs 8. Using Web Services 9. Publishing from APEX 10. APEX Environment 11. APEX Administration 12. Team Development 13. HTML5 and CSS3 14. Mobile Index

Controlling the display of regions and items with Dynamic Actions


Dynamic Actions are control items that dynamically can affect the display of regions or items on a page. There are several situations when you want to show or hide items. For example, a text item asking for a maiden name should only be displayed when the person is female and married. In other cases, it is irrelevant to ask for a maiden name (on the other hand, with homosexual marriages it's possible for a man to have a "maiden" name, and in some cases a man can adopt the family name of his wife, but let's not make this example more difficult than necessary).

The same applies to the Commission field in the employees table. This item should only be enterable when the employee's job is a salesman. Let's build the functionality for this last situation.

Getting ready

You should already have an application and a simple single record form on the employees table.

How to do it...

  1. Right-click on the Dynamic Actions link in the leftmost section and click on Create.

  2. Select Standard and proceed to the next step.

  3. Enter a name for this dynamic action. For example, D_JOB_COMM_SHOW. Click on Next.

  4. In the next screen, the Selection Type is Item(s) and in the Item(s) field, enter the name of the item holding Job. You can use the List of Values button to select the right Page Item.

  5. In the Condition list box, select equal to.

  6. In the Value textarea, enter SALESMAN. Click on Next.

  7. Select Show as the True Action and go to the next step.

  8. In the next screen select Item(s) in the Selection Type. In the shuttle item that now appears, move the name of the commission field to the right.

  9. Click on the Create button.

You have now created a dynamic action which shows the Commission field when the job is SALESMAN and hides the Commission field when the job is not SALESMAN.

How it works...

The Dynamic Actions are actually event handlers in HTML. There are several event handlers.

Because these events are HTML (or rather JavaScript) they are handled client side. This has the advantage that the page doesn't have to be reloaded completely when an action is triggered to show or hide items.

Event

Meaning

After refresh

Item has been refreshed (that is, by page refresh)

Before refresh

Fires before item has been refreshed (that is, by page refresh)

Blur

User navigates to another item

Change

User navigates to another item and the value of the item has changed

Click

User clicks on the item with a pointing device (like a mouse)

Dblclick

User double-clicks on the item with a pointing device

Focus

User navigates to the item via the tab key or a pointing device

keydown

User clicks on a key on the keyboard

keypress

User clicks on a key on the keyboard (=onkeyDown followed by onkeyUp)

keyup

User releases the key after having pressed it

load

The browser loads all content

mousedown

User clicks on the mouse button when the mouse pointer is over the item

mouseenter

User clicks on the item with the pointing device

mouseleave

User moves away the mouse from the item

mousemove

User moves the mouse while the mouse pointer is over the item

mouseover

User moves the mouse pointer over the item

mouseout

User moves away the mouse pointer from the item

nmouseup

User releases the mouse button after having it pressed

submit

Form is submitted

Resize

Document view is resized

Scroll

Document view is scrolled

Select

User selects some text in a text field

Submit

Form is submitted

Unload

Page is unloaded

In our example, we use the onchange event handler. So, when the user changes the value in JOB, the onchange is triggered and it calls the action to show or hide the COMMISSION field, depending on the value in JOB. If it is SALESMAN then show commission, else hide commission.

There's more...

You can control the display of more than one item at a time. Simply separate the items by a comma in the items field.

You can also control the display of regions. So, you can show or hide a complete report. Instead of item, select region and the name of the region in the affected element section when defining an action.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image