D53979GC20_ag

386
Oracle Fusion Middleware 11g: Build Applications with ADF I Activity Guide D53979GC20 Edition 2.0 July 2010 D68162 Oracle University and Datum, S.A. De C.V. use only THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

description

fgdf

Transcript of D53979GC20_ag

Oracle Fusion Middleware 11g: Build Applications with ADF I Activity Guide D53979GC20 Edition 2.0 July 2010 D68162 Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates. All rights reserved. Disclaimer This document contains proprietary information and is protected by copyright and other intellectual property laws. You may copy and print this document solely for your own use in an Oracle training course. The document may not be modified or altered in any way. Except where your use constitutes "fair use" under copyright law, you may not use, share, download, upload, copy, print, display, perform, reproduce, publish, license, post, transmit, or distribute this document in whole or in part without the express authorization of Oracle. The information contained in this document is subject to change without notice. If you find any problems in the document, please report them in writing to: Oracle University, 500 Oracle Parkway, Redwood Shores, California 94065 USA. This document is not warranted to be error-free. Restricted Rights Notice If this documentation is delivered to the United States Government or anyone using the documentation on behalf of the United States Government, the following notice is applicable: U.S. GOVERNMENT RIGHTS The U.S. Governments rights to use, modify, reproduce, release, perform, display, or disclose these training materials are restricted by the terms of the applicable Oracle license agreement and/or the applicable U.S. Government contract. Trademark Notice Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners. Authors Kate Heap, Patrice Daux Technical Contributors and Reviewers Joe Greenwald, Glenn Maslen This book was published using:Oracle Tutor Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates. All rights reserved. Oracle Fusion Middleware 11g: Build Applications with ADF I Table of Contents i Table of Contents Practices for Lesson 1 .....................................................................................................................................1-1 Practices for Lesson 1: Introduction to Oracle Fusion and Oracle ADF .........................................................1-3 Practices for Lesson 2 .....................................................................................................................................2-1 Practices for Lesson 2: Getting Started with JDeveloper Discovering the Shopping Cart Application ........2-3 Practice 2-1: Setting IDE Preferences ............................................................................................................2-4 Practice 2-2: Creating a JDeveloper Application and Project .........................................................................2-6 Practice 2-3: Initializing the Project and Creating a Database Connection ....................................................2-8 Practice 2-4: Examining the Course Application ............................................................................................2-10 Practices for Lesson 3 .....................................................................................................................................3-1 Practices for Lesson 3: Building a Data Model with ADF Business Components ..........................................3-3 Practice 3-1: Creating Default Business Components ...................................................................................3-4 Practice 3-2: Testing the Business Model ......................................................................................................3-8 Practices for Lesson 4 .....................................................................................................................................4-1 Practices for Lesson 4: Querying and Persisting Data ...................................................................................4-3 Practice 4-1: Creating Read-Only View Objects.............................................................................................4-4 Practice 4-2: Creating Multiple Read-Only View Objects at Once ..................................................................4-7 Practice 4-3: Creating Entity Objects Based on Database Views...................................................................4-9 Practice 4-4: Creating Multiple Entity Objects at Once ...................................................................................4-11 Practice 4-5: Creating Associations ...............................................................................................................4-12 Practice 4-6: Creating Updatable View Objects .............................................................................................4-14 Practice 4-7: Refactoring Associations and Links ..........................................................................................4-17 Practices for Lesson 5 .....................................................................................................................................5-1 Practices for Lesson 5: Exposing Data to Clients ...........................................................................................5-3 Practice 5-1: Creating an Application Module to Display Categories .............................................................5-4 Practice 5-2: Creating an Application Module to Display the Shopping Cart ..................................................5-5 Practices for Lesson 6 .....................................................................................................................................6-1 Practices for Lesson 6: Declaratively Customizing Data Services .................................................................6-3 Practice 6-1: Defining Control Hints ...............................................................................................................6-4 Practice 6-2: Declaratively Populating a Primary Key with a Database Sequence.........................................6-7 Practice 6-3: Designating History Columns ....................................................................................................6-9 Practice 6-4: Creating and Using View Criteria ..............................................................................................6-12 Practice 6-5: Creating Join View Objects .......................................................................................................6-15 Practice 6-6: Creating LOVs ..........................................................................................................................6-18 Practices for Lesson 7 .....................................................................................................................................7-1 Practices for Lesson 7: Programmatically Customizing Data Services ..........................................................7-3 Practice 7-1: Adding Code to Entity Objects ..................................................................................................7-4 Practice 7-2: Programmatically Assigning a Database Sequence..................................................................7-7 Practice 7-3: Populating History Columns When There Is No Logged-in User ..............................................7-9 Practice 7-4: Creating and Running a Test Client ..........................................................................................7-11 Practice 7-5: Creating an Application Module Base Class .............................................................................7-14 Practice 7-6: Editing an Application Module to Extend the New Base Class ..................................................7-17 Practice 7-7: Adding and Exposing Service Methods .....................................................................................7-18 Practice 7-8: Restrict the Shopping Cart Query .............................................................................................7-21 Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates. All rights reserved. Oracle Fusion Middleware 11g: Build Applications with ADF I Table of Contents ii Practices for Lesson 8 .....................................................................................................................................8-1 Practices for Lesson 8: Validating User Input ................................................................................................8-3 Practice 8-1: Adding Declarative Validation: List Validator .............................................................................8-4 Practice 8 -2: Adding Declarative Validation: Unique Key Validator ...............................................................8-7 Practice 8-3: Adding Programmatic Validation: Method Validator ..................................................................8-9 Practice 8-4: Creating and Using a Domain for Validation .............................................................................8-12 Practice 8-5: Testing the Validation ................................................................................................................8-14 Practices for Lesson 9 .....................................................................................................................................9-1 Practices for Lesson 9: Troubleshooting ADF BC Applications ......................................................................9-3 Practice 9-1: Discovering Application Problems .............................................................................................9-4 Practice 9-2: Setting Breakpoints in the Debugger .........................................................................................9-5 Practice 9-3: Running the Application Module in Debug Mode ......................................................................9-7 Practices for Lesson 10 ...................................................................................................................................10-1 Practices for Lesson 10: Understanding UI Technologies ..............................................................................10-3 Practices for Lesson 11 ...................................................................................................................................11-1 Practices for Lesson 11: Binding UI Components to Data .............................................................................11-3 Practice 11-1: Creating Databound Pages .....................................................................................................11-4 Practice 11-2: Examining the Page's Data Bindings ......................................................................................11-8 Practice 11-3: Adding an Additional Detail Table ...........................................................................................11-11 Practice 11-4: Renaming a Page ...................................................................................................................11-13 Practices for Lesson 12 ...................................................................................................................................12-1 Practices for Lesson 12: Planning the User Interface ....................................................................................12-3 Practice 12-1: Creating an Unbounded Task Flow .........................................................................................12-4 Practice 12-2: Creating Bounded Task Flows ................................................................................................12-10 Practice 12-3: Extracting Part of a Task Flow ................................................................................................12-16 Practices for Lesson 13 ...................................................................................................................................13-1 Practices for Lesson 13: Adding Functionality to Pages ................................................................................13-3 Practice 13-1: Creating a Table with Row Selection ......................................................................................13-4 Practice 13-2: Creating a Search Page ..........................................................................................................13-10 Practice 13-3: Creating a Read-Only Form ....................................................................................................13-16 Practice 13-4: Creating a Sortable Table .......................................................................................................13-18 Practice 13-5: Creating a Category Tree ........................................................................................................13-20 Practice 13-6: Creating LOVs ........................................................................................................................13-24 Practice 13-7: Setting Up the UI Project for Internationalization ....................................................................13-28 Practices for Lesson 14 ...................................................................................................................................14-1 Practices for Lesson 14: Implementing Navigation on Pages ........................................................................14-3 Practice 14-1: Creating Buttons for Navigation ..............................................................................................14-4 Practice 14-2: Creating Links for Navigation ..................................................................................................14-9 Practice 14-3: Using Breadcrumbs .................................................................................................................14-18 Practice 14-4: Defining a Sequence of Steps .................................................................................................14-19 Practice 14-5: Simplifying and Enhancing a Task Flow ..................................................................................14-26 Practices for Lesson 15 ...................................................................................................................................15-1 Practices for Lesson 15: Achieving the Required Layout ...............................................................................15-3 Practice 15-1: Stretching Tables and Columns ..............................................................................................15-4 Practice 15-2: Adjusting JDeveloper's Default Layout Components ..............................................................15-6 Practice 15-3: Adding Layout Components to Existing Pages .......................................................................15-8 Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates. All rights reserved. Oracle Fusion Middleware 11g: Build Applications with ADF I Table of Contents iii Practice 15-4: Creating New Pages with Required Layout .............................................................................15-12 Practice 15-5: Setting Conditional Display .....................................................................................................15-20 Practice 15-6: Implement PPR to Coordinate Products Display with Selected Subcategory .........................15-25 Practices for Lesson 16 ...................................................................................................................................16-1 Practices for Lesson 16: Ensuring Reusability ...............................................................................................16-3 Practice 16-1: Converting Bounded Task Flows to Use Page Fragments ......................................................16-4 Practice 16-2: Creating a Page Template and Applying It to Existing Pages .................................................16-7 Practice 16-3: Creating a Page Template and Applying It to a New Page .....................................................16-13 Practice 16-4: Using Bounded Task Flows as a Region on a Page ...............................................................16-20 Practices for Lesson 17 ...................................................................................................................................17-1 Practices for Lesson 17: Passing Values Between UI Elements ....................................................................17-3 Practice 17-1: Conditional Rendering Based on Parameters .........................................................................17-4 Practice 17-2: Using Parameters for Dynamic Breadcrumbs .........................................................................17-11 Practice 17-3: Implementing the Add to Cart Functionality ............................................................................17-13 Practice 17-4: Implementing Create Supplier Functionality (Optional) ...........................................................17-17 Practices for Lesson 18 ...................................................................................................................................18-1 Practices for Lesson 18: Responding to Application Events ..........................................................................18-3 Practice 18-1: Defining Task Flow Parameters ..............................................................................................18-4 Practice 18-2: Creating a Helper Method to Evaluate EL ...............................................................................18-5 Practice 18-3: Creating the Producer (Payload) Method ................................................................................18-9 Practice 18-4: Initiating the Contextual Event ................................................................................................18-12 Practice 18-5: Creating the Consumer (Handler) Method ..............................................................................18-14 Practice 18-6: Mapping the Contextual Event ................................................................................................18-16 Practice 18-7: Passing Values Through Region Parameters .........................................................................18-19 Practice 18-8: Modifying the JSF Life Cycle (Optional Exercise) ...................................................................18-21 Practices for Lesson 19 ...................................................................................................................................19-1 Practices for Lesson 19: Implementing Transactional Capabilities ................................................................19-3 Practice 19-1: Saving the Shopping Cart .......................................................................................................19-4 Practice 19-2: Updating, Deleting, and Displaying Details of Shopping Cart Items ........................................19-5 Practice 19-3: Controlling Transactions in the CheckoutFlow ........................................................................19-12 Practice 19-4: Adding CRUD Functionality for Suppliers (Optional Exercise) ................................................19-13 Practices for Lesson 20 ...................................................................................................................................20-1 Practices for Lesson 20: Implementing Security in ADF BC Applications ......................................................20-3 Practice 20-1: Configuring the Application to Use ADF Security ....................................................................20-4 Practice 20-2: Defining Users in the Identity Store .........................................................................................20-7 Practice 20-3: Defining Enterprise Roles .......................................................................................................20-8 Practice 20-4: Implementing Security on Task Flows and Pages...................................................................20-11 Practice 20-5: Testing Application Authentication and Authorization .............................................................20-13 Practice 20-6: Implementing Entity Object Security .......................................................................................20-15 Practice 20-7: Testing Entity Object Security .................................................................................................20-17 Practice 20-8: Accessing Security Context Programmatically ........................................................................20-18 Practice 20-9: Conditionally Displaying a Component Based on User Role ...................................................20-20 Practice 20-10: Modifying the Hard-Coded Username to Use the API ...........................................................20-23 Practices for Appendix A ................................................................................................................................21-1 Practices for Appendix A ................................................................................................................................21-3 Practice A-1: Creating a Database Diagram with Existing Schema Objects ..................................................21-4 Practice A-2: Adding New Schema Objects ...................................................................................................21-8 Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates. All rights reserved. Oracle Fusion Middleware 11g: Build Applications with ADF I Table of Contents iv Practices for Appendix B ................................................................................................................................22-1 Practices for Appendix B: Deploying ADF BC Applications ............................................................................22-3 Practice B-1: Creating Deployment Profiles ...................................................................................................22-4 Practice B-2: Using a WebLogic Server Data Source ....................................................................................22-6 Practice B-3: Creating an Application Server Connection ..............................................................................22-9 Practice B-4: Deploying the Application from JDeveloper ..............................................................................22-10 Practice B-5: Deploying the Application from the WebLogic Server Administration Console .........................22-12 Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 1 Chapter 1 - Page 1 Practices for Lesson 1 Chapter 1 Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 1 Chapter 1 - Page 2 Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 1 Chapter 1 - Page 3 Practices for Lesson 1: Introduction to Oracle Fusion and Oracle ADF There is no practice for this lesson. Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 1 Chapter 1 - Page 4 Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 2 Chapter 2 - Page 1 Practices for Lesson 2 Chapter 2 Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 2 Chapter 2 - Page 2 Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 2 Chapter 2 - Page 3 Practices for Lesson 2: Getting Started with JDeveloper Discovering the Shopping Cart Application Practices Overview In the practices for this lesson, you start JDeveloper, set preferences for the IDE, and create a JDeveloper application, project, and database connection. You then view the course application in a browser and identify the functionality of the pages. Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 2 Chapter 2 - Page 4 Practice 2-1: Setting IDE Preferences In this practice, you start JDeveloper and set general preferences on the IDE. 1.Start JDeveloper, using the Default role. a.Double-click the desktop shortcut to start JDeveloper. b.In the Select Role dialog box, select the Default Role option and click OK. c.In the Migrate User Settings dialog box, click No. d.JDeveloper starts by displaying the Tip of the Day. Deselect the Show tips at startup check box, and then click Close. e.Close the Start page by clicking the X at the right of its tab. (The X is not visible until you position the cursor over the tab.) 2.Set the global naming preferences for your ADF BC objects. Entity objects, view objects, and application modules should, by default, have the suffixes EO, VO, and AM, respectively, and should be created in the entity, uiview, and module packages, respectively. a.From the JDeveloper menu, select Tools > Preferences > Business Components > Object Naming.b.In the dialog box, set suffixes as follows: Entity EO View Object VO Application Module AM c.Select Packages in the list at the left and set the following values: Entity entity View Object uiview Application Module module Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 2 Chapter 2 - Page 5 d.Click OK. Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 2 Chapter 2 - Page 6 Practice 2-2: Creating a JDeveloper Application and Project In this practice, you begin developing the Storefront application by creating an application and project. 1.Create an application named Storefront in the oracle.fod.storefront package. Do not use an application template. Create the initial project with the name StorefrontModel. a.In the Application Navigator, click the New Application link.b.On the Name page of the Create Application Wizard: 1)Enter Storefront as the application name. 2)Enter oracle.fod.storefront as the application package prefix. 3)Select Generic Application as the Application Template. 4)Click Next. a.On the Name your project page of the wizard:1)Enter StorefrontModel as the project name.2)On the Project Technologies tab, shuttle ADF Business Components and Database (Offline) from the Available list to the Selected list. (This also selects the Java technology.) 3)Click Finish.b.Note that the Application Navigator displays your application and project. c.Also, note that the application overview page, Storefront Overview, is open in the editor. This page enables you to see all the aspects of your application at a glance, to obtain related help, and to create new objects. You can spend some time exploring this overview if you want to, but it is not used in these practices.Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 2 Chapter 2 - Page 7 When you have finished looking at the overview, close it by clicking the X on its tab. (The X is not visible until you move the cursor over the tab.) If you want to display it again, right-click a project and select Show Overview. Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 2 Chapter 2 - Page 8 Practice 2-3: Initializing the Project and Creating a Database Connection In this practice, you initialize the StorefrontModel project for business components. In the process of doing so, you create a database connection to use for the business components. You also add any libraries that it requires. 1.Initialize the StorefrontModel project for business components. This requires a database connection, so create that as part of this initialization. a.Double-click the StorefrontModel project (or right-click it and select Project Properties). b.In the Project Properties dialog box, select Business Components from the tree at the left.c.In the Business Components panel, select the Initialize Project for Business Components check box. d.Click Create a new database connection to the right of the Connection field.e.In the Create Database Connection dialog box: 1)Supply the information in the table below. Connection Name FOD Connection Type Oracle (JDBC) Usernamefod (or follow the instructions given by your instructor if you are using a shared database) Password fusionSave PasswordSelect the check box. 2)In the lower half of the page, Oracle (JDBC) Settings, leave the Driver field at its default, thin, and enter the Host Name, JDBC Port, and SID as given to you by the instructor if using a shared database, or localhost, 1521, and XE if using a local XE database. 3)Click Test Connection. You should see that the Status box displays the word Success!. Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 2 Chapter 2 - Page 9 f.Click OK to dismiss the Create Database Connection dialog box and return to the Business Components page of the Project Properties dialog box. g.Click OK to set the project properties and dismiss the Project Properties dialog box. h.Click Save All to save your work. You should get into the habit of frequently saving your work. Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 2 Chapter 2 - Page 10 Practice 2-4: Examining the Course Application In this practice, you run the completed application and explore its functionality. 1.Open the Storefront-CompletedApp application in JDeveloper. There are several ways to open an application. a.If there is no open application currently, you can click the Open Application link in the Application Navigator OR if there is an open application, you can invoke the drop-down application list by clicking the down arrow at the right of the application name in the Application Navigator, and then selecting Open Application OR click Open on the JDeveloper menu toolbar OR select File > Open from the JDeveloper main menu. b.When you select to open a new application, a file dialog box enables you to navigate to the directory where the application resides:1)Navigate to your courses \Labs directory and open the Storefront-CompletedApp folder. 2)Select Storefront-CompletedApp.jws and click Open. Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 2 Chapter 2 - Page 11 The application opens in the Application Navigator. If requested to migrate the application, execute the necessary steps to perform the operation. 2.Open the main task flow for the application, which is adfc-config. a.The application contains two projects that are displayed on the first level of the applications hierarchy. Expand the StorefrontUI node. b.In the StorefrontUI project, expand the Web Content and Page Flows nodes. c.Double-click adfc-config to open it in the editor. 3.When a task flow opens in the editor, you will see a Thumbnail tab to the left of the editor, below the Application Navigator. Click the Thumbnail tab, and then drag the viewport rectangle so that the view activities are visible in the editor. Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 2 Chapter 2 - Page 12 4.Examine the connection information and change it if necessary to point to your database. a.Right-click the StorefrontModel project and select Project Properties. (You can also double-click StorefrontModel to display the Project Properties Editor.) b.Select Business Components in the tree at the left.c.Next to Connection, click Edit.d.Edit the connection information to your database connection (FOD) (see Practice 2-3, step 1(e)).e.Test the connection, and if successful, click OK.f.Click OK to close the Project Properties Editor and save the settings. 5.To run the application, in the adfc-config diagram, right-click the FODShoppingDashboard view and select Run. Test the functionality of the shopping application. a.JDeveloper starts an integrated Oracle WebLogic Server, deploys the application to it, and runs the requested page in a browser. A tree of categories appears at the left, with a table of categories and descriptions at the right. In the tree, expand the Media category and click the Music subcategory. b.A list of Music products appears in the right panel. Note that there are breadcrumbs along the top of the table that enable you to navigate to the Media subcategory, or to the main-level list of categories if you click Store. For now, click the name of one of the products. Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 2 Chapter 2 - Page 13 c.Details about the selected product are shown. Buttons enable you to add the item to your cart, to search for products, or to return to the shopping page. For now, click Search. d.On the Search page, enter Pla in the ProductName field and click Search. A list of products beginning with Pla is returned. e.Click the Playstation Portable link to display details about this product. Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 2 Chapter 2 - Page 14 f.Click Add Item to Cart to add the Playstation Portable to the shopping cart and display the cart. g.The shopping cart is displayed. It is populated with the shopping cart items of a default user, and the Playstation Portable has been added. Resize the right panel of the page so that the line total is visible, and then change the quantity of the Playstation Portable to 2. Click Update to show the updated line total. h.With the Playstation Portable selected, click Delete to remove it from your cart. i.Click Details to display details about the selected product in a separate pop-up window. j.Click OK to close the pop-up window, and then click Checkout to begin the checkout process.Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 2 Chapter 2 - Page 15 k.The first page of the checkout process displays the shipping information. Navigate to the next page either by clicking Next or by clicking the Billing train stop at the top of the panel. l.The second page of the checkout process displays the billing information. Navigate to the next page either by clicking Next or by clicking the Confirmation train stop at the top of the panel. Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 2 Chapter 2 - Page 16 m.The final page of the checkout process displays all the informationshipping, billing, and order items. Click Submit to submit the order and return to the shopping page.Note: The Submit button does not actually do anything except perform navigation, but in a complete application, it could fire off some additional services, such as creating an order in the database, sending information about the order to the shipping department and the billing department, and sending an email confirmation to the customer. This functionality is outside the scope of the course application. 6.Test the functionality of managing suppliers. a.Click the Suppliers tab in the left panel of the page. b.The page displays a list of suppliers. Click New Supplier. Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 2 Chapter 2 - Page 17 c.The New Supplier page initializes. Enter any supplier name and select a supplier status from the drop-down list, and then click Save. d.The new row appears at the top of the list, with a supplier ID that is automatically assigned. Click Delete to delete the supplier. e.Click the SupplierId of one of the suppliers in the list.f.On the Update Supplier page, change the Status of the supplier and click Save. g.The supplier is shown in the list with the updated status. h.Close the browser when you have finished.i.To make the application start a little faster the next time you run it, you can undeploy the application:1)Select View > Run Manager. Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 2 Chapter 2 - Page 18 2)In the Run Manager window, select Storefront-CompletedApp (Running on IntegratedWebLogicServer), and then click the red square to undeploy. Another way to undeploy the application is to click Terminate in the JDeveloper menu toolbar, and then select the application to undeploy. j.The application is undeployed when the log window displays the message: [Application Storefront-CompletedApp stopped and undeployed from Server Instance Instance IntegratedWebLogicServer]. 7.Close the Storefront-CompletedApp application. You should continue to work in the Storefront application that you created. a.Invoke the application menu by clicking the right-most down arrow at the top of the Application Navigator. b.Select Close Application from the IDE. Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 3 Chapter 3 - Page 1 Practices for Lesson 3 Chapter 3 Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 3 Chapter 3 - Page 2 Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 3 Chapter 3 - Page 3 Practices for Lesson 3: Building a Data Model with ADF Business Components Practices Overview This exercise is to familiarize you with the default capabilities of JDeveloper and ADF Business Components. In this practice, you create a business model by using the wizards that are built into JDeveloper. You see how to build a default model without any coding. In subsequent lessons and practices, you learn to build and customize components to meet your specific application requirements. If you successfully completed all sections of the previous practice, you can continue working in the same project. However, if you prefer to start with a clean application that contains everything completed up to the start of this lesson, open Storefront-03.jws and edit the database information as described in step 4 of Practice 2-4. Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 3 Chapter 3 - Page 4 Practice 3-1: Creating Default Business Components In this practice, you create some default business components that compose part of the business model for the Storefront application. In the practices for subsequent lessons, you create more customized business components and refine the default components as well. 1.Invoke the Business Components Wizard. a.Right-click the StorefrontModel project in the Application Navigator and select New.b.Select Business Tier > ADF Business Components in the Categories list. c.Select Business Components from Tables in the Items list. d.Click OK. 2.In the Create Business Components from Tables Wizard, create entity objects for the ORDERS, ORDER_ITEMS, and PERSONS tables. Name them OrderEO, OrderItemEO, and PersonEO. a.On the Entity Objects page of the wizard, ensure that the schema from the connection that you created previously is the selected schema. b.Ensure that the package name is oracle.fod.storefront.entity. c.Enter ORD in the Name Filter field. Click Query to see the available tables (ORDERS and ORDER_ITEMS). d.Click Add All to move both tables to the Selected pane. Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 3 Chapter 3 - Page 5 e.Select ORDERS in the Selected pane and change the Entity Name to OrderEO (instead of OrdersEO). f.Similarly, change the Entity Name of OrderItemsEO to OrderItemEO. g.Set the Name Filter to % and click Query to show all the available tables. If you were creating several more entity objects, you could multiselect any tables for which you want to create EOs and shuttle them to the Selected pane at the same time. For now, just create one additional EO, PersonEO, based on the PERSONS table. Be sure to change the default name of the entity object. h.Click Next. 3.Continuing in the Create Business Components from Tables Wizard, create the following updatable view objects (do not create any read-only view objects at this time): VO Basedon ShoppingCartVO OrderEO ShoppingCartItemVO OrderItemEO a.On the Updatable View Objects page of the wizard, ensure that the package name is oracle.fod.storefront.uiview. b.Ctrl-click to select the OrderEO and OrderItemEO entities. c.Click Add to move the selected items to the Selected list.d.Rename OrderVO by selecting it in the Selected pane and changing the Object Name to ShoppingCartVO. The reason for this is that you are creating a model for a shopping application, where an order is represented as a customers shopping cart. Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 3 Chapter 3 - Page 6 e.Similarly, rename OrderItemVO to ShoppingCartItemVO. f.Click Next. g.The next page is for creating read-only view objects. These are based on SQL queries rather than on entity objects. For now, you will not create read-only VOs, so click Next.4.Continuing in the Create Business Components from Tables Wizard, create an application module to provide access to your components. You will later create application modules that are customized for your application, but you can use a default application module for testing your components. Create an application module named TestAM in the oracle.fod.storefront.test package.a.On the Application Module page of the wizard, ensure that the Application Module check box is selected. b.To separate this test application module from those that you customize for the Storefront application, change the package name to oracle.fod.storefront.test. c.Change the application module name to TestAM. d.Click Next. 5.Complete the wizard to finish creating the business components. Do not create a business components diagram. a.On the Diagram page of the wizard, ensure that the Business Components Diagram check box is not selected. b.Click Next. Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 3 Chapter 3 - Page 7 c.The last page of the wizard shows the components that you have chosen to create. It should show the following components to be created: d.Click Finish to create the business components. This may take a few moments. e.Click Save All to save your work. f.The StorefrontModel project in the Applications Navigator should look like this: Note that the wizard created not only EOs, VOs, and an AM, but also two associations and a view link based on the foreign key relationships that are defined in the database. Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 3 Chapter 3 - Page 8 Practice 3-2: Testing the Business Model In this practice, you examine and test the components you just created. 1.Use the editor to examine the OrderEO entity object. a.In the Applications Navigator, double-click the OrderEO entity to open the entity in the editor. b.Click the Attributes tab or panel to see the attributes. From this view, you can double-click any of the attributes to open the Attribute Editor. c.Each of the other panels (General, Business Rules, Java, Business Events, and View Accessors) shows different aspects of the OrderEO entity. Click and examine each panel. d.Click the Source tab at the bottom of the editor to view and examine the XML source. 2.Test the default components by running the application module in the Business Components Browser. a.In the Application Navigator, right-click the application module (TestAM) in the oracle.fod.storefront.test package and select Run. b.The Business Components Browser may take a few minutes to appear, and it may appear behind other windows. You can click its iconon the taskbar to display it. The Browser should initially look similar to the following (the objects can be in a different order): c.Under the ShoppingCart1 node, double-click the OrderItemsOrdersFkLink1 to open a page that shows the order items that belong to an order. Because this is a shopping application, an order is contained in a shopping cart and order items are referred to as shopping cart items. Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 3 Chapter 3 - Page 9 d.In the top portion of the page, click Move to the next row to navigate through rows in the Orders view. Note that the order items change as you move to a new order. e.Open the other views and examine the contents as you choose. f.When you have finished, close the Business Components Browser.Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 3 Chapter 3 - Page 10 Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 4 Chapter 4 - Page 1 Practices for Lesson 4 Chapter 4 Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 4 Chapter 4 - Page 2 Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 4 Chapter 4 - Page 3 Practices for Lesson 4: Querying and Persisting Data Practices Overview In the previous set of practices, you used the Create Business Components from Tables Wizard to create multiple types of objects at once. You performed some limited customization of components as enabled by the wizard, such as changing default names and locations. Now you begin to create components that are more customized for your application. First you determine the LOVs that your application requires, and you create read-only view objects to support those LOVs. Next you create entity objects for tables that the application will update, and you also create updatable view objects based on these. You also create and refactor associations and view links. For now, you place all of the view objects and links in the TestAM application module so that you can test them; in the next set of practices, you create custom application modules that are designed for your application. If you successfully completed all sections of the previous practice, you can continue working in the same project. However, if you prefer to start with a clean application that contains everything completed up to the start of this lesson, open Storefront-04.jws and edit the database information as described in step 4 of Practice 2-4. This practice contains some optional steps that are similar to steps already done. If you want to build the entire application yourself, you can complete the optional steps. However, in the interest of time, you may want to skip them. If you do so, you must begin the practices for the next lesson by opening the starter application for that lesson. Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 4 Chapter 4 - Page 4 Practice 4-1: Creating Read-Only View ObjectsMost of the view objects in your application are required for updating information. However, some view objects exist only to provide data for lists of values. In this practice, you createread-only view objects to support LOVs. Because these read-only view objects are based on SQL queries, you do not require an existing entity object on which to base them. You create them by using either of two wizards: Create View Object Wizard: Creates view objects individually; you must write the query Business Components from Tables Wizard: Creates multiple view objects at once; you select the table for the query that is automatically generated 1.Create a single read-only view object to query the LOOKUP_CODES table by using a bind variable for LOOKUP_TYPE. Name the view object LookupCodeVVO. Create it in the oracle.fod.storefront.view package. Put the view object in your TestAM application module. Use the following query statement for the VO: (You can copy the code from LookupCodes.txt in the \files subdirectory of your \labs directory for this course.) SELECTLOOKUP_CODES.LOOKUP_TYPE LOOKUP_TYPE,LOOKUP_CODES.LOOKUP_CODE LOOKUP_CODE,LOOKUP_CODES.MEANING MEANING,LOOKUP_CODES.DESCRIPTION DESCRIPTION,LOOKUP_CODES.LANGUAGE LANGUAGEFROMLOOKUP_CODESWHERELOOKUP_CODES.LANGUAGE = SYS_CONTEXT('USERENV', 'LANG') AND LOOKUP_CODES.LOOKUP_TYPE = :BindLookupType a.In the Application Navigator, right-click the StorefrontModel project and select New from the context menu. b.In the New Gallery, expand the Business Tier node in the Categories list and select ADF Business Components. Select View Object in the Items list and click OK. c.On the Name page of the Create View Object Wizard: 1)Change the package name to oracle.fod.storefront.view and enter LookupCodeVVO as the view object name. (Note that the suffix is VVO rather than VO that you used for the updatable view objects, and that you are placing the read-only VOs in a separate package.) Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 4 Chapter 4 - Page 5 2)Specify that the view object should have Read-only access through SQL query. 3)Click Next. d.On the Query page of the wizard: 1)Enter the query statement shown in step 1. (You can copy from LookupCodes.txt, or click Query Builder to build the query if desired, but make sure that the finished query is as shown above.) 2)Click Test to verify that the query is valid. 3)Click Next. e.On the Bind Variables page of the wizard: 1)Click New.2)On the Variable tab in the lower section of the page, enter BindLookupType as the name for the variable, leaving all other values at their defaults. 3)Click Next. f.Continue clicking Next until you reach the Application Module page:1)Select the Application Module check box.2)Click Browse next to the Package field. 3)Click the Hierarchy tab in Package Browser and browse to and select the oracle > fod > storefront > test package. Click OK. Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 4 Chapter 4 - Page 6 4)If the Name field is not automatically populated with TestAM: a)Click Browse next to the Name field. b)In the Select Parent dialog box, expand oracle > fod > storefront > test. c)Select the TestAM application module to enable you to test the query. 5)Click Finish to create the view object. The Application Navigator should look similar to the following screenshot: g.Save your work. 2.Test the query: a.Run TestAM as you did previously. b.In the Business Components Browser, double-click the LookupCodeV1 node. c.In the Bind Variables dialog box, enter a Value such as SHIPPING_CLASS_CODE and click OK. d.Navigate through the rows to see all the payment type codes. Note that all fields are disabled, because this view object is read-only. e.Click Edit Bind Variables to invoke the Bind Variables dialog box to modify the value. You can enter different values for bind variables to test whatever lookup codes you want to check from the following lookup types: SHIPPING_CLASS_CODEUSAGE_TYPE_CODECONTACT_METHOD_CODEPRODUCT_STATUS_CODE OWNER_TYPE_CODEPERSON_TITLE_CODE DISCOUNT_TYPE_CODECARD_TYPE_CODE PERSON_TYPE_CODEMEMBERSHIP_TYPE_CODE GENDER_CODEORDER_STATUS_CODE MARITAL_STATUS_CODEID_TYPE_CODE VERIFICATION_METHOD_CODESUPPLIER_STATUS_CODE PAYMENT_TYPE_CODE f.When you have finished testing, close the Business Components Browser. Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 4 Chapter 4 - Page 7 Practice 4-2: Creating Multiple Read-Only View Objects at Once In this practice, you use the Create Business Components from Tables Wizard to create multiple read-only view objects at once. 1.Create the following read-only view objects (note the VVO suffix) in the oracle.fod.storefront.view package: Query Table or ViewVO COUNTRY_CODESCountryVVO PERSONSCustomerVVO PAYMENT_OPTIONS (optional) PaymentOptionVVO PRODUCTS (optional) ProductVVO WAREHOUSES (optional) WarehouseVVO Note: Creating all of these view objects is optional. You can create them all if you want to, but you may choose to create only the first two. If you create only a subset of the objects, you must begin the practices for the next lesson by opening the starter application. a.As you did in Practice 3-1, step (1), invoke the Create Business Components from Tables Wizard.b.Click Next to navigate to the Read-Only View Objects page of the wizard: 1)Set the package name to oracle.fod.storefront.view. 2)Select your schema (FOD) from the drop-down list. 3)Use the Name Filter, or simply click Query, to find and select the tables and views shown above and modify the name in each case as before (note the VVO suffix). 4)Click Next. Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 4 Chapter 4 - Page 8 c.On the Application Module page of the wizard, place the view objects in your application module as you did before by using the Browse buttons to navigate to, and select the proper package (test) and application module (TestAM). d.Click Finish to create the view objects. e.Save your work. The Application Navigator should look like this: Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 4 Chapter 4 - Page 9 Practice 4-3: Creating Entity Objects Based on Database Views Although it is easy to create multiple EOs at once with the Create Business Components from Tables Wizard, there are cases where you may want to use the Create Entity Object Wizard to create EOs individually, because that enables a greater degree of customization at the time of creation.This application has some EOs that are based on database views, and it is necessary to designate a primary key for such EOs. You can do that with the Create Entity Object Wizard. In this practice, you create several database viewbased entity objects and designate their primary keys.1.Create an entity object named ProductCategoryEO and base it on the Product_Categories database view. Set the CategoryId to be its primary key. a.To invoke the Entity Object Wizard, you could use the New Gallery. However, there is an even easier way to invoke the wizards: 1)In the Application Navigator, expand the StorefrontModel project.2)Expand the Application Sources and oracle.fod.storefront nodes.3)Right-click the entity node and select New Entity Object. b.On the Name page of the Create Entity Object Wizard: 1)Ensure that oracle.fod.storefront.entity is the package name.2)Enter ProductCategoryEO as the entity object name.3)Ensure that the Database Schema Object option is selected and that the database schema is FOD.4)Click Browse to the right of the Schema Object field. a)In the Select Schema Object dialog box, select the Views object type and deselect Tables.b)Click Query. c)In the list of schema objects, select PRODUCT_CATEGORIES. Note that you cannot multiselect more than one schema object, because you are creating only one entity object with this wizard. d)Click OK.5)If the schema object is not automatically populated in the field, enter PRODUCT_CATEGORIES. Click Next.c.On the Attributes page, click Next to accept all columns. This wizard enables you to remove or add attributes if necessary. d.On the Attribute Settings page: 1)Select CategoryId from the Select Attribute drop-down list.2)Select the Primary Key check box. 3)Click Finish to create your ProductCategoryEO entity object.Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 4 Chapter 4 - Page 10 2.Optional step (If you choose not to create these objects, you must begin the practices for the next lesson by opening the starter application.) Similarly, create the following entity objects that are based on database views: EOBased on Database ViewPrimary Key PersonInformationEOPERSON_INFORMATIONCustomerId ProductEOPRODUCTSProductId Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 4 Chapter 4 - Page 11 Practice 4-4: Creating Multiple Entity Objects at Once You can create entity objects individually as above, but it is much quicker to create multiple entity objects if you do not have to specify the columns to include or change attribute settings (such as setting the primary key). In this practice, you create the remaining entity objects at once by using the Business Components from Tables Wizard. 1.Create the following entity objects that are based on tables: EO Basedon AddressEO ADDRESSES AddressUsageEO ADDRESS_USAGES CountryEO COUNTRY_CODES LookupCodeEO LOOKUP_CODES PaymentOptionEO PAYMENT_OPTIONS SupplierEO SUPPLIERS WarehouseEO WAREHOUSES WarehouseStockLevelEOWAREHOUSE_STOCK_LEVELS Note: Creating all of these entity objects is optional. You can create them all if you want to, but you may choose to create only the first two. If you create only a subset of the objects, you must begin the practices for the next lesson by opening the starter application. a.In the Application Navigator, right-click the oracle.fod.storefront.entity package, and select New Business Components from Tables. b.On the Entity Objects page of the Business Components from Tables Wizard, check whether the package name is oracle.fod.storefront.entity and the schema is FOD. Click Query. c.As you did in an earlier practice, Ctrl-click to select multiple tables for which to create entity objects, and rename the entity objects, according to the table shown above. d.Click Finish to create the entity objects.Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 4 Chapter 4 - Page 12 Practice 4-5: Creating Associations When you use the Business Components from Tables Wizard to create entity objects, database foreign keys are used to automatically generate associations. However, there are some additional associations that you must create for the EOs that are based on database views, and others that you must create where there are no foreign keys. In this practice, you create these additional associations. 1.Create an association that relates CategoryId of the ProductCategoryEO entity object to ParentCategoryId of the same entity object. Name the association ProductCategoriesSubProductCategoriesAssoc.a.Right-click the oracle.fod.storefront.entity package and select New Association. b.On the Name page of the Create Association Wizard: 1)Ensure that the package is oracle.fod.storefront.entity. 2)Enter a name of ProductCategoriesSubProductCategoriesAssoc.3)Click Next. c.On the Entity Objects page of the wizard: 1)Expand ProductCategoryEO in the Select Source Attribute list and select the CategoryId attribute. 2)Expand ProductCategoryEO in the Select Destination Attribute list and select the ParentCategoryId attribute. 3)Click Add, and then click Next. d.On the Association Properties page of the wizard: 1)Leave the check boxes selected in both Source Accessor and Destination Accessor sections.2)Click Next, and then click Finish. Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 4 Chapter 4 - Page 13 2.Optional step (If you choose not to create these associations, you must begin the practices for the next lesson by opening the starter application.)In a similar manner, create the following additional associations, with accessors in both source and destination (leave both check boxes selected): Name Source Destination OrdersOrderItemsAssocOrderEO.OrderIdOrderItemEO.OrderId ProductCategoriesProductsAssoc ProductCategoryEO.CategoryId ProductEO.CategoryId3.Optional step (If you choose not to create this association, you must begin the practices for the next lesson by opening the starter application.)In a similar manner, create an association named OrderItemsProductsAssoc between the ProductId fields of the OrderItemEO and ProductEO entity objects. The application needs to access the product for a particular order item, but never needs to access order items that pertain to a particular product, so expose accessors only in the destination entity for this association. (Deselect the check box in the Source Accessor section.) 4.Save your work. Including the optional steps, the entity package in the Application Navigator should now look like this: Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 4 Chapter 4 - Page 14 Practice 4-6: Creating Updatable View Objects In this practice, you create updatable view objects based on some of the entity objects you created in previous practices. Because you are creating view objects that are based on existing entity objects, you must use the Create View Object Wizard.In the application that you are building, the user interface displays categories and subcategories. To accomplish this, the model requires two view objects: one that displays the root categories (those without a parent category), and another that displays the subcategories. A view link is also required to set up this master-detail relationship. 1.In the oracle.fod.storefront.uiview package, create two view objects that are based on ProductCategoryEO: RootCategoryVO for those rows whose ParentCategoryId is null, and SubCategoryVO. Place the view objects in your TestAM application module. a.In the Application Navigator, right-click the oracle.fod.storefront.uiview package and select New View Object from the context menu. b.On the Name page of the Create View Object Wizard: 1)Ensure that the package is oracle.fod.storefront.uiview. 2)Enter RootCategoryVO as the view object name. 3)Select the Updatable access through entity objects option.4)Click Next.c.On the Entity Objects page: 1)Expand the oracle.fod.storefront.entity package node.2)Shuttle ProductCategoryEO into the Selected pane.3)Click Next. d.On the Attributes page: 1)Click Add All to shuttle all attributes into the Selected pane. 2)Click Next. e.On the Attribute Settings page, click Next. Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 4 Chapter 4 - Page 15 f.On the Query page: 1)Add the following WHERE clause: ProductCategoryEO.PARENT_CATEGORY_ID IS NULL 2)Click Test to ensure that the query is valid, and click OK to acknowledge the message. 3)Click Next.g.Navigate through the subsequent pages until you reach the Application Module page: 1)Add the view object to the TestAM application module as you have been doing.2)Click Finish to create the updatable view object. h.Similarly, create the SubCategoryVO view object based on the same ProductCategoryEO entity object, with all attributes.1) Use the following WHERE clause: ProductCategoryEO.PARENT_CATEGORY_ID IS NOT NULLPlace the view object in your TestAM application module. 2.The two view objects that you just created should be related by ProductCategoriesSubProductCategoriesAssoc in a view link named RootCategoriesSubCategoriesLink. Create this view link. a.Right-click the oracle.fod.storefront.uiview package and select New View Link. b.On the Name page of the Create View Link Wizard, enter a name of RootCategoriesSubCategoriesLink, and then click Next. c.From the Select Source Attribute list, select oracle.fod.storefront.uiview > RootCategoryVO > ProductCategoriesSubProductCategoriesAssoc. d.From the Select Destination Attribute list, select oracle.fod.storefront.uiview> SubCategoryVO > ProductCategoriesSubProductCategoriesAssoc. Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 4 Chapter 4 - Page 16 e.Click Add. f.Click Next several times until you reach the Application Module page. Select the Application Module check box and browse to select the TestAM application module in the oracle.fod.storefront.test package. Click Finish to create the view link. 3.Optional step (If you choose not to create this object, you must begin the practices for the next lesson by opening the starter application.)Similarly, create one more updatable view object named SupplierVO in the oracle.fod.storefront.uiview package. Base it on SupplierEO, including all attributes. Do not include a WHERE clause. Add the view object to the TestAM application module. 4.Save your work, and then test the view objects and view link that you just created.a.Run TestAM as before. b.Check whether the RootCategory1 view object instance displays the data you expect (only those categories without a ParentCategoryId should display). c.Check whether the SubCategory1 view object instance displays the data you expect (only those categories with a ParentCategoryId). d.Test that RootCategoriesSubCategoriesLink displays the master-detail relationship between root categories and subcategories, similar to the following: e.Close the Business Components Browser when you have finished testing. Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 4 Chapter 4 - Page 17 Practice 4-7: Refactoring Associations and Links If you inadvertently create objects in the wrong package, or if you want to reorganize the created objects into different packages, you can use refactoring. In this practice, you move existing associations and links into a separate package. 1.Move all associations into the oracle.fod.storefront.assoc package. a.In the Application Navigator, multiselect (Ctrl-click) all associations in the oracle.fod.storefront.entity package. b.Right-click and select Refactor > Move. Note that depending on the optional steps you have or have not done, your application might look different from the following images. c.In the Move Business Components dialog box, enter the Package name of oracle.fod.storefront.assoc and click OK. d.Confirm that you would like to create the package by clicking Yes. Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 4 Chapter 4 - Page 18 e.JDeveloper creates the assoc package and moves the associations into it. This may take several minutes. 2.In a similar manner, move all view links into the oracle.fod.storefront.link package. Refactor links in both the uiview and the view packages. 3.Test the application module to ensure that all view links still function correctly.Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 5 Chapter 5 - Page 1 Practices for Lesson 5 Chapter 5 Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 5 Chapter 5 - Page 2 Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 5 Chapter 5 - Page 3 Practices for Lesson 5: Exposing Data to Clients Practices Overview In this practice, you take some of the view objects you have created and add them to application modules. You create two application modules in this practice. The first application module displays categories and subcategories. The second application module is for displaying and managing a customers shopping cart.In the interest of time, you create only two of the five application modules that are required for the Storefront application, although you have the knowledge to create all five. When you begin to develop the user interface, you will start with a completed model with all the objects and application modules that you require. If you successfully completed all sections of the previous practice, including the optional steps, you can continue working in the same project. However, if you prefer to start with a clean application that contains everything completed up to the start of this lesson, open Storefront-05.jws and edit the database information as described in step 4 of Practice 2-4. Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 5 Chapter 5 - Page 4 Practice 5-1: Creating an Application Module to Display Categories In this practice, you create the application module to display categories. It contains the two VOs that are based on ProductCategoryEO and the view link that establishes a master-detail relationship between root categories and subcategories.1.Create an application module named FODCategoryAM and put it in the oracle.fod.storefront.module package. It should contain RootCategoryVO and also the VO for the subcategories, accessed through the view link. a.Right-click the oracle.fod.storefront package and select New Application Module. b.On the Name page of the Create Application Module Wizard, ensure that the package name is oracle.fod.storefront.module. Enter the name FODCategoryAM and click Next. c.On the Data Model page, in the Available View Objects pane, expand oracle.fod.storefront.uiview and RootCategoryVO. d.Select RootCategoryVO and shuttle it to the Data Model. e.With RootCategoryVO1 selected in the Data Model panel, shuttle SubCategoryVO via RootCategoriesSubCategoriesLink to the Data Model. f.Click Finish to create the application module. g.Save your work. 2.Test the application module and then close the Business Components Browser when you have finished. Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 5 Chapter 5 - Page 5 Practice 5-2: Creating an Application Module to Display the Shopping Cart In this practice, you create the application module to display a customers shopping cart. 1.Create the shopping cart application module named FODShoppingCartAM in the oracle.fod.storefront.module package. It should contain the VOs that are based on Orders and OrderItems, with the view link. a.Right-click the oracle.fod.storefront.module package and select New Application Module. b.On the Name page of the Create Application Module Wizard, enter the name FODShoppingCartAM and click Next. c.On the Data Model page, expand oracle.fod.storefront.uiview and ShoppingCartVO.d.Select ShoppingCartVO and shuttle it to the Data Model. e.With ShoppingCartVO1 selected in the DataModel, shuttle ShoppingCartItemVO via OrderItemsOrdersFkLink to the Data Model. f.Click Finish to create the application module. g.Save your work. 2.Test the application module and then close the Business Components Browser when you have finished. Note: At first, this application module shows all orders. In the practices for a later lesson, you add code so that it displays the shopping cart (status CART order) for a particular user. Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 5 Chapter 5 - Page 6 Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 6 Chapter 6 - Page 1 Practices for Lesson 6 Chapter 6 Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 6 Chapter 6 - Page 2 Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 6 Chapter 6 - Page 3 Practices for Lesson 6: Declaratively Customizing Data Services Practices Overview In this set of practices, you make declarative modifications to your business components. If you successfully completed all sections of the previous practice, you can continue working in the same project. However, if you prefer to start with a clean application that contains everything completed up to the start of this lesson, open Storefront-06.jws and edit the database information as described in step 4 of Practice 2-4. This practice contains some optional steps that are similar to steps already done. If you want to build the entire application yourself, you can complete the optional steps. However, in the interest of time, you may want to skip them. If you do so, you must begin the practices for the next lesson by opening the starter application for that lesson. Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 6 Chapter 6 - Page 4 Practice 6-1: Defining Control Hints Control hints on entity object attributes enable you to globally define labels, tool tips, and formatting for any views that are based on those entity objects. In this practice, you define and test several control hints. 1.In the OrderEO entity object, format the OrderTotal as currency and set the labels of OrderTotal, OrderDate, and OrderShippedDate to have spaces between the words. You also set some tool tips. a.In the Application Navigator, in the entity package, double-click OrderEO to open it in the editor. b.Click the Attributes tab at the left of the editor. c.Select the OrderTotal attribute and click Edit. (You can also double-click the attribute to open its editor.) d.In the Edit Attribute dialog box, select Control Hints in the list at the left. e.Set the Format Type to Currency. f.Set the Label Text to Order Total by using a resource bundle (for translatable text), as follows: 1)Click the ellipsis to the right of the Label Text field. 2)In the Select Text Resource dialog box: a)In the Display Value field, enter Order Total. This automatically populates the Key field, but you could change the Key value if desired. However, you can leave it at the default for this attribute. b)Enter the following in the Description field: Label for OrderTotal attribute. c)Click the Save and Select button. g.Set the appropriate tool tip text, using a resource bundle. 1)Click the ellipsis to the right of the Tooltip Text field. Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 6 Chapter 6 - Page 5 2)In the Select Text Resource dialog box: a)In the Display Value field, enter Computed total of the order, and in the Key field, enter ORDER_TOTAL_TOOLTIP. b)Enter the following in the Description field: Tooltip for the Order Total attribute. c)Click Save and Select. Note: Whether or not the instructions specifically direct you to do so, you can use a text resource in a resource bundle for any translatable text throughout these practices, as you would need to do for a real application. However, in the interest of time, you may choose to simply enter the hard-coded text. h.Click OK to dismiss the attribute editor for OrderTotal. i.Optional step: Using a resource bundle, enter appropriate Label Text and Tool tip Text for OrderDate and OrderShippedDate. For example: 2. Optionalstep: Similarly, edit OrderItemEO to format UnitPrice as Currency and set its Label Text to have a space between words. 3.Test the changes by running TestAM in the oracle.fod.storefront.test package.a.Double-click ShoppingCart1 > OrderItemsOrdersFkLink1. b.Look at the labels and formatting that you defined.c.Position the cursor over OrderTotal, OrderDate, and OrderShippedDate to see the tool tip text.Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 6 Chapter 6 - Page 6 d.Close the Business Components Browser when you have finished. Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 6 Chapter 6 - Page 7 Practice 6-2: Declaratively Populating a Primary Key with a Database Sequence Declarative use of a database sequence to populate an EO attribute value relies on existence of a database sequence and a database trigger to use that sequence. For example, the FOD schema has a database sequence named SUPPLIER_SEQ and a database trigger that the DBA created with the following script: CREATE TRIGGER ASSIGN_SUPPLIER_ID BEFORE INSERT ON SUPPLIERS FOR EACH ROW BEGIN IF :NEW.SUPPLIER_ID IS NULL OR :NEW.SUPPLIER_ID < 0 THEN SELECT SUPPLIER_SEQ.NEXTVAL INTO :NEW.SUPPLIER_ID FROM DUAL; END IF; END; This ensures that when a new row is committed with a null primary key, the value from the database sequence populates the primary key. When you use a database trigger to populate the primary key, there are few gaps in the sequence of the primary keys, because the database sequence does not get used until the row is committed.On the Business Components model side, all that is required is to populate the value temporarily, so that the NOT NULL primary key can be committed. That is what happens when you declaratively set the column to use a database sequence, as you do in this practice. 1.Set SupplierEO to use a database sequence at commit time for its primary key. There is already a database trigger defined that populates the primary key from a database sequence if it is null. a.In the Application Navigator, double-click SupplierEO to open it in the editor. b.Click the Attributes tab.c.Select the SupplierId attribute and click Edit.d.In the Edit Attribute dialog box, select Entity Attribute in the list at the left. e.Select DBSequence from the Type drop-down list. (If not in the list, click Browse and select it in the oracle.jbo.domain package.) Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 6 Chapter 6 - Page 8 f.Make sure that the attribute has the following properties: Value0 While New Selected PersistentSelected Primary KeySelected QueryableSelected Insert Selected g.Click OK. Oracle University and Datum, S.A. De C.V. use onlyTHESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITEDCopyright 2010, Oracle and/or its affiliates.All rights reserved. Practices for Lesson 6 Chapter 6 - Page 9 Practice 6-3: Designating History Columns There are several mandatory attributes in many of the entity objects that record information about the record: who created it and when it was created, who last updated it and when it was last updated, and a version number. These attributes can be automatically populated if you designate them as history columns. In this practice, you modify three of the entity objects so that the history columns are populated automatically.1.In the SupplierEO entity object, designate the following columns as history columns and ensure that they are automatically populated at run time: CreatedBy, CreationDate, LastUpdatedBy, LastUpdateDate, and ObjectVersionId.a.In the Application Navigator, double-click SupplierEO to open it in the editor, or click its tab if it is already open.b.Click the Attributes tab.c.Select the CreationDate attribute and click Edit.