Oracle® HTML DB 2 Day Developer Release 2.0 Part Number B16376-01 |
|
|
View PDF |
Storing information in an Oracle database organizes it into tables that group similar information together and removes redundancies. Using the Oracle HTML DB development environment, you can quickly build an application that enables a user to view and update information stored in an Oracle Database.
This tutorial describes how to use Oracle HTML DB to create and deploy an application that tracks the assignment, status, and progress of issues related to a project.
Topics in this section include:
Effective project management is the key to completing any project on time and within budget. Within every project there are always multiple issues that need to be tracked, prioritized, and dealt with.
The MRVL Company has several projects that must be completed on time for the company to be profitable. Missing deadlines for any of the projects will cause the company to lose money. The project leads are tracking issues in several different ways. Some individuals are manually tracking issues in notebooks, others are tracking issues in text documents, and other managers are using spreadsheets.
By creating a hosted application in Oracle HTML DB, each project lead can easily record and track issues in one central location. Not only will everyone have access to just the data they need, but having the data stored in one location, will make it easier for management to determine if any critical issues are not being addressed.
Before any beginning development on an application, you first need to define requirements that describe what the application does. Once defined, you can turn these requirements into a database design and an outline that describes how the user interface accepts and presents data.
For this business scenario, the project leads establish requirements that define what information needs to be tracked, how security will work, what data management functions will be included, and how data will be presented to users.
Topics in this section include:
Currently, each project lead tracks information slightly differently. Together, everyone agrees that the application should include the following information:
Summary of the issue
Detailed description of the issue
Who identified the issue
The date the issue was identified
Which project the issue is related to
Who the issue is assigned to
A current status of the issue
Priority of the issue
Target resolution date
Actual resolution date
Progress report
Resolution summary
Because the project leads were concerned about everyone having access to all the information, they agree upon the following access rules:
Each team member and project lead is only assigned to one project at a time
Each team member and project lead must be assigned to a project
Managers are never assigned to a specific project
Only managers can define and maintain projects and people
Everyone can enter new issues
Once assigned, only the person assigned or a project lead can change data about the issue
Management needs views that summarize the data without access to specific issue details
Next, the project leads determine how information will be entered into the system. In this case, users must be able to:
Create issues
Assign issues
Edit issues
Create projects
Maintain projects
Create people
Maintain people information
Maintain project assignments
Once the data is entered into the application, users will need to view the data. The team decides they initially need to be able to view the following:
All issues by project
Open issues by project
Overdue issues, by project and for all
Recently opened issues
Unassigned issues
Summary of issues by project, for managers
Resolved issues by month identified
Issue resolution dates displayed on a calendar
Days to Resolve Issues by person
Once you have defined the database object requirements, the next step is to turn these requirements in a database design and an outline that describes how the user interface accepts and presents data. In this step you need to think about how information should be organized in the tables in the underlying database. Given the requirements described "Planning and Project Analysis", for this project you need to create three tables:
Projects
tracks all current projects
People
contains information about who can be assigned to handle issues
Issues
tracks all the information about an issue, including the project to which it is related and the person assigned to rectify the issue
Be aware that you will also need create additional database objects, such as sequences and triggers, to support the tables. System generated primary keys will be used for all tables so that all the data can be edited without needing to implement a cascade update.
Topics in this section include:
Each project must have a name and include a project start date as well as the projected end date. These dates will be used to help determine if any outstanding issues are jeopardizing the end date. Table 10-1 describes the columns to be included in the Projects table.
Table 10-1 Project Table Details
Column Name | Type | Size | Not Null? | Constraints | Description |
---|---|---|---|---|---|
project_id | integer | n/a | Yes | Primary key | A unique numeric identification number for each project.
Populated by a sequence using a trigger. |
project_name | varchar2 | 100 | Yes | Unique key | A unique alphanumeric name for the project. |
start_date | date | n/a | Yes | None | The project start date. |
target_end_date | date | n/a | Yes | None | The targeted project end date. |
actual_end_date | date | n/a | No | None | The actual end date. |
Each person will have a defined name and role. Project leads and team members will also have an assigned project. To tie the current user to their role within the organization, e-mail addresses will be used for user names.
Table 10-2 describes the columns that will be included in the People table.
Table 10-2 People Table Details
Column Name | Type | Size | Not Null? | Constraints | Description |
---|---|---|---|---|---|
person_id | integer | n/a | Yes | Primary key | A numeric ID that identifies each user.
Populated by a sequence using a trigger. |
person_name | varchar2 | 100 | Yes | Unique key | A unique name that identifies each user. |
person_email | varchar2 | 100 | Yes | None | User e-mail address. |
person_role | varchar2 | 7 | Yes | Check constraint | The role assigned to each user. |
Note: For the purposes of this exercise, this application has been simplified. People data is usually much more elaborate and is often pulled from a corporate Human Resource system. Also, people typically work on more than one project at a time. If the roles that are assigned to a person need to be dynamic, you would implement roles as a separate table with a foreign key back to the people table. |
When the project leads defined their application requirements, they determined they needed to track specific issues assigned to a specific person. Issues will be included as a columns along with additional columns to provide an audit trail. The audit trail will track who created the issue, when it was created, as well as who last modified the issue and on what date that modification was made.
Table 10-3 describes the columns to be included in the Issues table.
Table 10-3 Issue Table Details
Column Name | Type | Size | Not Null? | Constraints | Description |
---|---|---|---|---|---|
issue_id | integer | n/a | Yes | primary key | A unique numeric ID that identifies an issue.
Populated by a sequence using a trigger |
issue_summary | varchar2 | 200 | Yes | None | A brief summary of the issue. |
issue_description | varchar2 | 2000 | No | None | A detailed description of the issue. |
identified_by | integer | n/a | Yes | foreign key to People | The user who identifies the issue. |
identified_date | date | n/a | Yes | None | The date the issue was identified |
related_project | integer | n/a | Yes | foreign key to Projects | Projects related to the issue. |
assigned_to | integer | n/a | No | foreign key to People | The person who owns this issue. |
status | varchar2 | 8 | Yes | check constraint | The issue status. Automatically set to Open when new and set to Closed when actual resolution date entered |
priority | varchar2 | 6 | No | check constraint | The priority of the issue. |
target_resolution_date | date | n/a | No | None | The target resolution date. |
progress | varchar2 | 2000 | No | None | The progress of the issue. |
actual_resolution_date | date | n/a | No | None | Actual resolution date of the issue. |
resolution_summary | varchar2 | 2000 | No | None | Resolution summary. |
created_date | date | n/a | Yes | None | Populated by a trigger. |
created_by | varchar2 | 60 | Yes | None | User who create this issue. |
last_modified_date | date | n/a | No | None | Populated by a trigger. |
Note: A real-world application might need more extensive auditing. For example, you might need to track each change to the data rather than just the last change. Tracking each change to the data would require an additional table, linked to the issues table. If the valid priorities assigned to issues needed to be dynamic, you would need to add a separate table with a foreign key back to the issues table. |
This first step in building an application is to create the database objects in the underlying database. You create database objects within a user account in the Oracle database. To create this application, you need to request a new workspace within the Oracle HTML DB development environment. An administrator creates a workspace within an initial schema that will house the application objects.
Topics in this section include:
Note: If you have a local installation of Oracle HTML DB, you may skip this section and use and existing workspace. |
To request a workspace:
In a Web browser, navigate to the Oracle HTML DB Login page. To log in to the Oracle supported site of Oracle HTML DB development, go to:
http://htmldb.oracle.com/
The Login page appears.
Under Tasks, click Request a Workspace.
Click Continue and follow the on-screen instructions.
You will be notified through e-mail when your request has been approved and your workspace has been provisioned.
There are several ways to create objects in Oracle HTML DB. You can:
Create an Object in Object Browser. Use Object Browser to create tables, views, indexes, sequences, types, packages, procedures, functions, triggers database links, materialized views, and synonyms. A wizard walks you through the choices necessary to create the selected database object. To create an object in Object Browser, navigate to Object Browser and click Create.
Execute commands in SQL Command Processor. Run SQL commands by typing or pasting them into the SQL Command Processor. To access SQL Command Processor, click SQL Workshop on Workspace home page and then select SQL Commands.
Upload a script. Upload and script that contains all the necessary create object statements to the SQL Script Repository. To upload a script, click SQL Workshop on Workspace home page, select SQL Scripts, and then click Upload.
Create script online. Create a script online in the Script Repository. This is the method you will use to create the database objects for this exercise. To create a script online, click the SQL Workshop icon on Workspace home page, select SQL Scripts, and then click Create.
To build database objects by creating a script:
Log in to Oracle HTML DB.
Click the SQL Workshop icon on the Workspace home page.
Click SQL Scripts.
Click Create.
In the Script Editor:
For Script Name, enter DDL for Issue Management Application
.
In Script, copy and paste the DDL (data definition language) in "Create Application Database Objects DDL".
Click Save.
To run the DDL for Issue Management Application script:
On the SQL Scripts page, select the DDL for Issue Management Application icon.
The Script Editor appears.
Click Run.
A summary page appears.
Click Run again.
You can view database objects using Object Browser.
To view database objects in SQL Workshop:
Click the SQL Workshop tab.
Click Object Browser.
From the Object list on left side of the page, select Tables.
Under Database Browser, click Tables.
To view the details of a specific object (HT_ISSUES
, HT_PEOPLE
, or HT_PROJECTS
), simply select it.
Once you have created all the necessary database objects, the next step is to load data into the tables. You can manually load data using the import functionality available in SQL Workshop. In the following exercise, you will use SQL Workshop to load demonstration data.
Look at the DDL you copied from "Create Application Database Objects DDL". Notice that the sequences used for the primary keys start at 40 in order to leave room for the demonstration data. Because the before insert triggers are coded so that the sequence is only accessed if a primary key value is not provided, they will not needed to be disabled in order for you to load data.
Topics in this section include:
To import data into the Projects table:
Select the SQL Workshop tab.
Click SQL Scripts.
Click Create.
In the Script Editor:
For Script Name, enter Load Project Data
.
In Script, copy and paste the following:
INSERT INTO ht_projects (project_id, project_name, start_date, target_end_date) values (1, 'Internal Infrastructure', sysdate-150, sysdate-30) / INSERT INTO ht_projects (project_id, project_name, start_date, target_end_date) values (2, 'New Payroll Rollout', sysdate-150, sysdate+15) / INSERT INTO ht_projects (project_id, project_name, start_date, target_end_date) values (3, 'Email Integration', sysdate-120, sysdate-60) / INSERT INTO ht_projects (project_id, project_name, start_date, target_end_date) values (4, 'Public Website Operational', sysdate-60, sysdate+30) / insert into ht_projects (project_id, project_name, start_date, target_end_date) values (5, 'Employee Satisfaction Survey', sysdate-30, sysdate+60) /
Click Save.
On the SQL Scripts page, select the Load Project Data icon.
Click Run.
A summary page appears.
Click Run again.
Although you have created the Projects, the dates need to be updated to make the projects current. To accomplish this, you run another script.
To update the project dates and make the projects current:
Select the SQL Workshop tab.
Click SQL Scripts.
Click Create.
In the Script Editor:
For Script Name, enter Update Project Dates
.
In Script, copy and paste the following:
UPDATE ht_projects SET start_date = sysdate-150, target_end_date = sysdate-30 WHERE project_id = 1 / UPDATE ht_projects SET start_date = sysdate-150, target_end_date = sysdate+15 WHERE project_id = 2 / UPDATE ht_projects SET start_date = sysdate-120, target_end_date = sysdate-60 WHERE project_id = 3 / UPDATE ht_projects SET start_date = sysdate-60, target_end_date = sysdate+30 WHERE project_id = 4 / UPDATE ht_projects SET start_date = sysdate-30, target_end_date = sysdate+60 WHERE project_id = 5 /
Click Save.
On the SQL Scripts page, select the Update Project Dates icon.
Click Run.
A summary page appears.
Click Run again.
Once you have loaded data into the Project table, you can load People data. Because of foreign keys in the Projects table, People data must be loaded after Project data. You will load data into the People table by creating and running a script in SQL Workshop.
To load data into the People table:
Select the SQL Workshop tab.
Click SQL Scripts.
Click Create.
In the Script Editor:
For Script Name, enter Load People Data
.
In Script, copy and paste the following:
INSERT INTO ht_people (person_id, person_name, person_email, person_role, assigned_project) VALUES (1, 'Joe Cerno', 'joe.cerno@mrvl-bademail.com', 'CEO', null) / INSERT INTO ht_people (person_id, person_name, person_email, person_role, assigned_project) VALUES (2, 'Kim Roberts', 'kim.roberts@mrvl-bademail.com', 'Manager', null) / INSERT INTO ht_people (person_id, person_name, person_email, person_role, assigned_project) VALUES (3, 'Tom Suess', 'tom.suess@mrvl-bademail.com', 'Manager', null) / INSERT INTO ht_people (person_id, person_name, person_email, person_role, assigned_project) VALUES (4, 'Al Bines', 'al.bines@mrvl-bademail.com', 'Lead', 1) / INSERT INTO ht_people (person_id, person_name, person_email, person_role, assigned_project) VALUES (5, 'Carla Downing', 'carla.downing@mrvl-bademail.com', 'Lead', 2) / INSERT INTO ht_people (person_id, person_name, person_email, person_role, assigned_project) VALUES (6, 'Evan Fanner', 'evan.fanner@mrvl-bademail.com', 'Lead', 3) / INSERT INTO ht_people (person_id, person_name, person_email, person_role, assigned_project) values (7, 'George Hurst', 'george.hurst@mrvl-bademail.com', 'Lead', 4) / INSERT INTO ht_people (person_id, person_name, person_email, person_role, assigned_project) VALUES (8, 'Irene Jones', 'irene.jones@mrvl-bademail.com', 'Lead', 5) / INSERT INTO ht_people (person_id, person_name, person_email, person_role, assigned_project) VALUES (9, 'Karen London', 'karen.london@mrvl-bademail.com', 'Member', 1) / INSERT INTO ht_people (person_id, person_name, person_email, person_role, assigned_project) values (10, 'Mark Nile', 'mark.nile@mrvl-bademail.com', 'Member', 1) / INSERT INTO ht_people (person_id, person_name, person_email, person_role, assigned_project) VALUES (11, 'Jane Kerry', 'jane.kerry@mrvl-bademail.com', 'Member', 5) / INSERT INTO ht_people (person_id, person_name, person_email, person_role, assigned_project) VALUES (12, 'Olive Pope', 'olive.pope@mrvl-bademail.com', 'Member', 2) / INSERT INTO ht_people (person_id, person_name, person_email, person_role, assigned_project) VALUES (13, 'Russ Sanders', 'russ.sanders@mrvl-bademail.com', 'Member', 3) / INSERT INTO ht_people (person_id, person_name, person_email, person_role, assigned_project) VALUES (14, 'Tucker Uberton', 'tucker.uberton@mrvl-bademail.com', 'Member', 3) / INSERT INTO ht_people (person_id, person_name, person_email, person_role, assigned_project) VALUES (15, 'Vicky Williams', 'vicky.willaims@mrvl-bademail.com', 'Member', 4) / INSERT INTO ht_people (person_id, person_name, person_email, person_role, assigned_project) VALUES (16, 'Scott Tiger', 'scott.tiger@mrvl-bademail.com', 'Member', 4) / INSERT INTO ht_people (person_id, person_name, person_email, person_role, assigned_project) VALUES (17, 'Yvonne Zeiring', 'yvonee.zeiring@mrvl-bademail.com', 'Member', 4) /
Click Save.
On the SQL Scripts page, select the Load People Data icon.
Click Run.
A summary page appears.
Click Run again.
The last data you need to load is the Issues data. As with People data, you will create and run a script to populate the Issues
table.
To load data into the Issues
table:
Select the SQL Workshop tab.
Click SQL Scripts.
Click Create.
In the Script Editor:
For Script Name, enter Load Issue Data
.
In Script, copy and paste the script in "Create Issues Script".
Click Save.
On the SQL Scripts page, select the Load Issue Data icon.
Click Run.
A summary page appears.
Click Run again.
Once you have created the objects that support your application and have loaded the demonstration data, the next step is to create a user interface. In this exercise, you use the Create Application Wizard in Application Builder to create an application and then the pages that support the data management and data presentation functions described in "Planning and Project Analysis".
Topics in this section include:
You can use the Create Application Wizard to create an application that contains pages that enables users to view a report on and create data for selected tables within a schema. Alternatively, you can create an application first and then add pages to it. Since the application requirements include customized overview pages, for this exercise you will use latter approach.
To create the application manually:
Navigate to the Workspace home page.
Click the Application Builder icon.
Click Create.
For Method, select Create Application.
For Name:
In Name, enter a Issue Tracker
.
For Create Application, select From scratch.
Click Next.
Add a blank page:
Under Select Page Type, select Blank.
Click Add Page.
Click Next.
For Tabs, select No Tabs and click Next.
For Shared Components, accept the defaults and click Next.
For Attributes, accept the defaults for Authentication Scheme, Language, and User Language Preferences Derived From and click Next.
For User Interface, select Theme 10 and click Next.
Click Create.
To view the application:
Click the Run Application icon on the Applications home page.
When prompted, enter your workspace username and password and click Login.
This authentication is part of the default security of any newly created application. As shown in Figure 10-1, the home page appears.
Although the page has no content, notice that the Create Application Wizard created the following items:
Navigation Links - A navigation bar entry displays in the upper right of the page. Logout enables the user to log out of the application.
Developer Links - The Developer Toolbar appears at the bottom of the page. These links only display if you are logged in as a developer. Regular users, those who only have access to run the application, will not see these links. From left to right, the Developer Toolbar contains the following links:
Edit Application - Edit the application by linking to the Application Builder home page.
Edit Page 1 - Edit the current running page. This link takes you to Page Definition for the current page.
Create - Add a new component to the current page.
Session - Open a new page containing session details for the current page.
Debug - Display the current page in debug mode.
Show Edit Links - Displays edit links next to each object on the page that can be edited. Each edit link resembles two colons (::
) and appears to the right of navigation bar items, tabs, region titles, buttons, and items. Clicking a edit link displays another window in which to edit the object.
Click Edit Application on the Developer Toolbar to return to Application Builder home page. Notice that the Create Application Wizard also created a Login page.
Once you have created the basic application structure, the next step is to create individual pages.
First, you need to create pages that enable users to view and add data to tables. To accomplish this, you will use the Form on a Table with Report Wizard. This wizard creates a report page and maintenance page for each table the start with HT_PROJECTS
.
Topics in this section include:
To create pages for maintaining HT_PROJECTS
table:
On the Application Builder home page, click Create Page.
Select Form and click Next.
Select Form on a Table with Report and click Next.
For Table/View Owner, select the appropriate schema and click Next.
For Table/View Name, select HT_PROJECTS
and click Next.
For Define Reports Page:
For Page, enter 2
.
For Page Name and Region Title, enter Projects
.
Click Next.
For Tab Options, accept the default selection Do not use tabs and click Next.
For Select Column(s), select every column except PROJECT_ID
and click Next.
Note that Project Name is unique and identifies the project. The ID was added to simplify the foreign key and enable cascading updates.
For Edit Link Image, select the third option (the word Edit in blue with a white background) and click Next.
For Define Form Page:
For Page, enter 3
.
For Page Name and Region Title, enter Create/Edit Project
.
Click Next.
For Tab Options, accept the default Do not use tabs and click Next.
For Primary Key, accept the default PROJECT_ID
and click Next.
For Source Type, accept the default Existing Trigger
and click Next.
For Select Column(s), selected all columns and click Next.
Under Identify Process Options, accept the defaults for Insert, Update and Delete, and click Next.
Review your selections and click Finish.
To preview your page, click Run Page. As shown in Figure 10-0, the newly created report displays the demo data.
Click the Edit icon to view an existing row or click the Create button to create a new record. If you click the Edit icon to the left of Employee Satisfaction Survey, a form resembling Figure 10-3 appears.
You can change the appearance of the Projects report page by adding a format mask to the dates.
To add a format mask to the dates on the Create/Edit Project page:
Navigate to the Page Definition for page 2, Projects. Select Edit Page 2 from the Developer Toolbar.
Under Regions, select Report adjacent to Projects.
Edit the format for the START_DATE:
Click the Edit icon the left of START_DATE
.
The Column Attributes page appears.
For Number/Date Format, enter DD-MON-YYYY.
Edit the format for the TARGET_END_DATE:
Click the Next button (>) at the top of the page to navigate to the next Report Item.
The Column Attributes page appears.
For Number/Date Format, enter DD-MON-YYYY.
Edit the format for the ACTUAL_END_DATE:
Click the Next button (>) at the top of the page to navigate to the next Report Item.
The Column Attributes page appears.
For Number/Date Format, enter DD-MON-YYYY.
Click Apply Changes.
The Report Attributes page appears.
For PROJECT_ID, delete the Heading Edit.
For the START_DATE, TARGET_END_DATE and ACTUAL_END_DATE columns, select center for Column Alignment and Heading Alignment.
To enable column heading sorting, check Sort for all columns except PROJECT_ID.
For PROJECT_NAME, select 1 for Sort Sequence.
This selection specifies PROJECT_NAME as the default column to sort on. Note this functionality can overridden by any user selections.
Scroll down to Sorting. For Ascending and Descending Image, select the light gray arrow.
Under Messages, enter the following in When No Data Found Message:
No Projects found.
Click Apply Changes.
To view your changes, click the Run icon in the upper right of the page. As shown in Figure 10-4, note the addition of a sort control on the Project Name column and the format of the dates in the Start Date and Target End Date columns.
Next, you will customize the Create/Edit Project page to make the Project Name field larger, the date fields smaller, change the date picker type and add a format mask for dates, and add validations that check if the target and actual end dates are after the start date.
To make the Project Name field larger and the date fields smaller:
Navigate to the Page Definition for Page 3, Create/Edit Project.
From the Developer toolbar, select Edit Application.
Select Create/Edit Project.
Under Items, select the heading Items.
Scroll to the right and locate the Width column:
For Project Name, enter 60
.
For Start Date, enter 12
.
For Target End Date, enter 12
.
For Actual End Date, enter 12
.
Click Apply Changes.
Click the Edit Page icon in the upper right corner of the page to return to the Page Definition.
To change the date picker type and add a format mask for dates:
Edit the item P3_START_DATE.
Under Items, select P3_START_DATE.
Under Identification, for Display As select Date Picker (DD-MON-YYYY).
Click Apply Changes.
Edit the item P3_TARGET_END_DATE.
Under Items, select P3_TARGET_END_DATE.
Under Identification, for Display As select Date Picker (DD-MON-YYYY).
Click Apply Changes.
Edit the item P3_ACTUAL_END_DATE.
Under Items, select P3_ACTUAL_END_DATE.
Under Identification, for Display As select Date Picker (DD-MON-YYYY).
Click Apply Changes.
To add validations to check if the target and actual end dates are after the start date:
Under the Validations section, click the Create icon.
For Identify the validation level, accept the default Item level validation and click Next.
For Item, select Create/Edit Project: 40. P3_TARGET_END_DATE (Target End Date) and click Next.
For Select a validation method, select PL/SQL and click Next.
Specify the type of validation you want to create. Accept the default PL/SQL Expression and click Next.
For Validation Name, enter TARGET_AFTER_START
and click Next.
On Identify Validation and Error Message:
For Validation, enter:
to_date(:P3_ACTUAL_END_DATE,'DD-MON-YYYY') >= to_date(:P3_START_DATE,'DD-MON-YYYY')
For Error Message, enter:
Actual End Date must be same or after Start Date.
Click Next.
For Conditions:
For Condition Type, select the shortcut link [item not null].
Selecting this shortcut link selects Value of Item in Expression 1 is NOT NULL from the Condition Type list.
For Expression 1, enter:
P3_ACTUAL_END_DATE.
This selection ensures that this validation will only execute if the user enters an Actual End Date.
Click Create.
To view your changes, click the Run Page icon in the upper right of the page. (See Figure 10-5.)
Once the initial Projects pages are complete, you create pages for maintaining people.
Topics in this section include:
To create pages for maintaining the HT_PEOPLE
table:
Return to the Application home page.
Click Create Page.
Select Form and click Next.
Select Form on a Table with Report and click Next.
For Table/View Owner, select the appropriate schema and click Next.
For Table/View Name, select HT_PEOPLE and click Next.
For Define Report Attributes:
For Page, enter 4
.
For Page Name and Region Title, enter People
.
Click Next.
For Tab Options, accept the default Do not use tabs and click Next.
For Select Column(s), select all columns except PERSON_ID
and click Next.
For Edit Link Image, select the third option (the word Edit in blue with a white background) and click Next.
For Define Form Page:
For Page, enter 5
.
For Page Name and Region Title, enter Create/Edit Person. Information
.
Click Next.
For Tab Options, accept the default Do not use tabs and click Next.
For Primary Key, accept the default PERSON_ID and click Next.
Specify the source for the primary key columns. Accept the default Existing Trigger and click Next.
For Select Column(s), select all the columns and click Next.
For Insert, Update and Delete, accept the defaults and click Next.
Review your selections and click Finish.
To preview your page, select Run Page. As shown in Figure 10-6, notice the newly created report displays the demo data.
To preview the page for adding or editing people, click the Edit button in the far left column.
Next, you will alter the People Report by changing the query to include a join to the Projects table and modify the headings.
To change the query to include a join to the Projects table:
Navigate to the Page Definition for page 4, People.
Under Regions, select People.
Scroll down to Source.
In Region Source, enter:
SELECT a."PERSON_ID", a."PERSON_NAME", a."PERSON_EMAIL", a."PERSON_ROLE", b."PROJECT_NAME" FROM "#OWNER#"."HT_PEOPLE" a, "#OWNER#"."HT_PROJECTS" b WHERE a.assigned_project = b.project_id (+)
Note that the outer join is necessary because the project assignment is optional.
Select the Report Attributes tab.
For PERSON_ID, remove the Heading Edit.
For PERSON_NAME, change Heading to Name
.
For PERSON_EMAIL, change Heading to Email
.
For PERSON_ROLE, change Heading to Role
.
For PROJECT_NAME, change Heading to Assigned Project
and select left for Heading Align.
Enable column heading sorting by selecting Sort for all columns except PERSON_ID.
For PERSON_NAME, select 1 for Sort Sequence.
This selection specifies PERSON_NAME as the default column to sort on. Note this functionality can overridden by user selections.
Scroll down to Sorting. For Ascending and Descending Image, select the light gray arrow.
Under Messages, enter the following in When No Data Found Message:
No people found.
Click Apply Changes.
To view your changes, click the Run Page icon in the upper right of the page. As shown in Figure 10-7, note the addition of a sort control on the Name column.
Next, you will customize the Create/Edit People page by adding lists of values to make it easier for users to select a Role or Assigned Project.
To add a list of values for Projects:
Navigate to the Page Definition for page 5, Create/Edit Person.
Under Shared Components, locate the Lists of Values section and click the Create icon.
For Create List of Values, accept the default From Scratch and click Next.
For Name and Type:
For Name, enter PROJECTS
.
For Type:, select Dynamic.
Click Next.
In Query, enter:
SELECT project_name d, project_id v FROM ht_projects ORDER BY d
Click Create List of Values.
To add a list of values for Roles:
Under Shared Components, locate the Lists of Values section and click the Create icon.
For Create List of Values, accept the default From Scratch and click Next.
For Name and Type:
For Name, enter ROLES
.
For Type:, select Static
Click Next.
Enter the display value and return value pairs shown in Table 10-4:
Click Create List of Values.
Return to the Page Definition for Page 5. Click the Edit Page icon in the upper right corner.
To edit display attributes for P5_PERSON_ROLE:
Under Items, select P5_PERSON_ROLE.
Under Name, select Radiogroup from the Display As list.
Scroll down to Label.
Edit Label to be Role
.
Under Element, enter the following in Form Element Option Attribute:
class="instructiontext"
This specifies that the text associated with each radio group option is the same size as other items on the page.
Scroll down to List of Values.
From the Named LOV list, select ROLES.
Click Apply Changes.
To edit display attributes for P5_ASSIGNED_PROJECT:
Under Items, select P5_ASSIGNED_PROJECT.
Under Name, select Select List from the Display As list.
Scroll down to List of Values.
Under List of Values:
From the Named LOV list, select PROJECTS.
Next, specify that the underlying column is not mandatory.
For Null display value, enter:
- None -
Click Apply Changes.
To alter the display of fields and field labels:
Click the heading Items.
For P5_PERSON_NAME:
For Prompt, enter Name
.
For Width, enter 60
.
For P5_PERSON_EMAIL:
For Prompt, enter Email Address
.
For Width, enter 60
.
Click Apply Changes.
Click the Edit Page icon in the upper right corner to return to the Page Definition for Page 5.
The wizard created not null validations for Name, Email and Role. You must manually create another validation to ensure that Leads and Members have an assigned project while the CEO and Managers do not. As a best practice, it is generally best to use built-in validation types since they are faster. However, for this compound type of validation, you will write a PL/SQL validation.
To add validations to ensure the correct people are assigned projects:
Under the Validations section, click the Create icon.
On Identify Validation Type, accept the default Item level validation and click Next.
For Item, select Create/Edit Person Information: 50. P5_ASSIGNED_PROJECT (Assigned Project) and click Next.
For Validation Method, select PL/SQL and click Next.
Specify the type of PL/SQL validation you want to create. Accept the default PL/SQL Expression and click Next.
For Validation Name, enter PROJECT_MAND_FOR_LEADER_AND_MEMBER
and click Next.
On Identify Validation and Error Message:
For Validation, enter:
(:P5_PERSON_ROLE IN ('CEO','Manager') AND :P5_ASSIGNED_PROJECT = '%'||'null%') OR (:P5_PERSON_ROLE IN ('Lead','Member') AND :P5_ASSIGNED_PROJECT != '%'||'null%')
Oracle HTML DB passes nulls as %null%
. It also replaces %null%
with a null when it processes data so to keep it in the validation, you need to break the string apart so that it is not recognized and replaced.
For Error Message, enter:
Leads and Members must have an Assigned Project. CEO and Managers cannot have an Assigned Project.
Click Next.
Click Create.
To view your changes, click the Run Page icon in the upper right of the page. (See Figure 10-8.)
Figure 10-8 Revised Create/Edit Person Information Form
Try entering some records to test the validation. Try to enter a CEO with a project and then try to enter a Lead without a project. Both cases will fail and display the error message you defined.
Lastly, you need to create pages for HT_ISSUES
. This application needs multiple views on Issues. You can create these views as one, more complex reports or as separate reports. For this exercise you will be creating the complex report. This report will have an Issues maintenance form. You will then link this maintenance form in multiple places. Ultimately, the Issues report will display Issues by the person who identified the issue, project, assigned person, status, or priority.
Topics in this section include:
To create a report for maintaining HT_ISSUES
:
Return to the Application home page.
Click Create Page.
Select Form and click Next.
Select Form on a Table with Report and click Next.
For Table/View Owner, select the appropriate schema and click Next.
For Table/View Name, select HT_ISSUES and click Next.
For Page and Region Attributes:
For Page, enter 6
.
For Page Name and Region Title, enter Issues
.
Click Next.
For Tab Options, accept the default Do not use tabs and click Next.
For Select Column(s), select the following and click Next:
ISSUE_SUMMARY
IDENTIFIED_BY
RELATED_PROJECT
ASSIGNED_TO
STATUS
PRIORITY
TARGET_RESOLUTION_DATE
ACTUAL_RESOLUTION_DATE
For Edit Link Image, select the third option (the word Edit in blue with a white background) and click Next.
For Define Form Page:
For Page, enter 7
.
For Page Name and Region Title, enter Create/Edit Issues
.
Click Next.
For Tab Options, accept the default Do not use tabs and click Next.
For Primary Key, accept the default ISSUE_ID and click Next.
For Select Column(s), select all the columns and click Next.
For Insert, Update and Delete, accept the default value Yes and click Next.
Review your selections and click Finish.
When you refine the Create/Edit Page you will:
Add lists of values to make it easier for users to select foreign key columns
Organize and clean up items
Change the display of audit columns
Add a button to make data entry faster
Next, you need to add lists of values for Status, Priorities, and People.
To add a list of values for Status:
Navigate to the Page Definition for page 7.
Under the Lists of Values section and click the Create icon.
For Create List of Values, accept the default From Scratch and click Next.
On Create List of Values (LOV):
For Name, enter STATUS
.
For Type, select Static.
Click Next.
Enter the Display Value and Return Value pairs shown in Table 10-5:
Click Create List of Values.
To add a list of values for Priorities:
Return to the Page Definition for Page 7. Click the Edit Page icon in the upper right corner.
Under the Lists of Values section and click the Create icon.
For Create List of Values, accept the default From Scratch and click Next.
On Create List of Values (LOV):
For Name, enter PRIORITIES
.
For Type, select Static and click Next.
Enter the Display Value and Return Value pairs shown in Table 10-6.
Click Create List of Values.
To add a list of values for People:
Return to the Page Definition for Page 7. Click the Edit Page icon in the upper right corner.
Under the Lists of Values section and click the Create icon.
For Create List of Values, accept the default From Scratch and click Next.
On Create List of Values (LOV):
For Name, enter PEOPLE
.
For Type, select Dynamic and click Next.
In Query enter:
SELECT person_name d, person_id v FROM ht_people ORDER BY 1
Click Created List of Values.
Next, you edit individual items.
To edit P7_IDENTIFIED_BY:
Return to the Page Definition for Page 7. Click the Edit Page icon in the upper right corner.
Under Items, select P7_IDENTIFIED_BY.
Under Name, select Select List from the Display As list.
Scroll down to List of Values:
For Named LOV, select PEOPLE.
For Display Null, select Yes. The base column is mandatory but you do not want the first name in the list becoming the default value.
For Null display value, enter:
- Select Person -
Click the Next button (>) at the top of the page to navigate to the next item.
To edit P7_IDENTIFIED_DATE:
Navigate to P7_IDENTIFIED_DATE.
Under Name, for select Date Picker (DD-MON-YYYY) from the Display As list.
Scroll down to Default:
For Default Value, enter:
to_char(sysdate,'DD-MON-YYYY')
For Default Value Type, select PL/SQL Expression.
Click the Next button (>) at the top of the page to navigate to the next item.
To edit P7_RELATED_PROJECT:
Navigate to P7_RELATED_PROJECT.
Under Identification, for select Select List from the Display As list.
Scroll down to List of Values:
For Named LOV, select PEOPLE.
For Display Null, select Yes.
For Null display value, enter:
- Select Person -
Click the Next button (>) at the top of the page to navigate to P7_STATUS.
To edit P7_STATUS:
Navigate to P7_STATUS.
Under Identification, for select Radiogroup from the Display As list.
In Label, enter:
Status:
Scroll down to Element. Enter the following in the Form Element Option Attributes:
class="instructiontext"
Scroll down to Default. In Default Value, enter Open
.
Scroll down to List of Values:
For Named LOV, select STATUS.
For Columns, enter 3.
This selection enables the three valid values to display side by side.
Click the Next button (>) at the top of the page to navigate to P7_PRIORITY.
To edit P7_PRIORITY:
Navigate to P7_PRIORITY.
Under Name, for select Radiogroup from the Display As list.
In Label, enter:
Priority:
Scroll down to Element. Enter the following in the Form Element Option Attributes:
class="instructiontext"
Scroll down to Default. In Default value, enter Open
.
Scroll down to List of Values:
For Named LOV, select PRIORITIES.
For Display Null, select Yes.
For Columns, enter 4.
This selection reflects that fact there are three valid values plus the null value.
For Null display value, enter None
.
Click the Next button (>) at the top of the page to navigate to the next item.
To edit P7_TARGET_RESOLUTION_DATE:
Navigate to P7_TARGET_RESOLUTION_DATE.
Under Name, for select Date Picker (DD-MON-YYYY) from the Display As list.
Click the Next button (>) at the top of the page to navigate to P7_ACTUAL_RESOLUTION_DATE.
To edit P7_ACTUAL_RESOLUTION_DATE:
Navigate to P7_ACTUAL_RESOLUTION_DATE.
Under Name, for select Date Picker (DD-MON-YYYY) from the Display As list.
Click Apply Changes.
Currently all items are grouped into one large region. Displaying items in logical groups will make data entry easier for users. Next, you will create four new regions named Buttons, Identification, Progress, Resolution, and Auditing.
To create new regions to group items:
Under Regions, click the Create icon.
Select Multiple HTML.
For the first row:
For Sequence, enter 5
.
For Title, enter Buttons
.
For Template, select Button Region without Title.
For the second row, in Title enter Progress
.
For the third row, in Title enter Resolution
.
For the fourth row, in Title enter Audit Information
.
Click Create Region(s).
Now that the new regions exist, rename the first region, Create/Edit Issues:
Under Regions, select Create/Edit Issue.
In Title, enter:.
Issue Identification
Click Apply Changes.
Next, move each item to the appropriate region. Note that you will also need to modify some item widths.
To move items to the appropriate regions:
Under Items, select the Items heading.
Under Region, select Progress for the following items:
P7_ASSIGNED_TO
P7_STATUS
P7_PRIORITY
P7_TARGET_RESOLUTION_DATE
P7_PROGRESS
Under Region, select Resolution for the following items:
P7_ACTUAL_RESOLUTION_DATE
P7_RESOLUTION_SUMMARY
Under Region, select Audit Information for the following items:
P7_CREATED_DATE
P7_CREATED_BY
P7_LAST_MODIFIED_DATE
P7_LAST_MODIFIED_BY
For P7_ISSUE_SUMMARY, enter 60
for Width.
For P7_IDENTIFIED_DATE, enter 12
for Width.
For P7_TARGET_RESOLUTION_DATE, enter 12
for Width.
For P7_ACTUAL_RESOLUTION_DATE, enter 12
for Width.
Click Apply Changes.
Click the Edit Page icon in the upper right to return the Page Definition of Page 7.
To move buttons to the Button region:
Return to the Page Definition for Page 7.
Under the Buttons section, click the Buttons heading.
Under Region for all buttons, select Buttons.
Click Apply Changes.
Click the Edit Page icon in the upper right to return the Page Definition of Page 7.
Because the Audit columns should be viewable but not editable, you need to make them display only. In the following exercise, you create a condition for the Audit Information region. As a result, the Audit Information region will display when a user edits an existing issue, but will not appear when a user creates a new issue.
To create a condition for the Audit Information region.
On the Page Definition of Page 7, select the Audit Information region.
Scroll down to Conditional Display.
From Condition Type, select Value of Item in Expression 1 is NOT NULL.
In Expression 1, enter P7_ISSUE_ID
.
Click Apply Changes.
Next, change the audit columns to display only.
To edit P7_CREATED_DATE:
Under Items, select P7_CREATED_DATE.
Under Name, select Display as Text (saves state) from the Display As list.
Scroll down to Label:
For Label, enter:
Created Date:
For Template, select Optional Label with Help.
For HTML Table Cell Attributes, enter:
class="instructiontext"
Under Source, enter the following in Format Mask:
DD-MON-YYYY
Click the Next button (>) at the top of the page to navigate to the next item.
To edit P7_CREATED_BY:
Under Name, select Display as Text (saves state) from the Display As list.
Scroll down to Label:
For Label, enter:
Created By:
For Template, select Optional Label with Help.
For HTML Table Cell Attributes, enter:
class="instructiontext"
Click the Next button (>) at the top of the page to navigate to the next item.
To edit P7_LAST_MODIFIED_DATE:
Under Name, select Display as Text (saves state) from the Display As list.
Scroll down to Label:
For Label, enter:
Last Modified Date:
For Template, select Optional Label with Help.
For HTML Table Cell Attributes, enter:
class="instructiontext"
Under Source, for Format Mask, enter:
DD-MON-YYYY
Click the Next button (>) at the top of the page to navigate to the next item.
To edit P7_LAST_MODIFIED_BY:
Under Name, select Display as Text (saves state) from the Display As list.
Scroll down to Label:
For Label, enter:
Last Modified By:
For Template, select Optional Label with Help.
For HTML Table Cell Attributes, enter:
class="instructiontext"
Click Apply Changes.
The wizard created not null validations for Issue Summary, Identified By, Related Project, Status, Created Date, and Created By. Since the Audit columns are set by a trigger, you need to remove these validations.
To remove not null validations:
Under Validations, select P7_CREATED_DATE not null.
Click Delete.
Click OK to confirm your selection.
Under Validations, select P7_CREATED_BY not null.
Click Delete.
Click OK to confirm your selection.
Because this Create/Edit page will be called from several places, when users finish with the display they should return to the calling page. To accomplish this, you create an item and change the branch on this page. Every time this page is called, the item must be set with the number of the calling page.
To create a hidden item:
Under Items, click the Create icon.
For Select Item Type, select Hidden and click Next.
For Display Position and Name:
For Item Name, enter:
P7_PREV_PAGE
For Region, select Issue Identification.
Click Next.
Click Create Item.
Next, edit the Cancel button.
Under Buttons, select Cancel.
Scroll down to Optional URL Redirect.
In Page, enter:
&P7_PREV_PAGE.
Note the period at the end.
Click Apply Changes.
Next, edit the branch.
Under Action, enter the following in Page:
&P7_PREV_PAGE.
Click Apply Changes.
Next, you will add functionality that will enable users to add more than one issue at time. To accomplish this, you will first add a new button and then a new branch.
To add a new button:
Under the Buttons section, click the Copy icon.
Under Name, select CREATE.
For Target Page, accept the default 7 and click Next.
For Button Name, enter CREATE_AGAIN
.
For Label, enter Create and Create Another
.
Click Copy Button.
Functionally, the Copy Button currently works the same as the CREATE button. Next, create a branch that keeps the user on the create page.
Note that this branch will also reset P7_PREV_PAGE because the value of that item will be lost when the cache of the page is cleared. The sequence of this new branch will be 0. That will make it fire before the default branch but only when the Create and Create Another button is used.
To create a branch that keeps the user on the create page:
Under Branches, click the Create icon.
For Point and Type, accept the defaults and click Next.
For Target:
For Page, enter 7
.
For Clear Cache, enter 7
.
For Set these items, enter:
P7_PREV_PAGE
For With these values, enter:
&P7_PREV_PAGE.
Click Next.
For Branch Conditions:
For Sequence, enter 0.
For When Button Pressed, select CREATE_AGAIN.
Click Create Branch.
Under Branches, select the newly created branch.
Under Branch Action, select include process success message.
Click Apply Changes.
To see the changes, click the Run Page icon. (See Figure 10-9.)
The branch you just created is looking for a value in P7_PREV_PAGE. Since the page was not called from another page, the value has not been set. You will fix that next.
Next, you will refine the Issues report page to support dynamic modification of the query. To accomplish this, you must:
Move the Create button to a new region and edit the label
Create new items that will enable the user to restrict the query
Add a WHERE
clause to reference those new items
Alter the report column attributes to display each person's name and the project
Modify headings
To create a new region of the Create button:
Navigate to the Page Definition for page 6, Issues.
Under Regions, click the Create icon.
Select HTML and click Next.
Specify the type of HTML region container you want to create. Select HTML and click Next.
For Display Attributes:
For Title, enter Buttons
.
For Region Template, select Button Region without Title.
For Display Point, select Page Template Body (2. items below region content).
Click Next.
Click Create Region.
To move the Create button to the Buttons region:
Under Buttons, select the CREATE button.
In Text Label, enter:
Add a New Issue
From Display in Region, select Buttons.
Scroll down to Optional URL Redirect:
For Set These Items, enter:
P7_PREV_PAGE
For With These Values, enter 6
.
Click Apply Changes.
Next, alter the query to display the actual values for people and projects instead of the ID and then clean up the report display.
To edit column attributes for ISSUE_ID:
Under the Regions section, select Report adjacent to Issues.
Click the Edit Icon to the left of ISSUE_ID.
Scroll down to Column Link.
For Item 2, for Name enter:
P7_PREV_PAGE
For Item 2, for Value enter 6.
Click Apply Changes.
To edit column attributes for IDENTIFIED_BY, RELATED_PROJECT and ASSIGNED_TO:
Click the Edit Icon to the left of IDENTIFIED_BY.
Scroll down to Tabular Form Element. From the Display As list, select Display as Text (based on LOV, does not save state).
Scroll down to List of Values. For Named LOV, select PEOPLE.
Return to the top of the page and click the Next (>) icon.
The Column Attributes page for RELATED_PROJECT appears.
Scroll down to Tabular Form Element. From the Display As list, select Display as Text (based on LOV, does not save state).
Scroll down to List of Values:
For Named LOV, select PROJECTS.
For Display Null, select Yes.
In Null Text, enter a hyphen (-).
Return to the top of the page and click the Next (>) icon.
The Column Attributes page for ASSIGNED_TO appears.
Scroll down to Tabular Form Element. From the Display As list, select Display as Text (based on LOV, does not save state).
Scroll down to List of Values:
For Named LOV, select PEOPLE.
For Display Null, select Yes.
In Null Text, enter a hyphen (-).
Click Apply Changes.
Next, you will customize how the report displays by changing report attributes.
To alter the report display:
For ISSUE_ID, delete the Heading Edit.
For ISSUE_SUMMARY, change Heading to Summary
.
For TARGET_RESOLUTION_DATE:
Force the heading to wrap. In Heading, enter:
Target<br>Resolution<br>Date
For Column Align., select center.
For Heading Align. select center.
For all columns except ISSUE_ID, check Sort.
For ISSUE_SUMMARY, select 1 for Sort Sequence.
Scroll down to Layout and Pagination:
For Show Null Values as, enter a hyphen (-).
For Number of Rows, enter 5
.
Under Sorting, select the light gray arrow for Ascending and Descending Image.
Under Messages, enter the following in When No Data Found Message:
No issues found.
Click Apply Changes.
Although the report now displays nicely, it does not support filtering by the end user. To add this functionality, you will first create items that will enable the user to set values to query against. You will store these new items in a new region which will display above the report.
To create a new region:
Under Regions, click the Create icon.
Select HTML and click Next.
Select the type of HTML region container you want to create. Select HTML and click Next.
For Display Attributes:
For Title, enter Issue Report Parameters
.
For Region Template, select accept the default of Reports Region.
For Sequence, enter 5
.
Click Next.
Click Create Region.
Next, create the items.
To create the item for Identified By:
Under Items, click the Create icon.
For Select Item Type, select Select List and click Next.
For Select List Control Type, accept the default selection Select List and click Next.
On Identify Item Name and Display Position:
For Item Name, enter P6_IDENTIFIED_BY
.
For Region, select Issue Report Parameters.
Click Next.
On Identify List of Values:
For Named LOV, select PEOPLE.
For Null Text, enter:
- All -
For Null Value, enter:
-1
Click Next.
For Item Attributes, accept the defaults and click Next.
For Default, enter:
-1
Click Create Item.
To create an item for Assigned To.
Under Items, click the Create icon.
For Select Item Type, select Select List and click Next.
For Select List Control Type, accept the default selection Select List and click Next.
For Display Position and Name:
For Item Name, enter P6_ASSIGNED_TO
.
For Region, select Issue Report Parameters.
Click Next.
On Identify List of Values:
For Named LOV, select PEOPLE.
For Null Text, enter:
- All -
For Null Value, enter:
-1
Click Next.
For Item Attributes, accept the defaults and click Next.
For Default, enter:
-1
Click Create Item.
To create an item for Status.
Under Items, click the Create icon.
For Select Item Type, select Select List and click Next.
For Select List Control Type, accept the default selection Select List and click Next.
On Identify Item Name and Display Position:
For Item Name, enter P6_STATUS
.
For Region, select Issue Report Parameters.
Click Next.
On Identify List of Values:
For Named LOV, select STATUS.
For Null Text, enter:
- All -
For Null Value, enter:
-1
Click Next.
For Item Attributes, accept the defaults and click Next.
For Default, enter:
-1
Click Create Item.
To create an item for Priority.
Under Items, click the Create icon.
For Select Item Type, select Select List and click Next.
For Select List Control Type, accept the default selection Select List and click Next.
On Identify Item Name and Display Position:
For Item Name, enter P6_PRIORITY
.
For Region, select Issue Report Parameters.
Click Next.
On List of Values:
For Named LOV, select PRIORITIES.
For Null Text, enter:
- All -
For Null Value, enter:
-1
Click Next.
For Identify Item Attributes, accept the defaults and click Next.
For Default, enter:
-1
Click Create Item.
To create an item for Related Project.
Under Items, click the Create icon.
For Select Item Type, select Select List and click Next.
For Select List Control Type, accept the default selection Select List and click Next.
On Identify Item Name and Display Position:
For Item Name, enter P6_RELATED_PROJECT
.
For Region, select Issue Report Parameters.
Click Next.
On Identify List of Values:
For Named LOV, select PRIORITIES.
For Null Text, enter:
- All -
For Null Value, enter:
-1
Click Next.
For Identify Item Attributes, accept the defaults and click Next.
For Default, enter:
-1
Click Create Item.
Next, create a Go button. This button will enable the user to execute the query once they select report parameters. Buttons can be created in region positions or displayed among items. For this exercise, the Go button will display just to the right of the last report parameter so you will create it among the region's items.
To create Go button:
Under Buttons, click the Create icon.
For Select a region for the button, select Issue Report Parameters and click Next.
For Position, select Create a button displayed among this region's items and click Next.
For Button Name, enter P6_GO
.
For Button Style, select Template Based Button.
For Template, select Button.
Click Create Button.
Currently the items display stacked on top of one another. To use space more efficiently, change the position of P6_RELATED_PROJECT, P6_STATUS, and P6_PRIORITY so they display next to each other. Place P6_RELATED_PROJECT, P6_STATUS on the first line and P6_PRIORITY on the second line.
To change the position of 6_RELATED_PROJECT, P6_STATUS, and P6_PRIORITY:
Under the Items section, click the heading Items.
For P6_RELATED_PROJECT, P6_STATUS, and P6_PRIORITY, select No for New Line.
Click Apply Changes.
Click the Edit Page icon in the upper right corner to return to the Page Definition for page 6.
Next, you need to modify the report to react to the parameters. To accomplish this, you need to modify the WHERE
clause of the query. One approach would be add the following WHERE
clause. For example:
WHERE (IDENTIFIED_BY = :P6_IDENTIFIED_BY OR :P6_IDENTIFIED_BY = '-1') AND (RELATED_PROJECT = :P6_RELATED_PROJECT OR :P6_RELATED_PROJECT = '-1') AND (ASSIGNED_TO = :P6_ASSIGNED_TO OR :P6_ASSIGNED_TO = '-1') AND (STATUS = :P6_STATUS OR :P6_STATUS = '-1') AND (PRIORITY = :P6_PRIORITY OR :P6_PRIORITIY = '-1')
Although this is a valid approach, the query will execute faster if you generate it with the WHERE
clause that needs it. To accomplish this, turn the Issues region into a PL/SQL Function Body Returning a SQL Query.
To turn the Issues region into a PL/SQL Function Body Returning a SQL Query:
Under Regions, select Issues.
For Type, select SQL Query (Pl/Sql Function Body Returning Sql Query).
For Region Source, enter the following:
DECLARE q VARCHAR2(32767); -- query w VARCHAR2(4000) ; -- where clause we VARCHAR2(1) := 'N'; -- identifies if where clause exists BEGIN q := 'SELECT "ISSUE_ID", '|| ' "ISSUE_SUMMARY", '|| ' "IDENTIFIED_BY", '|| ' "RELATED_PROJECT", '|| ' "ASSIGNED_TO", '|| ' "STATUS", '|| ' "PRIORITY", '|| ' "TARGET_RESOLUTION_DATE", '|| ' "ACTUAL_RESOLUTION_DATE" '|| ' FROM "#OWNER#"."HT_ISSUES" '; IF :P6_IDENTIFIED_BY != '-1' THEN w := ' IDENTIFIED_BY = :P6_IDENTIFIED_BY '; we := 'Y'; END IF; IF :P6_RELATED_PROJECT != '-1' THEN IF we = 'Y' THEN w := w || ' AND RELATED_PROJECT = :P6_RELATED_PROJECT '; ELSE w := ' RELATED_PROJECT = :P6_RELATED_PROJECT '; we := 'Y'; END IF; END IF; IF :P6_ASSIGNED_TO != '-1' THEN IF we = 'Y' THEN w := w || ' AND ASSIGNED_TO = :P6_ASSIGNED_TO '; ELSE w := ' ASSIGNED_TO = :P6_ASSIGNED_TO '; we := 'Y'; END IF; END IF; IF :P6_STATUS != '-1' THEN IF we = 'Y' THEN w := w || ' AND STATUS = :P6_STATUS '; ELSE w := ' STATUS = :P6_STATUS '; we := 'Y'; END IF; END IF; IF :P6_PRIORITY != '-1' THEN IF we = 'Y' THEN w := w || ' AND PRIORITY = :P6_PRIORITY '; ELSE w := ' PRIORITY = :P6_PRIORITY '; we := 'Y'; END IF; END IF; IF we = 'Y' THEN q := q || ' WHERE '|| w; END IF; RETURN q; END;
Click Apply Changes.
Note that this function first sets the variable q
to the original SELECT
statement. It then builds WHERE
clause (w
) composed of just the variables set by the user. If any variables have been set, it appends the WHERE clause to the original SELECT
and passes that new SELECT to the database.
The report is now complete. Click the Run Page icon. (See Figure 10-10).
To change the report parameters, make new selections under Issue Report Parameters and click Go.
Currently, you can assign an issue by editing it. Next, you will add a new page that will enable users to assign multiple issues at once and modify the Related Project, Status, and Priority.
To add a new page to support assigning multiple issues:
Navigate to the Application home page.
Click Create Page.
Select Form and click Next.
Select Tabular Form and click Next.
For Table/View Owner, select the appropriate schema.
Since the purpose of this form is to enable users to assign issues, it is assumed they will only update existing records, not create or delete issues.
To enforce this assumption, select Update Only from the Allowed Operations list and click Next.
For Table/View Name, select HT_ISSUES and click Next.
For Displayed Columns, select the following columns and click Next:
ISSUE_SUMMARY
IDENTIFIED_BY
IDENTIFIED_DATE
RELATED_PROJECT
ASSIGNED_TO
STATUS
PRIORITY
For Primary Key, accept the default ISSUE_ID and click Next.
For Primary Key Source, accept the default Existing trigger and click Next.
For Updatable Columns, select the following and click Next:
RELATED_PROJECT
ASSIGNED_TO
STATUS
PRIORITY
For Page and Region Attributes:
For Page, enter 8
.
For Page Name, enter Assign Issues
.
For Region Title, enter Assign Issues
.
Click Next.
For Tab Options, accept the default Do not use tabs and click Next.
On Button Labels:
For Cancel Button Label, accept the default.
For Submit Button Label, enter Apply Changes
.
Click Next.
For Branching, accept the defaults and click Next.
Review your selections and click Finish.
Once you have created the initial tabular form, you need to add lists of values to make it easier to select issues. Additionally, you need to restrict the query to only display unassigned issues.
To add lists of values:
From the Success page, select Edit Page.
The Page Definition for page 8, Assign Issues, appears.
Under Regions, select Assign Issues.
In Region Source, enter the following:
SELECT "ISSUE_ID", "ISSUE_SUMMARY", "IDENTIFIED_BY", "IDENTIFIED_DATE", "RELATED_PROJECT", "ASSIGNED_TO", "STATUS", "PRIORITY" FROM "#OWNER#"."HT_ISSUES" WHERE assigned_to IS NULL
To edit report attributes:
Select the Report Attributes tab.
Under Report Column Attributes:
For ISSUE_SUMMARY, edit the existing Heading to read:
Summary
For all columns except ISSUE_ID, select Sort.
For IDENTIFIED_DATE, for Sort Sequence, select 1.
Click the Edit icon to the left of IDENTIFIED_BY and edit the following attributes:
Scroll down to Tabular Form Element. From the Display As list, select Display as Text (based on LOV, does not save state).
Scroll down to List of Values. From Named LOV list, select PEOPLE.
Click the Next button (>) at the top of the page to navigate to the next column.
Edit the following attributes for IDENTIFIED_DATE:
Under Column Formatting, enter DD-MON-YYYY
in Number/Date Format.
Click the Next button (>) at the top of the page to navigate to the next column.
Edit the following attributes for RELATED_PROJECT:
Scroll down to Tabular Form Element. From Display As, select Select List (Named LOV).
Scroll down to List of Values. From the Named LOV list, select PROJECTS.
Click the Next button (>) at the top of the page to navigate to the next column.
Edit the following attributes for ASSIGNED_TO:
Scroll down to Tabular Form Element. From Display As, select Select List (Named LOV).
Scroll down to List of Values:
From the Named LOV list, select PEOPLE.
For Display Null, select Yes.
For Null Text, enter a hyphen (-).
Click the Next button (>) at the top of the page to navigate to the next column.
Edit the following attributes for STATUS:
Scroll down to Tabular Form Element. From Display As, select Select List (Named LOV).
Scroll down to List of Values. From the Named LOV lists, select STATUS.
Click the Next button (>) at the top of the page to navigate to the next column.
Edit the following attributes for PRIORITY:
Scroll down to Tabular Form Element. From Display As, select Select List (Named LOV).
Scroll down to List of Values:
From Named LOV, select PRIORITIES.
For Display Null, select Yes.
For Null Text, enter a hyphen (-).
Click Apply Changes.
The Report Attributes page appears.
Scroll down to Sorting. Under Ascending and Descending Image, select the light gray arrow.
Under Messages, enter the following in When No Data Found Message:
No Unassigned Issues.
Click Apply Changes.
The wizard created an unnecessary Cancel button.
To delete the Cancel button:
On the Page Definition for page 8, select the CANCEL button.
Click Delete.
Click OK to confirm your selection.
The tabular form is now complete. To view the new form, click the Run Page icon. (See Figure 10-11.)
To assign an issue, make a selection from the Assigned To list and click Apply Changes. Notice that once an issue has been assigned, the issue no longer displays.
Lastly, you will add four summary reports.
Topics in this section include:
The Issue Summary report enable users to select a project and then see a summary of issues related to that project. This report includes the following summary information:
Date first issue identified
Date last issue closed
Total number of issues
Number of issues by status
Number of open issues by priority
Assignments by status
To create this report, you will code the information in two SQL statements. The first statement gathers information having a a singular result and the second statement gathers information having multiple results.
To add an Issue Summary by Project report:
Navigate to the Application home page.
Click Create Page.
Select Report and click Next.
Select SQL Report and click Next.
On Page Attributes:
For Page, enter 9
.
For Page Name, enter Issue Summary by Project
.
Click Next.
For Tab Options, accept the default Do not use tabs and click Next.
Enter the following SQL SELECT statement and click Next:
SELECT MIN(identified_date) first_identified, MAX(actual_resolution_date) last_closed, COUNT(issue_id) total_issues, SUM(DECODE(status,'Open',1,0)) open_issues, SUM(DECODE(status,'On-Hold',1,0)) onhold_issues, SUM(DECODE(status,'Closed',1,0)) closed_issues, SUM(DECODE(status, 'Open',decode(priority,null,1,0), 0)) open_no_prior, SUM(DECODE(status, 'Open',decode(priority,'High',1,0), 0)) open_high_prior, SUM(DECODE(status, 'Open',decode(priority,'Medium',1,0), 0)) open_medium_prior, SUM(DECODE(status, 'Open',decode(priority,'Low',1,0), 0)) open_low_prior FROM ht_issues WHERE related_project = :P9_PROJECT
For Report Attributes:
For Region Name, enter Issue Summary by Project
.
Click Next.
Review your selections and click Finish.
Now that you have the first query, you need to edit the headings and create the item to control the related project. First, create a region to display above the report and that will contain the Project parameter.
To create a new region to display above the report:
From the Success page, click Edit Page.
The Page Definition for page 9, Issue Summary by Project appears.
Under Regions, click the Create icon.
Select HTML and click Next.
Select the type of HTML region container you want to create. Select HTML and click Next.
For Display Attributes:
For Title, enter Issue Summary Report Parameters
.
For Display Point, select Page Template Body (2. items below region content).
For Sequence, enter 5
.
Click Next.
Click Create Region.
To create the Project item:
Under Items, click the Create icon.
For Select Item Type, select Select List and click Next.
For Select List Control Type, accept the default Select List and click Next.
On Display Position and Name:
For Item Name, enter P9_PROJECT
.
For Region, select Issue Summary Report Parameters.
Click Next.
On Identify List of Values:
For Named LOV, select PROJECTS.
For Null Text, enter:
- Select -
For Null Value, enter -1
.
Click Next.
On Identify Item Attributes, accept the defaults and click Next.
For Default, enter -1
.
Click Create Item.
To create a Go button to execute the query:
Under Buttons, click the Create icon.
For Button Region, select Issue Summary Report Parameters and click Next.
For Position, select Create a button displayed among this region's items and click Next.
On Button Attributes:
For Button Name, enter P9_GO
.
For Button Style, select Template Based Button.
For Template, select Button.
Click Create Button.
Next, you need to edit the headings and report setting for the report region. You also need to set the report regions to conditionally display when the user has selected a project.
To edit the headings and report settings:
Under Regions, select Report adjacent to Issue Summary by Project.
For Headings Type, select Custom.
Under Report Column Attributes:
Change the Heading for FIRST_IDENTIFIED to:
First Issue Identified:
Change the Heading for LAST_CLOSED to:
Last Issue Closed:
Change the Heading for TOTAL_ISSUES to:
Total Issues:
Change the Heading for OPEN_ISSUES to:
Open Issues:
Change the Heading for ONHOLD_ISSUES to:
On-Hold Issues:
Change the Heading for CLOSED_ISSUES to:
Closed Issues:
Change the Heading for OPEN_NO_PRIOR to:
Open Issues with No Priority:
Change the Heading for OPEN_HIGH_PRIOR:
Open Issues of High Priority:
Change the Heading for OPEN_MEDIUM_PRIOR to:
Open Issues of Medium Priority:
Change the Heading for OPEN_LOW_PRIOR:
Open Issues of Low Priority:
Scroll down to Layout and Pagination:
For Show Null Values as, enter a hyphen (-).
For Pagination Scheme, select - No Pagination Selected -.
Select the Region Definition tab at the top of the page.
Scroll down to Conditional Display.
For Condition Type, select Value of Item in Expression 1 Is NOT Contained within Colon Delimited List in Expression 2.
In Expression 1, enter P9_PROJECT
.
For Expression 2, enter -1
.
Click Apply Changes.
To create a query to retrieve assignments by status.
Under Regions, click the Create icon.
Select Report and click Next.
For Report Implementation, select SQL Report and click Next.
On Display Attributes:
For Title, enter Assignments by Status
.
For Column, select 2.
Click Next.
For Source:
In Enter SQL Query, enter:
SELECT p.person_name, i.status, COUNT(i.issue_id) issues FROM ht_issues i, ht_people p WHERE i.related_project = :P9_PROJECT AND i.assigned_to = p.person_id GROUP BY person_name, status
For Rows Per Page, enter 20
.
For Break Columns, select Column 1.
Click Next.
For Conditional Display:
From Condition Type, select Value of Item in Expression 1 Is NOT Contained within Colon Delimited List in Expression 2.
In Expression 1 enter:
P9_PROJECT
For Expression 2 enter -1
.
Click Create Region.
To edit headings and report settings:
Under Regions, select Report adjacent to Assignments by Status.
For Headings Type, select Custom.
For PERSON_NAME, change Heading to Assigned To
.
Scroll down to Layout and Pagination. From Pagination Scheme, select Row Ranges 1-15 16-30 in select list.
Under Messages, enter the following in When No Data Found Message:
No Issues found.
Click Apply Changes.
To see your newly created report, click the Run Page icon. Note that initially no data displays since no project is selected. Select a project. Your report should resemble Figure 10-12.
The Resolved by Month Identified report is a line chart. This report first calculates the number of days it took to resolve each closed issue, averaged by the month the issue was identified, and finally displayed by the month.
To add a Resolved by Month Identified report:
Navigate to the Application home page.
Click Create Page.
Select Chart and click Next.
Select Line and click Next.
For Page Attributes:
For Page, enter 10
.
For Page Name and Region Name, enter Resolved by Month Identified
.
Click Next.
For Tab (Optional), accept the default Do not use tabs and click Next.
For Query:
For Series Name, enter Resolved .
In SQL, enter:
SELECT NULL l, TO_CHAR(identified_date,'Mon YYYY') month, AVG(actual_resolution_date-identified_date) days FROM ht_issues WHERE status = 'Closed' GROUP BY TO_CHAR(identified_date,'Mon YYYY')
Note that this query has no link (that is, the l column). It extracts the month from the identified date so that the data can be grouped by month. Lastly, it calculates the average number of days it took for the issues to be closed that were identified in that month.
For When No Data Found Message, enter:
No Closed Issues found.
Click Next.
Review your selections and click Finish.
Next, add a correct axis label and turn off the Chart Title and legend.
To edit the chart:
From the Success page, select Edit Page.
The Page Definition for page 10, Resolved by Month Identified, appears.
Under Regions, select Chart adjacent to Resolved by Month Identified.
Under Chart Settings:
For Chart Height, enter 300
.
Disable Show Legend.
Under the Axes Setting section:
For X Axis Title, enter Date Identified
.
For Y Axis Title, enter Days to Resolve
.
Click Apply Changes.
To view your newly created line chart, click the Run Page icon. Your line chart should resemble Figure 10-13.
The Target Resolution Dates report is a calendar which displays issues that have not yet closed and the assigned person on the day that corresponds to the issue target resolution date.
To create a calendar of target resolution dates:
Navigate to the Application home page.
Click Create Page.
Select Calendar and click Next.
Select SQL Calendar and click Next.
For Page Attributes:
For Page, enter 11
.
For Page Name and Region Name, enter Target Resolution Dates
.
Click Next.
For Tab Options, accept the default Do not use tabs and click Next.
For Enter SQL Query, enter the following and click Next:
SELECT I.TARGET_RESOLUTION_DATE, I.ISSUE_SUMMARY || ' ('||nvl(P.PERSON_NAME,'Unassigned') ||') ' disp, I.ISSUE_ID FROM HT_ISSUES I, HT_PEOPLE P WHERE I.ASSIGNED_TO = P.PERSON_ID (+) AND (I.RELATED_PROJECT = :P11_PROJECT OR :P11_PROJECT = '-1') AND I.STATUS != 'Closed'
Note that:
The target_resolution_date
is the date on which the issue will display
The issue_summary
is concatenated with the person assigned
The issue_id
will not display, but will be used to create a link to enable the user to view and edit the issue
On Identify Calendar Columns:
For Date Column, select TARGET_RESOLUTION_DATE.
For Display Column, select DISP.
Click Next.
Review your selections and click Finish.
To enable the user to look up one project or all projects, you need to add an item.
To add an item to support project look up:
From the Success page, select Edit Page.
The Page Definition for page 11, Target Resolution Dates, appears.
Under Items, click the Create icon.
For Select Item Type, select Select List and click Next.
For Select List Control Type, accept the default of Select List and click Next.
For Item Name, enter P11_PROJECT
and click Next.
For List of Values:
For Named LOV, select PROJECTS.
For Null Text, enter:
- All Projects -
For Null Value, enter:
-1
Click Next.
For Item Attributes, accept the defaults and click Next.
For Default, enter:
-1
Click Create Item.
To create a Go button to execute the query:
Under Buttons, click the Create icon.
For Button Region, select Target Resolution Dates and click Next.
For Postilion, select Create a button displayed among this region's items and click Next.
For Button Attributes:
For Button Name, enter P11_GO
.
For Button Style, select Template Based Button.
For Template, select Button.
Click Create Button.
Lastly, you need to modify the Calendar Attributes to add link support for viewing and editing the displayed issues. To accomplish this, you need to call page 7, View/Edit Issues, clear any data from the page and pass in the current issue ID along with the fact that page 11 was the calling page. Then, you need to add a note that displays when the query excludes Closed issues.
To modify the Calendar Attributes:
Under Regions, select CAL to the left of Target Resolution Dates.
Scroll down to Column Link:
For Page, enter 7
.
For Clear Cache, enter 7
.
For Set these items, enter:
P7_ISSUE_ID,P7_PREV_PAGE
For With these values, enter:
#ISSUE_ID#,11
Select the Region Definition tab.
Scroll down to Header and Footer Text.
Enter the following in Region Footer:
This excludes Closed issues.
Click Apply Changes.
To see your newly created calendar, click the Run Page icon. Your report should resemble Figure 10-14. Note that you can click the text displayed for an issue to display the Edit Issue page. To return to the calendar, click Cancel.
The Average Days to Resolve report is a bar chart that calculates the number of days it takes to resolve each closed issue and then averages that number that by assigned person.
To add the Average Days to Resolve report:
Navigate to the Application home page.
Click Create Page.
Select Chart and click Next.
Select Bar (HTML) and click Next.
On Identify Page Attributes:
For Page, enter 12
.
For Page Name, enter Average Days to Resolve
.
For Region Name, enter Average Days to Resolve
.
Click Next.
For Tab (Optional), accept the default Do not use tabs and click Next.
On Identify Chart Attributes:
In Chart SQL, enter:
SELECT NULL l, NVL(p.person_name,'None Assigned') person, AVG(i.actual_resolution_date-i.identified_date) days FROM ht_issues i, ht_people p WHERE i.assigned_to = p.person_id (+) AND i.status = 'Closed' GROUP BY p.person_name
In the above SELECT statement:
The first item selected is the link. Because this report will not link to any other page, NULL
was selected.
The second item is the person's name, or None Assigned
if assigned_to
is NULL
.
The third item selected is the average number of days it took for that person to resolve all their issues so the issues have a status of closed.
For Include in summary, select only Number of data points. Deselect all other options.
Click Next.
Review your selections and click Finish.
To view your newly created bar chart, select Run Page. Your report should resemble Figure 10-15.
Now that you have completed all the detail pages, next you need to add content to the home page and tie all the pages together. In this section, you modify the home page to display the following information:
A menu of all available reports
Navigation to the maintenance pages
A button to Add a New Issue
Overdue Issues
Recently Opened Issues
Open Issues by Project as a chart
Unassigned Issues
Topics in this section include:
First, you add a menu implemented as a list.
To add a menu:
Navigate to the Application home page.
Select Shared Components.
Under Navigation, select Lists.
Click Create.
For Name, enter Main Menu
.
For List Template, select Vertical Sidebar List.
Click Create.
Now that the list has been created, you add list items to it. You need to add one list item for each report page.
To add a list item for Assign Issues:
Click Create List Entry.
For List Entry Label, enter Assign Issues
.
Under Target:
For Page, select 8.
Select reset pagination for this page.
Click Create.
Now you will create four more list items, one for each of the other reports in your application.
To add list items for each of the other reports in your application:
Click Create List Entry.
To define list item attributes for Issues:
For Sequence, enter 20
.
For List Entry Label, enter Issues
.
Under the Target section:
For Page, select 6
.
Select reset pagination for this page.
For Clear Cache, enter 6
.
This clears any selections for page 6 from the session state.
Click Create and Create Another.
To define list item attributes for Issue Summary:
For Sequence, enter 30
.
For List Entry Label, enter Issue Summary by Project
.
Under the Target section:
For Page, select 9.
Select reset pagination for this page.
For Clear Cache, enter 9
.
Click Create and Create Another.
To define list item attributes for Resolved by Month Identified:
For Sequence, enter 40
.
For List Entry Label, enter Resolved by Month Identified (chart)
.
Click Create and Create Another.
To define list item attributes for Target Resolution Dates:
For List, select Main Menu.
For Sequence, enter 50
.
For List Entry Label, enter Target Resolution Dates (calendar)
.
Under the Target section:
For Page, select 11.
Select reset pagination for this page.
Click Create and Create Another.
To define list item attributes for Average Days to Resolve:
For Sequence, enter 60
.
For List Entry Label, enter Average Days to Resolve (chart)
.
Under Target, select 12 for Page.
Click Create.
Now that the list is created, you need to include it on the home page. To display the list in the left margin, you need to change the page template to one that supports the appropriate region position.
To change the page template on the home page:
Click the Edit Page icon.
The Page Definition for page 12, Average Days to Resolve, appears.
In the Page field, enter 1
and click Go.
Click Edit Attributes.
Locate Display Attributes.
From the Page Template list, select No Tabs with Sidebar.
Click Apply Changes.
Next, create a region to contain your menu.
To create a a new region:
Under Regions, click the Create icon.
Select List and click Next.
For Display Attributes:
For Title, enter Menu
.
For Region Template, select No Template.
For Display Point, select Page Template Region Position 2 (or select the quick link [Pos. 2].
Click Next.
For List, select Main Menu.
Click Create List Region.
Next, you will add maintenance navigation as a list. This list will display just below the reports in the left margin.
Navigate to the Application home page.
Click Shared Components.
Under Navigation, select Lists.
Click Create.
For Name, enter Maintenance
.
For List Template, select Vertical Sidebar List.
Click Create.
Next, create three list items. The first list item acts as a separator between the two navigation regions. The other two enable users to view people and projects.
To add list items:
Click Create List Entry.
To define list item attributes for the first list item:
For List Entry Label, enter:
Under Target, select 1 for Page.
Click Create and Create Another.
To define list item attributes for Projects:
For Sequence, enter 20
.
For List Entry Label, enter:
Projects
Under Target:
For Page, select 2.
Check reset pagination for this page.
Click Create and Create Another.
To define list item attributes for People:
For Sequence, enter 30
.
For List Entry Label, enter:
People
Under Target:
For Page, select 4.
Check reset pagination for this page.
Click Create.
To create a region to display the new list.
Click the Edit Page icon.
Under Regions, click the Create icon.
Select List and click Next.
For Display Attributes:
For Title, enter Maintenance
.
For Region Template, select No Template.
For Display Point, select Page Template Region Position 2 (or select the quick link [Pos. 2].
Click Next.
For List, select Maintenance.
Click Create List Region.
Next, you create a button to navigate the user to page 7, Create/Edit Issue.
To create a region to contain the button:
Under Regions, click the Create icon.
Select HTML and click Next.
Select the type of HTML region container you want to create. Select HTML and click Next.
For Display Attributes:
For Title, enter Buttons
.
For Region Template, select No Template.
For Display Point, select Page Template Region Position 1 (or select the quick link [Pos. 1].
Click Next.
Click Create Region.
To add a button:
Under Buttons, click the Create icon.
For Region, select Buttons and click Next.
For Button Position, accept the default Create a button in a region position and click Next.
For Button Attributes:
For Button Name, enter ADD
.
For Label, enter:
Add a New Issue
For Action, select Redirect to URL without submitting page.
Click Next.
For Button Template, select Button and click Next.
For Position, select Top of Region and click Next.
On the Branching page, you need to call the correct page, clear the cache, and specify that the Create and Cancel buttons returns the user to the home page.
On Branching:
For Page, select 7.
For Clear Cache, enter 7
.
For Set these items, enter:
P7_PREV_PAGE
For With these values, enter 1
.
Click Create Button.
Next, add some content to the home page. In this exercise you add a report to display overdue issues. The query for this report retrieves all unclosed issues with a past target resolution date.
To add a report to display overdue issues:
Under Regions, click the Create icon.
Select Report and click Next.
For Report Implementation, select SQL Report and click Next.
For Display Attributes, enter Overdue Issues
for Title and click Next.
For Enter SQL Query, enter:
SELECT i.issue_id, i.priority, i.issue_summary, p.person_name assignee, i.target_resolution_date, r.project_name FROM ht_issues i, ht_people p, ht_projects r WHERE i.assigned_to = p.person_id (+) AND i.related_project = r.project_id AND i.target_resolution_date < sysdate AND i.status != 'Closed'
The outer join is necessary because the assignment is optional.
Click Create Region.
Now that the region has been created, you need to edit the headings and turn the summary into a link to display the issue details.
To edit the column headings:
Under Regions, select Report to the left of Overdue Issues.
For Headings Type, select Custom.
For ISSUE_ID, remove the Heading.
For ISSUE_SUMMARY, edit the Heading to read:
Summary
For ASSIGNEE, change the Heading to:
Assigned To
For TARGET_RESOLUTION_DATE:
For Heading, enter:
Target<br>Resolution<br>Date
For Column Align, select center.
For Heading Align, select center.
For ISSUE_ID, deselest Show.
This enables the query to pass in the link, but not display it.
Select Sort for all columns except ISSUE_ID.
For TARGET_RESOLUTION_DATE, select 1 for Sort Sequence.
For ISSUE_SUMMARY, select 2 for Sort Sequence.
To edit column attributes for ISSUE_SUMMARY:
Click the Edit icon to the left of ISSUE_SUMMARY.
Scroll down to Column Link:
For Link Text, use the quick link of [Icon 3].
For Page, select 7.
For Clear Cache, select 7
.
For Item 1, enter the Name:
P7_ISSUE_ID
For Item 1, enter the Value:
#ISSUE_ID#
For Item 2, enter the Name:
P7_PREV_PAGE
For Item 2, enter the Value:
1
Click Apply Changes.
To select layout and pagination attributes:
Scroll down to Layout and Pagination:
For Pagination Scheme, select Search Engine 1,2,3,4 (set based pagination).
For Number of Rows, enter 5
.
Under Sorting, select the light gray arrow for Ascending and Descending Image.
Under the Messages section, enter the following in When No Data Found Message:
No Overdue Issues.
Click Apply Changes.
The next report you add displays unassigned, open issues. This report is very similar to Overdue Issues. Rather than creating it manually, you will copy the Overdue Issues report and modify it.
To create the Unassigned Issues report by copying an existing report:
Under Regions, click the Copy icon.
Under Name, select Overdue Issues.
For To Page, accept the default 1 and click Next.
For Region Name, enter Unassigned Issues
.
Click Copy Region.
To modify the query and edit the report region:
Under the Regions section, select Unassigned Issues.
For Region Source, enter:
SELECT i.issue_id, i.priority, i.issue_summary, i.target_resolution_date, r.project_name, p.person_name identifiee FROM ht_issues i, ht_people p, ht_projects r WHERE i.assigned_to IS NULL AND i.status != 'Closed' AND i.related_project = r.project_id AND i.identified_by = p.person_id
Select the Report Attributes tab.
Note that previously defined columns have retained their modified attributes.
For IDENTIFIEE, enter the following Heading:
Identified By
Under Messages, enter the following in When No Data Found Message:
No Unassigned Issues.
Click Apply Changes.
Lastly, you will add a report of recently opened issues. The underlying query displays the five most recently opened issues. As in the existing exercise, you will copy an existing report and modify it.
To create a report of recently opened issues by copying an existing report:
Under Regions, click the Copy icon.
Under Name, select Unassigned Issues.
For To Page, accept the default 1 and click Next.
For Region Name, enter Recently Opened Issues
.
Click Copy Region.
To modify the query and edit the report region:
Under Regions, click the Report to the left of Recently Opened Issues.
For all columns:
Disable sorting by deselecting Sort.
Set Sequence to -.
Select the Region Definition tab.
For Region Source, enter:
SELECT issue_id, priority, issue_summary, assignee, target_resolution_date, project_name, identifiee FROM ( SELECT i.issue_id, i.priority, i.issue_summary, p.person_name assignee, i.target_resolution_date, r.project_name, p2.person_name identifiee FROM ht_issues i, ht_people p, ht_people p2, ht_projects r WHERE i.assigned_to = p.person_id (+) AND i.related_project = r.project_id AND i.identified_by = p2.person_id AND i.created_date > (sysdate - 7) ORDER BY i.created_date desc ) WHERE rownum < 6
Select the Report Attributes tab.
For ASSIGNEE, click the gray up arrow to the right of the Edit column until ASSIGNEE is just after ISSUE_SUMMARY.
For ASSIGNEE, change Heading to:
Assigned To
Scroll down to Layout and Pagination section. From the Pagination Scheme list, select - No Pagination Selected -.
Under the Messages section, enter the following in When No Data Found Message:
No Recently Opened Issues.
Click Apply Changes.
Next, add a pie chart displaying Open Issues by Project.
To add a pie chart:
Under Regions, click the Create icon.
Select Chart and click Next.
Select Pie and click Next.
For Title, enter Open Issues by Project
and click Next.
For Enter SVG Chart SQL Query, enter:
SELECT NULL LINK, NVL(r.project_name,'No Project') label, COUNT(r.project_name) value FROM ht_issues i, ht_projects r WHERE i.status = 'Open' AND i.related_project = r.project_id GROUP BY NULL, r.project_name ORDER BY r.project_name
Note that this query does not include a link, the label is the Project Name
, and the value calculated and used for the pie chart is the total number of open issues by project.
Click Create Region.
To edit the chart.
Under Regions, select Chart to the left of Open Issues by Project.
For Chart Width, enter 500
.
For Chart Height, enter 200
.
For Chart Title, remove the title.
Under Chart Query, enter the following in When No Data Found Message:
No Open Issues.
Under Font Settings, for Legend select 14 for the Font Size.
Click Apply Changes.
To view the revised page, click the Run Page icon. Your home page should resemble Figure 10-16.
In the previous exercise, you created menus on the home page to enable users to navigate to various pages within your application. Next, you need to provide users with a way to navigate to the home page. You can accomplish by utilizing breadcrumb. When you created your application, the wizard automatically created a breadcrumb.
In the next exercise, you add breadcrumb entries and then include that breadcrumb within a region on page 0. Adding components to page 0 makes them display on all pages with an application.
Topics in this section include:
To navigate to the Breadcrumbs page:
Navigate to the Application home page.
Click Shared Components.
Under Navigation, select Breadcrumbs.
Select the breadcrumb, Breadcrumb.
Next, add breadcrumb entries.
To edit the existing breadcrumb entry for page 1:
Under Breadcrumb Entries, click Page 1.
Under Breadcrumb, enter 1
in Page.
For Short Name, enter Home
.
Under Target, enter 1
in Page.
Click Create.
To create a breadcrumb entry for page 2:
Click Create Breadcrumb Entry.
Under Breadcrumb, enter 2
in Page.
Under Entry:
For Parent Entry, select Home.
For Short Name, enter Projects
.
Under Target, enter 2
in Page.
Click Create.
To create a breadcrumb entry for page 3:
Click Create Breadcrumb Entry.
Under Breadcrumb, enter 3
in Page.
Under Entry:
For Parent Entry, select Projects.
For Short Name, enter Create/Edit Projects
.
Under Target, enter 3
in Page.
Click Create.
To create a breadcrumb entry for page 4:
Click Create Breadcrumb Entry.
Under Breadcrumb enter 4
in Page.
Under Entry:
For Parent Entry, select Home.
For Short Name, enter People
.
Under Target, enter 4 in Page.
Click Create.
To create a breadcrumb entry for page 5:
Click Create Breadcrumb Entry.
Under Breadcrumb enter 5
in Page.
Under Entry:
For Parent Entry, select People.
For Short Name, enter Create/Edit Person Information
.
Under Target, enter 5 in Page.
Click Create.
To create a breadcrumb entry for page 6:
Click Create Menu Option.
Under Breadcrumb enter 6
in Page.
Under Entry:
For Parent Entry, select Home.
For Short Name, enter Issues
.
Under Target, enter 6 in Page.
Click Create.
To create a breadcrumb entry for page 7:
Click Create Breadcrumb Entry.
Under Breadcrumb enter 7
in Page.
Under Entry:
For Parent Entry, select Home.
For Short Name, enter Create/Edit Issue
.
Under Target, enter 7 in Page.
Click Create.
To create a breadcrumb entry for page 8:
Click Create Menu Option.
Under Breadcrumb enter 8
in Page.
Under Entry:
For Parent Entry, select Home.
For Short Name, enter Assign Issues
.
Under Target, enter 8
in Page.
Click Create.
To create a breadcrumb entry for page 9:
Click Create Breadcrumb Entry.
Under Breadcrumb enter 9
in Page.
For Entry:
For Parent Entry, select Home.
For Short Name, enter Issue Summary by Project
.
Under Target, enter 9
in Page.
Click Create.
To create a breadcrumb entry for page 10:
Click Create Breadcrumb Entry.
Under Breadcrumb enter 10
in Page.
Under Menu Option:
For Parent Entry, select Home.
For Short Name, enter Resolved by Month Identified
.
Under Target, enter 10
in Page.
Click Create.
To create a breadcrumb entry option for page 11:
Click Create Breadcrumb Entry.
Under Breadcrumb enter 11
in Page.
Under Entry:
For Parent Entry, select Home.
For Short Name, enter Target Resolution Dates
.
Under Target, enter 11
in Page.
Click Create.
To create a breadcrumb entry for page 12:
Click Create Breadcrumb Entry.
Under Breadcrumb, enter 12 in Page.
Under Entry:
For Parent Entry, select Home.
For Short Name, enter Average Days to Resolve
.
Under Target, enter 12
in Page.
Click Create.
Now that the breadcrumb exists, you need to create page 0 and then create a region to contain your Breadcrumb menu.
To create page 0:
Navigate to the Application home page.
Click Create Page.
Select Blank Page and click Next.
For Page, enter 0
and click Next.
For Name, enter Breadcrumbs and click Next.
On Identify Tabs, accept the default No and click Next.
Review your selections and click Finish.
To create a region to contain your breadcrumb:
From the Success page, select Edit Page.
The Page Definition for page 0 appears.
Under Regions, click the Create icon.
For Select a common region type, select Breadcrumb and click Next.
For Breadcrumb Container Region:
For Title, enter Breadcrumbs.
For Region Template, select No Template.
For Display Point, select Page Template Region Position 1.
This selection displays the breadcrumb above all other content on the page.
Click Next.
For Breadcrumb:
For Breadcrumb, select Breadcrumb.
For Menu Template, select Breadcrumb Menu.
Click Next.
For Breadcrumb Entry, accept the defaults and click Next.
Click Finish.
Return to the home page by clicking Edit Page. When the Page Definition for page 0 appears, click the Next Page icon (>). The Page Definition for page 1 appears. To see your completed home page, click the Run Page icon. Your home page should resemble Figure 10-17.
Notice the Breadcrumb in the top bar. Click one of the items on the Maintenance menu on the left side of the page. Notice how the breadcrumb menu changes.and watch the breadcrumb change.
At this stage your application is fully functional, but is missing the security and email notification. Those topics will be discussed in the next section.
Once your application is fully functional you can focus on adding advanced features outlined during the planning and project analysis phase.
Topics in this section include:
The planning and project analysis phase produced two e-mail requirements:
Notify people when an issue is assigned to them
Notify the project lead when any issue becomes overdue
Topics in this section include:
To send mail from within an Oracle HTML DB application, you create a PL/SQL process that calls the supplied HTMLDB_MAIL
package.
E-mail is not sent immediately from Oracle HTML DB, but is stored in a temporary queue until a DBMS_JOB
pushes the queue. The DBMS_JOB
utilizes two preferences named SMTP_HOST_ADDRESS
and SMTP_HOST_PORT
to send mail in the queue. By default, these preferences are set to localhost
and 25
.
If the server where Oracle HTML DB is installed is not configured for SMTP services, you will need to change the SMTP_HOST_ADDRESS
preference. Check with your Oracle HTML DB administrator to make sure the instance you are using is properly configured to send e-mail.
The following is a description of the SEND procedure of the HTMLDB_MAIL
package.
PROCEDURE SEND Argument Name Type In/Out Default? ------------------------------ ----------------------- ------ -------- P_TO VARCHAR2 IN P_FROM VARCHAR2 IN P_BODY VARCHAR2 IN P_BODY_HTML VARCHAR2 IN DEFAULT P_SUBJ VARCHAR2 IN DEFAULT P_CC VARCHAR2 IN DEFAULT P_BCC VARCHAR2 IN DEFAULT
First, you will add a notification to a person when he or she has a new assignment. An assignment can be made or changed from two different pages
Create/Edit Issue
Assign Issues.
On the Create/Edit Issue page, you can store the initial values and then check them against any changes to see if an assignment has been made or changed. Because Assign Issues is a tabular form, there is no way to check the old values against the new values. For that reason, the best way to implement the notification is with a before insert and update trigger on HT_ISSUES
. You can create this trigger programmatically using SQL Workshop.
Note: The trigger you are about to create sends e-mails. If you plan on using this application, change thep_to and p_from to your own e-mail address so that you do not create e-mails with invalid addresses each time you assign or reassign an issue. |
To create a before insert and update trigger on HT_ISSUES
:
Navigate to the Workspace home page.
Click SQL Workshop.
Click Object Browser.
Click Create.
For Select the type of database object you want to create, select Trigger and click Next.
For Name:
For Schema, select the appropriate schema and click Next.
For Table Name, select HT_ISSUES and click Next.
For Action, keep the default of Create Trigger and click Next.
For Define:
For Trigger Name, enter BIU_HT_ISSUES_NOTIFY_ASSIGNEE.
For Firing Point, select AFTER.
For Options, select insert, update.
For Trigger Body, enter:
IF (INSERTING AND :new.assigned_to IS NOT NULL) OR (UPDATING AND (:old.assigned_to IS NULL OR :new.assigned_to != :old.assigned_to) AND :new.assigned_to IS NOT NULL) THEN FOR c1 IN (SELECT person_name, person_email FROM ht_people WHERE person_id = :new.assigned_to) LOOP IF c1.person_email IS NOT NULL THEN FOR c2 IN (SELECT project_name FROM ht_projects WHERE project_id = :new.related_project) LOOP HTMLDB_MAIL.SEND( p_to => c1.person_email, p_from => c1.person_email, p_body => 'You have been assigned a new issue. '|| 'The details are below. ' ||chr(10)|| chr(10)|| ' Project: '|| c2.project_name ||chr(10)|| ' Summary: '||:new.issue_summary ||chr(10)|| ' Status: '||:new.status ||chr(10)|| 'Priority: '||nvl(:new.priority,'-'), p_subj => 'New Issue Assignment'); END LOOP; END IF; END LOOP; END IF;
Click Next.
To review the code, expand the SQL icon.
Click Finish.
Note: If you plan on using this application, you should either disable this trigger or change thep_to and p_from to your own e-mail address so that you do not create e-mails with invalid addresses each time you assign or reassign an issue. |
The second email notification notifies the project lead whenever an issue becomes overdue. An issue becomes overdue when the target resolution date has passed, but the issue is not yet closed. Because there is no human interaction to determine if an issues overdue, you cannot check for it on a page or in a trigger.
The best way to check for overdue issues is to write a package that queries the HT_ISSUES
table. If it finds any overdue issues, the package will initiate an email to the Project Lead. This procedure will check for issues by project so that the project lead will receive just one email with all overdue issues rather than an email for each issue. The package will be called once a day by a dbms_job
.
You can use the Create Object function as follows:
Create the package and package body from within the SQL Workshop
Use SQL Command Processor to run the create commands
For this exercise, you will use SQL Command Processor.
To create the package:
Navigate to the SQL Workshop home page.
Select SQL Commands.
For Schema, select the appropriate schema.
For Enter a SQL or PL/SQL Statement enter:
CREATE OR REPLACE package ht_check_overdue_issues AS PROCEDURE email_overdue; END; /
Click Run.
To create the package body:
Navigate to the SQL Workshop home page.
Select SQL Command Processor.
For Schema, select the appropriate schema.
In Enter a SQL or PL/SQL Statement, enter the following:
CREATE OR REPLACE PACKAGE BODY ht_check_overdue_issues AS PROCEDURE email_overdue IS l_msg_body varchar2(32000) := null; l_count number := 0; BEGIN FOR c1 IN (SELECT pr.project_id, pr.project_name, pe.person_name, pe.person_email FROM ht_projects pr, ht_people pe WHERE pr.project_id = pe.assigned_project AND pe.person_role = 'Lead') LOOP FOR c2 IN (SELECT i.target_resolution_date, i.issue_summary, p.person_name, i.status, i.priority FROM ht_issues i, ht_people p WHERE i.assigned_to = p.person_id (+) AND i.related_project = c1.project_id AND i.target_resolution_date < SYSDATE AND i.status != 'Closed' ORDER BY i.target_resolution_date, i.issue_summary) LOOP IF l_count = 0 THEN l_msg_body := 'As of today, the following issues '|| 'are overdue:'||chr(10)|| chr(10)|| ' Project: '|| c1.project_name ||chr(10)|| chr(10)|| ' Target: '||c2.target_resolution_date ||chr(10)|| ' Summary: '||c2.issue_summary ||chr(10)|| ' Status: '||c2.status ||chr(10)|| ' Priority: '||c2.priority ||chr(10)|| 'Assigned to: '||c2.person_name; ELSE l_msg_body := l_msg_body ||chr(10)|| chr(10)|| ' Target: '||c2.target_resolution_date ||chr(10)|| ' Summary: '||c2.issue_summary ||chr(10)|| ' Status: '||c2.status ||chr(10)|| ' Priority: '||c2.priority ||chr(10)|| 'Assigned to: '||c2.person_name; END IF; l_count := l_count + 1; END LOOP; IF l_msg_body IS NOT NULL THEN HTMLDB_MAIL.SEND( p_to => c1.person_email, p_from => c1.person_email, p_body => l_msg_body, p_subj => 'Overdue Issues for Project '|| c1.project_name); END IF; l_count := 0; END LOOP; END email_overdue; END ht_check_overdue_issues; /
Click Run.
To create the DBMS_JOB
:
Note: This job generates e-mail. Do not execute the following script if you running on a hosted Oracle HTML DB instance. If you are running Oracle HTML DB instance locally and want to test this script, update the demonstration data to include valid e-mail addresses. |
Navigate to the SQL Workshop home page.
Select SQL Commands.
For Schema, select the appropriate schema.
In Enter a SQL or PL/SQL Statement, enter the following:
DECLARE jobno number; BEGIN DBMS_JOB.SUBMIT( job => jobno, what => 'BEGIN ht_check_overdue_issues.email_overdue; END;', next_date => SYSDATE, interval => 'TRUNC(SYSDATE)+(25/24)' ); COMMIT; END; /
Click Run.
This dbms_job executes just after midnight each day.
Note: If you plan on using this application, change either thep_to and p_from in the ht_check_overdue_issues package body to your own email address, or do not create the dbms_job . Running the code as written results in the creation of email with invalid addresses that will sit in mail queue. |
See Also: Send email from HTML DB applications How To on OTN at:http://www.oracle.com/technology/products/database/htmldb/howtos/index.html |
The planning and project analysis phase produced two security requirements:
Only the CEO and Managers can define and maintain projects and people
Once assigned, only the person assigned or a project lead can change data about the issue
Within Oracle HTML DB, you can define authorization schemes. Authorization controls user access to specific controls or components based on user privileges. Once defined, you can associate an authorization scheme with any page, region or item to restrict access. Each authorization schema is run only when needed and is defined to validate either once for each page view or once for each session.
Topics in this section include:
The first requirement states only the CEO and Managers may define and maintain projects and people. To address this requirement you will:
Create an authorization scheme to check the current user's role
Associate the authorization scheme with the items on the Projects and People report that navigate to the Create/Edit pages
Associate the authorization scheme with the Create/Edit pages themselves so that a user cannot bypass the security by manually editing the URL to the target page.
To reference the current user, use the session variable :APP_USER
. This will be compared with the person's email address (which is the same as their Oracle HTML DB user name). Whenever coding this type of security, you should always code in a user that can pass all security. You will find this user very useful for development and testing. If you do not take this approach, you will not be able to access the restricted pages unless you define yourself as the CEO or Manager.
To create the authorization scheme:
Navigate to the Workspace home page.
Click Application Builder.
Select the Issue Tracker application.
Click Shared Components.
Under Security, select Authorization Schemes.
Click Create.
For Create Authorization Scheme, accept the default From Scratch and click Next.
Under Authorization Scheme Identification, enter the following in Name:
USER_CEO_OR_MANAGER
Under Authorization Scheme:
For Scheme Type, select Exists SQL Query.
In Expression 1, enter:
SELECT '1' FROM ht_people WHERE (upper(person_email) = UPPER(:APP_USER) AND person_role IN ('CEO','Manager')) OR (UPPER(:APP_USER) = 'HOWTO')
For Identify error message displayed when scheme violated, enter:
You are not authorized to access this function.
Scroll down to Evaluation Point. For Validate authorization scheme, select Once per session.
This selection is sufficient in this instance since the assigned role will not typically change within a given session.
Click Create.
Next, you need to associate the authorization scheme with the appropriate objects.
To associate the authorization scheme with the Projects report:
Click the Edit Page icon.
In Page, enter 2
and click Go.
The Page Definition for page 2, Projects, appears.
Under Regions, select Report to the left of Projects.
Click the Edit icon to the left of PROJECT_ID
.
Under Authorization, select the Authorization Scheme USER_CEO_OR_MANAGER.
Click Apply Changes.
Click Cancel.
To associate the authorization scheme with the Create button on the Projects report:
Navigate to the Page Definition for page 2.
Under Button, select Create.
Under Authorization, select the Authorization Scheme USER_CEO_OR_MANAGER.
Click Apply Changes.
To associate the authorization scheme with the Create/Edit Project page:
Navigate to page 3 by clicking the Next Page (>) icon.
The Page Definition for page 3, Create/Edit Project, appears.
Click Edit Attributes.
Scroll down to Security.
Select the Authorization Scheme USER_CEO_OR_MANAGER.
Click Apply Changes.
To associate the authorization scheme with the People report.
Navigate to page 4 by clicking the Next Page (>) icon.
The Page Definition for page 4, People, appears.
Under Regions, select Report to the left of People.
Click the Edit icon to the left of PERSON_ID.
Under Authorization, select the Authorization Scheme USER_CEO_OR_MANAGER.
Click Apply Changes.
Click Cancel.
To associate the authorization scheme with the Create button on the People report:
Navigate to the Page Definition for page 5.
Under Buttons, select Create.
Under Authorization, select the Authorization Scheme USER_CEO_OR_MANAGER.
Click Apply Changes.
To associate the authorization scheme with the Create/Edit Person Information page:
Navigate to page 5.
The Page Definition for page 5, Create/Edit Person Information, appears.
Click Edit Attributes.
Scroll down to Security.
Select the Authorization Scheme USER_CEO_OR_MANAGER.
Click Apply Changes.
You can test this creating a user with the username of HOWTO. The HOWTO user should be able to see the edit link. Then, create another user, HOWTO2. This user should not be able to see the link.
The second requirement states that once an issue has been assigned, only the person assigned (or a project lead) can change data about the issue. This requirement is a little trickier since it changes for every issue.
Currently, there are two pages that enable users to modify an issue, the Create/Edit Issue page and the Assign Issues page. On the Assign Issues page, the only issues that display are those that are unassigned. Since the issues are unassigned, security is not necessary.
There are many places that a user can navigate to edit an issue:
Three regions on the home page display issues or have edit links
The Issues report has links to edit each issue
The Target Resolution Dates report enables users to select an issue to edit.
Although other users are not allowed to change the data, you do want to enable users to view all the detailed data about an issue so that they can view the progress and resolution. Given this requirement, the best approach would be to create an authorization scheme that will be evaluated once for each page view.
The authorization scheme will be associated with both the Apply Changes and Delete buttons on the Create/Edit Issue page. This way, unauthorized users can view all the details, but if they do change something, they have no way of saving that change.
For added security, you will also associate the authorization scheme with the process that performs the insert, update and delete on HT_ISSUES
. This protects your application against someone changing the URL to call the Apply Changes process. To let users know why they are not able to make changes, you will add an HTML region which will display an explanation when the authorization fails. The SQL for this scheme will be specific to the Create/Edit Issues page because it needs to reference P7_ISSUE_ID. It will need to retrieve data from the database because at the time it will be evaluated, the necessary data will not be available in the session state. The only item that will be available will be P7_ISSUE_ID because it will be passed by the link.
To create the authorization scheme:
Navigate to the Application home page.
Select Shared Components.
Under Security, select Authorization Schemes.
Click Create.
For Creation Method, accept the default From Scratch and click Next.
Under Authorization Scheme Identification, enter the following in Name:
P7_ASSIGNED_OR_PROJECT_LEAD
Under Authorization Scheme:
For Scheme Type, select PL/SQL Function Returning Boolean.
For Expression 1, enter:
DECLARE l_related_project integer; l_assigned_to integer; l_person_id integer; l_person_role varchar2(7); l_assigned_project integer; BEGIN -- User is HOWTO or new Issue IF :APP_USER = 'HOWTO' or :P7_ISSUE_ID IS NULL THEN RETURN TRUE; END IF; FOR c1 IN (SELECT related_project, assigned_to FROM ht_issues WHERE issue_id = :P7_ISSUE_ID) LOOP l_related_project := c1.related_project; l_assigned_to := c1.assigned_to; END LOOP; -- Issue not yet assigned IF l_assigned_to IS NULL THEN RETURN TRUE; END IF; FOR c2 IN (SELECT person_id, person_role, assigned_project FROM ht_people WHERE upper(person_email) = upper(:APP_USER)) LOOP l_person_id := c2.person_id; l_person_role := c2.person_role; l_assigned_project := c2.assigned_project; END LOOP; -- User is lead of related project IF l_person_role = 'Lead' and l_assigned_project = l_related_project THEN RETURN TRUE; -- User is assigned to issue ELSIF l_assigned_to = l_person_id THEN RETURN TRUE; ELSE RETURN FALSE; END IF; END;
For Identify error message displayed when scheme violated, enter:
This issue is not assigned to you, nor are you the Project Lead. Therefore you are not authorized to modify the data.
Scroll down to Evaluation Point. For Validate authorization scheme, select Once per page view.
This selection is necessary since each issue may have a different result.
Click Create.
Now you need to associate the authorization scheme with the appropriate objects on the Create/Edit Issue page.
To associate the authorization scheme with buttons and processes:
Navigate to Application home page.
Select page 7 - Create/Edit Issues.
Under Buttons, select DELETE.
Under Authorization, select the Authorization Scheme P7_ASSIGNED_OR_PROJECT_LEAD.
Click Apply Changes.
Under Buttons, select SAVE.
Under Authorization, select the Authorization Scheme P7_ASSIGNED_OR_PROJECT_LEAD.
Click Apply Changes.
Under Processes, select Process Row of HT_ISSUES.
Under Authorization, select the Authorization Scheme P7_ASSIGNED_OR_PROJECT_LEAD.
Click Apply Changes.
Lastly, create a new region to display an explanation when the authorization fails
To create a new region:
Under Regions, click the Create icon.
For Select a common region type, accept the default HTML and click Next.
On Region Type, select HTML and click Next.
For Display Attributes:
For Title, enter Not Authorized
.
For Display Point, select Page Template Body (2. items below region content).
Click Next.
For Enter HTML Text Region Source, enter the following and click Next:
You are not authorized to modify the data for this issue because<br>you are not the Project Lead nor is the issue assigned to you.
For Authorization Scheme, select {Not}P7_ASSIGNED_OR_PROJECT_LEAD. This will make the region only display when the Authorization Scheme fails.
Click Create Region.
Figure 10-18 displays the Create/Edit Issue page being run by a person for whom the Authorization fails. Notice a new region displays at the top of the page and that the only button being displayed is Cancel.
Figure 10-18 New Region Displaying Authorization Failure
A more elegant solution to this security requirement would be to create a different page for viewing the details of an issue. You would need to have a procedure that would take in the issue_id and current user and pass back a flag for view only or edit. Then you could dynamically build the link for all the reports to call either the View page or the Edit page based upon a call to that procedure. You would still want to protect against someone accessing the edit page without using a link so you would also check permission before firing the insert, update and delete process.
Now that your application is complete, the next step is to deploy it. Typically, developers create applications on one server and deploy it on another. Although this approach is not required, it enables you to resolve bugs without impacting the production instance.
Note: To deploy an application on another server, you need to install and configure another Oracle HTML DB instance. |
Topics in this section include:
The definition for your application lives within the Oracle database. The application definition includes everything that makes up the application, including the templates, but it does not include database object definitions or the underlying data. To move an application to another Oracle HTML DB instance, you must export the application definition from your development server and import it into your production server.
Topics in this section include:
To export the application definition from your development server:
Navigate to the Workspace home page.
Click the Application Builder icon.
Select the application you want to export.
Click the Export/Import icon and then Export.
For Application, select the application created in this exercise.
Click Export Application.
When prompted, click to Save the file.
Specify a location on your local hard drive and click Save.
On your production instance, you need to create the objects necessary to support the application. Log in to the production instance and follow the directions in "Build the Database Objects".
Note: Although the supporting objects do not need to exist for you to import the application definition, be aware you cannot test the code until they exist. |
Login to the production instance of Oracle HTML DB:
Navigate to the Workspace home page.
Click the Application Builder icon.
Select the application you want to export.
Click the Export/Import icon and then Import.
On Import File:
For Import File, click the Browse button and locate your exported file.
For File Type, select Application/Page Export.
For File Character Set, accept the default and click Next.
Once the success message appears, the next step is to install the file.
Click Install.
On Application Install:
For Parse As Schema, select the schema on your production server that contains your application objects.
For Build Status, you select Run and Build Application.
This option enables other users to run the application and enables you to log in and change the code if necessary. Alternatively, you can select Run Application Only. Be aware that if you select this option you will not be able to access the source code for the application.
For Install As Application, you can select:
Reuse Application ID from Export File - Only select this option if the application ID is not being used on the production instance.
Auto Assign New Application ID - Select this option to assign a new application ID.
Change Application ID - Select this option to change the existing application ID. If you select this option, you will be prompted to enter a new application ID.
When you install an application having the same ID as an existing application in the current workspace, the existing application is deleted and then the new application is installed. If you attempt to install an application having the same ID as an existing application in a different workspace, an error message appears.
If all statements are successful the install commits and becomes permanent. If any errors are encountered, the install is rolled back, resulting in no permanent changes.
Click Install Application.
If the install is successful, the Post-App Install Utility Options page appears. From here, you can select one of the following:
Select Run Application to see application running
Select Edit Application Attributes to view the application definition within Oracle HTML DB
The next step in deploying your application would be to load the data. At a minimum, you would need to populate the project
and people
tables.
Note there are various mechanisms you could use to accomplish this task, including:
Use the application itself to create data.
Use the Data Loader to load data copied from a spreadsheet.
Use the SQL Workshop and run scripts to create data.
If you have data existing already within an Oracle database, use either export/import to move data between machines or use SQL to retrieve and transform existing data and load it into the application tables.
When the application login page calls the Oracle HTML DB login API with a username and password, the HTML DB engine calls the credentials verification method specified in the application's current authentication scheme. You have three choices as to how credentials are verified from within the login API:
Implement the method yourself as a PL/SQL function returning Boolean and put it in your application's schema.
Use the built-in LDAP authentication method, which checks username and password against the LDAP directory that you specify.
Use the built-in Oracle HTML DB authentication method, which checks the username and password against the Oracle HTML DB account repository.
Your application is currently using the built-in Oracle HTML DB. It is also possible to use an external authentication service such Oracle Application Server Single Sign-On. Be aware, however, that Oracle HTML DB redirects to these services instead of showing a login page.
See Also: Using Oracle AS Single Sign-On with HTML DB Applications and Changing Authentication Methods How To documents on OTN:http://www.oracle.com/technology/products/database/htmldb/howtos/index.html |
In order for your application to be accessible, you need to create users. If you are still using Oracle HTML DB authentication, the simplest way to create users it to access the Manage Users page within the workspace that owns the application. Note that you will need to have been granted Administration rights for the workspace in order to access this page.
To create a new user:
Navigate to the Workspace home page and click the Administration icon.
Click Manage HTML DB Users.
Select Create Developer.
Under User Identification, enter the required information. If you are using Oracle HTML DB authentication, make User Name and Email Address identical.
Developer Privileges enable the user to run the application but not access the Application Builder.
Under Developer Privileges:
For User is a developer, select No.
For User is an administrator, select No.
Click Create or Create and Create Another.
Now that you have deployed your application, loaded data, and created users, you can publish your production URL.
You can determine the URL to your application by positioning the mouse over the Run icon on the Application home page. The URL displays in the status bar at the bottom of the page.
The Run icon gets its value from the Home link attribute on the Edit Security Attributes page. This link is only referenced by this icon and by applications that do not use the Oracle HTML DB Login API. Consider the following example:
http://htmldb.oracle.com/pls/otn/f?p=11563:1:3397731373043366363
Where:
htmldb.oracle.com
is the URL of the server
pls
is the indicator to use the mod_plsql
cartridge
otn
is the data access descriptor (DAD) name
f?p=
is a prefix used by Oracle HTML DB
11563
is application being called
1
is the page within the application to be displayed
3397731373043366363
is the session number
To run this example application, you would use the URL:
http://htmldb.oracle.com/pls/otn/f?p=11563:1
When each user logs in, he or she will receive an unique session number.
As you may recall, you created the Issue Tracker application using the Create Application wizard. This wizard creates a process on the Login page (page 101) that controls authentication. The contents of the process are:
WWV_FLOW_CUSTOM_AUTH_STD.LOGIN( P_UNAME => :P101_USERNAME, P_PASSWORD => :P101_PASSWORD, P_SESSION_ID => :FLOW_SESSION, P_FLOW_PAGE => :APP_ID||':1' );
Note that the Page is hard coded into this process. Because of this, the page you pass in the URL is overwritten and does not need to be included. You can access the application by using the following URL:
http://htmldb.oracle.com/pls/otn/f?p=11563:1
As you can see from the example used, the URL has no meaning and can be rather long. The host name can be changed to make it more symbolic. You can also configure Apache to rewrite your URL so that you can publish an abbreviated format and a URL that would be more intuitive to your users. See your Apache documentation for details.