Sie sind auf Seite 1von 43

Create Employee

1. Entity Object Creation


Before creating entity object, first is set to the database connection to be used for selecting
object in entity object. Hence, go to project properties by clicking on search icon located in
applications navigator window shown below:

Navigate to Business Components tab and use the connection which has been created. You
can create a new connection if it is not available and then can use the same. (shown below is using
existing connection)

Click Ok once selected the database connection.

It might ask for password verification. If it asks, enter the password and click ok.
Once project properties are set, we are good to proceed with Entity Object creation.

Right click on server directory (oracle.apps.training.oaf.server) and click on New Entity Object as
shown below

Welcome page will appear (shown below)


Click Next. Step 1 of 5 page will appear (shown below)

Enter following fields:

Name: EmployeeEO

Package: oracle.apps.training.oaf.server

Check the checkbox: Tables and Synonyms

Schema Object: FWK_TBX_EMPLOYEES


Click Next. Below page (Step 2 of 5) will appear.

You can create new attributes or remove existing attributes from entity object. But for this exercise,
dont do anything and click Next

Following page (Step 3 of 5) will appear listing all attribute related details. By default, it will populate
Primary key, mandatory, persistent, queryable, updateable check as per the database columns. We
need not modify anything as such on this page as well.

Ensure that there is exactly one attribute marked as primary key. If you have table without primary
key then you can create a new attribute in this entity object which can be marked as primary key.
Avoid using ROWID as primary key.
1. For columns that are never updateable, or updateable only when new, select the
appropriate Updateable radio button.
2. For columns whose values change after database triggers execute, select the Refresh
After update or insert as appropriate.
3. Never select the Unique checkbox; uniqueness checking should always be performed
programmatically. The Unique property has no effect if the EO is created on an already existing
database table.
4. The Discriminator column is used for polymorphic entity objects
5. If you are using an Object Version Number column, select the Change Indicator checkbox
for it.
6. For primary key columns, ensure that the Primary Key and Mandatory checkboxes are
selected.
7. All database column attributes have the Persistent and Queriable checkboxes selected as
shown.

Click next and following page (Step 4 of 5) will appear. This page is to select which java file to be
generated. By default, Entity object class will be checked and its accessors. Generally, we will not
generate Collection and definition class of entity object. Hence keep the default checked boxes as it
is. And click next
Last step (step 5 of 5) will ask if you need to generate default view object. Keep the default settings
(i.e. unchecked) and click on Finish.

It will generate EmployeeEO under server directory in Applications Navigator. Moreover it will also
show 2 files: EmployeeEO.xml and EmployeeEOImpl.java in Structure window as shown below:
2. View Object Creation (EO Based)

Right click server directory (oracle.apps.training.oaf.server) and click on New View Object as shown
below.

Ignore welcome page and then click next button.


Enter following details in Step 1 of 7 page:

Package: oracle.apps.training.oaf.server

Name: EmployeeVO

Select Rows populated by a SQL query radio button

Select Updateable access through entity objects radio button within above radio button.

Click Next button. And then Step 2 of 7 page will appear as shown below.
Select EmployeeEO entity object and shuttle to next box. Ensure that there is no numeric in Alias
text box. If there is any then remove the numbers to follow proper naming convention.

Click next and new page (step 3 of 7) will appear. Select all the attributes from EmployeeEO and
shuttle to next box.
Click next button and page (Step 4 of 7) will appear. You can alter the settings of each of the
attribute. But for this exercise, keep this default.

Click next and below page (Step 5 of 7) will appear. As VO is based on EO, it will generate default
query and not modifiable until you check the checkbox Expert Mode. If you are modifying the
query with additional tables, where clauses or order by clauses, then make sure you click on Test
button. For this exercise, we will not modify anything on this page.
Click next button and page (Step 6 of 7) will appear. This page is again not much used and generally,
this page is being used to define the bind variables in VO. For this exercise, we will not modify
anything on this page.

Click next button and below page (Step 7 of 7) will appear. This page is to select which all java files to
generate for View Object. We will select View object class and View row class. VOImpl.java is
used to create rows, iterate rows and execute the query. VORowImpl.java is to get the handle of
row.
Click next and review page will appear. Once reviewed, click Finish button.

3. Create Application Module

Right click on server oracle.apps.training.oaf.server and click on New Application Module.

Welcome page (below) will appear. Click next


In the below page, enter package as oracle.apps.training.oaf.server and name as EmployeeAM

Click next and below page will appear. Select EmployeeVO and shuttle to next box. Ensure the
instance name is meaningful and doesnt contains any number. Hence give instance name as
EmployeeVO for our exercise.
Click next and below screen will appear. Do not select any AM and so click next.

