Beruflich Dokumente
Kultur Dokumente
Eventually, we'll add the ability to view, create and delete employees.
Figure 1: Search Page Exercise Finished Product
42
Oracle Java Coding Standards Oracle corporate Java coding standads.
(internal access only)
Oracle Applications Java Standars and guidelines applying to any Java code written in
Coding Standards the Oracle Applications division (supplemental to the Oracle
corporate standards).
OA Framework Model Coding OA Framework coding standards for model objects in an MVC
Standards application.
OA Framework View Coding OA Framework coding standards for the view (user interface) in
Standards an MVC application.
OA Framework Controller OA Framework coding standards for the (user interface)
Coding Standards controller in an MVC application.
Step 2.2 Create the BC4J Package for Server (Business Logic) Objects
Create a new BC4J package for entity objects, association objects, validation application modules and
validation view objects.
Select the TutorialLabs.jpr project in the Navigator, right-click and select New Business
Components Package... from the context menu.
If the Welcome page appears in the Business Components Package Wizard, select Next.
Enter oracle.apps.ak.schema.server as the package name.
Verify that the radio button Entity Objects mapped to database schema objects is selected (you
will not be able to create your entity object in this package if you fail to do this).
Select the Finish button to create the package.
Step 2.3 Create Your Root UI Application Module (AM)
Create a new Application Module (AM) to be used as the root UI application module for your page.
Select the oracle.apps.ak.employee.server BC4J package in the Navigator, right-click and
select New Application Module... from the context menu to open the Application Module (AM)
wizard.
If the Welcome page appears, select Next.
In the Name page, specify EmployeeAM as the AM name and verify that the Package is
oracle.apps.ak.employee.server.
Click the Next button until you get to Step 4 of 4.
In the Java page, select the Generate Java File(s) checkbox.
Select the Finish button to create the AM.
Step 2.5 Save Your Work
Save your work as shown in Figure 4. Using the menu option File > Save All will save your metadata
changes to an XML file and save all your other file changes (such as to a .jsp or .java file).
Tip: Though it will not be written out as a separate step from here on, you should save your work
43
frequently: at least at the end of each task.
Figure 4: File > Save All Option in JDeveloper Main Menu
45
Create an employee-to-manager association (AO) for the self-join condition on the
FWK_TBX_EMPLOYEES table. Note that an employee must have a manager only if her assigned
POSITION_CODE != "PRESIDENT". An employee may have, at most, 1 manager. A manager can
have many employees.
Select the oracle.apps.ak.schema.server BC4J package in the Navigator, right-click and
select New Association...from the context menu to open the Association Object (AO) wizard.
If the Welcome page appears, select Next.
In the Name page, specify EmpToMgrAO as the association's name and verify that the
Package is oracle.apps.ak.schema.server.
Select the Next button.
Select * to 0...1 in the Cardinality poplist.
In the Select Source Attribute list, select the ManagerId attribute in your
oracle.apps.ak.schema.server.EmployeeEO.
In the Select Destination Attribute list, select the EmployeeId attribute in your
oracle.apps.ak.schema.server.EmployeeEO.
Select the Add button.
Select the Next button.
In the Association Attributes page, verify that the Expose Accessor check box is checked for
both the Source and the Destination.
Select the Finish button to create your association.
Step 2.8 Create an EmployeeSummaryVO View Object (VO)
Create a summary-level view object including only those attributes that you need for the Employees
search results table. This view object should leverage the EmployeeEO and EmpToMgrAO that you just
created (per the OA Framework Model Coding Standards for View Objects, all but the simplest view
objects for things like poplists, lists of values and so on should be based on entity objects).
Select the oracle.apps.ak.employee.server BC4J package in the Navigator, right-click and
select New View Object... from the context menu to open the View Object wizard.
If the Welcome page appears, select Next.
In the Name page, specify EmployeeSummaryVO as the view object's name and verify that
the Package is oracle.apps.ak.employee.server.
Select the Next button.
In the Entity Objects page, select the EmployeeEO in the Available list and shuttle it to the
Selected list twice (once for the employee, and once for the employee's manager).
Verify that the Alias for the second instance of the EmployeeEO class is EmployeeEO1, and
that the Association End field is set to ManagerIdEmployeeEO.
Select the Next button.
In the Attributes page, select the following attributes from the Available list and shuttle them to
the Selected list:
From EmployeeEO:
EmployeeId
FullName
EmailAddress
From EmployeeEO1:
EmployeeId (JDeveloper assigns this attribute the default name of EmployeeId1)
FullName (JDeveloper assigns this attribute the default name of FullName1)
EmailAddress (JDeveloper assigns this attribute the default name of
EmailAddress1)
Select the Next button.
In the Attribute Settings page, select the FullName attribute using the Select Attribute poplist,
set the Attribute Name field to be EmployeeName, and change the Query Column Alias field to
be EMPLOYEE_NAME.
46
Now select the EmployeeId1 attribute in the Select Attribute poplist, set the Attribute Name field
to be ManagerId, and change the Query Column Alias field to be MANAGER_ID.
Now select the EmailAddress attribute, set the Attribute Name field to be EmployeeEmail, and
change the Query Column Alias field to be EMPLOYEE_EMAIL.
Now select the FullName1 attribute, set the Attribute Name field to be ManagerName, and
change the Query Column Alias field to be MANAGER_NAME.
Now select the EmailAddress1 attribute, set the Attribute Name field to be ManagerEmail, and
change the Query Column Alias field to be MANAGER_EMAIL.
Select the Next button.
At this point the query should look like the following in the Query page (without the
formatting we've used here to improve readability):
SELECT EmployeeEO.EMPLOYEE_ID,
EmployeeEO.FULL_NAME AS EMPLOYEE_NAME,
EmployeeEO.EMAIL_ADDRESS AS EMPLOYEE_EMAIL,
EmployeeEO1.EMPLOYEE_ID AS MANAGER_ID,
EmployeeEO1.FULL_NAME AS MANAGER_NAME,
EmployeeEO1.EMAIL_ADDRESS AS MANAGER_EMAIL
FROM FWK_TBX_EMPLOYEES EmployeeEO,
FWK_TBX_EMPLOYEES EmployeeEO1
WHERE EmployeeEO.MANAGER_ID = EmployeeEO1.EMPLOYEE_ID
Select the Expert Mode checkbox. This allows you to edit the generated query.
In the Query Statement text box modify the query so it looks like the following. Note that you
must add the outer join (+) operator to the MANAGER_ID / EMPLOYEE_ID join (as of OA
Extension 9.0.3.8.1/OA Framework 11.5.10C, this is not automatically derived from the
association), and you must join to the FWK_TBX_LOOKUP_CODES_VL view to obtain the
display name for the employee's assigned position.
When you are finished with your editing, select the Test button to ensure your syntax is correct.
SELECT EmployeeEO.EMPLOYEE_ID,
EmployeeEO.FULL_NAME AS EMPLOYEE_NAME,
EmployeeEO.EMAIL_ADDRESS AS EMPLOYEE_EMAIL,
EmployeeEO1.EMPLOYEE_ID AS MANAGER_ID,
EmployeeEO1.FULL_NAME AS MANAGER_NAME,
EmployeeEO1.EMAIL_ADDRESS AS MANAGER_EMAIL,
flkp.meaning AS POSITION_DISPLAY
FROM FWK_TBX_EMPLOYEES EmployeeEO,
FWK_TBX_EMPLOYEES EmployeeEO1,
FWK_TBX_LOOKUP_CODES_VL flkp
WHERE EmployeeEO.MANAGER_ID = EmployeeEO1.EMPLOYEE_ID
(+) and EmployeeEO.POSITION_CODE = flkp.lookup_code
and flkp.lookup_type = 'FWK_TBX_POSITIONS'
Select the Next button.
In the Attribute Mappings page, verify that your view object attributes map to the correct query
columns. If you need to make any changes, place your cursor into the incorrect View Attributes
field and select the correct value from the poplist.
Select the Next button.
In the Java page, deselect the Generate Java File for View Object Class:
EmployeeSummaryVOImpl (you don't need to add any code to this view object). Do select the
Generate Java File for View Row Class: EmployeeNamesVORowImpl to comply with OA
Framework coding standards.
Select the Finish button to create your VO.
Now verify that your VO attribute settings match the aliases in your SQL query: Select
the EmployeeSummaryVO in the Navigator, right-click and select Edit
EmployeeSummaryVO... from the context menu to open the View Object wizard.
47
Navigate to the Attributes section for your attributes and verify that any aliases in your query
are shown correctly. Make any necessary changes and select Apply.
Navigate to the Attribute Mappings page and verify that all the mappings are correct. Make
any necessary changes and select Apply.
Select the OK button to finish editing your VO.
Step 2.9 Add Your View Object to the Root UI Application Module
View objects can be used only within the context of a containing application module. Before you can use the
EmployeeSummaryVO in your page, you must add it to the page's root UI Application Module.
Select the EmployeeAM in the Navigator pane, right-click and select Edit EmployeeAM... from
the context menu to open the Application Module wizard.
Navigate to the Data Model page.
Select the EmployeeSummaryVO view object in the Available View Objects list and shuttle it to
the Data Model list.
Tip: Take careful note of the default View Instance name that BC4J creates when you add your
VO to the selected AM (BC4J creates this name by appending a "1" to your VO name). Leave
it or change it, your choice (we suggest leaving the default value as is). In either case, know
what the value is before creating your Results table region in the next task.
Select the OK button to finish adding your VO to your root AM.
48
Region Style pageLayout
AM Definition oracle.apps.ak.employee.server.EmployeeAM
Window Title Framework ToolBox Tutorial: Labs <your name>
Title Employees <your name>
AutoFooter True
(This ensures that the standard footer, including the Oracle copyright and privacy notice,
render in the page).
Tip: For the purposes of these Toolbox tutorial exercises (only), it is a good idea to include your name
or some other identifying information in the window title and titles (page headers) for all your pages.
Later in the exercises, when you are creating links or destinations that use function names, these
names in the headers will help you know if you have gone to your own page or a page in the Toolbox
lab solution files (the names and functions are very similar).
Tip: You can set the Property Inspector to list the properties by category or in alphabetical order. To
change between category and alphabetical sorting, select the Categories button in toolbar at the top of
the Property Inspector as shown in Figure 7.
Figure 7: Categorized JDeveloper Property Inspector
51
EmployeeId
EmployeeName
PositionDisplay
ManagerName
Select the Next button.
In the Region Items page, set the ID, Style, and Attribute Set properties as follows (note that the
Prompt value is set for you as soon as you apply the Attribute Set, so do the attribute sets first
and then verify that the prompts are correct):
ID Prompt Style Data Type Attribute Set *
EmpNum Number messageStyledText NUMBER /< base path
>/EmployeeId_Number
EmpName Name messageStyledText VARCHAR2 /< base path >/FullName
Position Position messageStyledText VARCHAR2 /< base path >/Position
ManagerNa Manager messageStyledText VARCHAR2 /< base path
me >/FullName_Manager
* Please replace the < base path > variable in the table above with the following text:
oracle/apps/fnd/framework/toolbox/attributesets/FwkTbxEmployees. When you do this, be VERY
careful with the slashes. For example, if we had room in the table to be explicit, the first attribute set
would be:
/oracle/apps/fnd/framework/toolbox/attributesets/FwkTbxEmployees/EmployeeId_Number
Tip: You can use the Search capability to help find your attribute sets. Type
/oracle/apps/fnd/framework/toolbox/attributesets/ (or a shorter path such as
/oracle/apps/fnd/framework) into the Package field in the Search window, select Search in: Entire
MDS XML Path, then select the Search button (not the Browse button).
Tip: Remember, you can always change the table and item properties using the Property Inspector
after you leave the wizard.
Click the Finish button to create your data table.
Step 4.3 Set or Verify Your ResultsTable Region Properties
Select the ResultsTable region in the Structure pane, and set/verify the following properties:
Property Value
ID ResultsTable
Region Style table
AM Definition Make absolutely sure that you have not inadvertently associated an
application module here. If you have, please delete it.
Rendered True
Records 10
Displayed
Width 100%
Step 4.4 Set or Verify EmpNum Item Properties
Configure this item to support sorting in the table, to be included in the "results-based" search region
that the OA Framework automatically creates, and to be a selectively required search value (for
performance reasons, blind queries are disallowed in Oracle Applications unless the underlying view
object has been tuned to include a performant query so no additional search criteria is required).
For the EmpNum item:
Set the Search Allowed property to True to enable sorting on this table column.
Set the Sort Allowed property to ascending
Set the Initial Sort Sequence property to first.
Set the Selective Search Criteria property to True.
52
Tip: For more information on the Sort Allowed and Initial Sort Sequence properties, refer to the
Developer's Guide topic on Tables > Sorting.
Tip: For more information on the Search Allowed and Selective Search Criteria properties, refer to the
Developer's Guide topics on Search > Declarative Implementation: Results Based Search and
Search > Declarative Implementation: Auto Customization Criteria.
Step 4.4 Set or Verify EmpName Item Properties
For the EmpName item:
Set the Search Allowed property to True.
Set the Selective Search Criteria property to True.
Step 4.5 Set or Verify Position Item Properties
For the Position item:
Set the Search Allowed property to True.
Step 4.6 Set or Verify Manager Item Properties
For the Manager item:
Set the Search Allowed property to True.
Set the Destination URI property to mailto:{@ManagerEmail}.
Step 4.7 Test Your Work
Test your work. Your results should appear as shown in Figure 8 above. Try selecting the Advanced
Search button, and the Save Search button after executing a query. Also try selecting the Go button
without specifying any search criteria.
Note that you don't have to implement the query; the OA Framework implements this for you
automatically based on the table items that you identified with the Search Allowed property.
Furthermore, the OA Framework creates a Search UI based on the data and item types of the Search
Allowed items.
54
Length 15
Step 5.5 Create Search Mappings Between Your Name / Number Items and the
ResultsTable
The OA Framework uses the mappings that you define between your custom search items and
columns in the ResultsTable to automatically handle the query when the user selects the Go button.
Select the query bean or the query Components folder in the Structure pane, right-click and
choose New > simpleSearchMappings from the context menu.
Select the default mapping created under the simpleSearchMappings and set its properties to
the following:
Property Value
ID EmpNameMap
Search Item SearchEmpName
Results Item EmpName
Select the simpleSearchMappings folder in the Structure pane, right-click and choose New
> queryCriteriaMap from the context menu.
Select the new mapping and set its properties as follows:
Property Value
ID EmpNumMap
Search Item SearchEmpNum
Results Item EmpNum
Step 5.6 Test Your Work
Test your work. Your results should appear as shown in Figure 9 above. Notice how this differs from
the results-based search you tested earlier.