11
Guided Demonstration - Setting Up Your Development Environment In JDeveloper, in the LabSolutions.jpr (part of Tutorial.zip): 1. Create the BC4J Package for Client (UI) Objects Create a new Business Components for Java (BC4J) package to contain your user interface (UI) related application modules, view objects and view links. Select the TutorialLabs.jpr project in the Navigator, right- click and select New Business Components Package... from the context menu. Enter <yourname>.oracle.apps.ak.employee.server as the package name. Tip: By convention, all OA Framework-related BC4J components belong in a package whose name ends with “server”. Verify that the radio button Entity Objects mapped to database schema objects is selected. Select Next. Select the Finish button to create the package. 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. Enter <yourname>.oracle.apps.ak.schema.server as the package name.

oracle BC4J Demonstration

Embed Size (px)

DESCRIPTION

oracle BC4J Demonstration

Citation preview

Guided Demonstration - Setting Up Your Development EnvironmentIn JDeveloper, in the LabSolutions.jpr (part of Tutorial.zip):1. Create the BC4J Package for Client (UI) ObjectsCreate a new Business Components for Java (BC4J) package to contain your user interface (UI)related application modules, view objects and view links.

Select the TutorialLabs.jpr project in the Navigator, right-click and select New Business Components Package... from the context menu.

Enter .oracle.apps.ak.employee.server as the package name.Tip: By convention, all OA Framework-related BC4J components belong in a package whosename ends with server.

Verify that the radio button Entity Objects mapped to database schema objects isselected.

Select Next.

Select the Finish button to create the package.

2. Create the BC4J Package for Server (Business Logic) ObjectsCreate a new BC4J package for entity objects, association objects, validation application modulesand validation view objects.

Select the TutorialLabs.jpr project in the Navigator, right-click and select New Business Components Package... from the context menu.

Enter .oracle.apps.ak.schema.server as the package name.

Verify that the radio button Entity Objects mapped to database schema objects isselected (you will not be able to create your entity object in this package if you fail to dothis).

Select the Finish button to create the package.

3. Create Your Root UI Application Module (AM)Create a new Application Module (AM) to be used as the root UI application module for yourpage.

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 theApplication Module (AM) wizard.

In the Name page, specify EmployeeAM as the AM name and verify that the Packageis .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.

4. Save Your WorkSave your work. 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).

5. Create an Employee Entity Object (EO)Create an entity object (EO) for the FWK_TBX_EMPLOYEES table.

Select the .oracle.apps.ak.schema.server BC4J package in the Navigator,right-click and select New Entity Object... from the context menu to open the EntityObject wizard.

In the Name page:

Enter EmployeeEO in the Name field.

Verify that the Package is .oracle.apps.ak.schema.server.

In the Schema Object field, enter FWK_TBX_EMPLOYEES. You must type thisname correctly. Otherwise, you can check the Synonyms check box (so both Tablesand Synonyms are checked) and choose the correct name from a very long list.