In below page, select generate java files of Application module class. We need not generate
application module definition class. And so, click finish.
4. Create Attributesets file

Right click webui (oracle.apps.training.oaf.webui) and select New.

In OA Components category, select package file and click ok (as shown below).
There will appear new dialog page as below. Enter Name as Attributesets and package as
oracle.apps.training.oaf.webui. Click ok button.

In structure window (below), right click on Attributesets > Click New > Click Attribute Set
Give the attribute set name as EmployeeId and select 2 properties: Prompt and Additional Text
and shuttle to next box. Click ok button, after that.

Then Select EmployeeId in structure window, and in Properties window enter the value of 2
properties:

Prompt: Employee ID

Additional Text: Employee Identifier


Similarly, define attributesets for other fields to be shown on page:

Attributeset Property1 Property1 Value Property2 Property2 Value


Name
FirstName Prompt First Name Additional Text Please enter first
name of an
employee
MiddleName Prompt Middle Name(s) Additional Text Please enter
middle name(s) of
an employee
LastName Prompt Last Name Additional Text Please enter last
name of an
employee
FullName Prompt Full Name Additional Text Please enter full
name of an
employee
EmailAddress Prompt Email Address Additional Text Personal/Corporate
email address
PositionCode Prompt Position Code Additional Text Position code
Salary Prompt Salary Additional Text Current salary
StartDate Prompt Start Date Additional Text Start date of an
employee
EndDate Prompt End Date Additional Text Last date of an
employee
ManagerName Prompt Manager Name Additional Text Name of manager
Title Prompt Title Additional Text Title of an
employee
CreateBtn Prompt Create Employee Additional Text Create employee
button
5. Create Employee Page

Right click on webui (oracle.apps.training.oaf.webui) and click New as shown below.

Select Page items from OA components category. Click ok after then.


In below dialog page, enter CreateEmployeePG for Name and oracle.apps.training.oaf.webui for
package. Click ok button after then.

Set following properties for region1 > pageLayout region style

Property Value
ID PageLayoutRN
AM Definition oracle.apps.training.oaf.server.EmployeeAM
Window Title Training: Create Employee Page
Title Create an employee
Create new region inside PagelayoutRN by right clicking on PagelayoutRN > New > Region

Select below properties of newly created region

Property Value
ID CreateEmpMesgCompRN
Region Style messageComponentLayout
Rows 10 (Give as per your requirements)
Columns 1 (Give as per your requirements)

Create new item under newly created CreateEmpMesgCompRN region by right clicking on
CreateEmpMesgCompRN> New > Item.

Set below properties of newly created item:

Property Value
ID EmployeeIdMTI
Item Style messageTextInput
Attribute Set /oracle/apps/training/oaf/webui/Attributesets/EmployeeId
View Instance EmployeeVO
View Attribute EmployeeId
Data Type NUMBER
Required Yes
Show Required True
Use the attribute set
Verify that prompt and additional text got automatically populated:

Same way create other items for different fields just one below another:

Title Field

Property Value
ID TitleMTI
Item Style messageTextInput
Attribute Set /oracle/apps/training/oaf/webui/Attributesets/Title
Maximum Length 30
View Instance EmployeeVO
View Attribute Title
Required Yes
Show Required True

First Name Field

Property Value
ID FirstNameMTI
Item Style messageTextInput
Attribute Set /oracle/apps/training/oaf/webui/Attributesets/FirstName
Maximum Length 20
View Instance EmployeeVO
View Attribute FirstName
Required Yes
Show Required True

Middle Name Field

Property Value
ID MiddleNameMTI
Item Style messageTextInput
Attribute Set /oracle/apps/training/oaf/webui/Attributesets/MiddleName
Maximum Length 60
View Instance EmployeeVO
View Attribute MiddleNames

Last Name Field

Property Value
ID LastNameMTI
Item Style messageTextInput
Attribute Set /oracle/apps/training/oaf/webui/Attributesets/LastName
Maximum Length 40
View Instance EmployeeVO
View Attribute LastName
Required Yes
Show Required True

Full Name Field

Property Value
ID FullNameMTI
Item Style messageTextInput
Attribute Set /oracle/apps/training/oaf/webui/Attributesets/FullName
Maximum Length 240
View Instance EmployeeVO
View Attribute FullName

Email Address Field

Property Value
ID EmailAddressMTI
Item Style messageTextInput
Attribute Set /oracle/apps/training/oaf/webui/Attributesets/EmailAddress
Maximum Length 240
View Instance EmployeeVO
View Attribute EmailAddress

