However new the
technologies, we developers have to resolve the same old problems to keep
our users and customers happy. Granted, some new challenges make our lives
more interesting. However, the same basic issues have to be resolved in
order to provide decent systems.
What do users expect from a good information system? Well, as the name suggests, such system should provide a very efficient and flexible access to information. Different users will focus on distinct areas of the database and follow diverse paths to navigate to the same information.
In this article we focus on navigation. We show how to use the PL/SQL Package List preference to give you a free hand to include navigation buttons that call other web server modules and pass parameters containing context information.
To help the reader
we move step by step through the process to provide such navigation to
users. Process steps are illustrated with snapshots of the web modules,
key Designer settings together with PL/SQL and JavaScript code extracts.
In one module we
enable users to view, create, update and delete positions. In another module
we provide the same functionality for business units. Our objective is
to get Designer to generate code to display a button on the web page that
handles positions. When the user clicks on this button the system must
display the web page that manages business unit information and automatically
bring up the record of the business unit corresponding to the position
that the user was looking at.
Now, how do we
figure out how to call this module with parameters and make it display
one or several specific records?
Listing A outlines
the structure of the called module. We will need to call one of its program
units when users click on our navigation button. Can you guess which one
we’ll pick?
With this structure
in mind, the next step is easy. Designer has already coded a parameterized
procedure that queries the database and displays the business unit details.
This procedure is ActionQuery. In Listing B we show the header of this
procedure in the called module package.
This is the procedure
that is called in the business unit module when the user submits the query
HTML form by pressing the Find button. So all we have to do is get Designer
to generate such an HTML form in the calling module.
First, we need to use the PL/SQL Package List preference. You can get Designer to include any HTML or JavaScript code in the module that it generates by creating a package of functions that return varchar2. All you have to do is put the package name in the PL/SQL Package List preference and include the calls to your functions in the "right places" in the module definition. The "right places" are usually user text areas, titles, headers and footers.
We set the web generator preference Text Handling à PL/SQL Package List = wfs_weblib. Wfs_weblib is the package where we put all the custom client code that we need the generator to include. This package must be created on the database server.
Then in the Design
Editor, we navigate to the calling module: pos_mw and double click on its
module component pos_m. A dialog pops up on the screen. The dialog title
is "Edit Module Component <module component name>". If you do not get
this dialog but see the property palette instead, select menu option: Optionsà
Use Property Dialogs and double-click on the module component again. In
the User Text tab we select "Bottom of the View Form" and type this in
the User text: "wfs_weblib.pos_m_but_bu". Note1: do not include the quotes.
Note2: no semi-column is required. The attentive reader will recognize
the package name that we introduced earlier. The function code of pos_m_but_bu
is in Listing C.
This function returns
a piece of HTML and JavaScript code. The code creates a form with 2 elements:
a button with label "Show PC Details" and a hidden text field that gets
populated by the code in the onClick trigger of the button item. When you
see a statement like "this.form.P_PC_CODE.value=document.forms[0].P_L_BU_PC_CODE.value
" you may wonder how you would know the exact spelling of the fields in
your own modules. With experience you can guess. If you lack the experience,
here is a technique for you. Generate your module once without the button.
When you have achieved the design that you intended, check the source HTML
in your browser. This will show all the items and their HTML names.
If you have analyzed
thoroughly the code in Listing C, you know what server procedure gets called
when the user presses the button: wfs_weblib.call_bu_m. Creating this procedure
is the last step of this technique. If you are not an HTML expert, you
may be surprised that you did not see an explicit call to this procedure
in the onClick trigger of the button. This is what an HTML form does. It
contains a number of items, some text fields, some hidden fields and some
submit items. Our button is a submit item. When users select submit items,
the instructions in the "action" property of the HTML form are executed.
This is how wfs_weblib.call_bu_m is executed.
Important Note: our package wfs_weblib is not as small as
listing D suggests. We only show extracts of it for the sake of brevity.
For this reason we did not repeat the code shown in Listing C into Listing
D, although it is the same package.
In our situation,
when in Figure D the user presses on the button "Show PC Detail" the information
illustrated in Figure C is displayed. Note that there is only one record
in the record list in the left frame in Figure C. This record corresponds
to the PC Code assigned to the employee in Figure D.
Giving users an easy access to information is what information systems are all about.
Hervé Deschamps is a Senior Principal Consultant with Oracle Corporation. He has had over five years of experience with Oracle Development Environments (Designer, Developer 2000 and their previous versions). He specialises in tending towards 100% Generation using Designer for both web and client server applications. You can reach him by e-mail at herve@iherve.com. He also maintains a web page full of articles, scripts, tips, techniques at: http://www.iherve.com.