Select the Next button twice to navigate to the Attribute Settings page (note that all thetable's columns are automatically included as attributes).

Verify that the EmployeeId attribute's Primary Key check box is selected. Do notchange any other default settings.

Tip: Primary Key and other settings are picked up from the database. You can changethem in the entity object if necessary.

Select the Next button.

In the Java page, select the Generate Java File check box for the Entity Object Class:EmployeeEOImpl.

In the Generate Methods region, check the Accessors, Create Method, ValidationMethod and Remove Method check boxes.

In the Generate page, deselect the Generate Default View Object check box (or, verifythat it is not selected).

Select the Finish button to create your EO.

6. Examine the generated EO files

In the Navigator, select and expand your entity object.

Note that there is an XML file, which holds any declarative information such as thenames of the included attributes.

Note also that there is an EmployeeEOImpl.java file that was generated because youchecked the Generate Java File check box in the EO wizard.

Select the EmployeeEOImpl.java file and choose Code Editor from the context menu(or doubleclick on the filename).

Note that EmployeeEOImpl.java contains stub methods for create, remove, andvalidateEntity, and the accessors (the set and getmethods). These were generated because you checked the corresponding check boxes inthe EO wizard.

7. Create an Employee-to-Manager Association (AO)Create an employee-to-manager association (AO) for the self-join condition on theFWK_TBX_EMPLOYEES table. Note that an employee must have a manager only if herassigned POSITION_CODE != "PRESIDENT". An employee may have, at most, 1manager. 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 Associationwizard.

In the Name page, specify EmpToMgrAO as the association's name and verify that thePackage is .oracle.apps.ak.schema.server.

Select the Next button.

Select * to 0..1 in the Cardinality poplist (yes, it's really this cardinality).

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 Properties page, verify that the Expose Accessor check box ischecked for both the Source and the Destination.

Select the Finish button to create your association.

8. Create an EmployeeSummaryVO View Object (VO)Create a summary-level view object including only those attributes that you need for theEmployees search results table. This view object is the main view object for the Search page lab.It should leverage the EmployeeEO and EmpToMgrAO that you just created.

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 ViewObject wizard.

In the Name page, specify EmployeeSummaryVO as the view object's name and verifythat 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 tothe Selected list twice (once for the employee, and once for the employee's manager).Tip: if you do not see your entity object, check the scrollbar at the bottom of the Available listand move the control over to the far left. You will then see expansion controls for the packagesdisplayed, and you should be able to find your EO.

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 shuttlethem to the Selected list:

From EmployeeEO:EmployeeIdFullName

From EmployeeEO1:EmployeeId (JDeveloper assigns this attribute the default name of EmployeeId1)FullName (JDeveloper assigns this attribute the default name of FullName1)

Select the Next button.

In the Attribute Settings page, select the FullName attribute using the Select Attributepoplist, set the Attribute Name field to be EmployeeName, and change the QueryColumn Alias field to be EMPLOYEE_NAME.

Now select the EmployeeId1 attribute in the Select Attribute poplist, set the AttributeName field to be ManagerId, and change the Query Column Alias field to beMANAGER_ID.

Now select the FullName1 attribute, set the Attribute Name field to be ManagerName,and change the Query Column Alias field to be MANAGER_NAME.

Select the Next button.

At this point the query should look like the following in the Query page (without theformatting we've used here to improve readability):SELECT EmployeeEO.EMPLOYEE_ID,EmployeeEO.FULL_NAME AS EMPLOYEE_NAME,EmployeeEO1.EMPLOYEE_ID AS MANAGER_ID,EmployeeEO1.FULL_NAME AS MANAGER_NAMEFROM FWK_TBX_EMPLOYEES EmployeeEO,FWK_TBX_EMPLOYEES EmployeeEO1WHERE EmployeeEO.MANAGER_ID = EmployeeEO1.EMPLOYEE_ID

Tip: Most of the BC4J wizards allow you to resize the wizard window, even though there maynot be visible resize controls. This is helpful for viewing long values and SQL statements.

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. Notethat you must add the outer join (+) operator to the MANAGER_ID / EMPLOYEE_ID join(as of OA Extension 9.0.3.8/OA Framework 11.5.10, this is not automatically derivedfrom the association). While you are here, switch the order of the EMPLOYEE_NAMEand MANAGER_ID lines (we are doing this to demonstrate attribute mappings). Theresulting query should look like the following:

SELECT EmployeeEO.EMPLOYEE_ID,EmployeeEO1.EMPLOYEE_ID AS MANAGER_ID,EmployeeEO.FULL_NAME AS EMPLOYEE_NAME,EmployeeEO1.FULL_NAME AS MANAGER_NAMEFROM FWK_TBX_EMPLOYEES EmployeeEO,FWK_TBX_EMPLOYEES EmployeeEO1WHERE EmployeeEO.MANAGER_ID = EmployeeEO1.EMPLOYEE_ID (+)

When you are finished with your editing, select the Test button to ensure your syntax iscorrect.

Select the Next button.

In the Attribute Mappings page, note that your view object attributes do not map to thecorrect query columns. To make these mappings correct, place your cursor into theincorrect View Attributes fields and select the correct values from the poplist.Tip: the icon with the red slash indicates a transient attribute instead of one derived from anentity object.

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). Doselect the Generate Java File for View Row Class: EmployeeSummaryVORowImpl tocomply 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 EditEmployeeSummaryVO... from the context menu to open the View Object wizard.

Navigate to the Attributes section for your attributes and verify that any aliases inyour 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.

9. Add Your View Object to the Root UI Application ModuleView objects can be used only within the context of a containing application module. Before youcan use the EmployeeSummaryVO in your page, you must add it to the page's root UIApplication 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 andshuttle it to the Data Model list.

Tip: Take careful note of the default View Instance name that BC4J creates when you add yourVO to the selected AM (BC4J creates this name by appending a "1" to your VO name). Leave itor change it, your choice (we suggest leaving the default value as is). In either case, know whatthe value is before creating your various regions.

Select the OK button to finish adding your VO to your AM.