Position Code Field This will be messageChoice field. Follow the steps mentioned later in
this document.

Salary Field

Property Value
ID SalaryMTI
Item Style messageTextInput
Attribute Set /oracle/apps/training/oaf/webui/Attributesets/Salary
Data Type NUMBER
View Instance EmployeeVO
View Attribute Salary

Manager Name Field This field will be messageLovInput and steps are mentioned further
in this document.

Start Date Field

Property Value
ID StartDateMTI
Item Style messageTextInput
Attribute Set /oracle/apps/training/oaf/webui/Attributesets/StartDate
Data Type DATE
View Instance EmployeeVO
View Attribute StartDate
Tip Type dateFormat
Required Yes
Show Required True

End Date Field


Property Value
ID EndDateMTI
Item Style messageTextInput
Attribute Set /oracle/apps/training/oaf/webui/Attributesets/EndDate
Data Type DATE
View Instance EmployeeVO
View Attribute EndDate
Tip Type dateFormat

Create Submit button in page

Right click on PageLayoutRN > New > Region and set below properties

Property Value
ID PageButtonBarRN
Region Style pageButtonBar

Once region has been created, right click on PageButtonBarRN and click New > Item and set
following properties of this item:

Property Value
ID SubmitBtn
Item Style submitButton
Prompt Submit
Create 2 methods in AMImpl.java

Select AM in applications navigator window > And then double click on EmployeeAMImpl.java in
Structure window:

Write below 2 methods in this EmployeeAMImpl.java as mentioned below in different highlighters:

public void createEmployee()

EmployeeVOImpl vo = getEmployeeVO();

vo.setMaxFetchSize(0);

Row row = vo.createRow();

vo.insertRow(row);

// Required per OA Framework Model Coding Standard M69

row.setNewRowState(Row.STATUS_INITIALIZED);
} // end createEmployee()

public String[] commit()

EmployeeVOImpl empVO = getEmployeeVO();

EmployeeVORowImpl empRow = (EmployeeVORowImpl) empVO.getCurrentRow();

String firstName = empRow.getFirstName();

String empNum = empRow.getEmployeeId().toString();

getOADBTransaction().commit();

createEmployee();

return new String[] {firstName, empNum};

}
Create new page controller and call above 2 methods from page controller

Right click on PagelayoutRN > Set new controller:

Enter package and controller name as shown below:

In this controller write below code:

import java.io.Serializable;
import oracle.apps.fnd.common.MessageToken;

import oracle.apps.fnd.common.VersionInfo;

import oracle.apps.fnd.framework.OAApplicationModule;

import oracle.apps.fnd.framework.OAException;

import oracle.apps.fnd.framework.webui.OAControllerImpl;

import oracle.apps.fnd.framework.webui.OAPageContext;

import oracle.apps.fnd.framework.webui.beans.OAWebBean;

public void processRequest(OAPageContext pageContext, OAWebBean webBean)

super.processRequest(pageContext, webBean);

OAApplicationModule am = pageContext.getApplicationModule(webBean);

am.invokeMethod("createEmployee");

public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)

super.processFormRequest(pageContext, webBean);

OAApplicationModule am = pageContext.getApplicationModule(webBean);

if (pageContext.getParameter("SubmitBtn") != null)

Serializable ret = am.invokeMethod("commit");

String retArr[] = (String[]) ret;

String firstName = retArr[0];

String empNum = retArr[1];


MessageToken mt[] = {new MessageToken("EMP_NAME", firstName), new MessageToken
("EMP_NUMBER", empNum)};

OAException exc = new OAException("AK", "FWK_TBX_T_EMP_CREATE_CONFIRM", mt,


OAException.CONFIRMATION, null);

pageContext.putDialogMessage(exc);

Create pageStatus (to show required field instructions)

Right click on PagelayoutRN > New > pageStatus

Set following properties of region1 generated under pageStatus in structure window:

Property Value
ID PageStatusRN
Extends /oracle/apps/fnd/framework/webui/OAReqFieldDescRG
Horizontal Alignment Left
Create poplist VO for position codes

We will be creating position codes message choice which we left above in the document while
designing fields on the page.

To proceed, firstly we need to create VO which will based on query to fetch all available position
codes:

Right click on oracle.apps.training > New View Object and enter following data shown below:
Ensure that you select read only access radio button as this VO will not be based on entity object and
will be based on plain query.

Click next and enter the query to select position codes as shown below:

Test the query. And click next in all the further pages with no modifications and finally click on Finish
button.

Now we need to associate PositionsLovVO in new LovAM. Hence, right click on oracle.apps.training >
New Application Module
Click next and then select PositionsLovVO into next box without number characters:

And then click next in all the further pages without any changes. And finally, click on finish button.

Then, we need to add this LovAM into existing EmployeeAM.

Hence, Double click on EmployeeAM in Applications navigator window > It will popup application
module window > Click on application modules in left panel > Select LovAM from Available
application modules list box and shuttle to next list box (without number values appended). Then
click apply and ok button. Shown below:
Now we can define PositionsCode messageChoice in page. Hence Select CreateEmployeePG.xml and
in structure window > Right click CreateEmpMesgCompRN > New Item (Place this item between
Email address and salary by dragging item to salary field). Set below properties of this item:

Property Value
ID PositionCodeMC
Item Style messageChoice
Attribute Set /oracle/apps/training/oaf/webui/Attributesets/PositionCode
Picklist View Definition oracle.apps.training.lov.server.PositionsLovVO
Picklist View Instance PositionsLovVO
Picklist Display Attribute Meaning
Picklist Value Attribute LookupCode
View Instance EmployeeVO
View Attribute PositionCode

Create manager LOV

We will be creating manager namelist of values (LOV) which we left above in the document while
designing fields on the page.

Firstly, we need to create VO which will fetch all the managers. Follow the steps below to create
query based VO:

Right click on oracle.apps.training.lov.server > New View Object and enter following details:

Click next and enter query as mentioned below:


Click on test and then click next in rest of all the pages (steps) without any changes. Finally click on
Finish button.

Add above created VO in LovAM as shown below:

Double click on LovAM in applications navigator window. In the new pop up window, select data
model in left panel, Select ManagersLovVO in Available view objects list box and shuttle to next list
box (without numbers) as shown below:
Now go back to CreateEmployeePG. Select CreateEmpMesgCompRN, right click on it > New > Item
(Place this new item between Salary and Start Date fields by dragging it on Start date field). Enter
following property values for this new item:

Property Value
ID ManagerIdLov
Item Style messageLovInput
Attribute Set /oracle/apps/training/oaf/webui/Attributesets/ManagerName
Search Allowed True
Selective Search Criteria True

Beneath above LOV, there will be another region created automatically with ID as region1 with
region style as listofValues. Change the property values for the same as:

Property Value
ID ManagerLovRN
Region Style listOfValues
AM Definition oracle.apps.training.lov.server.LovAM

Right click on above ManagerLovRN > New > table and set following properties for new table

Property Value
ID ManagerLovTbl
Region Style Table

Select ManagerLovTbl > New Item and add below 4 items:

Property Value
ID FirstNameLovMST
Item Style messageStyledText
Attribute Set /oracle/apps/training/oaf/webui/Attributesets/FirstName
Search Allowed True
Selective Search Criteria True
View Instance ManagersLovVO
View Attribute FirstName

Property Value
ID LastNameLovMST
Item Style messageStyledText
Attribute Set /oracle/apps/training/oaf/webui/Attributesets/LastName
Search Allowed True
Selective Search Criteria True
View Instance ManagersLovVO
View Attribute LastName

Property Value
ID FullNameLovMST
Item Style messageStyledText
Attribute Set /oracle/apps/training/oaf/webui/Attributesets/FullName
Search Allowed True
Sort Allowed True
Selective Search Criteria True
View Instance ManagersLovVO
View Attribute FullName

Property Value
ID ManagerIdLovFV
Item Style formValue
Attribute Set /oracle/apps/training/oaf/webui/Attributesets/EmployeeId
Data Type NUMBER
View Instance ManagersLovVO
View Attribute EmployeeId

After these, it will look like:

Now also, create one form value field at messagecomponent layout level. Right click
CreateEmpMesgCompRN > New messageLayout and give its ID as FormValuesML
Right click FormValuesML > New > Item and set below properties:

Property Value
ID ManagerIdFV
Item Style formValue
Attribute Set /oracle/apps/training/oaf/webui/Attributesets/EmployeeId
Data Type NUMBER
View Instance EmployeeVO
View Attribute EmployeeId

Now navigate back to lovMappings located under ManagerIdLov. And define following mappings (to
define additional lov mapping, right click on lovMappings and click lovMap):

Property Value
ID FullNameLovMap
Lov Region Item FullNameLovMST
Return Item ManagerIdLov
Criteria Item ManagerIdLov

Property Value
ID ManagerIdLovMap
Lov Region Item ManagerIdLovFV
Return Item ManagerIdFV
Now we are good to run the CreateEmployeePG and on click of submit, we should be able insert the
record in employees table.

Initially, when the page is run it will look like:

After entering all the details, and once clicked on submit, it will look like:

Das könnte Ihnen auch gefallen