APEX Item Submission

In his 3 part series ending with APEX and the Order Items are Submitted, Martin D’Souza did a great job explaining how APEX page items are submitted and why you can’t reorder the DOM in arbitrary ways. If you haven’t read it already it I strongly recommend that you do so. I can’t improve on how he explained it but I have just two things to add.

Why does APEX do this?

I was very confused by this when I first joined the APEX team. I think that others especially people with front end web development experience will also wonder why APEX uses p_arg_names and p_tnn names rather than the more traditional way where you get to name your inputs as you please. For example <input name="phone_number"...>.

Martin explains that the p_arg_names values are used to map the post parameter values back to the APEX item metadata. The other part of the puzzle has to do with how HTTP post parameters are passed into the APEX engine. The interface between the web listener and APEX Engine maps post parameters to PL/SQL procedure formal parameter names. So there is actually a PL/SQL procedure with formal parameters named p_arg_names and p_t01, p_t02…p_t200. The same procedure is used for all apps and all pages so this is why fixed names must be used.

A subtle and unfortunate consequence.

If you have used any APEX applications you have undoubtedly run into the situation shown in the following image where the browser auto complete feature offers suggestions that have nothing to do with the current field.

Auto Complete

How a browser implements the auto complete feature is up to the browser (meaning there is no common specification that must be followed) but the primary method of choosing what values to show is the name attribute. Fields with the same name tend to show the same auto complete choices. The underlying assumption that browsers are making is that web developers choose meaningful names for input fields such as firstName, phone_number, etc. With APEX this assumption fails. Because the name attribute is assigned automatically and sequentially, it is the order of the form item on the page that determines what auto complete values will be shown.

I’m a little surprised that more people haven’t complained about this. Its a tricky problem to solve and it may not even be worth solving. How bothersome do you find this?

APEX Interactive Report Checkbox Row Selection

The question of how to add checkboxes to interactive reports comes up often. Usually the problem is not getting the checkbox to display in a row but in how to do something useful with the checked state. There are many forum or blog posts on this topic but they all seem to be rather dated. Even when the general idea is still applicable they use outdated practices including:

  • Inline event handlers using onchange or onclick attributes. These should be dynamic actions.
  • HTML regions with script tags in them or script tags in the HTML Header page attribute. There are much better ways to get JavaScript on a page now. Consider JavaScript File URLs, Function and Global Variable Declaration, and Execute when Page Loads attributes as well as dynamic actions.
  • Making ajax requests using the htmldb_Get API. This should be replaced with dynamic actions or apex.server.process API calls.

So I thought I would take a stab at solving this problem.

Continue reading APEX Interactive Report Checkbox Row Selection

APEX 5.0 Custom Menus

This topic has been motivated by a few different APEX forum threads as well as direct questions from teammates. Here I will show how to add a menu button to each row of an interactive report that will open a menu and the menu item actions will be specific to the row.

Custom Menu Demo

The above pictured Custom Menu Demo is available to try out and to download. This article assumes some familiarity with APEX and JavaScript.

Simple Popup Menu

Before going into how to create a custom menu let me make sure that we all know how to create a simple list based popup menu.

Continue reading APEX 5.0 Custom Menus