How To Extend A View Object in OA Framework
How To Extend A View Object in OA Framework
View Objects are the queries that provide the data seen on a Self Service web
page. Oracle offers many attributes in each View Object, but often an
additional attribute is needed. Oracle allows developers to extend the
delivered View Objects to meet this need. The following iRecruitment Vacancy
Search Page will be used for demonstration, but any page developed using the
OAF architecture is a candidate for this exercise.
In our example, the Posting's Job Title and Organization Name that were
entered during step 4 of the Vacancy Create process are not offered in the
delivered VO. These values are shown during data entry in the below screen
print. We will write PL/SQL functions to retrieve them; our extended VO will
then call these functions to return the values so they can be rendered on the
page:
Continue to step 3 and specify a DBC file. This file is found on the application
tier at $FND_TOP/secure. It must be copied to
C:\JDEVOAF\jdevbin\jdev\multi\system\oa\dbc_files\secure on your local
machine, where "JDEVOAF" is the directory where you installed JDeveloper.
Enter an Oracle Applications user and valid short name and responsibility key
before finishing:
When you have finished marveling over your newly created project, right click
it and choose "New Business Components":
If you don't have a connection to use already defined, follow these steps below
to create a new one. The connection name is arbitrary:
Click Finish and return to the Navigator. The custom package where the
extended VO will be created is complete, but we must import the delivered VO
before continuing. These files are stored in the $JAVA_TOP directory on the
application (middle) tier and must be downloaded. Since we are extending the
View Object (VO) oracle.apps.per.irc.vacancy.server.IrcVacancyVO, we must
import the oracle.apps.per.irc.vacancy.server pacakge and all dependent
packages. In order to do this efficiently, I perform the following steps:
1.
2.
3.
4.
5.
6.
7.
8.
Once this task is complete, right click your project and "Import Business
Components..."
and answer "Yes" when presented with the dialog "The following XML file is on
the classpath.
Would you like to add these objects to your project?"
Upon importing the first package, you may see an information message telling
you that additional packages are needed. In this example, import the
oracle.apps.per.schema.server (server.xml) package next. Repeat this process
until no additional messages appear.
If you see an Information message like the following, it means that the
server.xml has defined a file not contained in the classpath directory. It can be
ignored; if it really bothers you, open an SR and request that Oracle fix the
server.xml file.
Be sure to close JDeveloper and re-open after importing all packages. You may
see an additional warning to import more. Your project will look like the
following:
We must now create a new View Object in our custom package that extends
the delivered VO. A common practice is to use a PL/SQL function for the new
column so that any custom logic can be maintained easily. Rather than reimplementing the VO extension, the PL/SQL can be updated anytime the
business rules change.
Before proceeding in JDeveloper, lettuce first create the PL/SQL function:
Package spec:
create or replace package hack_jdev_pkg as
-function get_vac_posting_org (p_vacancy_id in number) return varchar2;
-function get_vac_posting_job (p_vacancy_id in number) return varchar2;
-end hack_jdev_pkg;
/
show errors;
Package body:
create or replace package body hack_jdev_pkg as
--
Name your new VO; the best practice is to give it a prefix before the delivered
name. Be sure to enter oracle.apps.per.irc.vacancy.server.IrcVacancyVO in the
"Extends" field.
Continue to step 3 and click New and configure as shown in the following two
screen prints. This is the actual extension to the VO where the values from
Step 4 of the Vacancy Create process are added to the VO:
Continue to step 6 and configure as shown below and Finish. Check the
"Generate Java File" if you need to extend the methods delivered with the VO:
Double click the .jpx file in your project to add a substitution, which tells
Oracle to use your View Object instead of the delivered VO. Highlight the
delivered VO and the extended VO and click "Add".
To upload the substitution, open a command prompt on the local machine and
run the following command:
C:\JDEVOAF\jdevbin\jdev\bin\jpximport
C:\JDEVOAF\jdevhome\jdev\myclasses\hack.jpx -username apps -password apps
-dbconnection "(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)
(HOST=oracle.hack.com)(PORT=1521))(CONNECT_DATA=(SID=hack)))"
Bounce Apache and then return to iRecruitment Recruiter -> Search for
Vacancies -> About this Page. The delivered VO has been replaced by your
extended VO:
Create the necessary personalization fields on the Advanced Table Region of the
page to render the new column, beginning with the Job Posting: