O A Framework Guide Comsbined 3
O A Framework Guide Comsbined 3
O A Framework Guide Comsbined 3
Copyright Oracle Corporation, 2006. All rights reserved. This documentation contains proprietary information of Oracle Corporation. It is provided under a license agreement containing restrictions on use and disclosure and is also protected by copyright law. Reverse engineering of the software is prohibited. If this documentation is delivered to a U.S. Government Agency of the Department of Defense, then it is delivered with Restricted Rights and the following legend is applicable: Oracle and all references to Oracle Products are trademarks or registered trademarks of Oracle Corporation. All other products or company names are used for identification purposes only,and may be trademarks of their respective owners.
Technical Contributors Deepika Vimal Devi Viswanathan Pawan Kumar Purbey Arunkumar Pasupathy Balachander Ganesh Sijith Narendran Varunkumar Vedantham
A
...
Order Page
The workshop has two entities essentially, Orders and Order Lines
Order Page .
Figure 2 Order Lines tabs Alternative regions within tabbed region contain several items o Quantity, Units, and Prices o Account
Fig: Orders Search Window Provide only those criteria likely to be used frequently Order number Order status Ship Date Customer information Salesperson name
'|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '||
' ,attribute2 VARCHAR(150) ' ,attribute3 VARCHAR(150) ' ,attribute4 VARCHAR(150) ' ,attribute5 VARCHAR(150) ' ,attribute6 VARCHAR(150) ' ,attribute7 VARCHAR(150) ' ,attribute8 VARCHAR(150) ' ,attribute9 VARCHAR(150) ' ,attribute10 VARCHAR(150) ' ) ' TABLESPACE SYSTEM ' PCTFREE 10 PCTUSED 40 ' INITRANS 1 MAXTRANS 255 ' STORAGE ' (INITIAL 65536 ' MINEXTENTS 1 MAXEXTENTS 2147483645 ' FREELISTS 1 FREELIST GROUPS 1 ' ) ' NOCACHE'; EXECUTE IMMEDIATE ' CREATE UNIQUE INDEX dem_sales_reps_u1 ' ON dem_sales_reps(sales_rep_id) '; END;
Tables and Predefined Data: Customers . ' FREELISTS 1 FREELIST GROUPS 1 '|| ' ) '|| ' NOCACHE'; EXECUTE IMMEDIATE ' CREATE UNIQUE INDEX dem_customers_u1 '|| ' ON dem_customers(customer_id) '; END;
'|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '||
Appendix A: Order Entry Workshop ' (INITIAL 65536 '|| ' MINEXTENTS 1 MAXEXTENTS 2147483645 '|| ' FREELISTS 1 FREELIST GROUPS 1 '|| ' ) '|| ' NOCACHE '; EXECUTE IMMEDIATE ' CREATE UNIQUE INDEX dem_orders_u1 '|| ' ON dem_orders(order_id) '; END;
REM ************************************************************** REM Delete registration of Orders table REM ************************************************************** EXECUTE ad_dd.delete_table('DEMXX', 'DEM_ORDERS'); COMMIT; REM ************************************************************** REM Register Orders table and columns REM ************************************************************** EXECUTE ad_dd.register_table('DEMXX', 'DEM_ORDERS','T',8,10,90); EXECUTE ad_dd.register_column('DEMXX', 'DEM_ORDERS', 'ORDER_ID',1, 15, 'N', 'N');
'NUMBER',
REM ************************************************************** REM Delete registration of columns in Order Lines table REM ************************************************************** EXECUTE EXECUTE EXECUTE EXECUTE ad_dd.delete_column('DEMXX', ad_dd.delete_column('DEMXX', ad_dd.delete_column('DEMXX', ad_dd.delete_column('DEMXX', 'DEM_ORDER_LINES', 'DEM_ORDER_LINES', 'DEM_ORDER_LINES', 'DEM_ORDER_LINES', 'ORDER_ID'); 'ORDER_LINE_NUM'); 'LAST_UPDATE_DATE'); 'LAST_UPDATED_BY');
REM ************************************************************** REM Delete registration of Order Lines table REM ************************************************************** EXECUTE ad_dd.delete_table('DEMXX', 'DEM_ORDER_LINES'); COMMIT; REM ************************************************************** REM Register Order Lines table and columns REM ************************************************************** EXECUTE ad_dd.register_table('DEMXX', 'DEM_ORDER_LINES','T',8,10,90); EXECUTE ad_dd.register_column('DEMXX', 'DEM_ORDER_LINES', 'ORDER_ID', 1, 'NUMBER', 15, 'N', 'N'); EXECUTE ad_dd.register_column('DEMXX', 'DEM_ORDER_LINES', 'ORDER_LINE_NUM', 2, 'NUMBER', 15, 'N', 'N'); EXECUTE ad_dd.register_column('DEMXX', 'DEM_ORDER_LINES', 'LAST_UPDATE_DATE', 3, 'DATE', 9, 'N', 'N'); EXECUTE ad_dd.register_column('DEMXX', 'DEM_ORDER_LINES', 'LAST_UPDATED_BY', 4, 'NUMBER', 15, 'N', 'N'); EXECUTE ad_dd.register_column('DEMXX', 'DEM_ORDER_LINES', 'CREATION_DATE', 5, 'DATE', 9, 'N', 'N'); EXECUTE ad_dd.register_column('DEMXX', 'DEM_ORDER_LINES', 'CREATED_BY', 6, 'NUMBER', 15, 'N', 'N'); EXECUTE ad_dd.register_column('DEMXX', 'DEM_ORDER_LINES', 'LAST_UPDATE_LOGIN', 7, 'NUMBER', 15, 'N', 'N'); EXECUTE ad_dd.register_column('DEMXX', 'DEM_ORDER_LINES', 'PRODUCT_ID', 8, 'NUMBER', 15, 'N', 'N'); EXECUTE ad_dd.register_column('DEMXX', 'DEM_ORDER_LINES', 'GL_ACCOUNT_CC_ID', 9, 'NUMBER', 15, 'Y', 'N'); EXECUTE ad_dd.register_column('DEMXX', 'DEM_ORDER_LINES', 'ORDERED_QUANTITY', 10, 'NUMBER', 15, 'Y', 'N'); EXECUTE ad_dd.register_column('DEMXX', 'DEM_ORDER_LINES', 'ATTRIBUTE_CATEGORY', 11, 'VARCHAR2', 30, 'Y', 'N'); EXECUTE ad_dd.register_column('DEMXX', 'DEM_ORDER_LINES', 'ATTRIBUTE1', 12, 'VARCHAR2', 150, 'Y', 'N'); EXECUTE ad_dd.register_column('DEMXX', 'DEM_ORDER_LINES', 'ATTRIBUTE2', 13, 'VARCHAR2', 150, 'Y', 'N'); ... EXECUTE ad_dd.register_column('DEMXX', 'DEM_ORDER_LINES', 'ATTRIBUTE9', 20, 'VARCHAR2', 150, 'Y', 'N'); EXECUTE ad_dd.register_column('DEMXX', 'DEM_ORDER_LINES', 'ATTRIBUTE10', 21, 'VARCHAR2', 150, 'Y', 'N'); COMMIT;
Appendix A: Order Entry Workshop MESSAGE NAME MESSAGE TEXT payment mode is Cheque. ORDLINES_LINE_ID_UNIQUE Duplicate Order-Line Number encountered. Please ensure Line Number is unique.
Register Lookups
We use lookups to display drop-downs/list-boxes. o In your Application Developer responsibility, select Application : Lookups > Application Object Library. o You can register all your lookups here with your Custom Application name as follows: o Type: CCTYPE_LOOKUP o Meaning: Credit Card Type Lookup CODE A E V MEANING American Express Euro Card Visa
o Type: ORDER_STATUS_LOOKUP o Meaning: Order Status Lookup CODE N P F MEANING New Partly Filled Filled
Oracle Applications Setup . o Name: DEM_ORDERS o Title: Demo Orders xx o Description: Orders DFF for Order Entry Workshop o Table Application: Order Entry Demo xx o Table Name: DEM_ORDERS o Structure Column: ATTRIBUTE_CATEGORY o DFV View Name: DEM_ORDERSxx_DFV Similarly we can register a flexfield for DEM_ORDER_LINES if it does not exist. o Application: Order Entry Demo xx o Name: DEM_ORDER_LINES o Title: Demo Orders xx o Description: Order Lines DFF for Order Entry Workshop o Table Application: Order Entry Demo xx o Table Name: DEM_ORDERS o Structure Column: ATTRIBUTE_CATEGORY o DFV View Name: DEM_ORDER_LINESxx_DFV
B
...
Practices
Appendix B: Practices
Appendix B: Practices
Appendix B: Practices 6. Set or Verify CustomerId Item Properties 7. Set or Verify CustomerName Item Properties 8. Set or Verify DateShipped Item Properties 9. Set or Verify SalesRepName Item Properties 10. Test Your Work
Lab 2: Orders: Search . 5. Make the Customer Id Search Item an LOV Define LOV Mappings 6. Make the Customer Name Search Item an LOV Define LOV Mappings 7. Make the Salesperson Name Search Item an LOV Define LOV Mappings 8. Test Your Work
Appendix B: Practices
Lab 3: Orders: Drilldown to Details 1: Create the Details Page View Object
1. Create the OrderDetailsVO View Object 2. Add Your View Object to the Root UI Application Module 3. Save Your Work
Appendix B: Practices
Lab 4: Orders: Create 1: Revise Search Page to Include Create Order Button
1. Add Create Order Button to Your Search Page 2. Add Create Order Button Press Handler 3. Compile and Save Your Work
4: Implement Browser Back Button Safe Page Initialization and create/rollback Methods
1. Add a createOrderEntry( ) Method to OrderEntryAMImpl Class 2. Add a rollbackOrder( ) Method to Your OrderEntryAMImpl Class 3. Add Back Button Handling to the OrderSearchCO processRequest( ) 4. Add Create Page Initialization 5. Test Your Work
10. Add Validation Logic to setOrderStatus( ) Method in OrderEOImpl Class . Oracle Applications Framework - Practices B-11
Appendix B: Practices
Lab 5: Orders: Partial Page Rendering (PPR) 1: Create an "Application Properties" View Object
1. Create the OrderEntryPVO View Object and necessary Transient Atrributes. 2. Add the OrderEntryPVO View Object to the OrderEntryAM
Figure 2: A Closer look at the Payment Type region when the page renders first time
Figure 3: A Closer look at the Payment Type region when Credit Card radio button is chosen . Oracle Applications Framework - Practices B-15
Appendix B: Practices
Figure 1: Order Search page: Delete column Included B-16 Oracle Applications Framework - Practices
Appendix B: Practices
10. Set or Verify SuggestedPrice Item Properties 11. Set or Verify UnitOfMeasure Item Properties 12. Set or Verify TotalPrice Item Properties 13. Test Your Work . Oracle Applications Framework - Practices B-19
Appendix B: Practices
Lab 8: Lines: Search . Revise Details Page to Include Link to Lines Search
Appendix B: Practices
Lab 9: Lines: Create 1: Create a View Object for the Create Page
1. Create a LinesDetailsVO View Object (VO) 2. Create a OrderToLinesVL View Link (VL) 3. Add the LinesDetailsVO to OrderEntryAM
10. Add an initQuery() to LinesDetailsVO 11. Add the initTableQuery() to OrderEntryAMImpl 12. Set the Controller for the PageLayoutRN 13. Add Add Another Row Button Handling to LinesDetailsCO processRequest( ) 14. Configure OrderLines Button Click 15. Save and Test Your Work
3: Implement Browser Back Button Safe Page Initialization and create/rollback Methods
1. Add a createOrderLineEntry( ) Method to OrderEntryAMImpl Class 2. Add a rollbackOrderLine( ) Method to OrderEntryAMImpl Class 3. Add Back Button Handling to the OrderCreateCO processRequest( ) 4. Test Your Work B-22 Oracle Applications Framework - Practices
Appendix B: Practices
Lab 10: Lines: Partial Page Rendering (PPR) 1: Create an OrderEntryPVO View Object Attribute
Create the Transient Attributes in OrderEntryPVO View Object
Figure 1: A Closer look at the PPR Items and Quantity Ordered field before firing PPR
Figure 2: Note the difference in the PPR items after firing PPR event on Quantity Ordered field
Lab 11: Lines: Layout 1: Modify your Lines Create Page Layout
1. Create the Sub-tab Layout Region 2. Modify the LinesCreateCO 3. Delete Button Handling 4. Rebuild and test your work
Appendix B: Practices
Appendix B: Practices
Appendix B: Practices
C
...
Lab 1: Building and Running "Hello, World!" . Note that there are several profile options that control features such as personalization, the visual appearance of global links, and other features, so what you see may be different from the picture above. Differences you are most likely to encounter are not seeing the Personalize Region link, seeing button icons above the corresponding global links, or not seeing certain global links such as Customize (if personalization is not enabled for your username). Prerequisite: Set Up Your Development Environment If it has not been done already, complete the tasks outlined in Setting Up Your Development Environment. You should also consult the Oracle9i JDeveloper OA Extension FAQ for the latest troubleshooting information. Configure the JDEV_USER_HOME Environment Variable on Your PC Windows 2000 Select My Computer on your desktop, right-click and select Properties . In the System Properties dialog, select the Advanced tab. In the Advanced page, select the Environment Variables button. In the Environment Variables dialog, select the New.. . button at the User variables for <username> box. o In the New User Variable dialog,Enter JDEV_USER_HOME in the Variable Name field. o Set the Variable Value field to point to your jdev directory (ex: D:\jdevhome\jdev) Warning: The variable value should not contain a leading space before the drive name. If it does, your environment will not work properly. Select OK in each of the dialogs you opened to save the new user environment variable. Get Tutorial.zip File and Extract Open the D:\jdev\Tutorial.zip file with WinZip. Extract Tutorial.zip to <JDEVHOME> (it will create jdev subdirectory for you) to get: o D:\jdev\jdevhome\jdev\myhtml o D:\jdev\jdevhome\jdev\myprojects Oracle Applications Framework - Practices and Solutions C-5
Appendix C: Practices and Solutions Start JDeveloper and Verify Installation Launch Oracle 9i Jdeveloper. Open the OA Framework Toolbox Tutorial workspace file by selecting File > Open from the main menu. o Navigate to <JDEV_USER_HOME>\myprojects toolbox.jws. and open the file
In the JDeveloper System Navigator, expand the toolbox.jws to display its contents. o In the System Navigator, select the Tutorial.jpr project and select Project > Project Settings. In the Project Settings dialog, expand the Oracle Applications node and select Runtime Connection. Verify that the DBC file shown in the Connection box matches the database where you instructor directs you to work. If you need to change it: Use the Browse... button to locate the appropriate DBC file (the file should be in the <drive>:\users\dbc_files\secure\ directory. It can be obtained from the server under $FND_TOP/secure The User Name and Password should be specified for an Oracle Applications user that has responsibility "Framework Toolbox Tutorial" attached to it
Expand the Connections node in the JDeveloper System Navigator, o Then expand the Database node. o Right-click on the Database node o Select New Connection... to open the Connection Wizard. o Follow the JDeveloper instructions to define a new database connection for the Oracle Applications database identified by the DBC file you selected above. In the System Navigator, select the Tutorial.jpr project again. o Right-click and select Edit Business Components Project .... In the Business Components Project Wizard, select the Connection option and set the Connection Name to the connection you just defined. Select OK to save your changes. Repeat all steps described above for the LabSolutions.jpr project. Oracle Applications Framework - Practices and Solutions C-7
Appendix C: Practices and Solutions In the System Navigator, select toolbox.jws and select Project > Rebuild toolbox.jws from the main menu. You should get 0 errors (warnings are OK and expected). Expand the HTML Sources category beneath Tutorial.jpr o Select test_fwktutorial.jsp o Select Run > Run test_fwktutorial.jsp from the main menu. The Test Framework Toolbox Tutorial page displays a list of lesson links. o Select Hello, World! to run a very simple page. If you cannot run the Hello, World! Page, please revisit the steps listed above to ensure that you completed everything correctly. Make Sure You Have a Working Data Source Your data source is the database you'll be developing against. You'll need a connection to the database to access the Repository and BC4J objects during development. Note: The test_<varies>.jsp file (included with the Tutorial.zip) contains connection information for running your project within JDeveloper (assuming you are using the dev115 database). For Oracle Applications Division developers, Repository metadata information and objects needed for BC4J, such as tables, are in the same database (although you will not be using the Repository for the Hello World example). If the database you use for development is not in the list of database connections, please file a bug with Development Services. If you have completed the development environment setup, including unpacking and running the latest Tutorial.zip (in your JDEV_USER_HOME directory), when you open up JDeveloper for the first time you should open the toolbox.jws workspace using File > Open on the main menu). Warning: Do not import modifications to any Toolbox metadata to the Repository in the database. This metadata in the database is shared by everyone using the Toolbox Lessons in the same database, and modifying this metadata can make them inoperable. Note that you can modify your own copies of the Toolbox XML files so long as you do not import them into the database. Importing to the Repository in the database is a separate process that uses a command-line interface. Warning: Any Toolbox application data that you type into a Toolbox form and save will be shared by everyone using these applications, so be cautious about entering or modifying any data.
Lab 1: Building and Running "Hello, World!" . Create a New OA Workspace and Empty OA Project with the New Dialog Select File > New to open the New... dialog (shown in the following diagram). This dialog is also called the New Object Gallery.
Choose General > Workspace Configured for Oracle Applications from the New... dialog, or highlight Workspaces in the Navigator and choose New OA Workspace... from the context menu (right mouse button menu that changes depending on the context).
Appendix C: Practices and Solutions You'll be prompted to create an OA workspace. Verify that the default workspace directory name points to your own <JDEV_USER_HOME>\myprojects directory, as shown in the following diagram. Modify the workspace file name as well (any name is okay for a workspace, such as HelloWorldOAWorkspace.jws). Check the Add a New OA Project check box.After you click OK, you will see the Oracle Applications Project Wizard. In Step 1 of the wizard, verify that the default project directory name points to your own JDEV_USER_HOME\myprojects directory, as shown in the following diagram. Modify the project file name as well (any name is okay for a project, such as HelloWorldOAProject.jpr). Set the default package name to the following (where "hello" is the component): oracle.apps.icx.hello Note: For this exercise and for all later lab exercises, you must use the exact package, page, region, item and variable names specified in the instructions, because the instructions depend on having these names. Specifically, you must use oracle.apps.... in your package names for the labs even if you are an Oracle Applications customer or partner (though you would use <3rd party identifier>.oracle.apps.... in production objects you create).
For your Hello World project, you do not use the Repository for metadata in the database (the Hello World example uses only the XML files). In regular development work, where you use standard components that have been imported into the Repository, you would check the Use Repository for Design Time check box and provide connection information in Step 2.
Appendix C: Practices and Solutions In Step 3 of the wizard, adjust the runtime connection information, if necessary, for the database and Oracle Applications username, password, and responsibility you are using (it must be a valid user and responsibility for your installation). Set Run Options in OA Project Settings To verify that your project includes all of the appropriate libraries, paths and other settings, select your project in the Navigator and choose Project Settings from the context menu, or double-click on your project. Select the Common > Oracle Applications > Run Options settings page. Select OADeveloperMode and OADiagnostic, and move them to the On Options List. OADeveloperMode provides extra code checking and standards checking at runtime. OADiagnostic enables the Diagnostics button in the global buttons at the top of the page, overriding any corresponding profile option set for the application. You should always have these two modes turned on during development. The other modes are generally used for testing towards the end of developing your page, and are fully described in Chapter 7.
Lab 1: Building and Running "Hello, World!" . Create the OA Components Page File Within your new workspace, select your new project (your .jpr file). To add an OA Components page file to your project, choose New from the context menu or use File > New... on the main menu to open the New dialog. Select Web Tier > OA Components in the Categories column. Then select Page, and press OK as shown in the following diagram:
You will then see a dialog box that asks for the name and package file for your new page. This dialog box is shown in the following diagram:
Name your page HelloWorldPG. Your page name cannot include any spaces. In the Package field, type the following: oracle.apps.icx.hello.webui Your package file name (which determines the location of the XML page file in the directory structure) should be set to oracle.apps.<application_shortname>.<optional_modulename>. <optional_subcomponent>.webui (to comply with Oracle Applications directory structure standards), where the application shortname is lowercase and is an existing Oracle Applications C-14 Oracle Applications Framework - Practices and Solutions
Lab 1: Building and Running "Hello, World!" . product shortname, such as INV. Note that pages migrated from old AK pages may use a different directory structure (pages instead of webui).Be sure to follow the package name, directory location and object naming standards in the OA Framework File / Package / Directory Structure standards. Your initial page structure appears in the Structure window as shown below, with an initial pageLayout region called region1, and a folder called pageLayout Components. The pageLayout Components folder contains a standard corporate branding image ("Oracle") that you cannot change (though you can add other elements).
Modify the Page Layout (Top-level) Region JDeveloper creates your top-level page layout region for you automatically when you create your page.
If the Property Inspector is not already open, select View > Property Inspector from the main menu. You can alternate between the alphabetical list of properties and the categorized list by clicking on the Categories button at the top of the Property Inspector (shown above with categories enabled). Set the following properties for your page layout region: Oracle Applications Framework - Practices and Solutions C-15
Appendix C: Practices and Solutions Set the ID property to PageLayoutRN. Verify that the Region Style property is set to pageLayout. Verify that the Form property is set to True. Verify that the Auto Footer property is set to True. Set the Window Title property to <your name >: Hello World Window Title. This becomes the window title for the page. Set the Title property to <your name>: Hello World Page Header. This becomes the page header for the page (it appears under the blue bar). Set the AM Definition property to: oracle.apps.fnd.framework.server.OAApplicationModule (you will have to type in the value). This is a generic application module supplied by the OA Framework.
Lab 1: Building and Running "Hello, World!" . Create the Second Region (Main Content Region) Create your second region under the page layout region by selecting the page layout region in the Structure window and choosing New > Region from the context menu
This region is merely going to provide a container for your items and ensure that the items are properly indented. Set the following properties for your second region:
Replace the default value in the ID property with MainRN. Set the Region Style property to messageComponentLayout (this provides an indented single- or multiple-column layout for the child items of the region.
Appendix C: Practices and Solutions If you want to, you can run your page at this point. You will see the global links, the copyright and privacy footer elements, and your page header text. Create the First Item (Empty Field) Create your first item under the second region (main content region) by selecting the second region in the Structure window and choosing New > messageTextInput from the context menu.
Set the ID property to HelloName. Verify that your Item Style property is set to messageTextInput (this style provides a text label and an input field). Set the Prompt property to Name (in the later labs, you will use an attribute set to set the prompt). Set the Length to 20.
Appendix C: Practices and Solutions Create a Container Region for the Go Button To add a non-message*-type bean such as a submitButton to a messageComponentLayout region, you must first add the bean to a messageLayout region. Select the messageComponentLayout region and select New > messageLayout .
Name this region ButtonLayout. Create the Second Item (Go Button) Create your Go button item by selecting the messageLayout region, ButtonLayout, in the Structure window and choosing New > Item from the context menu. Set the following properties for your button item: Set the value of the ID property to Go. Set the Item Style property to submitButton . Set the Attribute Set property to /oracle/apps/fnd/attributesets/Buttons/Go. Note that you can search for this attribute set, even though the attribute set file is not part of your project, by choosing the Search in: Entire MDS XML path option but not selecting the Show Components in Same Scope Only check box. You can use /oracle/apps/fnd/attributesets/ and % as criteria for your search. Verify that the Prompt property is now set to Go (this is your button label, inherited from the attribute set). C-20 Oracle Applications Framework - Practices and Solutions
If you want to, you can run your page at this point. Save Your Work Save your work. Using the menu choice File > Save All will save your metadata changes to an XML file as well as save all your other file changes (such as to a .jsp or .java file). Tip: Though it usually will not be written out as a separate step in the exercises, you should save your work frequently.
Appendix C: Practices and Solutions Run Your Page Using the Run Option You can try out your page using the Run option on the context menu. If you are using a database other than what you already have in your project settings, you will need to modify the Runtime Connection project settings by selection your project file and choosing Project Settings ... from the main menu. Specifically, you must use a combination of Username, Password, (Responsibility) Application Short Name and Responsibility Key that is valid for your database to enable your session to log in. You can use the Run option in the context menu to test your page in a standard browser. This option allows you to test your layout as well as functionality such as handling button presses. Select your page or page layout region in the Structure window, and choose Run from the context menu.
Alternatively, you can select your page in the Navigator window, and choose Run <page name> from the context menu. You may have to wait a few minutes or more before you see your page in a separate browser window (it often takes longer the first time). If your page does not appear after a few minutes, or gives errors, check the messages in the Log window. See the Hello, World! Troubleshooting Guide or the Oracle9i JDeveloper OA Extension FAQ. Your page should look like the following picture (with your own name in the page header and window title). You should see your page header, your Name field, and your Go button, along with global links and buttons (some global buttons may not appear depending on profile option settings). You may or may not see a Personalize Region link below your page header, depending on profile option settings. Do not personalize this page, as personalizations are data driven and you will affect anyone else building the Hello World page on the same database.
Each time you make changes to your layout (by adding regions or items, modifying properties, or changing code), you must run your page again to see your changes. If the Run process seems to hang for several minutes after you have already run your page previously, you may need to terminate the OC4J server using the Run > Terminate > Embedded OC4J Server main menu option, and then run again. Add a Controller Add a controller to display a message when the user clicks on the Go button. Select your second region (MainRN) and choose Set New Controller... from the context menu.
Give your controller the package name oracle.apps.icx.hello.webui and an appropriate class name, such as HelloWorldMainCO , and click OK. Edit Your Controller Edit your controller code as follows: Add the following line as the last line of the import section to make the OA Framework OAException routines available: import oracle.apps.fnd.framework.OAException;
Lab 1: Building and Running "Hello, World!" . Code the processFormRequest() method to match the following (making sure to match the item IDs you chose):
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean) { super.processFormRequest(pageContext, webBean); if (pageContext.getParameter("Go") != null) { String userContent = pageContext.getParameter("HelloName"); String message = "Hello, " + userContent + "!"; throw new OAException(message, OAException.INFORMATION); } }
Note that hardcoding a message text string is not translatable and would not be acceptable in a real Oracle Applications product. Normally you would define your message in Message Dictionary and call it from your code using its message name using the OAException routine.
Build Your Controller Build your controller by selecting Rebuild from the context menu within the code editor window. Test Your Work Using the Run Option Save your work, then test it using the Run option. Type something into your field and then click the Go button. You should see the your page with an informational message that contains what you typed into the field, as shown:
You have finished your first page with Oracle9i JDeveloper and the OA Framework!
Appendix C: Practices and Solutions (such as nitinpaul), a similar unique name (such as npaul), or your Global UID(preferably choose this), or an instructor-supplied name(for instructor led training). Create a new OA Workspace, select File > New from the main menu, in the General menu choose Workspace Configured for Oracle Applications, and select OK. In the window that pops up o Check if the directory name is Drive_name:\<your JDEV_USER_HOME>\myprojects o In the file name field, fill in OrderEntry.jws o Ensure that Add a New OA Project checkbox is checked. If the Welcome page appears, select Next. Change (or verify) the Directory Name field to your directory <your JDEV_USER_HOME>\myprojects Change the File Name field to OrderEntry.jpr. Set the Default Package field to <yourname>.oracle.apps.demxx.orderentry (In place of xx use your Employee Number) Select Next and check the Use repository at design time" check box, and select the database connection that you defined Select Next to define the runtime connections
Verify your connection information and adjust it if necessary. Unless your instructor tells you otherwise, set the following: Value If this does not default correctly, set this to the correct DBC file name identified for the current environment. For customers, consultants and others working with local JDeveloper installs, your DBC files are located in your <JDEV_USER_HOME >\myhtml\OA_HTML\secure directory as described in Setting Up Your Development Environment. Load the DBC file corresponding to the Oracle APPS Instance that you are working on. Demxx <Passwd> ICX FWK_TBX_TUTORIAL
Click the Finish button to create your project. C-28 Oracle Applications Framework - Practices and Solutions
Lab 2: Orders: Search . 1.2 Enable Developer Diagnostics As a general rule you should ensure that the developer test mode and OA diagnostics are enabled in your projects to help you identify various coding standards violations and leverage the AOL/J logging feature. Select the OrderEntry.jpr project in the Navigator, right-click and select Project Settings... from the context menu. In the Project Settings page, choose Common > Oracle Applications > Run Options. Select OADeveloperMode and OADiagnostic, and shuttle them to the Selected Options if they aren't there already. Select OK to exit the Project Settings window. 1.3 Organize Your Project Into Categories It is far easier to manage and navigate a large project when the files are categorized. For example, Figure 2 shows a part of the ToolBox Tutorial project without categorization. All the files are listed in alphabetical order regardless of file type.
Figure 2: Uncategorized Project in JDeveloper Navigator If you select the Show Categories toolbar button as shown above, the project's files are organized as shown in Figure 3.
Figure 3: Categorized Project in JDeveloper Navigator. Tip: You can also toggle Project > Show Categories in the JDeveloper main menu.
Fig 4: Create new BC4J package Verify that the radio button Entity Objects mapped to database schema objects is selected. Select Next twice.
Appendix C: Practices and Solutions 2.2 Create the BC4J Package for Server (Business Logic) Objects Create a new BC4J package for entity objects, association objects, validation application modules and validation view objects. Select the OrderEntry.jpr project in the Navigator, right-click and select New Business Components Package... from the context menu. If the Welcome page appears in the Business Components Package Wizard, select Next. Enter <yourname>.oracle.apps.demxx.schema.server as the package name. Verify that the radio button Entity Objects mapped to database schema objects is selected (you will not be able to create your entity object in this package if you fail to do this). Select the Finish button to create the package. 2.3 Create Your Root UI Application Module (AM) Create a new Application Module (AM) to be used as the root UI application module for your page. Select the <yourname>.oracle.apps.demxx.orderentry.server BC4J package in the Navigator, right-click and select New Application Module... from the context menu to open the Application Module (AM) wizard. If the Welcome page appears, select Next. In the Name page, specify OrderEntryAM as the AM name and verify that the Package is <yourname>.oracle.apps.demxx.orderentry.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. Note: The packages have been split into orderentry.server and schema.server for better classification. orderentry.server will contain the components that involve UI and schema.server will contain components that interact with the database. This classification is not mandatory but it is followed to get a better understanding.
2.4 Enable Passivation for the Root UI Application Module Passivation should be enabled for all root UI application modules. C-32 Oracle Applications Framework - Practices and Solutions
Lab 2: Orders: Search . Note that passivation is not fully supported in release 11.5.10 production; this is included for preview purposes. Select the OrderEntryAM application module in the Navigator, right-click and select Edit OrderEntryAM... from the context menu. In the Application Module Wizard, navigate to the Properties page. In the Name field enter RETENTION_LEVEL. In the Value field enter MANAGE_STATE. Warning: you must match the case and spelling exactly as shown. Select the Add button. Select the Apply button. Select the OK button to close the Application Module Wizard window. 2.5 Save Your Work Save your work using the menu option File > Save All will save your metadata change XML file and save all your other file changes (such as to a .jsp or .java file). to an
Tip: Though it will not be written out as a separate step from here on, you should save your work frequently: at least at the end of each task.
2.6 Create an Orders Entity Object (EO) Create an entity object (EO) for the DEM_ORDERS table in the OA Framework OrderEntry schema. Tip: Most of the BC4J wizards allow you to resize the wizard window, even though there may not be visible resize controls. This is helpful for viewing long values and SQL statements. Select the <yourname>.oracle.apps.demxx.schema.server BC4J package in the Navigator, right-click and select New Entity Object... from the context menu to open the Entity Object wizard. If the Welcome page appears, select Next. In the Name page: o Enter OrderEO in the Name field. o Verify that the Package is <yourname>.oracle.apps.demxx.schema.server. o In the Schema Object field, enter DEM_ORDERS. You must type this name Oracle Applications Framework - Practices and Solutions C-33
Appendix C: Practices and Solutions correctly. Otherwise, you can check the Synonyms check box (so both Tables and Synonyms are checked) and choose the correct name from the list. Select the Next button twice to navigate to the Attribute Settings page (note that all the table's columns are automatically included as attributes, which complies with the OA Framework Model Coding Standards for Entity Objects. Verify that the OrderId attribute's Primary Key check box is selected. Do not change any other default settings. Select the Next button. In the Java page, select the Generate Java File check box for the Entity Object Class: OrderEOImpl (you will add business logic to this Java file in a later exercise). In the Generate Methods region, check the Accessors, Create Method, Validation Method and Remove Method check boxes. Select the Next button. In the Generate page, deselect the Generate Default View Object check box (or, verify that it is not selected). Select the Finish button to create your EO. Select your EO, right-click and select Edit OrderEO... Select the Tuning tab. Check the Use Update Batching checkbox and set the Threshold field value to 100.
Lab 2: Orders: Search . 2.7 Create an OrderSearchVO View Object (VO) Create a summary-level view object including only those attributes that you need for the Orders search results table. This view object is the main view object for your Search page. It should leverage the OrderEO (per the OA Framework Model Coding Standards for View Objects, all but the simplest view objects for things like poplists, lists of values and so on should be based on entity objects). Select the <yourname>.oracle.apps.demxx.orderentry.server BC4J package in the Navigator, right-click and select New View Object... from the context menu to open the View Object wizard. If the Welcome page appears, select Next. In the Name page, specify OrderSearchVO as the view object's name and verify that the Package is <yourname>.oracle.apps.demxx. orderentry.server. Select the Next button. In the Entity Objects page, select the OrderEO in the Available list and shuttle it to the Selected list. Select the Next button. In the Attributes page, select the following attributes from the Available list and shuttle them to the Selected list From OrderEO: o OrderId o CustomerId o SalesRepId o DateShipped o OrderStatus Select the Next button twice.
At this point the query should look like the following in the Query page (without the formatting we've used here to improve readability):
SELECT OrderEO.ORDER_ID, OrderEO.CUSTOMER_ID, OrderEO.SALES_REP_ID, OrderEO.DATE_SHIPPED, OrderEO.ORDER_STATUS FROM DEM_ORDERS OrderEO
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
SELECT OrderEO.ORDER_ID, OrderEO.CUSTOMER_ID, OrderEO.SALES_REP_ID, OrderEO.DATE_SHIPPED, OrderEO.ORDER_STATUS, DemCust.NAME AS CUSTOMER_NAME, DemSale.FIRST_NAME||' '||DemSale.LAST_NAME AS SALES_REP_NAME FROM DEM_ORDERS OrderEO, DEM_CUSTOMERS DemCust, DEM_SALES_REPS DemSale WHERE OrderEO.CUSTOMER_ID = DemCust.CUSTOMER_ID AND OrderEO.SALES_REP_ID = DemSale.SALES_REP_ID(+)
Note: The Customer name and sales rep name are obtained in the VO for display purpose. The outer join on the sales rep id is to ensure that the order is displayed even if the sales rep is not specified for the order. When you are finished with your editing, select the Test button to ensure your syntax is correct. Select the Next button. In the Attribute Mappings page, verify that your view object attributes map to the correct query columns. If you need to make any changes, place your cursor into the incorrect View Attributes field and select the correct value from the poplist. Select the Next button. In the Java page, o Deselect the Generate Java File for View Object Class: OrderSearchVOImpl (you don't need to add any code to this view object). o Do select the Generate Java File for View Row Class: OrderSearchVORowImpl to comply with OA Framework coding standards. Select the Finish button to create your VO. Now verify that your VO attribute settings match the aliases in your SQL query: Select the OrderSearchVO in the Navigator, right-click and select Edit OrderSearchVO... from the context menu to open the View Object wizard. Navigate to the Attributes section for your attributes and verify that any aliases in your query are shown correctly. Make any necessary changes and select Apply. Navigate to the Attribute Mappings page and verify that all the mappings are correct. Make any necessary changes and select Apply. C-36 Oracle Applications Framework - Practices and Solutions
Lab 2: Orders: Search . Select the OK button to finish editing your VO. 2.8 Add Your View Object to the Root UI Application Module View objects can be used only within the context of a containing application module. Before you can use the OrderSearchVO in your page, you must add it to the page's root UI Application Module. Select the OrderEntryAM in the Navigator pane, right-click and select Edit OrderEntryAM... from the context menu to open the Application Module wizard. Navigate to the Data Model page. Select the OrderSearchVO view object in the Available View Objects list and shuttle it to the Data Model list. The Instance Name appears as OrderSearchVO1 at the right bottom. Change the instance name to OrderSearchVO. Tip: Take careful note of the default View Instance name that BC4J creates when you add your VO to the selected AM (BC4J creates this name by appending a "1" to your VO name). Leave it or change it, your choice. In either case, know what the value is before creating your Results table region in the next task. Select the OK button to finish adding your VO to your root AM.
Tip: You can set the Property Inspector to list the properties by category or in alphabetical order. To change between category and alphabetical sorting, select the Categories button in toolbar at the top of the Property. 3.3 Add a Product Branding Image C-38 Oracle Applications Framework - Practices and Solutions
Lab 2: Orders: Search . Each Oracle Applications page requires a product-branding image. Select your PageLayoutRN in the Structure pane, right-click and select New ... productBranding from the context menu. JDeveloper creates a pageLayoutComponents folder containing a productBranding image item (named item1). Select this item and set the following properties: Property ID Image URI Additional Text Value ProdBrand FNDTAPPBRAND.gif OA Framework Order Entry Tutorial (This is required per the accessibility coding standards with which all Oracle E-Business Suite pages must comply).
3.4 Create the Page Instruction Text Add the page-level instruction text. Note that we are using an Oracle Applications Message Dictionary message to ensure that the text is translatable. Furthermore, all the properties that you specify in JDeveloper that can be seen by the user are translatable. Select the PageLayoutRN in the Structure pane, right-click select New > pageStatus from the context menu (any instruction text or other content added to the pageStatus will render in parallel with any page-level action or navigation buttons that you add). JDeveloper automatically creates a flowLayout region for you beneath the pageStatus component. Select this region and set its ID to PageStatusRN. Select PageStatusRN, right-click and select New > Item. Set this item's properties as follows: Property ID Item Style Data Type CSS Class Message Appl Short Name Message Name Value PageHelp staticStyledText VARCHAR2 OraInstructionText DEMXX ORDLINES_PAGE_GENERAL
3.5 Test Your Work Select your page in either the Structure pane or the Navigator window, right-click and choose Run < file name > from the context menu.
Figure 5: Task 4-Finished Product 4.1 Add a Query Bean to Your Page Add the query bean region to your page. Select the PageLayoutRN in the Structure pane, right-click and select New > Region from the context menu. Select the new region (region1), and set/verify its properties as follows: Property ID Region Style Construction Mode Include Simple Panel Include Views Panel Value QueryRN query resultsBasedSearch True True
Lab 2: Orders: Search . 4.2 Add a Results Data Table to Your QueryRN Select the QueryRN in the Structure pane, right-click and select New > Region Using Wizard from the context menu. If the Welcome page appears, select Next. In the BC4J Objects page, select your OrderEntryAM (<yourname >.oracle.apps.demxx.orderentry.server.OrderEntryAM), and then select your OrderSearchVO view object instance from the Available View Objects list. DO NOT select the Use this as Application Module Definition for this region checkbox. Select the Next button. In the Region Properties page, set the Region ID field value to ResultsTable and set the Region Style to table. Select the Next button. In the View Attributes page, select the following attributes from the Available View Attributes list and shuttle them to the Selected View Attributes list: o OrderId o OrderStatus o CustomerId o CustomerName o DateShipped o SalesRepName Select the Next button.
In the Region Items page, set the ID, Style, and Attribute Set properties as follows
Prompt Order Number Order Status Customer Number Customer Name Ship Date Salesperson Name
Attribute Set
Appendix C: Practices and Solutions Click the Finish button to create your data table.
Select the ResultsTable region in the Structure pane, and set/verify the following
properties: Property ID Region Style AM Definition Additional Text Rendered Records Displayed Width User Personalization Value ResultsTable table Make absolutely sure that you have not inadvertently associated an application module here. If you have, please delete it. Orders Table (This is required per the accessibility coding standards). True 10 100% True (needed so the user can save a Personalized View)
4.4 Set or Verify OrderId Item Properties Configure this item to support sorting in the table, to be included in the "results-based" search region that the OA Framework automatically creates, and to be a selectively required search value (for performance reasons, blind queries are disallowed in Oracle Applications unless the underlying view object has been tuned to include a performant query so no additional search criteria is required). For the OrderId item set or verify: o Item Style property to messageStyledText o Sort Allowed property to yes o Initial Sort Sequence to first o Search allowed True o Selective Search Criteria property to True o Data Type property to NUMBER o View Instance to OrderSearchVO o View Attribute to OrderId o Prompt to Order Number o User Personalization property to True (needed so the user can save a C-42 Oracle Applications Framework - Practices and Solutions
Lab 2: Orders: Search . Personalized View). Tip: For more information on the Sort Allowed and Initial Sort Sequence properties, refer to the Developer's Guide topic on Tables > Sorting. Tip: For more information on the Search Allowed and Selective Search Criteria properties, refer to the Developer's Guide topics on Search > Declarative Implementation: Results Based Search and Search > Declarative Implementation: Auto Customization Criteria.
4.5 Set or Verify OrderStatus Item Properties For the OrderStatus item: o Item Style property to messageStyledText o Search Allowed property to True o Selective Search Criteria property to True o Data Type property to VARCHAR2 o View Instance to OrderSearchVO o View Attribute to OrderStatus o Prompt to Order Status o User Personalization property to True (needed so the user can save a Personalized View). o Maximum Length to 1
4.6 Set or Verify CustomerId Item Properties For the CustomerId item: o Item Style property to messageStyledText o Search Allowed property to True o Selective Search Criteria property to True o Data Type property to NUMBER o View Instance to OrderSearchVO o View Attribute to CustomerId Oracle Applications Framework - Practices and Solutions C-43
Appendix C: Practices and Solutions o Prompt to Customer Number o User Personalization property to True (needed so the user can save a Personalized View).
o
Maximum Length to 15
4.7 Set or Verify CustomerName Item Properties For the CustomerName item: o Item Style property to messageStyledText o Search Allowed property to True o Selective Search Criteria property to True o Data Type property to VARCHAR2 o View Instance to OrderSearchVO o View Attribute to CustomerName o Prompt to Customer Name o User Personalization property to True (needed so the user can save a Personalized View). o Maximum Length to 50 4.8 Set or Verify DateShipped Item Properties For the DateShipped item: o Item Style property to messageStyledText o Search Allowed property to True o Selective Search Criteria property to True o Data Type property to DATE o View Instance to OrderSearchVO o View Attribute to DateShipped o Prompt to Ship Date o Tip Type to dateFormat o User Personalization property to True (needed so the user can save a C-44 Oracle Applications Framework - Practices and Solutions
Lab 2: Orders: Search . Personalized View). o Drag and drop the item between OrderStatus and CustomerId 4.9 Set or Verify SalesRepName Item Properties For the SalesRepName item: o Item Style property to messageStyledText o Search Allowed property to True o Selective Search Criteria property to True o Data Type property to VARCHAR2 o View Instance to OrderSearchVO o View Attribute to SalesRepName o Prompt to Salesperson Name o User Personalization property to True (needed so the user can save a Personalized View).
o
Maximum Length to 15
4.10 Test Your Work Test your work. Your results should appear as shown in Figure 5 above. Try selecting the Advanced Search button, and the Save Search button after executing a query. Also try selecting the Go button without specifying any search criteria. Try selecting the Views button and saving a personalized search. Try using your saved search. Note that you do not have to implement the query; the OA Framework implements this for you automatically based on the table items that you identified with the Search Allowed property. Furthermore, the OA Framework creates a Search UI based on the data and item types of the Search Allowed items.
Figure 6: Task 5-Finished Product 5.1 Change the Query Bean to Use autoCustomizationCriteria Select the QueryRN in the Structure pane. Change its Construction Mode property to autoCustomizationCriteria. Change its Include Views Panel property to False. Change its Include Advanced Panel property to False. 5.2 Add a Simple Search Region Select the QueryRN in the Structure pane, right-click and choose New > simpleSearchPanel from the context menu (remember this is a named child of the query region). A header region (region2) and a messageComponentLayout region (region1) will be created automatically. Select the header region, set its ID to SimpleSearchHdr and change the default Text property value to Simple Search. Select the default messageComponentLayout region created under simpleSearchPanel folder (region1 ) and set its ID to CustomSimpleSearch . the
Lab 2: Orders: Search . 5.3 Create an OrderId Search Item Select CustomSimpleSearch region in the Structure pane, right-click and select New > messageTextInput from the context menu.
5.4 Create an Order Status Search Item Select the CustomSimpleSearch region in the Structure pane, right-click and select New > messageTextInput from the context menu.
5.5 Create a DateShipped Search Item Select CustomSimpleSearch region in the Structure pane, right-click and select New >messageTextInput from the context menu.
Appendix C: Practices and Solutions Property Value Maximum Length 15 Prompt Ship Date CSS Class OraFieldText Length 15 5.6 Create an CustomerId Search Item Select CustomSimpleSearch region in the Structure pane, right-click and select New >messageTextInput from the context menu.
5.8 Create an SalesRepName Search Item Select CustomSimpleSearch region in the Structure pane, right-click and select New >messageTextInput from the context menu.
Lab 2: Orders: Search . Property ID Item Style Selective Search Criteria Data Type Prompt CSS Class Length Value SearchSalespersonName messageTextInput (we will change this to LOV later) True VARCHAR2 Salesperson Name OraFieldText 15
5.9 Create Search Mappings Between Search Items and ResultsTable The OA Framework uses the mappings that you define between your custom search items and columns in the ResultsTable to handle the query automatically when the user selects the Go button. Select the query bean or the query Components folder in the Structure pane, rightclick and choose New > simpleSearchMappings from the context menu.
Select the default mapping created under the simpleSearchMappings and set its
properties to the following: Property ID Search Item Results Item Value OrderNumMap SearchOrdNum OrderId
Select the simpleSearchMappings folder in the Structure pane, right-click and choose New > queryCriteriaMap from the context menu. Select the new mapping and set its properties as follows: Property ID Search Item Results Item Value DateShipMap SearchDateShipped DateShipped
Select the simpleSearchMappings folder in the Structure pane, right-click and choose New > queryCriteriaMap from the context menu. Select the new mapping and set its properties as follows: Oracle Applications Framework - Practices and Solutions C-49
Appendix C: Practices and Solutions Property ID Search Item Results Item Value CustIdMap SearchCustId CustomerId
Select the simpleSearchMappings folder in the Structure pane, right-click and choose New > queryCriteriaMap from the context menu.
Select the simpleSearchMappings folder in the Structure pane, right-click and choose New > queryCriteriaMap from the context menu. Select the new mapping and set its properties as follows: Property ID Search Item Results Item Value OrderStatusMap SearchOrdStatus OrderStatus
Select the simpleSearchMappings folder in the Structure pane, right-click and choose New > queryCriteriaMap from the context menu. Select the new mapping and set its properties as follows: Property ID Search Item Results Item Value SalesRepMap SearchSalespersonName SalesRepName
5.10 Test Your Work Test your work. Your results should appear as shown in Figure 6 above (but without the LOV icon). C-50 Oracle Applications Framework - Practices and Solutions
Figure 7b: Customer Name LOV Window Oracle Applications Framework - Practices and Solutions C-51
6.1 Create the BC4J Package for Your LOV-Related Model Objects All LOV view objects should be created in a common product package. Select the OrderEntry.jpr project in the Navigator, right-click and select New Business Components Package...to open the Business Components Package Wizard. If the Welcome page appears, select the Next button. In the Package Name page, enter <yourname>.oracle.apps.demxx.lov.server Verify that the radio button Entity Objects mapped to database schema objects is selected. Click the Finish button to create the LOV BC4J package. 6.2 Create a Common LOV Application Module Related LOV view objects should be grouped into a common application module. For example, any LOV view objects that you create for the OrderEntry application should be included in one application module. Select the <yourname>.oracle.apps.demxx.lov.server BC4J package in the Navigator, right-click and select New Application Module... from the context menu to open the Application Module (AM) wizard. If the Welcome page appears, select Next. C-52 Oracle Applications Framework - Practices and Solutions
Lab 2: Orders: Search . In the Name page, specify OrderEntryLovAM as the AM name and verify that the Package is <yourname>.oracle.apps.demxx.lov.server Click the Next button until you get to Step 4 of 4. In the Java page, deselect the Generate Java File(s) checkbox (you would not be adding any code to this application module). Select the Finish button to create the AM.
6.3.1 Create the Customer LOV View Object Select the <yourname>.oracle.apps.demxx.lov.server package in the Navigator, right-click and select "New View Object..." from the context menu to open the View Object wizard. If the Welcome page appears, select Next. In the Name page, specify CustomerLovVO as the view object name and verify that the Package is <yourname>.oracle.apps.demxx.lov.server. Select the Next button until you get to the Query page. In the Query page, enter the following query into the Query Statement text field.
SELECT DC.customer_id CUST_ID ,DC.name CUST_NAME FROM dem_customers DC
Select the Test button to ensure your syntax is correct. Select the Next button until you get to the Java page. In the Java page, deselect the Generate Java File for View Object Class: CustomerLovVOImpl (as you do not have to add any code to this view object). Do select the Generate Java File for View Row Class: CustomerLovVORowImpl to comply with OA Framework coding standards. Select the Finish button to create your VO. 6.3.2 Add the CustomerLovVO to the OrderEntryLovAM View objects can be used only within the context of a containing application module. Before we use the CustomerLovVO in our LOV, we must add it to the LOV application module. Select the OrderEntryLovAM in the Navigator pane; right-click and select Edit Oracle Applications Framework - Practices and Solutions C-53
Appendix C: Practices and Solutions OrderEntryLovAM... from the context menu to open the Application Module wizard. Navigate to the Data Model page. Select the CustomerLovVO view object in the Available View Objects list and shuttle it to the Data Model list. Change Instance name on the right from CustomerLovVO1 to CustomerLovVO.
6.4.1 Create the SalesRep LOV View Object Select the <yourname>.oracle.apps.demxx.lov.server package in the Navigator, right-click and select "New View Object..." from the context menu to open the View Object wizard. If the Welcome page appears, select Next. In the Name page, specify SalesRepLovVO as the view object name and verify that the Package is <yourname>.oracle.apps.demxx.lov.server. Select the Next button until you get to the Query page. In the Query page, enter the following query into the Query Statement text field.
SELECT first_name || ' ' || last_name sales_rep_name ,sales_rep_id FROM dem_sales_reps
Select the Test button to ensure your syntax is correct. Select the Next button until you get to the Java page. In the Java page, deselect the Generate Java File for View Object Class: SalesRepLovVOImpl (as we do not have to add any code to this view object). Do select the Generate Java File for View Row Class: SalesRepLovVORowImpl to comply with OA Framework coding standards. Select the Finish button to create your VO. 6.4.2 Add the SalesRepLovVO to the OrderEntryLovAM View objects can be used only within the context of a containing application module. Before we use the SalesRepLovVO in our LOV, we must add it to the LOV application module. Select the OrderEntryLovAM in the Navigator pane; right-click and select Edit C-54 Oracle Applications Framework - Practices and Solutions
Lab 2: Orders: Search . OrderEntryLovAM... from the context menu to open the Application Module wizard. Navigate to the Data Model page. Select the SalesRepLovVO view object in the Available View Objects list and shuttle it to the Data Model list. Change Instance name on the right from SalesRepLovVO1 to SalesRepLovVO. Select the OK button to finish adding this VO to the AM. 6.5.1 Create the Shared CustomerLovRN LOV Region Since the Customer details LOV can be used in many different pages, it must be created as a shared, standalone region. Select the OrderEntry.jpr project in the Navigator, right-click and select New.. . from the context menu. In the New window, expand the Web Tier hierarchy and select OA Components. Select Region in the OA Components Items list. Select the OK button to continue. In the New Region dialog, specify the following values: o In the Name field enter CustomerLovRN. o In the Package field enter <yourname>.oracle.apps.demxx.lov.webui. o In the Style field select listOfValues . o Click the OK button to create your region. o Select the CustomerLovRN in the Structure pane, set the AM Definition property to <yourname>.oracle.apps.demxx.lov.server.OrderEntryLovAM , set the Advanced Search Allowed property to True and set the Scope property to Public. 6.5.2 Add a Table to the LOV Region Select the CustomerLovRN in the Structure pane, right-click and select New > table Using Wizard from the context menu. If the Welcome page appears, select Next. In the BC4J Objects page, select your OrderEntryLovAM (<yourname >.oracle.apps.demxx.lov.server.OrderEntryLovAM), then select Oracle Applications Framework - Practices and Solutions C-55
Appendix C: Practices and Solutions your CustomerLovVO view object instance from the Available View Objects list. DO NOT select the Use this as Application Module Definition for this region checkbox. Select the Next button. In the Region Properties page, set the Region ID field value to CustLovTable and set the Region Style to table . Select the Next button. In the View Attributes page, add all the attributes in the CustomerLovVO. Select the Next button.
In the Region Items page, set the ID, Style properties as follows
ID CustId CustName Prompt Customer Number Customer Name Style Data Type messageStyledTex NUMBER t messageStyledTex VARCHAR2 t Attribute Set
Click the Finish button to create your data table. Set the Additional Text property on your table to Customer Details List. Select the CustId and CustName item in the Structure pane, and set their Search Allowed and Selective Search Criteria properties to True . The first property lets users search on these values in the LOV, and the second property ensures that the users specify search criteria for at least one of these values to avoid a blind query.
6.6.1 Create the Shared SalesRepLovRN LOV Region Since the Salesperson details LOV can be used in many different pages, it must be created as a shared, standalone region. Select the OrderEntry.jpr project in the Navigator, right-click and select New.. . from the context menu. In the New window, expand the Web Tier hierarchy and select OA Components. Select Region in the OA Components Items list. Select the OK button to continue. In the New Region dialog, specify the following values: o In the Name field enter SalesRepLovRN. C-56 Oracle Applications Framework - Practices and Solutions
Lab 2: Orders: Search . o In the Package field enter <yourname>.oracle.apps.demxx.lov.webui. o In the Style field select listOfValues . o Click the OK button to create your region. o Select the SalesRepLovRN in the Structure pane, set the AM Definition property to <yourname>.oracle.apps.demxx.lov.server.OrderEntryLovAM , set the Advanced Search Allowed property to True and set the Scope property to Public.
6.6.2 Add a Table to the LOV Region Select the SalesRepLovRN in the Structure pane, right-click and select New > table Using Wizard from the context menu. If the Welcome page appears, select Next. In the BC4J Objects page, select your OrderEntryLovAM (<yourname >.oracle.apps.demxx.lov.server.OrderEntryLovAM), then select your SalesRepLovVO view object instance from the Available View Objects list. DO NOT select the Use this as Application Module Definition for this region checkbox. Select the Next button. In the Region Properties page, set the Region ID field value to SalesRepLovTable and set the Region Style to table. Select the Next button. In the View Attributes page, add all the attributes in the SalesRepLovVO. Select the Next button.
In the Region Items page, set the ID, Style properties as follows
ID SalesRepName SalesRepId Prompt Salesperson Name Salesperson Number Style messageStyledText messageStyledText Data Type VARCHAR2 NUMBER Attribute Set
Click the Finish button to create your data table. Set the Additional Text property on your table to Salesperson Details List. Select the SalesRepName and SalesRepId item in the Structure pane, and set their Oracle Applications Framework - Practices and Solutions C-57
Appendix C: Practices and Solutions Search Allowed and Selective Search Criteria properties to True. The first property lets users search on these values in the LOV, and the second property ensures that the users specify search criteria for at least one of these values to avoid a blind query.
6.7.1 Make the Customer Id Search Item an LOV When we first created the Customer Number item, we set its style to messageTextInput (a standard text entry field). Now, we need to configure it to include an LOV. Select the SearchCustId item in the CustomSimpleSearch panel. Change its Item Style property to messageLovInput. When you set the Item Style property to messageLovInput, JDeveloper automatically creates an inline LOV region (region style listOfValues ) and a default LOV mapping. Set the External LOV property to /<yourname>/oracle/apps/demxx/lov/webui/CustomerLovRN. Note: When we change this property, JDeveloper displays a confirmation message indicating that children of our base field, such as the inline LOV region, will be removed by the change. Confirm the change (select the OK button). Once you confirm, the inline LOV region is removed and the new external LOV region appears in the hierarchy (grayed out because it cannot be edited directly in your page). Verify if its Disable Validation property is set to False. Note: Per the OA Framework View Coding Standards, validation should always be enabled on an LOV field unless the user should be able to enter partial values, as is often the case in a search criteria field. 6.7.2 Define LOV Mappings Create mappings between base page items and LOV items. The mappings identify the data input/output relationships between base page items and LOV items. Select the default LOV mapping, change ID as CustIdMap , and set the following properties: o Change the LOV Region Item property by selecting CustId field from the poplist. This indicates the column selected in the LOV query o Change the Return Item property by selecting SearchCustId field from the poplist. This indicates the field to in the screen to which the CustId value is assigned o Change the Criteria Item property by selecting SearchCustId field from the C-58 Oracle Applications Framework - Practices and Solutions
Lab 2: Orders: Search . poplist. This indicates the field from which the LOV should take value as a search criteria. Right-click lovMappings in the Structure panel, and select New > lovMap from the context menu. Select the default LOV mapping, change ID as CustNameMap, and set the following properties: o Change the LOV Region Item property by selecting CustName field from the poplist. o Change the Return Item property by selecting SearchCustName field from the poplist. 6.8.1 Make the Customer Name Search Item an LOV When we first created the Customer Name item, we set its style to messageTextInput (a standard text entry field). Now, we need to configure it to include an LOV. Select the SearchCustName item in the CustomSimpleSearch panel. Change its Item Style property to messageLovInput. When you set the Item Style property to messageLovInput, JDeveloper automatically creates an inline LOV region (region style listOfValues ) and a default LOV mapping. Set the External LOV property to /<yourname>/oracle/apps/demxx/lov/webui/CustomerLovRN. Note: When you change this property, JDeveloper displays a confirmation message indicating that children of your base field, such as the inline LOV region, will be removed by the change. Confirm the change (select the OK button). Once you confirm, the inline LOV region is removed and the new external LOV region appears in the hierarchy (grayed out because it cannot be edited directly in your page). Verify if its Disable Validation property is set to False. Note: Per the OA Framework View Coding Standards, validation should always be enabled on an LOV f ield unless the user should be able to enter partial values, as is often the case in a search criteria field. 6.8.2 Define LOV Mappings Create mappings between base page items and LOV items. The mappings identify the data input/output relationships between base page items and LOV items. Select the default LOV mapping, change ID as CustNameMap1, and set the following properties: Oracle Applications Framework - Practices and Solutions C-59
Appendix C: Practices and Solutions o Change the LOV Region Item property by selecting CustName field from the poplist. o Change the Return Item property by selecting SearchCustName field from the poplist. o Change the Criteria Item property by selecting SearchCustName field from the poplist. Right-click lovMappings in the Structure panel, and select New > lovMap from the context menu. Select the default LOV mapping, change ID as CustIdMap1 , and set the following properties: o Change the LOV Region Item property by selecting CustId field from the poplist. o Change the Return Item property by selecting SearchCustId field from the poplist. 6.9.1 Make the Salesperson Name Search Item an LOV When we first created the SalesRepName item, we set its style to messageTextInput (a standard text entry field). Now, we need to configure it to include an LOV. Select the SearchSalespersonName item in the CustomSimpleSearch panel. Change its Item Style property to messageLovInput. When you set the Item Style property to messageLovInput, JDeveloper automatically creates an inline LOV region (region style listOfValues ) and a default LOV mapping. Set the External LOV property to /<yourname>/oracle/apps/demxx/lov/webui/SalesRepLovRN . Note: When you change this property, JDeveloper displays a confirmation message indicating that children of your base field, such as the inline LOV region, will be removed by the change. Confirm the change (select the OK button). Once you confirm, the inline LOV region is removed and the new external LOV region appears in the hierarchy (grayed out because it cannot be edited directly in your page). Verify if its Disable Validation property is set to False. Note: Per the OA Framework View Coding Standards, validation should always be enabled on an LOV f ield unless the user should be able to enter partial values, as is often the case in a search criteria field. 6.9.2 Define LOV Mappings C-60 Oracle Applications Framework - Practices and Solutions
Lab 2: Orders: Search . Create mappings between base page items and LOV items. The mappings identify the data input/output relationships between base page items and LOV items. Select the default LOV mapping, ID labeled as SalesRepMap, and set the following properties: o Change the LOV Region Item property by selecting SalesRepName field from the poplist. o Change the Return Item property by selecting SearchSalespersonName field from the poplist. o Change the Criteria Item property by selecting SearchSalespersonName field from the poplist.
Figure 8:Task 6: Finished Product 6.9.3 Test Your Work Test your work. Your base page (the Orders Search page) should appear as shown in the figure above. When you select the list of values icon, your LOV windows should appear as shown in Figures 7 above. Warning: You cannot run and test the LOV page directly. You must run your base page, and then select the list of values icon to invoke the LOV. You are now finished with this exercise.
Figure 2: Details Page Finished Product C-62 Oracle Applications Framework - Practices and Solutions
Select the Expert Mode checkbox. This allows you to edit the generated query. In the Query Statement text box modify the query (the portion shown in bold is what you are expected to add to your already existing query) so that it looks like the following When you are finished with your editing, select the Test button to ensure your syntax is correct.
SELECT OrderEO.ORDER_ID, OrderEO.LAST_UPDATE_DATE, OrderEO.LAST_UPDATED_BY, OrderEO.CREATION_DATE, OrderEO.CREATED_BY, OrderEO.LAST_UPDATE_LOGIN, OrderEO.CUSTOMER_ID, OrderEO.SALES_REP_ID, OrderEO.PAYMENT_TYPE, OrderEO.CURRENCY_CODE, OrderEO.ORDER_STATUS, OrderEO.DATE_ORDERED, OrderEO.DATE_SHIPPED, OrderEO.CHECK_NUMBER, OrderEO.CC_TYPE, OrderEO.CC_NUMBER, OrderEO.CC_EXPIRATION, OrderEO.CC_APPROVAL_CODE, OrderEO.ORDER_NOTE, OrderEO.ATTRIBUTE_CATEGORY, OrderEO.ATTRIBUTE1, OrderEO.ATTRIBUTE2, OrderEO.ATTRIBUTE3, OrderEO.ATTRIBUTE4, OrderEO.ATTRIBUTE5, OrderEO.ATTRIBUTE6, OrderEO.ATTRIBUTE7, OrderEO.ATTRIBUTE8, OrderEO.ATTRIBUTE9, OrderEO.ATTRIBUTE10, DemCust.NAME AS CUSTOMER_NAME, DemSale.FIRST_NAME||' '||DemSale.LAST_NAME AS SALES_REP_NAME
Select the Next button. In the Attribute Mappings page, verify that your view object attributes map to the correct query columns. If you need to make any changes, place your cursor into the incorrect View Attributes field and select the correct value from the poplist. Select the Next button. In the Java page, select both the Generate Java File for View Object Class: OrderDetailsVOImpl checkbox and the Generate Java File for View Row Class: OrderDetailsVORowImpl. Select the Finish button to create your VO. Now verify that your VO attribute settings match the aliases in your SQL query. Select the OrderDetailsVO in the Navigator, right-click and select Edit OrderDetailsVO... from the context menu to open the View Object wizard. o Navigate to the Tunings section for your attributes and verify that Enable Passivation checkbox is selected o Navigate to the Attribute Mappings page and verify that all the mappings are correct. Make any necessary changes and select Apply. o Select the OK button to finish editing your VO. 1.2 Add Your View Object to the Root UI Application Module The Details page will share the same root UI application module that you used for the Search page, so you need to add the page's view object to the OrderEntryAM application module. Select the OrderEntryAM in the Navigator pane, right-click and select Edit OrderEntryAM... from the context menu to open the Application Module wizard. Navigate to the Data Model page. Select the OrderDetailsVO view object in the Available View Objects list and shuttle it to the Data Model list. Modify the Instance name shown on the right bottom from OrderDetailsVO1 to OrderDetailsVO. Select the OK button to finish adding your VO to your root AM.
1.3 Save Your Work Select the JDeveloper main menu option File > Save All. There is no need to test at this point since we have not associated the view object with your UI.
Note that this page using the application module type (same AM Definition value) as the OrderSearchPG. Later, we will make sure it uses the same instance of the same application module type when it renders. Oracle Applications Framework - Practices and Solutions C-67
Appendix C: Practices and Solutions 2.3 Add a Product Branding Image Each Oracle Applications page requires a product-branding image. Select your PageLayoutRN in the Structure pane, right-click and select New ... productBranding from the context menu.
2.4 Create the Main Content Region To achieve the correct indentation of our display fields, add a defaultSingleColumn region to your PageLayoutRN. Since each of the items in this region will bind to the OrderDetailsVO view instance, we will use the region wizard to quickly create this. Select the PageLayoutRN in the Structure pane, right-click and select New > Region Using Wizard from the context menu. If the Welcome page appears, select Next. In the BC4J Objects page, select your OrderEnryAM (<yourname>.oracle.apps.demxx.orderentry.server.OrderEnryAM), and then select your OrderDetailsVO view object instance from the Available View Objects list. DO NOT select the Use this as Application Module Definition for this region checkbox. Select the Next button. In the Region Properties page, set the Region ID field value to MainRN and set the Region Style to defaultSingleColumn. Select the Next button. In the View Attributes page, select the following from the Available View Attributes list and shuttle them to the Selected View Attributes list: o OrderId o CustomerId C-68 Oracle Applications Framework - Practices and Solutions
Lab 3: Orders: Drilldown to Details . o SalesRepId o PaymentType o CurrencyCode o OrderStatus o DateOrdered o DateShipped o CheckNumber o CcType o CcNumber o CcExpiration o CcApprovalCode o OrderNote o CustomerName o SalesRepName o AttributeCategory o Attribute1 o Attribute2 o Attribute3 o Attribute4 o Attribute5 o Attribute6 o Attribute7 o Attribute8 o Attribute9 o Attribute10 Select the Next button. In the Region Items page, set the item properties as follows Oracle Applications Framework - Practices and Solutions C-69
Appendix C: Practices and Solutions ID OrderId CustomerId SalesRepId PaymentType CurrencyCode OrderStatus DateOrdered DateShipped CheckNumber CcType CcNumber CcExpiration CcApprovalCode OrderNote CustomerName SalesRepName AttributeCategory Attribute1 Attribute2 Attribute3 Attribute4 Attribute5 Attribute6 Attribute7 Attribute8 Attribute9 Attribute10 Prompt Order Number Customer Number Salesperson Number Payment Type Currency Code Order Status Order Date Ship Date Check Number Type Creditcard Number Expiration Approval Code Order Note Customer Name Salesperson Name AttributeCategory Attribute1 Attribute2 Attribute3 Attribute4 Attribute5 Attribute6 Attribute7 Attribute8 Attribute9 Attribute10 Style messageStyledText messageStyledText messageStyledText messageStyledText messageStyledText messageStyledText messageStyledText messageStyledText messageStyledText messageStyledText messageStyledText messageStyledText messageStyledText messageStyledText messageStyledText messageStyledText messageStyledText messageStyledText messageStyledText messageStyledText messageStyledText messageStyledText messageStyledText messageStyledText messageStyledText messageStyledText messageStyledText Data Type Attribute Set NUMBER NUMBER NUMBER VARCHAR2 VARCHAR2 VARCHAR2 DATE DATE NUMBER VARCHAR2 VARCHAR2 VARCHAR2 VARCHAR2 VARCHAR2 VARCHAR2 VARCHAR2 VARCHAR2 VARCHAR2 VARCHAR2 VARCHAR2 VARCHAR2 VARCHAR2 VARCHAR2 VARCHAR2 VARCHAR2 VARCHAR2 VARCHAR2
Click the Finish button to create your data table. Select the MainRN region in the Structure pane. Set the Hide Header property to True (so no header text or line renders), and leave the Text property blank. 2.5 Finish Setting MainRN Item Properties Most of the MainRN item properties were set when you created the defaultSingleColumn region. Open each of the following items in the MainRN and set the following additional properties as shown: OrderId Property CSS Class Value OraDataText
Lab 3: Orders: Drilldown to Details . CustomerId Property CSS Class Value OraDataText
2.6 Change the Main Region's Style Select the MainRN defaultSingleColumn region and change its Region Style property to messageComponentLayout. JDeveloper will display the following warning; select the Yes button to proceed. Your items will not be adversely affected.
Tip: The messageComponentLayout region style is new in release 11.5.10 (and should be used in place of all default* regions which will eventually be deprecated). Since "region using wizard" creation support is not yet available for the messageComponentLayout , this is the most efficient way to create a single row region whose items bind to a view object instance. 2.7 Add a messageLayout Select the MainRN and right-click on it. Choose New -> messageLayout from the list. A default messageLayout1 item gets added at the end. Select the messageLayout item and set its ID to FormValueLayout. Now drag and drop the following items in the MainRN to the FormValueLayout. o SalesRepId o AttributeCategory o Attribute1 o Attribute2 o Attribute3 o Attribute4 o Attribute5 o Attribute6 o Attribute7 o Attribute8 o Attribute9 o Attribute10 In the Property Inspector, change the Item Style of all these items to formValue and set the following properties for each of them. Note that the View Attribute may be reset when we change the Item Style to formValue. Oracle Applications Framework - Practices and Solutions C-73
Appendix C: Practices and Solutions Assign the View Attribute property of all these items back to their original value just in case they are lost. FormValue Item SalesRepId AttributeCategory Attribute1 Attribute2 Attribute3 Attribute4 Attribute5 Attribute6 Attribute7 Attribute8 Attribute9 Attribute10 View Attribute SalesRepId AttributeCategory Attribute1 Attribute2 Attribute3 Attribute4 Attribute5 Attribute6 Attribute7 Attribute8 Attribute9 Attribute10
Also remember to set the Data Type property of SalesRepId to NUMBER. Note: This method is adopted, as we cannot directly add a non-message item (such as formValue item) to a messageComponentLayout as a child. In such cases, we add a messageLayout to which all our non-message items are added. Before we proceed further, rearrange the other items (by drag-and-drop) to display details in a particular order in the OrderDetailsPG. The order prescribed here is o OrderId o OrderStatus o DateOrdered o DateShipped o CustomerId o CustomerName o SalesRepName o CurrencyCode o PaymentType o CheckNumber o CcType o CcNumber o CcExpiration C-74 Oracle Applications Framework - Practices and Solutions
2.8 Add a "Return to Orders: Search Page" Link Add a "Return to Orders: Search Page" link at the bottom of your page beneath the page content bottom line (the ski). Select your PageLayoutRN in the Structure pane, right-click and select New > returnNavigation. Select the returnNavigation link item that JDeveloper creates for you beneath the pageComponents folder and set the following properties: Property ID Destination URL Text Value ReturnLink OA.jsp?page=/<yourname>/oracle/apps/demxx/orderentry/webui/OrderSearch PG&retainAM=Y Return to Orders: Search Page
2.9 Save Your Work Select the JDeveloper main menu option File > Save All.
public void initQuery(String orderNumber) { if ((orderNumber != null) && (!("".equals(orderNumber.trim())))) { // Do the following conversion for type consistency. Number ordNum = null; try { ordNum = new Number(orderNumber); } catch(Exception e) { throw new OAException("DEMXX", "ORDLINES_INVALID_LINE_NUMBER"); } setWhereClause("ORDER_ID = :1"); setWhereClauseParams(null); // Always reset setWhereClauseParam(0, ordNum); executeQuery(); } } // end initQuery()
3.2 Add an initDetails( ) Method to Your OrderEntryAMImpl Class You will invoke this method from your UI controller (per the OA Framework coding standards, you should interact only with the OAApplicationModule interface in your controller; you should not interact directly with view objects). This method delegates to the initQuery() method that you just created on the OrderDetailsVOImpl class. Note the import/use of the oracle.apps.fnd.framework.OAException and oracle.apps.fnd.common.MessageToken classes.
import oracle.apps.fnd.framework.OAException; import oracle.apps.fnd.common.MessageToken; ...
3.3 Save and Compile Your Work Select the JDeveloper main menu option File > Save All. Select your project, right-click and select Rebuild OrderEntry.jpr to compile everything (you can also select the same option from the main menu).
At runtime, the OA Framework substitutes the current row's view instance attribute values for the tokens inside the curly braces. So, for example, &orderNumber={@OrderId} becomes &orderNumber=1234. 4.2 Create a Controller for the Details Page Since the logic in this controller applies to the page title, it is best to simply add the controller at the pageLayout level. Select the PageLayoutRN of the OrderDetailsPG in the Structure pane, right-click and select Set New Controller ... from the context menu. In the New Controller dialog, set the Package Name to <yourname>.oracle.apps.demxx.orderentry.webui and the Class Name to OrderDetailsCO. Select OK to create your controller. C-78 Oracle Applications Framework - Practices and Solutions
Lab 3: Orders: Drilldown to Details . 4.3 Add Controller Logic to Initalize Order Query When Page Renders To automatically query the underlying OrderDetailsVO view object when the OrderDetailsPG renders, add the following code to the OrderDetailsCO.processRequest( ) method. Note that you are referencing the orderNumber parameter that you add to the URL when the user selects the Order Number link.
import java.io.Serializable; import oracle.apps.fnd.framework.OAApplicationModule; ... public void processRequest(OAPageContext pageContext, OAWebBean webBean) { // Always call this first. super.processRequest(pageContext, webBean); // Get the orderNumber parameter from the URL String orderNumber = pageContext.getParameter("orderNumber"); // Now we want to initialize the query for our single order // with all of its details. OAApplicationModule am = pageContext.getApplicationModule(webBean); Serializable[] parameters = { orderNumber }; am.invokeMethod("initDetails", parameters); }
4.4 Programmatically Set the Page Title Text Per the BLAF UI Guidelines on Header Components, you need to display the current selected customers name in the Details page title. To do this, add the following code to your controller's processRequest() method. Note that this assumes a message (ORDLINES_HDR_TEXT) has already been created in the database with the following content: Order Details for &CUST_NAME.
import oracle.apps.fnd.common.MessageToken; import oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean; ... public void processRequest(OAPageContext pageContext, OAWebBean webBean) { // Code from Step 4.3 omitted for clarity... The following should be // added after the code you added above. // Get the CustomerName parameter from the URL String Name = pageContext.getParameter("customerName"); // // // // Always use a translated value from Message Dictionary when setting strings in your controllers. Instantiate an array of message tokens and set the value for the CUST_NAME token.
((OAPageLayoutBean)webBean).setTitle(pageHeaderText); }
4.5 Save and Test Your Work Select the JDeveloper main menu option File > Save All. Select your project, right-click and select Rebuild OrderEntry.jpr to compile everything (you can also select the same option from the main menu). Select the OrderSearchPG, right-click and select Run OrderSearchPG.xml (if you want to debug, select Debug EmpSearchPG.xml). To test the Details page, query one or more orders and select the Order Number link. The Details page should render as shown in Figure 2 above. Note that the breadcrumbs will not render if you run the page directly from JDeveloper as described here since the associated application menu does not render in this mode (breadcrumbs render only if the menu renders). You are now finished with this exercise.
Select the ButtonLayout region, right-click and select New > Item. Set this item's
properties as follows: Property ID Item Style Attribute Set Prompt Additional Text Value Create SubmitButton /oracle/apps/fnd/attributesets/Buttons/Create Create Order Select to create an order
Select the OrderSearchPG, right-click and select Run OrderSearchPG.xml. 1.2 Add "Create Order" Button Press Handler to Your Search Page When the user presses the Create Order submitButton, you need processFormRequest() code to determine that this button has been pressed and navigate the user to the OrderCreatePG that you will be creating in Task 3 below. First, create a controller and associate with the PageLayoutRN region in the OrderSearchPG. Select the PageLayoutRN region in the OrderSearchPG, right-click and select Set New Controller ... from the context menu. In the Package Name field enter <yourname>.oracle.apps.demxx.orderentry.webui. In the Name field enter OrderSearchCO. Select the OK button to create your controller.
Lab 4: Orders: Create . Then, add the following code to the OrderSearchCO.processFormRequest( ) method:
import oracle.apps.fnd.framework.webui.OAWebBeanConstants; ...
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean) { // Always call this first super.processFormRequest(pageContext, webBean); if (pageContext.getParameter("Create")!=null) { // Navigate to the Order Create Page while retaining the AM. // Note the use of KEEP_MENU_CONTEXT as opposed to GUESS_MENU_CONTEXT // since we know the current tab should remain highlighted. pageContext.setForwardURL("OA.jsp?page=/<yourname>/oracle/apps/demxx/ orderentry/webui/OrderCreatePG", null, OAWebBeanConstants.KEEP_MENU_CONTEXT, null, null, //HashMap true, // Retain AM OAWebBeanConstants.ADD_BREAD_CRUMB_YES, OAWebBeanConstants.IGNORE_MESSAGES); } }
1.3 Compile and Save Your Work At this point, you are not ready for testing.
A poplist view object includes two attributes: one for the display value, and one for the internal selection value. Use the following query (in this case, meaning is the display value and lookup_code is the internal developer value):
You should not generate a *VOImpl file (you will not need any code for this), but you must generate the *VORowImpl file as usual per the coding standards.
2.2.2 Add the OrderStatusVO to the OrderEntryAM Add the OrderStatusVO view object to the OrderEntryAM. 2.3.1 Create the CcTypeVO in the Poplist BC4J Package In the <yourname>.oracle.apps.demxx.poplist.server package, create a new view object with CcTypeVO as the view object name and verify that the Package is <yourname>.oracle.apps.demxx.poplist.server. A poplist view object includes two attributes: one for the display value, and one for the internal selection value. Use the following query (in this case, meaning is the C-84 Oracle Applications Framework - Practices and Solutions
Lab 4: Orders: Create . display value and lookup_code is the internal developer value):
SELECT meaning, lookup_code FROM fnd_lookups WHERE lookup_type = 'CCTYPE_LOOKUP'
You should not generate a *VOImpl file (you will not need any code for this), but you must generate the *VORowImpl file as usual per the coding standards.
2.3.2 Add the CcTypeVO to the OrderEntryAM Add the CcTypeVO view object to the OrderEntryAM. 2.4 Compile and Save Your Work At this point, you are not ready for testing.
Verify and set (if necessary) the following properties for the pageLayout region of
your new OrderCreatePG : Property ID Region Style AM Definition Window Title Title Warn About Changes AutoFooter Value PageLayoutRN pageLayout <yourname>.oracle.apps.demxx.orderentry.server.OrderEntryAM Order Entry Tutorial: Labs <your name> Orders: Create True True
Note that setting the Warn About Changes property to True ensures that users are warned when they try to navigate from this data entry page with pending changes (the page's Cancel button is an exception, as you will see later). See the Save Model documentation for additional information about this. 3.3 Add a Product Branding Image Add the product branding image, FNDTAPPBRAND.gif, to your page, similar to the step done in Order search page. Make sure you include additional text for the same. 3.4 Add Page-Level Apply and Cancel Buttons Per the BLAF UI guidelines, all page-level buttons render twice on the page: below the page title, and below the ski. However, you only need to add them once using a special pageButtonBar region. First, select the PageLayoutRN in the Structure pane, then right-click and select New > Region from the context menu.
Second, add a Cancel button. Right-click PageButtons in the Structure pane, and select New > Item from the context menu. Set or verify the following properties for this item: Property ID Item Style Attribute Set Value Cancel submitButton /oracle/apps/fnd/attributesets/Buttons/Cancel (Always use the standard OA Framework attribute sets for common buttons.) Disable Server Side True Validation (So the user can leave the page by selecting this button without encountering server- side validation errors.) Disable Client Side True Validation (So the user can leave the page by selecting this button without encountering client- side validation errors.) Prompt Cancel (Set automatically when you specify the attribute set.) Warn About Changes False (So the user can leave the page by selecting this button without being warned about pending changes.) Additional Text Select to cancel this transaction. (This is required per the accessibility coding standards).
Third, add an Apply button. Right-click PageButtons in the Structure pane, and
select New > Item from the context menu. Set or verify the following properties for this item: Property ID Item Style Attribute Set Prompt Additional Text Value Apply submitButton /oracle/apps/fnd/attributesets/Buttons/Apply Apply (Set by the attribute set.) Select to save this order.
Appendix C: Practices and Solutions 3.5 Create the Main Content Region To achieve the correct indentation of our display fields, add a defaultSingleColumn region to your PageLayoutRN. Since each of the items in this region will bind to the OrderDetailsVO view instance, we will use the region wizard to quickly create this. Select the PageLayoutRN in the Structure pane, right-click and select New > Region Using Wizard from the context menu. In the BC4J Objects page, select your OrderEntryAM (<yourname >.oracle.apps.demxx.orderentry.server.OrderEntryAM), and then select your OrderDetailsVO view object instance from the Available View Objects list. DO NOT select the Use this as Application Module Definition for this region checkbox. In the Region Properties page, set the Region ID field value to MainRN and set the Region Style to defaultSingleColumn. In the View Attributes page, select the following attributes in the Available View Attributes list and shuttle them to the Selected View Attributes list: o OrderId o CustomerId o SalesRepId o PaymentType o CurrencyCode o OrderStatus o DateOrdered o DateShipped o CheckNumber o CcType o CcNumber o CcExpiration o CcApprovalCode o OrderNote C-88 Oracle Applications Framework - Practices and Solutions
Lab 4: Orders: Create . o CustomerName o SalesRepName o AttributeCategory o Attribute1 o Attribute2 o Attribute3 o Attribute4 o Attribute5 o Attribute6 o Attribute7 o Attribute8 o Attribute9 o Attribute10
In the Region Items page, set the ID, Prompt, Style as follows:
ID OrderId CustomerId SalesRepId PaymentType CurrencyCode OrderStatus DateOrdered DateShipped CheckNumber CcType CcNumber CcExpiration CcApprovalCode OrderNote CustomerName SalesRepName AttributeCategory Attribute1 Attribute2 Attribute3 Prompt Order Number Customer Number Salesperson Number Payment Type Currency Order Status Order Date Ship Date Number Type Number Expiration Approval Code Order Note Customer Name Salesperson Name AttributeCategory Attribute1 Attribute2 Attribute3 Style messageStyledText messageLovInput messageTextInput messageTextInput messageLovInput messageChoice messageTextInput messageTextInput messageTextInput messageChoice messageTextInput messageTextInput messageTextInput messageTextInput messageLovInput messageLovInput messageTextInput messageTextInput messageTextInput messageTextInput Data Type Attribute Set NUMBER NUMBER NUMBER VARCHAR2 VARCHAR2 VARCHAR2 DATE DATE NUMBER VARCHAR2 VARCHAR2 VARCHAR2 VARCHAR2 VARCHAR2 VARCHAR2 VARCHAR2 VARCHAR2 VARCHAR2 VARCHAR2 VARCHAR2
Appendix C: Practices and Solutions ID Prompt Style Data Type Attribute Set Attribute4 Attribute4 messageTextInput VARCHAR2 Attribute5 Attribute5 messageTextInput VARCHAR2 Attribute6 Attribute6 messageTextInput VARCHAR2 Attribute7 Attribute7 messageTextInput VARCHAR2 Attribute8 Attribute8 messageTextInput VARCHAR2 Attribute9 Attribute9 messageTextInput VARCHAR2 Attribute10 Attribute10 messageTextInput VARCHAR2 Click the Finish button to create your data table. 3.6 Finish Setting MainRN Item Properties Before we proceed further, rearrange the items (by drag-and-drop) to display details in a particular order in the OrderCreatePG. The order prescribed here is o OrderId o DateOrdered o OrderStatus o DateShipped o CustomerId o CustomerName o SalesRepName o CurrencyCode o PaymentType o CheckNumber o CcType o CcNumber o CcExpiration o CcApprovalCode o OrderNote o SalesRepId o AttributeCategory o Attribute1 C-90 Oracle Applications Framework - Practices and Solutions
Lab 4: Orders: Create . o Attribute2 o Attribute3 o Attribute4 o Attribute5 o Attribute6 o Attribute7 o Attribute8 o Attribute9 o Attribute10 Most of the MainRN item properties were set when you created the defaultSingleColumn region. Now, you need to complete the process of setting their properties. Open each of the following items in the MainRN and set/verify the following additional properties as shown. OrderId We are going to automatically generate the new order number using a database sequence, so this value is display only. Property Required CSS Class DateOrdered Property Required CSS Class Tip Type Value Yes OraFieldText DateFormat Value Yes OraDataText
Whenever you set the Required property to yes, a required field indicator renders next to the prompt. Also, when the page is submitted, UIX verifies that this field is non-null before issuing a POST request to the server. OrderStatus The OrderStatus item is a poplist. You have already specified the data source for the item's value (the OrderStatus view object attribute): like any other text field, this is the view object attribute Oracle Applications Framework - Practices and Solutions C-91
Appendix C: Practices and Solutions value that we will set in the OrderDetailsVO view object based on the user's poplist selection. In this step, you need to associate the 2- value view object that you created in Task 2 with the poplist so the poplist can display its list of selectable values. Tip: If the "Picklist" properties do not display in the property inspector, verify that the Item Style is messageChoice. Property Required Picklist View Instance Picklist Display Attribute Picklist Value Attribute CSS Class DateShipped Property CSS Class Value OraFieldText Value yes OrderStatusVO (Name of the view object to be used for the poplist values.) Meaning (The value to display in the poplist.) LookupCode (The internal developer value. ) OraFieldText
CustomerId The CustomerId field requires a list of values; we can reuse the CustomerLovRN that we already created in the Search lab. Tip: If the External LOV property does not display in the property inspector, verify that the Item Style is messageLovInput . Property Required External LOV Maximum Length CSS Class LOV Mappings Value Yes /<yourname>/oracle/apps/demxx/lov/webui/CustomerLovRN 15 OraFieldText You must create LOV mappings for the following: LOV Map 1 ID: CustIdMap Lov Region Item: CustId Return Item: CustomerId Criteria Item: CustomerId LOV Map 2 ID: CustNameMap Lov Region Item: CustName Return Item: CustomerName
Lab 4: Orders: Create . The CustomerName field requires a list of values as well; similarly we can reuse the CustomerLovRN that we already created in the Search lab. Tip: If the External LOV property does not display in the property inspector, verify that the Item Style is messageLovInput . Property Required Required External LOV Maximum Length CSS Class LOV Mappings Value Yes /<yourname>/oracle/apps/demxx/lov/webui/CustomerLovRN 50 OraFieldText You must create LOV mappings for the following: LOV Map 1 ID: CustNameMap1 Lov Region Item: CustName Return Item: CustomerName Criteria Item: CustomerName LOV Map 2 ID: CustIdMap1 Lov Region Item: CustId Return Item: CustomerId
SalesRepName The SalesRepName field again requires a list of values; hence we can reuse the SalesRepLovRN that we already created in the Search lab. Tip: If the External LOV property does not display in the property inspector, verify that the Item Style is messageLovInput . Property External LOV Maximum Length CSS Class LOV Mappings Value /<yourname>/oracle/apps/demxx/lov/webui/SalesRepLovRN 101 OraFieldText You must create LOV mappings for the following: LOV Map 1 ID: RepNameMap Lov Region Item: SalesRepName Return Item: SalesRepName Criteria Item: SalesRepName LOV Map 2 ID: RepIdMap Lov Region Item: SalesRepId Return Item: SalesRepId
CurrencyCode Create the CurrencyCode LOV View Object Oracle Applications Framework - Practices and Solutions C-93
Appendix C: Practices and Solutions Select the <yourname>.oracle.apps.demxx.lov.server package in the Navigator, right-click and select "New View Object..." from the context menu to open the View Object wizard. If the Welcome page appears, select Next. In the Name page, specify CurrencyCodeLovVO as the view object name and verify that the Package is <yourname>.oracle.apps.demxx.lov.server. Select the Next button until you get to the Query page. In the Query page, enter the following query into the Query Statement text field.
SELECT currency_code ,name FROM fnd_currencies_active_v
Select the Test button to ensure your syntax is correct. Select the Next button until you get to the Java page. In the Java page, deselect the Generate Java File for View Object Class: CurrencyCodeLovVOImpl (as you do not have to add any code to this view object). Do select the Generate Java File for View Row Class: CurrencyCodeLovVORowImpl to comply with OA Framework coding standards. Select the Finish button to create your VO. Add the CurrencyCodeLovVO to the OrderEntryLovAM View objects can be used only within the context of a containing application module. Before we use the CurrencyCodeLovVO in our LOV, we must add it to the LOV application module. Select the OrderEntryLovAM in the Navigator pane; right-click and select Edit OrderEntryLovAM... from the context menu to open the Application Module wizard. Navigate to the Data Model page. Select the CurrencyCodeLovVO view object in the Available View Objects list and shuttle it to the Data Model list. Change Instance name on the right from CurrencyCodeLovVO1 to CurrencyCodeLovVO. Select the OK button to finish adding this VO to the AM. Create the Shared CurrencyCodeLovRN LOV Region Since the Customer details LOV can be used in many different pages, it must be created as a shared, standalone region. Select the OrderEntry.jpr project in the Navigator, right-click and select New... from the context menu. C-94 Oracle Applications Framework - Practices and Solutions
Lab 4: Orders: Create . In the New window, expand the Web Tier hierarchy and select OA Components. Select Region in the OA Components Items list. Select the OK button to continue. In the New Region dialog, specify the following values: o In the Name field enter CurrencyCodeLovRN. o In the Package field enter <yourname>.oracle.apps.demxx.lov.webui. o In the Style field select listOfValues . o Click the OK button to create your region. o Select the CurrencyCodeLovRN in the Structure pane, set the AM Definition property to <yourname>.oracle.apps.demxx.lov.server.OrderEntryLovAM, set the Advanced Search Allowed property to True and set the Scope property to Public.
Add a Table to the LOV Region Select the CurrencyCodeLovRN in the Structure pane, right-click and select New > table Using Wizard from the context menu. If the Welcome page appears, select Next. In the BC4J Objects page, select your OrderEntryLovAM (<yourname >.oracle.apps.demxx.lov.server.OrderEntryLovAM), then select your CurrencyCodeLovVO view object instance from the Available View Objects list. DO NOT select the Use this as Application Module Definition for this region checkbox. Select the Next button. In the Region Properties page, set the Region ID field value to CurrCodeLovTable and set the Region Style to table. Select the Next button. In the View Attributes page, add all the attributes in the CurrencyCodeLovVO. Select the Next button.
In the Region Items page, set the ID, Style properties as follows
ID Prompt Style Data Type Attribute Set
Appendix C: Practices and Solutions CurrencyCode Code messageStyledText VARCHAR2 CurrencyName Name messageStyledText VARCHAR2 Click the Finish button to create your data table. Set the Additional Text property on your table to Currency Details List. Select the CurrencyCode and CurrencyName item in the Structure pane, and set their Search Allowed properties to True . Thefirst property lets users search on these values in the LOV. Now select your CurrencyCode item in your OrderCreatePG and set the following properties: Property Required External LOV Maximum Length Length CSS Class LOV Mappings Value yes /<yourname>/oracle/apps/demxx/lov/webui/CurrencyCodeLovRN 15 5 OraFieldText You must create LOV mappings for the following: LOV Map 1 ID: CodeMap Lov Region Item: CurrencyCode Return Item: CurrencyCode Criteria Item: CurrencyCode
CheckNumber Property Maximum Length CSS Class CcType The CcType item is a poplist. You have already specified the data source for the item's value (the CcType view object attribute): like any other text field, this is the view object attribute value that we will set in the OrderDetailsVO view object based on the user's poplist selection. In this step, you need to associate the 2- value view object that you created in Task 2 with the poplist so the poplist can display its list of selectable values. Tip: If the "Picklist" properties do not display in the property inspector, verify that the Item Style is messageChoice. Property Picklist View Instance Value CcTypeVO (Name of the view object to be used for the poplist values.) Picklist Display Attribute Meaning C-96 Oracle Applications Framework - Practices and Solutions Value 15 OraFieldText
Lab 4: Orders: Create . (The value to display in the poplist.) Picklist Value Attribute LookupCode (The internal developer value. ) CSS Class OraFieldText
OrderNote Property Maximum Length CSS Class Length Value 2000 OraFieldText 110
Appendix C: Practices and Solutions 3.7 Focus on Layout 3.7.1 Convert the MainRN Style from defaultSingleColumn to
messageComponentLayout
As we did in the Drilldown to Details exercise, change the MainRN Region Style to messageComponentLayout: to Select the MainRN defaultSingleColumn region and change its Region Style property messageComponentLayout. JDeveloper will display a warning; select the Yes button to proceed. Your items will not be adversely affected.
Tip: The messageComponentLayout region style is new in release 11.5.10 (and should be used in place of all default* regions which will eventually be deprecated). Since "region using wizard" creation support is not yet available for the messageComponentLayout , this is the most efficient way to create a single row region whose items bind to a view object instance. Select the messageComponentLayout region, right-click and select New > messageLayout. Set the messageLayout ID to FormValueLayout . Select the following items and drag and drop each of them beneath the messageLayout region. Now drag and drop the following items in the MainRN to the FormValueLayout. o SalesRepId o AttributeCategory o Attribute1 o Attribute2 o Attribute3 o Attribute4 o Attribute5 o Attribute6 o Attribute7 o Attribute8 o Attribute9 o Attribute10
Lab 4: Orders: Create . In the Property Inspector, change the Item Style of all these items to formValue and set the following properties for each of them. Note that the View Attribute may be reset when we change the Item Style to formValue. Assign the View Attribute property of all these items back to their original value just in case they are lost.
FormValue Item SalesRepId AttributeCategory Attribute1 Attribute2 Attribute3 Attribute4 Attribute5 Attribute6 Attribute7 Attribute8 Attribute9 Attribute10
View Attribute SalesRepId AttributeCategory Attribute1 Attribute2 Attribute3 Attribute4 Attribute5 Attribute6 Attribute7 Attribute8 Attribute9 Attribute10
Also remember to set the Data Type property of SalesRepId to NUMBER. Note: We have to create this extra region, as we cannot directly add a non-message item (such as formValue item) to a messageComponentLayout as a child. In such cases, we add a messageLayout to which all our non-message items are added. To learn more about working with the messageComponentLayout region, see Page Layout (How to Place Content) in the OA Framework Developer's Guide.
3.7.2 Create a new messageComponentLayout Region for PaymentTypeRN Select the PageLayoutRN, right-click and select New > Region Select the header region region1 that JDeveloper creates for you beneath the MainRN component and set its ID to PaymentTypeRN. Set the Region Style Property to messageComponentLayout. Now drag and drop the following items in the MainRN to the PaymentTypeRN as children: o PaymentType Oracle Applications Framework - Practices and Solutions C-99
3.7.3 Create a new messageComponentLayout Region for FooterRN Select the PageLayoutRN, right-click and select New > Region Select the header region region1 that JDeveloper creates for you beneath the PaymentTypeRN component and set its ID to FooterRN. Set the Region Style Property to messageComponentLayout. Now drag and drop the OrderNote item in the MainRN to the FooterRN as child.
3.7.4 Adjusting the Layout for MainRN Select the MainRN, in the property inspector set the following properties Value 8 2
Select the MainRN, right-click and select New > messageLayout. Set the messageLayout ID to TableContentLayout. Select the TableContentLayout , right-click and select New > Region. Set the region ID to TableLayout. Set the Region Style of this region to tableLayout. Set the Horizontal Alignment to center Set the Width to 100% Select the TableLayout , right-click and select New > rowLayout. C-100 Oracle Applications Framework - Practices and Solutions
Lab 4: Orders: Create . Set the region ID to RowOneRN. Select the RowOneRN , right-click and select New > cellFormat. Set the region ID to CellOne. Select the RowOneRN , right-click and select New > cellFormat. Set the region ID to CellTwo. Repeat the steps mentioned above to get rest of the cells. For RowTwoRN Select the TableLayout , right-click and select New > rowLayout. Set the region ID to RowTwoRN. Select the RowTwoRN , right-click and select New > cellFormat. Set the region ID to CellThree. Select the RowTwoRN , right-click and select New > cellFormat. Set the region ID to CellFour. For RowThreeRN Select the TableLayout , right-click and select New > rowLayout. Set the region ID to RowThreeRN. Select the RowThreeRN , right-click and select New > cellFormat. Set the region ID to CellFive. For RowFourRN Select the TableLayout , right-click and select New > rowLayout. Set the region ID to RowFourRN. Select the RowFourRN, right-click and select New > cellFormat. Set the region ID to CellSix. For RowFiveRN Select the TableLayout , right-click and select New > rowLayout. Set the region ID to RowFiveRN. Oracle Applications Framework - Practices and Solutions C-101
Appendix C: Practices and Solutions Select the RowFiveRN, right-click and select New > cellFormat. Set the region ID to CellSeven. Select the RowFiveRN, right-click and select New > cellFormat. Set the region ID to CellEight. Set the items into different cells as follows Now individually drag-and-drop OrderId into CellOne as child DateOrdered into CellTwo as child OrderStatus into CellThree as child DateShipped into CellFour as child CustomerId into CellFive as child CustomerName into CellSix as child SalesRepName into CellSeven as child CurrencyCode into CellEight as child Set or verify the following properties for the items- CellOne, CellTwo, CellThree, CellFour, CellFive, CellSix, CellSeven and CellEight Property Horizontal Alignment Vertical Alignment Value center top
Drag-and-drop FormValueLayout to the end below TableContentLayout so that the Structure window looks similar to what is shown in the figure below:
3.7.5 Adjusting the Layout for PaymentTypeRN Select the PaymentTypeRN, in the property inspector set the following properties Property Rows Columns Value 6 3
Select the PaymentTypeRN, right-click and select New > messageLayout. Oracle Applications Framework - Practices and Solutions C-103
Appendix C: Practices and Solutions Set the messageLayout ID to PaymentContentLayout. Select the PaymentContentLayout, right-click and select New > Region. Set the region ID to PaymentTypeTable. Set the Region Style of this region to tableLayout. Set the Horizontal Alignment to center. Set the Width to 100% Select the PaymentTypeTable, right-click and select New > rowLayout. Set the region ID to FirstRowRN. Select the FirstRowRN, right-click and select New > cellFormat. Set the region ID to FirstCell. Select the FirstRowRN, right-click and select New > cellFormat. Set the region ID to SecondCell. Repeat the steps mentioned above to create rest of the cells. For SecondRowRN Select the PaymentTypeTable, right-click and select New > rowLayout. Set the region ID to SecondRowRN. Select the SecondRowRN , right-click and select New > cellFormat. Set the region ID to ThirdCell. Select the SecondRowRN , right-click and select New > cellFormat. Set the region ID to FourthCell. Select the SecondRowRN , right-click and select New > cellFormat. Set the region ID to FifthCell. For ThirdRowRN Select the PaymentTypeTable, right-click and select New > rowLayout. Set the region ID to ThirdRowRN. Select the ThirdRowRN, right-click and select New > cellFormat. C-104 Oracle Applications Framework - Practices and Solutions
Lab 4: Orders: Create . Set the region ID to SixthCell. Select the ThirdRowRN, right-click and select New > cellFormat. Set the region ID to SeventhCell. For FourthRowRN Select the PaymentTypeTable, right-click and select New > rowLayout. Set the region ID to FourthRowRN. Select the FourthRowRN, right-click and select New > cellFormat. Set the region ID to EighthCell. For FifthRowRN Select the PaymentTypeTable, right-click and select New > rowLayout. Set the region ID to FifthRowRN. Select the FifthRowRN, right-click and select New > cellFormat. Set the region ID to NinthCell For SixthRowRN Select the PaymentTypeTable, right-click and select New > rowLayout. Set the region ID to SixthRowRN. Select the SixthRowRN , right-click and select New > cellFormat. Set the region ID to TenthCell We populate the different cells with the items as follows Select FirstCell, right-click and select New > Region. Set the Region ID to PaymentTypeHdr. Set the Text property to Payment Type. Select SecondCell, right-click and select New > Item. Set the following properties for the item Property ID Item Style Value FirstVertiSpace spacer
Appendix C: Practices and Solutions Height 70 Width 1 Select ThirdCell, right-click and select New > Item. Set the following properties for the item Property ID Item Style Checked Value View Instance View Attribute Prompt Value cashRB messageRadioButton CASH OrderDetailsVO PaymentType Cash
Select FourthCell, right-click and select New > Item. Set the following properties for the item Property ID Item Style Checked Value View Instance View Attribute Prompt Value checkRB messageRadioButton CHECK OrderDetailsVO PaymentType Cheque
Select FifthCell, right-click and select New > Item. Set the following properties for the item Property ID Item Style Checked Value View Instance View Attribute Prompt Value creditCardRB messageRadioButton CHARGE OrderDetailsVO PaymentType Credit Card
Now individually drag-and-drop CheckNumber into SixthCell as child. CcType into SeventhCell as child. C-106 Oracle Applications Framework - Practices and Solutions
Lab 4: Orders: Create . CcNumber into EighthCell as child CcExpiration into NinthCell as child CcApprovalCode into TenthCell as child
Set or verify the following properties for the mentioned regions and items For FirstRowRN Property Horizontal Alignment Value start
For ThirdRowRN Property Horizontal Alignment Vertical Alignment Value right top
For SecondCell Property Value Oracle Applications Framework - Practices and Solutions C-107
For SixthCell Property Horizontal Alignment Vertical Alignment Row Span Value right top 4
Now delete the PaymentType messageTextInputType item by right-clicking on it and selecting delete so that the Structure window looks similar to what is shown in the figure below
3.7.6 Adjusting the Layout for FooterR Select the FooterRN, in the property inspector set the following properties Value 3
Property Rows
Select the FooterRN, right-click and select New > messageLayout . Set the messageLayout ID to OrderNoteLayout. Select the OrderNoteLayout, right-click and select New > Region. Set the region ID to OrderNoteRowRN. Oracle Applications Framework - Practices and Solutions C-109
Appendix C: Practices and Solutions Set the Region Style of this region to rowLayout. Drag and drop OrderNote to OrderNoteRow as a child. Select the FooterRN, right-click and select New > messageLayout . Set the messageLayout ID to ButtonLayout
Select the ButtonLayout, right-click and select New > Region Set the region ID to ButtonRowRN Set the Region Style of this region to rowLayout Select the ButtonRowRN , right-click and select New > Item Set the item ID to OrderLinesButton,Style to submitButton and Prompt to
Order Lines Set the Disable Server Side Validation to True The FooterRN now should appear as shown in the figure below. Select OrderNoteRowRN and set the Horizontal Alignment property to center. Select OrderNoteRowRN Item, right-click and select New > Item. Set the following properties for the item Property ID Item Style Width Height Value OrdNoteVertiSpace Spacer 1 75
3.8 Add an "Indicates Required Field" Region The "Indicates Required Field" region should render on the same line as the page-level action/navigation buttons. To achieve this, always add page-level keys like this to a pageStatus component. Select the PageLayoutRN, right-click and select New > pageStatus. Select the flowLayout region that JDeveloper creates for you beneath the pageStatus component and set its ID to PageStatusRN. Select PageStatusRN, right-click and select New > Region .
Set the following properties for this region (whenever you need a BLAF-standard
"Indicates Required Field" key in your page, you can simply extend the common OA Framework region shown below). Property ID Extends Width Value RequiredKey /oracle/apps/fnd/framework/webui/OAReqFieldDescRG 100%
Note: When you set the Extends property to this region, JDeveloper may display a confirmation message like the following. If so, select Yes to proceed. Oracle Applications Framework - Practices and Solutions C-111
Appendix C: Practices and Solutions Component "/oracle/apps/fnd/framework/webui/OAReqFieldDescRG" cannot be referenced from "/<yourname>/oracle/apps/demxx/orderentry/webui/OrderCreatePG.RequiredKey" because it violates scope restrictions. Are you sure you want to use component "/oracle/apps/fnd/framework/webui/OAReqFieldDescRG"? For additional information about configuring content to render in parallel with page-level action/navigation buttons, see Page Stamps in the OA Framework Developer's Guide. 3.9 Save and Test Your Work Select OrderEntry.jpr, right-click and select Rebuild OrderEntry.jpr. Select the OrderSearchPG, right-click and select Run OrderSearchPG.xml. Select the Create Order button. The CreateOrderPG should appear approximately as shown in Figure 1 (without the order number and with no radio button selected). You will not be able to do anything in the Orders: Create page because you have not yet added any logic.
4: Implement Browser Back Button Safe Page Initialization and create/rollback Methods
4.1 Add a createOrderEntry( ) Method to Your OrderEntryAMImpl Class Add the following method to your OrderEntryAMImpl class for creating a new order in the OrderDetailsVO view object (the call to vo.createRow() ultimately calls a create( ) method in your OrderEOImpl entity object that you will be coding a bit later).
import oracle.apps.fnd.framework.OAViewObject; import oracle.apps.fnd.framework.OARow; ... /** ******************************************************* * Creates a new Order ******************************************************* */ public void createOrderEntry() { OAViewObject orderEntryVO = (OAViewObject)getOrderDetailsVO(); if(orderEntryVO != null) { OARow orderEntryRow =(OARow)orderEntryVO.createRow(); if(orderEntryRow != null) { orderEntryVO.setMaxFetchSize(0); orderEntryVO.insertRow(orderEntryRow); orderEntryRow.setNewRowState(orderEntryRow.STATUS_INITIALIZED); orderEntryVO.setCurrentRow(orderEntryRow); } } }
4.2 Add a rollbackOrder( ) Method to Your OrderEntryAMImpl Class Add the following method to your OrderEntryAMImpl class for rolling back the database and the middle tier (you will see how you are going to use this a bit later). Note that we call getTransaction() here to use an oracle.jbo.Transaction instead of calling getOADBTransaction() to get an OAF subclass oracle.apps.fnd.framework.server.OADBTransaction because the super class has the behavior we need, and as a rule, you should always instantiate the class that includes the behavior you want to use. Avoid instantiating subclasses if the additional behavior is not required.
4.3 Add Back Button Handling to the OrderSearchCO processRequest( ) To account for various Back button navigation patterns between the Create Order page and the Search page, add the following logic to your OrderSeachCO controller's processRequest() method. This ensures that any unfinished order objects are cleared from the middle tier cache when the user navigates to the Search page using the browser Back button, and then tries to create a new order. Note: When you are ready to start building your own products, you can learn more about coding for the browser Back button in the OA Framework Developer's Guide advanced topic Supporting the Browser Back Button. You can learn about passivation in the OA Framework State Management (Passivation) topic. Note that you will be adding the rollbackOrder() method to your OrderEntryAMImpl class a bit later in this exercise.
import oracle.apps.fnd.framework.webui.TransactionUnitHelper; import oracle.apps.fnd.framework.OAApplicationModule; ... public void processRequest(OAPageContext pageContext, OAWebBean webBean) { super.processRequest(pageContext, webBean); OAApplicationModule am = pageContext.getApplicationModule(webBean); // The following checks to see if the user navigated back to this page // without taking an action that cleared an "in transaction" indicator. // If so, we want to rollback any changes that he abandoned to ensure they // aren't left lingering in the BC4J cache to cause problems with // subsequent transactions. For example, if the user navigates to the // Create Orders page where you start a "create" transaction unit, // then navigates back to this page using the browser Back button and
4.4 Add Create Page Initialization This page includes logic to ensure that the user does not encounter errors due to navigation using the browser Back button. For example, it is important to ensure that there are no partially created OrderEO entity objects in the middle tier cache when the user tries to create a new order. While the solution prevents page access after "invalid" Back button navigation, the code below allows the page to be properly rebuilt if the transaction is passivated. First, create a controller and associate with the pageLayoutRN region in the OrderCreatePG . Select the pageLayoutRN region in the OrderCreatePG, right-click and select Set New Controller ... from the context menu. In the Package Name <yourname>.oracle.apps.demxx.orderentry.webui. In the Name field enter OrderCreateCO . Select the OK button to create your controller. Then, add the following code to your processRequest() method to be called when the page is initialized:
import oracle.apps.fnd.framework.OAApplicationModule; import oracle.apps.fnd.framework.webui.OADialogPage; import oracle.apps.fnd.framework.webui.TransactionUnitHelper; import oracle.apps.fnd.framework.webui.beans.message.OAMessageRadioButtonBean; import oracle.apps.fnd.framework.webui.beans.message.OAMessageChoiceBean; import oracle.apps.fnd.framework.webui.beans.message.OAMessageDateFieldBean; import oracle.apps.fnd.framework.server.OADBTransaction; import oracle.apps.fnd.framework.webui.beans.message.OAMessageTextInputBean; ... public void processRequest(OAPageContext pageContext, OAWebBean webBean)
field
enter
// Add Default RadioButton Selection during Page Initialization // The radio-buttons added for PaymentType have to be configured as a // single group first. The cash radio-button should be selected as default // when the page renders. // The following logic does that. /************ Radiobuttons as a Group Horizontally *******************/ // Configure the radio buttons as a group by 1) assigning them all the // same name and 2) assigning values to each radio button. OAMessageRadioButtonBean rb1 = (OAMessageRadioButtonBean)webBean.findChildRecursive("cashRB"); rb1.setSelected(true); //for setting initial default value whilepage loads rb1.setName("paymentTypeRG"); rb1.setValue("CASH");
4.5 Test Your Work Select OrderEntry.jpr, right-click and select Rebuild OrderEntry.jpr. Select the OrderSearchPG, right-click and select Run OrderSearchPG.xml. When the Search page renders, select the Create Order button Note that your invocation of the createOrderEntry() method ultimately results in BC4J calling your entity object's create() method. The OrderCreatePG should appear as shown in Figure 1, but without the order number. Try navigating to the Search page from the Create Order page using the browser Back button. Verify that your page renders without any errors.
DateOrdered
OrderStatus
CcType
Appendix C: Practices and Solutions o Disable CcApprovalCode OrderLinesButto Should take us to Lines Create Page. n
5.2 Add Import Statements Add the following import statements to your OrderEOImpl class:
import import import import import import import import import import import import import oracle.jbo.server.EntityDefImpl; oracle.jbo.server.AttributeDefImpl; oracle.jbo.AttributeList; oracle.jbo.domain.Number; oracle.jbo.domain.Date; oracle.jbo.Key; oracle.apps.fnd.framework.OAAttrValException; oracle.apps.fnd.framework.OARowValException; oracle.apps.fnd.framework.server.OADBTransaction; oracle.apps.fnd.framework.OAException; oracle.apps.fnd.framework.server.OAEntityImpl; oracle.jbo.RowIterator; oracle.jbo.server.EntityImpl;
Within the context of the entity object, note that we use an OADBTransaction (unlike the super class Transaction that we used in our application module above) because the OAEntityImpl super class provides a convenience getOADBTransaction() method for us to use in our OrderEOImpl subclass. See the oracle.apps.fnd.framework.server.OAEntityImpl for additional information.
5.3 Override the setOrderId( ) Method Add the following validation logic to the setOrderId() method in the OrderEOImpl class. This verifies that the order id is unique. See Java Entity Objects in the OA Framework Developer's Guide for additional information. Instructions for creating PL/SQL Entity Objects are also available (this workshop focuses exclusively on Java Entity Objects; once you understand these basic concepts, you can easily pick up the PL/SQL alternative). Note: You are strongly encouraged to copy the validation logic introduced in the next several tasks. It will be quite time-consuming to type this in directly, the risk of mistakes is higher, and you might not include the comments that will help explain what is happening as you debug the code. Tip: If you copy this code and paste it into your setOrderId() method, make sure you do not end up with duplicate calls to setAttributeInternal() since this call is automatically added to the default implementation of this method. The resulting method should appear as shown below. C-120 Oracle Applications Framework - Practices and Solutions
Lab 4: Orders: Create . Note this same consideration when adding validation logic to other setters.
/** ************************************************************** * Sets <code>value</code> as the attribute value for OrderId ************************************************************** */ public void setOrderId(Number value) { // Because of the declarative validation that you specified for this // attribute, BC4J validates that this can be updated only on a new line, // and that this mandatory attribute is not null. This code adds the // additional // check of only allowing an update if the value is null to prevent changes // while the object is in memory. if (getOrderId() != null) { throw new OAAttrValException(OAException.TYP_ENTITY_OBJECT, getEntityDef().getFullName(), // EO name getPrimaryKey(), // EO PK "OrderId", // Attribute Name value, // Attribute value "DEMXX", // Message product short name "ORDLINES_ORD_ID_NO_UPDATE"); // Message name } if (value != null) { // Order id must be unique. To verify this, you must check both the // entity cache and the database. In this case, it's appropriate // to use findByPrimaryKey() because you're unlikely to get a match, and // and are therefore unlikely to pull a bunch of large objects into // memory. // Note that findByPrimaryKey() is guaranteed to check all orders. // First it checks the entity cache, then it checks the database. OADBTransaction transaction = getOADBTransaction(); Object[] orderKey = {value}; EntityDefImpl ordDefinition = OrderEOImpl.getDefinitionObject(); OrderEOImpl order = (OrderEOImpl)ordDefinition.findByPrimaryKey(transaction, new Key(orderKey)); if (order != null) { throw new OAAttrValException(OAException.TYP_ENTITY_OBJECT, getEntityDef().getFullName(), // EO name getPrimaryKey(), // EO PK
5.4 Override the create( ) Method The create() method is called when your OrderEOImpl class is instantiated. Any programmatic defaulting logic should be added to this method. In this case, we're setting an order id based on a database sequence value, and we're setting the start date to the database SYSDATE. Note that we call the set<AttributeName>() methods and pass them the values we want to set. This ensures that all attribute-level validation is performed.
/** *********************************************************************** ** ** Add attribute defaulting logic here. *********************************************************************** ** */ public void create(AttributeList attributeList) { super.create(attributeList); OADBTransaction transaction = getOADBTransaction(); Number numberOrderId = transaction.getSequenceValue("DEM_ORDERS_S"); setOrderId(numberOrderId); // Ordered Date should be set to SYSDATE setDateOrdered(transaction.getCurrentDBDate()); } // end create()
Lab 4: Orders: Create . 5.5 Save and Test Your Work Select OrderEntry.jpr, right-click and select Rebuild OrderEntry.jpr. Select the OrderSearchPG, right-click and select Run OrderSearchPG.xml. Select the Create Order button. Verify that your create() method is called as expected, and that your setDateOrdered() and setOrderId() methods are behaving correctly. The OrderCreatePG should appear approximately as shown in Figure 1, but this time you should see your default Order Number and Order Date values.
Generate both the *VOImpl and the *VORowImpl for this VO. 6.4 Add the OrderStatusVVO to the OrderVAM Validation Application Module Add the OrderStatusVVO view object to the OrderVAM. Change the instance OrderStatusVVO. name on the right from OrderStatusVVO1 to
6.5 Add an initQuery( ) Method to the OrderStatusVVO Validation View Object Add the following simple initQuery() method to the OrderStatusVVOImpl class.
public void initQuery(String orderStatus) { setWhereClauseParams(null); // Always reset setWhereClauseParam(0, orderStatus); executeQuery(); }
6.6 Create an Entity Expert Class Entity experts are singletons (meaning there is one instance that is global to the application and shared by all users) that are closely affiliated with entity objects. They can be used to perform internal work on behalf of the entity object, and they can be used for lightweight operations by other classes instead of requiring multiple entity object instances. Select OrderEntry.jpr in the Navigator, right-click and select New> Class from the context menu. In the New Class dialog window: In the Name field enter OrderEntityExpert. In the Package field enter <yourname>.oracle.apps.demxx.schema.server. In the Extends field browse down oracle.apps.fnd.framework.server.OAEntityExpert . to and choose
In the Optional Attributes region, only select the Public checkbox. Select OK to create your Java class.
Appendix C: Practices and Solutions 6.7 Associate the Entity Expert with the OrderEO Entity Object Entity expert classes are officially registered with their owning entity object. Select the OrderEO in the Navigator, right-click and select Edit OrderEO ... from the content menu. Navigate to the Properties page, and change the Name field to ExpertClass. Change the Value field to <yourname>.oracle.apps.demxx.schema.server.OrderEntityExpert . Select the Add button. Select the OK button. 6.8 Add a Convenience Method for Expert Access in the OrderEOImpl Class Add the following static method to your OrderEOImpl class (we want this to be a static method so it can be called without the client having to instantiate your OrderEOImpl class).
import oracle.apps.fnd.framework.server.OADBTransaction; ... /** ******************************************************** * Convenience method returns the OrderEntityExpert. ******************************************************* **/ public static OrderEntityExpert getOrderEntityExpert (OADBTransaction txn) { return (OrderEntityExpert)txn.getExpert(OrderEOImpl.getDefinitionObject()); } // end getOrderEntityExpert()
6.9 Add the isOrderStatusValid( ) Method to the Entity Expert Add the following new method to your OrderEntityExpert class. Tip: If you fail to complete Step 6.2 above to register the OrderVAM with the OrderEO, the findValidationViewObject() method below will return null.
/** *********************************************************************** ****** * Returns true if the given order status is valid.
6.10 Add Validation Logic to setOrderStatus() Method in OrderEOImpl Class Add the following logic to the setOrderStatus() method in your OrderEOImpl class. It calls the entity expert isOrderStatusValid() method, and if this call returns false, it throws an attributelevel exception.
/** ****************************************************************** * Sets <code>value</code> as the attribute value for OrderStatus ****************************************************************** */ public void setOrderStatus(String value) { // BC4J ensures that this mandatory attribute is non-null if ((value != null) || (!("".equals(value.trim())))) { OrderEntityExpert expert = getOrderEntityExpert(getOADBTransaction()); if (!(expert.isOrderStatusValid(value))) { throw new OAAttrValException(OAException.TYP_ENTITY_OBJECT, getEntityDef().getFullName(), // EO name getPrimaryKey(), // EO PK "OrderStatus", // Attribute Name
Lab 4: Orders: Create . 6.11 Compile and Test Your Work Select OrderEntry.jpr, right-click and select Rebuild OrderEntry.jpr. Select the OrderSearchPG, right-click and select Run OrderSearchPG.xml. Select the Create Order button; verify if your new methods are called correctly (again, your data will be cached in the middle tier, but not yet saved to the database).
The following methods complete the business rules implementation for the order, however, if you are pressed for time you may skip this task since failing to implement this validation will not harm anything. 7.1 Add Logic to setDateShipped() Method; Add a validateDateShipped () Method These methods are virtually identical to the setDateOrdered() and validateDateOrdered() methods that you implemented earlier. Add the following logic to the setDateShipped() method in your OrderEOImpl class.
/** **************************************************************** * Sets <code>value</code> as the attribute value for DateShipped ***************************************************************** */ public void setDateShipped(Date value) { validateDateShipped(value); setAttributeInternal(DATESHIPPED, value); }
7.2 Save and Test Your Work Select OrderEntry.jpr, right-click and select Rebuild OrderEntry.jpr. Select the OrderSearchPG, right-click and select Run OrderSearchPG.xml. Select the Create Order button; verify that your new methods are called correctly (we still are not saving anything to the database).
if((getPaymentType().equalsIgnoreCase("CHECK")) && (getCheckNumber().intValue()<0)) { throw new OAAttrValException(OAException.TYP_ENTITY_OBJECT, getEntityDef().getFullName(), // EO name getPrimaryKey(), // EO PK "CheckNumber", // Attribute Name getCheckNumber(), // Attribute value "DEMXX", // Message product short name "ORDLINES_CHECK_NO_BAD"); // Message name } } // end validateEntity()
8.2 Compile and Save Your Work Select OrderEntry.jpr, right-click and select Rebuild OrderEntry.jpr. Select the OrderSearchPG, right-click and select Run OrderSearchPG.xml. Select the Create Order button; verify that your attribute setters are called first, and then your validateEntity() method is called.
/* *********************************************************************** ****** * Commits the transaction. *********************************************************************** ****** */ public void apply() { getTransaction().commit(); } // end apply()
9.2 Add processFormRequest( ) Logic to Your OrderCreateCO Class Add the following code to the OrderCreateCO class to handle Apply and Cancel button selection. Note: Remember to enter proper values for <yourname> and demxx while copying the code to your processFormRequest()at both apply and cancel button-handling.
import import import import import import ... public void processFormRequest(OAPageContext pageContext, OAWebBean webBean) { // Always call this first. super.processFormRequest(pageContext, webBean); OAApplicationModule am = (OAApplicationModule)pageContext.getApplicationModule(webBean); oracle.jbo.domain.Number; oracle.apps.fnd.common.MessageToken; oracle.apps.fnd.framework.OAApplicationModule; oracle.apps.fnd.framework.OAException; oracle.apps.fnd.framework.OAViewObject; oracle.apps.fnd.framework.webui.OAWebBeanConstants;
// Pressing the "Apply" button means the transaction should be validated // and committed. if (pageContext.getParameter("Apply") != null) { // Generally we have illustrated // all BC4J interaction on the server (except for the AMs, of course).Here,
pageContext.forwardImmediately("OA.jsp?page=/<yourname>/oracle/apps/dem xx/ orderentry/webui/OrderSearchPG", null, OAWebBeanConstants.KEEP_MENU_CONTEXT, null, null, true, // retain AM OAWebBeanConstants.ADD_BREAD_CRUMB_NO); } else if (pageContext.getParameter("Cancel") != null) { am.invokeMethod("rollbackOrder"); // Indicate that the Create transaction is complete. TransactionUnitHelper.endTransactionUnit(pageContext, "ordCreateTxn"); pageContext.forwardImmediately("OA.jsp?page=/<yourname>/oracle/apps/dem xx/ orderentry/webui/OrderSearchPG", null, OAWebBeanConstants.KEEP_MENU_CONTEXT, null, null, true, // retain AM OAWebBeanConstants.ADD_BREAD_CRUMB_NO); } }//end processFormRequest()
9.3 Test Your Work Select OrderEntry.jpr, right-click and select Rebuild OrderEntry.jpr. Select the OrderSearchPG, right-click and select Run OrderSearchPG.xml Select the Create Order button. The OrderCreatePG should appear as shown in Figure 1. Enter an order, and select the Apply button. The confirmation message should display in the OrderSearchPG as shown in Figure 2. Also try navigating to the OrderCreatePG and selecting the Cancel button.
Figure 2: Orders Search Page with Create Confirmation Message You are now finished with this exercise.
Figure 2: A Closer look at the Payment Type region when the page renders first time
Figure 3: A Closer look at the Payment Type region when Credit Card radio button is chosen
Appendix C: Practices and Solutions named OrderEntryPVO . 1.1 Create the OrderEntryPVO View Object In the <yourname>.oracle.apps.demxx.orderentry.server package, create the OrderEntryPVO view object and verify that the Package is <yourname>.oracle.apps.demxx.orderentry.server. In the Attributes page, select the New... button and create a transient attribute with the following properties: o Name: checkNumber o Type: Boolean o Updateable: Always Select the New... button again and create a transient attribute with the following properties: o Name: creditCardType o Type: Boolean o Updateable: Always Select the New... button again and create a transient attribute with the following properties: o Name: creditCardNumber o Type: Boolean o Updateable: Always Select the New... button again and create a transient attribute with the following properties: o Name: creditCardExpirationDate o Type: Boolean o Updateable: Always Select the New... button again and create a transient attribute with the following properties: o Name: approvalCode o Type: Boolean C-140 Oracle Applications Framework - Practices and Solutions
Lab 5: Orders: Partial Page Rendering (PPR) . o Updateable: Always You need not generate any Java files for this PVO. After you create the PVO, reopen and navigate to the Tuning page. Check the Enable Passivation and For All Transient Attributes checkboxes (it is important that the transient attributes in an application properties view object be properly passivated).
1.2 Add the OrderEntryPVO View Object to the OrderEntryAM Add the OrderEntryPVO view object to the OrderEntryAM. Change the instance name on the right bottom from OrderEntryPVO1 to OrderEntryPVO.
Disable Client Side Validation (this property appears after you set the
Action Type property to firePartialAction)
True (Do not perform any client side Javascript validation when
this radio-button value changes and the form is submitted. For example, ignore null required field values.)
Action Type Event (this property appears after you set the
Action Type property to firePartialAction)
Submit
(this property appears after you set the Action Type property to firePartialAction)
firePartialAction (Enables a PPR event for this radio-button) cashEvent (Name of PPR event added to request when the radiobutton value changes) True (Perform a form submit when the radio-button value changes )
2.2 Set the PPR Properties for Cheque RadioButton Set the following properties for the checkRB item in your Create page: Property Disable Server Side Validation Disable Client Side Validation Action Type Event Submit Value True True firePartialAction checkEvent True
2.3 Set the PPR Properties for Credit Card RadioButton Set the following properties for the creditCardRB item in your Create page: Property Disable Server Side Validation Disable Client Side Validation Action Type Event Submit Value True True firePartialAction creditCardEvent True
Lab 5: Orders: Partial Page Rendering (PPR) . 2.4 Set the PPR Properties for Credit Card Type Dropdown Set the following properties for the CcType item in your Create page: Property Disable Server Side Validation Disable Client Side Validation Action Type Event Submit Value True True firePartialAction visaEvent True
Note: We add a PPR to CcType item because we need to enable the CcApprovalCode item only if the CcType poplist value is Visa. Please note that for other values of the CcType poplist the CcApprovalCode item should be disabled.
Note that you must use the Enter key to get the new value to "stick" in the property. If you use the mouse to click directly out of the property after typing the SPEL value, the property resets to True. At runtime, this item will render according to the value of the transient attributes in the OrderEntryPVO application view object.
/********************* CheckNumber ************************/ /** ************************************************************ * PPR for CheckNumber Enable ************************************************************ */ public void enableCheckNumber() { OAViewObject vo = (OAViewObject)findViewObject("OrderEntryPVO"); if (vo != null) { if (vo.getFetchedRowCount() == 0) { vo.executeQuery(); } OARow row = (OARow)vo.first(); if(row!=null) row.setAttribute("checkNumber", Boolean.FALSE); } }
/** ************************************************************ * PPR for CheckNumber Disable ************************************************************ */ public void disableCheckNumber() {
// handle to CurrentRow
if(row!=null) row.setAttribute("checkNumber", Boolean.TRUE); if(dbRow!=null) dbRow.setAttribute("CheckNumber", null); // set null to CheckNumber } } /********************* CcType ************************/ /** ************************************************************ * PPR for CcType Disable ************************************************************ */ public void disableCcType() { OAViewObject vo = (OAViewObject)findViewObject("OrderEntryPVO"); OAViewObject dbVO = (OAViewObject)findViewObject("OrderDetailsVO"); if (vo != null) { if (vo.getFetchedRowCount() == 0) { vo.executeQuery(); } OARow row = (OARow)vo.first(); OARow dbRow = (OARow)dbVO.getCurrentRow(); CurrentRow
// handle to
/** ************************************************************ * PPR for CcNumber Disable ************************************************************ */ public void disableCcNumber() { OAViewObject vo = (OAViewObject)findViewObject("OrderEntryPVO"); OAViewObject dbVO = (OAViewObject)findViewObject("OrderDetailsVO"); if (vo != null) { if (vo.getFetchedRowCount() == 0) { vo.executeQuery(); } OARow row = (OARow)vo.first(); OARow dbRow = (OARow)dbVO.getCurrentRow(); CurrentRow
// handle to
if(row!=null) row.setAttribute("creditCardNumber", Boolean.TRUE); if(dbRow!=null) dbRow.setAttribute("CcNumber", null); // set null to CcNumber } } /** ************************************************************ * PPR for CcNumber Enable ************************************************************ */ public void enableCcNumber() { OAViewObject vo = (OAViewObject)findViewObject("OrderEntryPVO");
/** ************************************************************ * PPR for CcExpiration Disable ************************************************************ */ public void disableCcExpiration() { OAViewObject vo = (OAViewObject)findViewObject("OrderEntryPVO"); OAViewObject dbVO = (OAViewObject)findViewObject("OrderDetailsVO"); if (vo != null) { if (vo.getFetchedRowCount() == 0) { vo.executeQuery(); } OARow row = (OARow)vo.first(); OARow dbRow = (OARow)dbVO.getCurrentRow(); CurrentRow
// handle to
/** ************************************************************ * PPR for CcExpiration Enable ************************************************************ */ public void enableCcExpiration() { OAViewObject vo = (OAViewObject)findViewObject("OrderEntryPVO"); if (vo != null) {
// handle to
if(row!=null) row.setAttribute("approvalCode", Boolean.TRUE); if(dbRow!=null) dbRow.setAttribute("CcApprovalCode", null); // set null } } /** ************************************************************ * PPR for CcApprovalCode Enable ************************************************************ */ public void enableCcApprovalCode() { OAViewObject vo = (OAViewObject)findViewObject("OrderEntryPVO"); if (vo != null) { if (vo.getFetchedRowCount() == 0) { vo.executeQuery(); } OARow row = (OARow)vo.first();
Lab 5: Orders: Partial Page Rendering (PPR) . 4.2 Add an init( ) Method to the OrderEntryAM The following code ensures that your OrderEntryPVO includes a single row and initializes the application properties VO and defines the default values of transient attributes when the page renders.
/** *********************************************************************** ****** * Initializes the transient application properties VO. *********************************************************************** ****** */ public void init() { OAViewObject appPropsVO = (OAViewObject)findViewObject("OrderEntryPVO"); if (appPropsVO != null) { // Do not reinitialize the VO unless needed. Note that this method call // does not try to query the database for VOs with no SELECT statement and // only transient attributes. if (appPropsVO.getFetchedRowCount() == 0) { // Setting the max fetch size to 0 for an in-memory VO // prevents it from trying to query rows. Calling // executeQuery() ensures that rows are not lost after // a commit in the transaction (BC4J known issue workaround). appPropsVO.setMaxFetchSize(0); appPropsVO.executeQuery(); // You must create and insert a row in the VO before you can start // setting properties. appPropsVO.insertRow(appPropsVO.createRow()); // Initialize the application properties VO (and the UI) based on the // default order payment value set on the underlying object. OARow row = (OARow)appPropsVO.first(); row.setAttribute("checkNumber", Boolean.TRUE); row.setAttribute("creditCardType", Boolean.TRUE); row.setAttribute("creditCardNumber", Boolean.TRUE); row.setAttribute("creditCardExpirationDate", Boolean.TRUE); row.setAttribute("approvalCode", Boolean.TRUE); } }
4.3 Call the init( ) Method from processRequest( ) Add the following code to your OrderCreateCO processRequest() method after the call to am.invokeMethod("createOrderEntry"). This ensures that your application properties VO is properly initialized when the page renders. // Add the following code after am.invokeMethod("createOrderEntry") // Initialize the application properties VO for PPR. am.invokeMethod("init"); 4.4 Handle PPR Event Remember that we configured the radio-buttons and the poplist to perform a form submit. Add the following code to your existing OrderCreateCO processFormRequest() method to check to see if their PPR events have been fired, and if so, invoke the enable/disable methods coded in OrderEntryAMImpl to handle the change.
/*********** PPR Event Handling for Payment Type RadioButtons ************/ String event = pageContext.getParameter(EVENT_PARAM); if(event.equalsIgnoreCase("checkEvent")) { am.invokeMethod("enableCheckNumber"); am.invokeMethod("disableCcType"); am.invokeMethod("disableCcNumber"); am.invokeMethod("disableCcExpiration"); am.invokeMethod("disableCcApprovalCode"); } else if (event.equalsIgnoreCase("cashEvent")) { am.invokeMethod("disableCheckNumber"); am.invokeMethod("disableCcType"); am.invokeMethod("disableCcNumber"); am.invokeMethod("disableCcExpiration"); am.invokeMethod("disableCcApprovalCode"); } else if (event.equalsIgnoreCase("creditCardEvent")) { am.invokeMethod("disableCheckNumber"); am.invokeMethod("enableCcType"); am.invokeMethod("enableCcNumber"); am.invokeMethod("enableCcExpiration"); am.invokeMethod("disableCcApprovalCode"); } else if (event.equalsIgnoreCase("visaEvent")) { OAMessageChoiceBean ccType = (OAMessageChoiceBean)webBean.findChildRecursive("CcType");
4.5 Test Your Work Select OrderEntry.jpr, right-click and select Rebuild OrderEntry.jpr. Select the OrderSearchPG, right-click and select Run OrderSearchPG.xml Select the Create Order button. The OrderCreatePG should appear as shown in Fig. 1. Change the radio-buttons value to Cheque and the UI should appear as shown in Fig. 2. You are now finished with this exercise.
Warning: This lab assumes that you have completed the Create Exercise and builds on this work. If you have not completed this exercise, please do so before proceeding.
Select the OK button to update your view object and leave the VO editor. Now verify that your VO attribute settings match the aliases in your SQL query: Select the OrderSearchVO in the Navigator, right-click and select Edit OrderSearchVO... from the context menu to open the View Object wizard. o Navigate to the Attributes section for your attributes and verify that any aliases in C-156 Oracle Applications Framework - Practices and Solutions
Lab 6: Orders: Delete . your query are shown correctly. Make any necessary changes and select Apply. o Navigate to the Attribute Mappings page and verify that all the mappings are correct. Make any necessary changes and select Apply. o Select the OK button to finish editing your VO. The decode that you added checks whether a DATE_SHIPPED has been specified, and if set, it returns the value DeleteEnabled as the query's DELETE_SWITCHER value. If not, it returns DeleteDisabled. 2.2 Create the Switcher Region Create the switcher bean that will bind to the DeleteSwitcher view attribute you just created to determine which Delete icon to display. Select the ResultsTable in the Navigator, right-click and select New > switcher from context menu. Select this region, and set its properties as follows: Property ID Region Style Attribute Set Value DeleteSwitcher switcher /oracle/apps/fnd/attributesets/Buttons/Delete (You should use the standard Button attribute sets for standard image action columns) OrderSearchVO DeleteSwitcher
2.3 Configure the Default Switcher Case Switchers mimic a programmatic switch: you create a separate "case" for each option that might display. The switcher bean binds to the view object attribute that returns the name of the case to render. Each case that you add must have an ID value that matches one of your decode return value names. Configure the first switcher case item to show the disabled Delete image. Select the default <case> switcher case in the Structure pane, and select New > Item from context menu. Select this new item, and set its properties as follows: Property ID Value DeleteDisabled
(Note that this name MUST match the corresponding DECODE return value you defined for this case in Step 1.1 above.)
Appendix C: Practices and Solutions Item Style image Image URI deleteicon_disabled.gif Additional Delete order action is disabled. Text Height 24 Width 24 Note that you must specify the Height and Width properties for any images that you add to a page, except for the branding image. To find the values to enter, look for your image in either the Oracle Browser Look and Feel UI Guideline Icon Repository (internal link | external link) or the Ancillary Graphic Repository (internal link | external link). See the Adding Images to Your Pages document for additional information about icon creation and use procedures. 2.4 Create a New Switcher Case Configure the second switcher case item to show the enabled Delete image. When the user selects the Delete icon, we want to submit the form so we can handle the event in processFormRequest(). Normally, when you simply set a Destination URI property for an image, its selection results in an HTTP GET and not a POST; we want to perform a POST. To do this, we will be explicitly configuring the image to perform a form submit when selected. See the Developer's Guide Submitting the Form topic for additional information about manually forcing a form submit on a component that doesn't ordinarily do this. Select the DeleteSwitcher in the Structure pane, right-click and select New > case from context menu. Select this new <case> node, right-click and select New > Item from the context menu. Configure this item's properties as follows. Property ID Value DeleteEnabled (Note that this name MUST match the corresponding DECODE return value you defined for this case in Step 1.1 above.) image deleteicon_enabled.gif Delete order action is enabled. 24 24 fireAction
(Enables a form submit event for this image.)
Item Style Image URI Additional Text Height Width Action Type
Event delete (This property appears after you set the (Name of form submit event added to request when the Delete
Action Type property to fireAction) image is selected.)
Lab 6: Orders: Delete . Submit True (This property appears after you set the Action Type property to fireAction) Next, you need to define request parameters for the order number and name associated with the current row when the user selects a Delete icon. You will use these values a bit later to perform the delete action and display a dialog. Place your cursor in the Parameters property field and select the list of values "..." button. In the Parameters window, define a parameter whose name is ordNum and whose value is ${oa.OrderSearchVO.OrderId}. This SPEL ("Simplest Possible Expression Language") syntax indicates that the value for the ordNum parameter will be obtained from the OrderId attribute in the OrderSearchVO view instance. Select the Add Parameters button and define a second parameter whose name is custName and whose value is ${oa.OrderSearchVO.CustomerName}. This SPEL syntax indicates that the value for the custName parameter will be obtained from the CustomerName attribute in the OrderSearchVO view instance. Select the OK button to create your request parameters. At runtime, the OA Framework automatically creates and populates formParameter (hidden) items for the custName and ordNum parameters you configure. These formParameter values are then added to the request. 2.5 Format the Delete Column All image columns should be centered. Image columns are automatically centered, but switcher columns (even when displaying images) are not. To ensure the correct alignment for your Delete column, add the following code to your OrderSearchCO controller in the processRequest() method:
import oracle.cabo.ui.data.DictionaryData; import oracle.cabo.ui.data.DataObjectList; import oracle.apps.fnd.framework.webui.beans.table.OATableBean; ... // This controller is associated with the table. OATableBean table = (OATableBean)webBean.findChildRecursive("ResultsTable"); // We need to format the Switcher image column so the image is centered // (this isn't done automatically for Switchers as it is for // plain image columns). We start by getting the table's // column formats.
2.6 Test Your Work Select OrderEntry.jpr, right-click and select Rebuild OrderEntry.jpr. Select the OrderSearchPG, right-click and select Run OrderSearchPG.xml At this point, your Delete column should appear in your results table as illustrated in Figure 1 above.
3.1 Add a deleteOrder( ) Method to the OrderEntryAM Add a method to the OrderEntryAMImpl class that takes an orderNumber parameter and looks for a matching row in OrderSearchVO view object. Note that calling the remove() method on Oracle Applications Framework - Practices and Solutions C-161
Appendix C: Practices and Solutions your OrderSearchVORowImpl class delegates to the remove() method that you added to your OrderEOImpl class in Task 1 above. Tip: This code illustrates how to iterate through the result set manually so you can see how this works, however, as of release 11.5.10 there are new convenience methods in the oracle.apps.fnd.framework.server.OAViewObjectImpl class that let you quickly find one or more matching rows for given values. See the Javadoc for additional information.
import oracle.jbo.domain.Number; import oracle.jbo.RowSetIterator; ... /* *********************************************************************** ****** * Deletes an order. *********************************************************************** ****** */ public void deleteOrder(String orderNumber) { // First, we need to find the selected order in our VO. // When we find it, we call remove( ) on the row which in turn // calls remove on the associated OrderEOImpl object. int ordToDelete = Integer.parseInt(orderNumber); OAViewObject vo =(OAViewObject)getOrderSearchVO(); OrderSearchVORowImpl row = null;
// This tells us the number of rows that have been fetched in the // row set, and will not pull additional rows in like some of the // other "get count" methods. int fetchedRowCount = vo.getFetchedRowCount(); // We use a separate iterator -- even though we could step through the // rows without it -- because we don't want to affect row currency. RowSetIterator deleteIter = vo.createRowSetIterator("deleteIter"); if (fetchedRowCount > 0) { deleteIter.setRangeStart(0); deleteIter.setRangeSize(fetchedRowCount); for (int i = 0; i < fetchedRowCount; i++) { row = (OrderSearchVORowImpl)deleteIter.getRowAtRangeIndex(i); // For performance reasons, we generate ViewRowImpls for all // View Objects. When we need to obtain an attribute value, // we use the named accessors instead of a generic String lookup.
3.2 Add Delete Selection Handler Code to OrderSearchCO Add the following code to your OrderSearchCO.processFormRequest() method to ascertain whether the Delete icon has been selected, and if so, display the Warning dialog. See the Dialog Pages topic in the OA Framework Developer's Guide for additional information about this component. Note: Add this to the processFormRequest() if statement that you already added to handle the Create Order button press.
import import import import ... com.sun.java.util.collections.HashMap; oracle.apps.fnd.framework.webui.OADialogPage; oracle.apps.fnd.common.MessageToken; oracle.apps.fnd.framework.OAException;
/************************ Delete Selection Handler ********************/ else if ("delete".equals(pageContext.getParameter(EVENT_PARAM))) { // The user has clicked a "Delete" icon so we want to display a "Warning" // dialog asking if he really wants to delete the order. Note that we // configure the dialog so that pressing the "Yes" button submits to // this page so we can handle the action in this processFormRequest( ) // method. String orderNumber = pageContext.getParameter("ordNum"); String customerName = pageContext.getParameter("custName"); MessageToken[] tokens = { new MessageToken("ORD_NUM", orderNumber)};
3.3 Add Delete Confirmation Handler Code to OrderSearchCO Add the following code to your OrderSearchCO processFormRequest() method to handle the Warning dialog button's OK press indicating the user does wish to the delete the selected order. C-164 Oracle Applications Framework - Practices and Solutions
Lab 6: Orders: Delete . Note: Add this to the processFormRequest() if statement that you already added to handle the Delete icon selection.
import java.io.Serializable; ...
else if (pageContext.getParameter("DeleteYesButton") != null) { // User has confirmed that he wants to delete this order. // Invoke a method on the AM to set the current row in the VO and // call remove() on this row. String orderNumber = pageContext.getParameter("ordNum"); String customerName = pageContext.getParameter("custName"); Serializable[] parameters = { orderNumber }; OAApplicationModule am = pageContext.getApplicationModule(webBean); am.invokeMethod("deleteOrder", parameters); // Now, redisplay the page with a confirmation message at the top. Note // that the deleteOrder() method in the AM commits, and our code // won't get this far if any exceptions are thrown. MessageToken[] tokens = { new MessageToken("ORD_NUM", orderNumber) }; OAException message = new OAException("DEMXX", "ORDLINES_ORD_DELETE_CONFIRM", tokens, OAException.CONFIRMATION, null); pageContext.putDialogMessage(message); }
3.4 Test Your Work Rebuild your project and run the OrderSearchPG Select the Create Order button to create a new order. Be sure to set the Ship Date value to any date >= Ordered Date. You can not test deleting an order unless you create one with a non-null ship date. Query your new order in the Search page and verify that the Delete icon is enabled and the Status image is correct as shown in Figure 2. Select the Delete icon and verify that the Warning dialog displays as shown in Figure 3.
Select the OK button in the Warning dialog to delete your order. Verify that the confirmation displays as shown in Figure 4.
Lab 7: Orders: Update . 1.2 Copy and Change the Create Page Controller We need to change the controller associated with your new update page. Open your OrderCreateCO controller in JDeveloper and select File > Save As from the main menu. Name your new file OrderUpdateCO. Change the class name in your new OrderCreateCO file to OrderUpdateCO . Tip: If you forgot to change class name to match the file name and you recompile, you will get a warning like this: Warning(28,8): class OrderCreateCO is public; should be declared in a file named OrderCreateCO.java; or the class should be renamed to OrderDescriptionCO to match the filename. Select the OrderUpdatePG page's PageLayoutRN region in the JDeveloper structure pane to open the property inspector. Change its Controller Class property value <yourname>.oracle.apps.demxx.orderentry.webui.OrderCreateCO <yourname>.oracle.apps.demxx.orderentry.webui.OrderUpdateCO. Change its Title property value to Update Order . from to
Now make a few modifications on the update page as described Select the MainRN, choose the DateOrdered item from RowOneRN in RowOneLayout. Set the Read Only property to True (as Order Date should be update-disallowed). 1.3 Compile and Save Your Work Rebuild your project and save your work.
2.1 Add the "Update" Column to the Results Table Note that the Update icon should be declaratively configured to perform a form submit when selected. Select the ResultsTable in the Structure pane, right-click and select New > Item from context menu. Configure this item's properties as follows:
Property Value ID UpdateImage Item Style image Attribute Set /oracle/apps/fnd/attributesets/Buttons/Update Image URL updateicon_enabled.gif Additional Text Select to update this order. Height 24 C-168 Oracle Applications Framework - Practices and Solutions
Lab 7: Orders: Update . Width 24 Action Type fireAction Event update Submit True
Place your cursor in the Parameters property field and select the list of values "..." button. In the Parameters window, define a parameter whose name is ordNum and whose value is ${oa.OrderSearchVO.OrderId}. Select the Add Parameters button and define a second parameter whose name is custName and whose value is ${oa. OrderSearchVO.CustomerName}. Select the OK button to create your request parameters. 2.2 Modify the OrderSearchCO Controller First, add processRequest() logic to handle Back button navigation. Add the else if logic shown in bold to the if statement that you already added in the Create lab.
if (TransactionUnitHelper.isTransactionUnitInProgress(pageContext, "ordCreateTxn", false)) { am.invokeMethod("rollbackOrder"); TransactionUnitHelper.endTransactionUnit(pageContext, "ordCreateTxn"); } else if (TransactionUnitHelper.isTransactionUnitInProgress(pageContext, "ordUpdateTxn", false)) { am.invokeMethod("rollbackOrder"); TransactionUnitHelper.endTransactionUnit(pageContext, "ordUpdateTxn"); }
Then, add code to your processFormRequest() method to determine if the Update icon is selected. Note: Remember to fill-in value for <yourname> and demxx while using this code.
... /******************* Update Icon Click Handler *********************/ else if ("update".equals(pageContext.getParameter(EVENT_PARAM))) {
2.3 Modify the OrderUpdateCO Controller Now you need to change the logic in the OrderUpdateCO controller to properly support the update action and page flow. Create logic needs to be removed. Delete the logic in your processRequest() method and add the following instead:
import oracle.apps.fnd.framework.webui.TransactionUnitHelper; import java.io.Serializable; ... public void processRequest(OAPageContext pageContext, OAWebBean webBean) { super.processRequest(pageContext, webBean); // Put a transaction value indicating that the update transaction // is now in progress. TransactionUnitHelper.startTransactionUnit(pageContext, "ordUpdateTxn"); String ordNum = pageContext.getParameter("ordNum"); // We'll use this at the end of the flow for a confirmation message. String custName = pageContext.getParameter("custName"); pageContext.putTransactionValue("custName", custName); Serializable[] params = { ordNum }; OAApplicationModule am = pageContext.getApplicationModule(webBean); // For the update, since we're using the same VO as the "Details" page, we // can use the same initialization logic. am.invokeMethod("initDetails", params); /************** Radio Button as a Group configured *****************/
OAMessageRadioButtonBean rb2 = (OAMessageRadioButtonBean)webBean.findChildRecursive("checkRB"); rb2.setName("paymentTypeRG"); rb2.setValue("CHECK"); OAMessageRadioButtonBean rb3 = (OAMessageRadioButtonBean)webBean.findChildRecursive("creditCardRB"); rb3.setName("paymentTypeRG"); rb3.setValue("CHARGE"); // To initialise your PPR components am.invokeMethod("init"); } // end processRequest ...
Change the name of the "in transaction indicator" in the processFormRequest() method from ordCreateTxn to ordUpdateTxn, and change the confirmation message name from ORDLINES_ORD_CREATE_CONFIRM to ORDLINES_ORD_UPDATE_CONFIRM. 2.4 Rebuild and Test Your Work Rebuild your project and run the OrderSearchPG At this point, your Update column should appear in your results table as illustrated in Figure 1 above. Select it to open and test your new update page.
Lab 8: Lines: Search . o Verify that the Package is <yourname>.oracle.apps.demxx.schema.server. o In the Schema Object field, enter DEM_ORDER_LINES . You must type this name correctly. Otherwise, you can check the Synonyms check box (so both Tables and Synonyms are checked) and choose the correct name from the list. Select the Next button. Click on New From Table button and choose ROWID. Select the Next button to navigate to the Attribute Settings page (note that all the table's columns are automatically included as attributes, which complies with the OA Framework Model Coding Standards for Entity Objects. Select the RowID attributes Primary Key check box. Do not change any other default settings. Select the Next button. In the Java page, select the Generate Java File check box for the Entity Object Class: OrderEOImpl (you will add business logic to this Java file in a later exercise). In the Generate Methods region, check the Accessors, Create Method, Validation Method and Remove Method check boxes. Select the Next button. In the Generate page, deselect the Generate Default View Object check box (or, verify that it is not selected). Select the Finish button to create your EO. Select your EO, right-click and select Edit OrderEO...
1.2 Create an Order to Lines Association Object Select the <yourname>.oracle.apps.demxx.schema.server BC4J package in the Navigator; right-click and select New Association Object to open the Association Wizard. If the Welcome page appears, select Next. In the Name page (Step 1 of 3): o Enter OrderToLinesAO in the Name field o Verify that the Package is <yourname>.oracle.apps.demxx.schema.server. o DO NOT enter a value in the Extends Association field Oracle Applications Framework - Practices and Solutions C-173
In the Entity Objects page (Step 2 of 3), o Select OrderEO on the left half; expand it and select OrderId as Source Join Attribute o Select LinesEO on the right half; expand it and select OrderId as Destination Join Attribute o Specify 1 to * in the association's cardinality (as Order to Lines is a one-to-many relationship) o Select the Add button to create the join. o Select Next to proceed.
Figure 2: Selecting source and destination entity objects and attributes in the Entity Object page C-174 Oracle Applications Framework - Practices and Solutions
Lab 8: Lines: Search . In the Association Properties page (Step 3 of 3): o Verify if both the Expose Accessor options are checked for the source and destination objects o Select the Composition Association checkbox if the destination object cannot exist outside the context of the source object. o Ensure that Implement cascade delete is also checked Note: For compositions, always check the Expose Accessor option on the destination object. Optionally enable this for the source object as required in your code. o Do not select any of the other page options. o Select Finish to save your association.
1.3 Create a LinesSearchVO View Object (VO) Create a summary-level view object including only those attributes that you need for the Lines search results table. This view object is the main view object for your Search page. It should leverage the LinesEO (per the OA Framework Model Coding Standards for View Objects, all but the simplest view objects for things like poplists, lists of values and so on should be based on entity objects).
Select the <yourname>.oracle.apps.demxx.orderentry.server BC4J package in the Navigator, right-click and select New View Object... from the context menu to open the View Object wizard. If the Welcome page appears, select Next. In the Name page, specify LinesSearchVO as the view object's name and verify that the package is <yourname>.oracle.apps.demxx.orderentry.server. Select the Next button. In the Entity Objects page, select the LinesEO in the Available list and shuttle it to the Selected list. Select the Next button. In the Attributes page, select the following attributes from the Available list and shuttle them to the Selected list. o From LinesEO: Oracle Applications Framework - Practices and Solutions C-175
Appendix C: Practices and Solutions OrderId OrderLineNum ProductId GlAccountCcId OrderedQuantity AttributeCategory Attribute1 Attribute2 Attribute3 Attribute4 Attribute5 Attribute6 Attribute7 Attribute8 Attribute9 Attribute10 RowID Select the Next button twice. At this point the query should look like the following in the Query page (without the formatting we've used here to improve readability):
SELECT LinesEO.ORDER_ID, LinesEO.ORDER_LINE_NUM, LinesEO.PRODUCT_ID, LinesEO.GL_ACCOUNT_CC_ID, LinesEO.ORDERED_QUANTITY, LinesEO.ATTRIBUTE_CATEGORY, LinesEO.ATTRIBUTE1, LinesEO.ATTRIBUTE2, LinesEO.ATTRIBUTE3, LinesEO.ATTRIBUTE4, LinesEO.ATTRIBUTE5, LinesEO.ATTRIBUTE6, LinesEO.ATTRIBUTE7, LinesEO.ATTRIBUTE8, LinesEO.ATTRIBUTE9, LinesEO.ATTRIBUTE10,
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
SELECT LinesEO.ORDER_ID, LinesEO.ORDER_LINE_NUM, LinesEO.PRODUCT_ID, LinesEO.GL_ACCOUNT_CC_ID, LinesEO.ORDERED_QUANTITY, LinesEO.ATTRIBUTE_CATEGORY, LinesEO.ATTRIBUTE1, LinesEO.ATTRIBUTE2, LinesEO.ATTRIBUTE3, LinesEO.ATTRIBUTE4, LinesEO.ATTRIBUTE5, LinesEO.ATTRIBUTE6, LinesEO.ATTRIBUTE7, LinesEO.ATTRIBUTE8, LinesEO.ATTRIBUTE9, LinesEO.ATTRIBUTE10, LinesEO.ROWID, DemProd.DESCRIPTION, DemProd.SUGGESTED_PRICE, DemProd.UNIT_OF_MEASURE, LinesEO.ORDERED_QUANTITY * DemProd.SUGGESTED_PRICE AS TOTAL_PRICE FROM DEM_ORDER_LINES LinesEO, DEM_PRODUCTS DemProd WHERE LinesEO.PRODUCT_ID = DemProd.PRODUCT_ID
When you are finished with your editing, select the Test button to ensure your syntax is correct. Select the Next button. In the Attribute Mappings page, verify that your view object attributes map to the correct query columns. If you need to make any changes, place your cursor into the incorrect View Attributes field and select the correct value from the poplist. Select the Next button. In the Java page, o Select the Generate Java File for View Object Class: LinesSearchVOImpl o Select the Generate Java File for View Row Class: LinesSearchVORowImpl Oracle Applications Framework - Practices and Solutions C-177
Appendix C: Practices and Solutions to comply with OA Framework coding standards. Select the Finish button to create your VO. Now verify that your VO attribute settings match the aliases in your SQL query: Select the LinesSearchVO in the Navigator, right-click and select Edit LinesSearchVO... from the context menu to open the View Object wizard. Navigate to the Attributes section for your attributes and verify that any aliases in your query are shown correctly. Make any necessary changes and select Apply. Navigate to the Attribute Mappings page and verify that all the mappings are correct. Make any necessary changes and select Apply. Select the OK button to finish editing your VO.
1.4 Add the LinesSearchVO View Object to the OrderEntryAM Add the LinesSearchVO view object to the OrderEntryAM. Change the instance name on the right bottom from LinesSearchVO1 to LinesSearchVO.
Appendix C: Practices and Solutions 2.3 Add a Product Branding Image Each Oracle Applications page requires a product-branding image. Select your PageLayoutRN in the Structure pane, right-click and select New ... productBranding from the context menu. JDeveloper creates a pageLayoutComponents folder containing a productBranding image item (named item1). Select this item and set the following properties:
Value ProdBrand FNDTAPPBRAND.gif OA Framework Order Entry Tutorial (This is required per the accessibility coding standards with which all Oracle E-Business Suite pages must comply)
2.4 Create the Page Instruction Text Add the page-level instruction text. Note that we are using an Oracle Applications Message Dictionary message to ensure that the text is translatable. Furthermore, all the properties that you specify in JDeveloper that can be seen by the user are translatable. Select the PageLayoutRN in the Structure pane, right-click select New > pageStatus from the context menu (any instruction text or other content added to the pageStatus will render in parallel with any page-level action or navigation buttons that you add).
Lab 8: Lines: Search . JDeveloper automatically creates a flowLayout region for you beneath the pageStatus component. Select this region and set its ID to PageStatusRN. Select PageStatusRN, right-click and select New > Item. Set this item's properties as follows:
Property ID Item Style Data Type CSS Class Message Appl Short Name Message Name 2.5 Test Your Work
Select your page in either the Structure pane or the Navigator window, right-click and choose Run < file name > from the context menu.
3.1 Add a Query Bean to Your Page Add the query bean region to your page. Select the PageLayoutRN in the Structure pane, right-click and select New > Region from the context menu. C-182 Oracle Applications Framework - Practices and Solutions
Lab 8: Lines: Search . Select the new region (region1), and set/verify its properties as follows:
Property ID Region Style Construction Mode Include Simple Panel Include Views Panel Include Advanced Panel
3.2 Add a Results Data Table to Your QueryRN Select the QueryRN in the Structure pane, right-click and select New > Region Using Wizard from the context menu. If the Welcome page appears, select Next. In the BC4J Objects page, select your OrderEntryAM (<yourname >.oracle.apps.demxx.orderentry.server.OrderEntryAM ), and then select your LinesSearchVO view object instance from the Available View Objects list. DO NOT select the Use this as Application Module Definition for this region checkbox. Select the Next button. In the Region Properties page, set the Region ID field value to ResultsTable and set the Region Style to table. Select the Next button. In the View Attributes page, select the following attributes from the Available View Attributes list and shuttle them to the Selected View Attributes list: o OrderId o OrderLineNum o ProductId o GlAccountCcId o OrderedQuantity o Description Oracle Applications Framework - Practices and Solutions C-183
Select the Next button. In the Region Items page, set the ID, Style, and Attribute Set properties as follows
Prompt Order Number Line Number Account Quantity Ordered Description Price UOM Total Price
Style messageStyledText messageStyledText messageStyledText messageStyledText messageStyledText messageStyledText messageStyledText messageStyledText messageStyledText
Data Type Attribute Set NUMBER NUMBER NUMBER NUMBER NUMBER VARCHAR2 NUMBER VARCHAR2 NUMBER
3.3 Set or Verify Your ResultsTable Region Properties Select the ResultsTable region in the Structure pane, and set/verify the following properties:
Additional Text Lines Table (This is required per the accessibility coding standards ). Rendered True Records 10 Displayed Width 100% User True (needed so the user can save a Personalized View) C-184 Oracle Applications Framework - Practices and Solutions
3.4 Set or Verify OrderId Item Properties Configure this item to support sorting in the table, to be included in the "results-based" search region that the OA Framework automatically creates, and to be a selectively required search value (for performance reasons, blind queries are disallowed in Oracle Applications unless the underlying view object has been tuned to include a performant query so no additional search criteria is required). For the OrderId item set or verify: o Item Style property to messageStyledText o Search Allowed property to True o Sort Allowed property to yes o Initial Sort Sequence to first o Selective Search Criteria property to True o Data Type property to NUMBER o View Instance to LinesSearchVO o View Attribute to OrderId o Prompt to Order Number o User Personalization property to True (needed so the user can save a Personalized View). o Maximum Length to 15 3.5 Set or Verify OrderLineNum Item Properties For the OrderLineNum item: o Item Style property to messageStyledText o Search Allowed property to True o Selective Search Criteria property to True o Data Type property to NUMBER Oracle Applications Framework - Practices and Solutions C-185
Appendix C: Practices and Solutions o View Instance to LinesSearchVO o View Attribute to OrderLineNum o Prompt to Line o User Personalization property to True o Maximum Length to 15 3.6 Set or Verify ProductId Item Properties For the ProductId item: o Item Style property to messageStyledText o Search Allowed property to True o Selective Search Criteria property to True o Data Type property to NUMBER o View Instance to LinesSearchVO o View Attribute to ProductId o Prompt to Number o User Personalization property to True o Maximum Length to 15 3.7 Set or Verify Description Item Properties For the Description item: o Item Style property to messageStyledText o Search Allowed property to True o Selective Search Criteria property to True o Data Type property to VARCHAR2 o View Instance to LinesSearchVO o View Attribute to Description o Prompt to Description o User Personalization property to True C-186 Oracle Applications Framework - Practices and Solutions
3.8 Set or Verify GlAccountCcId Item Properties For the GlAccountCcId item: o Item Style property to messageStyledText o Selective Search Criteria property to True o Data Type property to NUMBER o View Instance to LinesSearchVO o View Attribute to GlAccountCcId o Prompt to Account o User Personalization property to True o Maximum Length to 38 3.9 Set or Verify OrderedQuantity Item Properties For the OrderedQuantity item: o Item Style property to messageStyledText o Selective Search Criteria property to True o Data Type property to NUMBER o View Instance to LinesSearchVO o View Attribute to OrderedQuantity o Prompt to Quantity Ordered o User Personalization property to True o Maximum Length to 15
Appendix C: Practices and Solutions 3.10 Set or Verify SuggestedPrice Item Properties For the SuggestedPrice item: o Item Style property to messageStyledText o Selective Search Criteria property to True o Data Type property to NUMBER o View Instance to LinesSearchVO o View Attribute to SuggestedPrice o Prompt to Price o User Personalization property to True o Maximum Length to 25 3.11 Set or Verify UnitOfMeasure Item Properties For the UnitOfMeasure item: o Item Style property to messageStyledText o Selective Search Criteria property to True o Data Type property to VARCHAR2 o View Instance to LinesSearchVO o View Attribute to UnitOfMeasure o Prompt to UOM o User Personalization property to True o Maximum Length to 25
3.12 Set or Verify TotalPrice Item Properties For the TotalPrice item: o Item Style property to messageStyledText o Selective Search Criteria property to True C-188 Oracle Applications Framework - Practices and Solutions
Lab 8: Lines: Search . o Data Type property to NUMBER o View Instance to LinesSearchVO o View Attribute to TotalPrice o Prompt to Total Price o User Personalization property to True 3.13 Test Your Work Test your work. Your results should appear as shown in Figure 3 above.
Before you proceed with Task 4, arrange your items (drag-drop in the following order: o OrderId o OrderLineNum o ProductId o Description o OrderedQuantity o SuggestedPrice o UnitOfMeasure C-190 Oracle Applications Framework - Practices and Solutions
4.1 Change the Query Bean to Use autoCustomizationCriteria Select the QueryRN in the Structure pane. Change its Construction Mode property to autoCustomizationCriteria. Change its Include Views Panel property to False. Change its Include Advanced Panel property to False.
4.2 Add a Simple Search Region Select the QueryRN in the Structure pane, right-click and choose New > simpleSearchPanel from the context menu (remember this is a named child of the query region). A header region (region2) and a messageComponentLayout region (region1) will be created automatically. Select the header region, set its ID to SimpleSearchHdr and change the default Text property value to Search . Select the default messageComponentLayout region created under simpleSearchPanel folder (region1 ) and set its ID to CustomSimpleSearch . the
4.3 Create an OrderId Search Item Select CustomSimpleSearch region in the Structure pane, right-click and select New > messageTextInput from the context menu. Select this item, and set or verify its properties as follows
Appendix C: Practices and Solutions Property Value Selective Search True Criteria Data Type NUMBER Maximum Length 15 Prompt Order Number CSS Class OraFieldText Length 5
4.4 Create an OrderLineNum Search Item Select the CustomSimpleSearch region in the Structure pane, right-click and select New > messageTextInput from the context menu. Select this item, and change or verify its properties as follows: Property ID Item Style Selective Search Criteria Data Type Prompt CSS Class Length Value SearchOrdLineNum messageTextInput True NUMBER Line OraFieldText 15
4.5 Create a ProductId Search Item Select CustomSimpleSearch region in the Structure pane, right-click and select New > messageTextInput from the context menu.
Lab 8: Lines: Search . 4.6 Create a Description Search Item Select CustomSimpleSearch region in the Structure pane, right-click and select New > messageTextInput from the context menu. Select this item, and set or verify its properties as follows Property ID Item Style Selective Search Criteria Data Type Prompt CSS Class Maximum Length Length Value SearchDesc messageTextInput (we will change this to LOV later) True VARCHAR2 Description OraFieldText 255 15
4.7 Create Search Mappings Between Search Items and ResultsTable The OA Framework uses the mappings that you define between your custom search items and columns in the ResultsTable to handle the query automatically when the user selects the Go button. Select the query bean or the query Components folder in the Structure pane, rightclick and choose New > simpleSearchMappings from the context menu. Select the default mapping created under the simpleSearchMappings and set its properties to the following: Property ID Search Item Results Item Value OrderNumMap SearchOrdNum OrderId
Select the simpleSearchMappings folder in the Structure pane, right-click and choose New > queryCriteriaMap from the context menu.
Appendix C: Practices and Solutions Select the new mapping and set its properties as follows: Property ID Search Item Results Item Value OrdLineMap SearchOrdLineNum OrderLineNum
Select the simpleSearchMappings folder in the Structure pane, right-click and choose New > queryCriteriaMap from the context menu. Select the new mapping and set its properties as follows: Property ID Search Item Results Item Value ProdNumMap SearchProdNum ProductId
Select the simpleSearchMappings folder in the Structure pane, right-click and choose New > queryCriteriaMap from the context menu. Select the new mapping and set its properties as follows: Property ID Search Item Results Item Value DescMap SearchDesc Description
4.8 Test Your Work Test your work. Your results should appear as shown in Figure 4 above (but without the LOV icon).
5.1 Create the Product LOV View Object Select the <yourname>.oracle.apps.demxx.lov.server package in the Navigator, right-click and select "New View Object..." from the context menu to open the View Object wizard. If the Welcome page appears, select Next. In the Name page, specify ProductLovVO as the view object name and verify that the package is <yourname>.oracle.apps.demxx.lov.server . Select the Next button until you get to the Query page. In the Query page, enter the following query into the Query Statement text field.
SELECT D.PRODUCT_ID, D.DESCRIPTION, D.UNIT_OF_MEASURE,
Select the Test button to ensure your syntax is correct. Select the Next button until you get to the Java page. In the Java page, deselect the Generate Java File for View Object Class: ProductLovVOImpl. Do select the Generate Java File for View Row Class: ProductLovVORowImpl to comply with OA Framework coding standards. Select the Finish button to create your VO. 5.2 Add the ProductLovVO to the OrderEntryLovAM View objects can be used only within the context of a containing application module. Before we use the ProductLovVO in our LOV, we must add it to the LOV application module. Select the OrderEntryLovAM in the Navigator pane; right-click and select Edit OrderEntryLovAM... from the context menu to open the Application Module wizard. Navigate to the Data Model page. Select the ProductLovVO view object in the Available View Objects list and shuttle it to the Data Model list. Change Instance name on the right from ProductLovVO1 to ProductLovVO. Select the OK button to finish adding this VO to the AM. 5.3 Create the Shared ProductLovRN LOV Region Since the Product details LOV can be used in many different pages, it must be created as a shared, standalone region. Select the OrderEntry.jpr project in the Navigator, right-click and select New.. . from the context menu. In the New window, expand the Web Tier hierarchy and select OA Components. Select Region in the OA Components Items list. Select the OK button to continue. In the New Region dialog, specify the following values: o In the Name field enter ProductLovRN. Oracle Applications Framework - Practices and Solutions C-197
Appendix C: Practices and Solutions o In the Package field enter <yourname>.oracle.apps.demxx.lov.webui. o In the Style field select listOfValues . o Click the OK button to create your region. Select the ProductLovRN in the Structure pane, set the AM Definition property to <yourname>.oracle.apps.demxx.lov.server.OrderEntryLovAM , set the Advanced Search Allowed property to True and set the Scope property to Public. 5.4 Add a Table to the LOV Region Select the ProductLovRN in the Structure pane, right-click and select New > table Using Wizard from the context menu. If the Welcome page appears, select Next. In the BC4J Objects page, select your OrderEntryLovAM (<yourname >.oracle.apps.demxx.lov.server.OrderEntryLovAM), then select your ProductLovVO view object instance from the Available View Objects list. DO NOT select the Use this as Application Module Definition for this region checkbox. Select the Next button. In the Region Properties page, set the Region ID field value to ProdLovTable and set the Region Style to table . Select the Next button. In the View Attributes page, add all the attributes in the ProductLovVO. Select the Next button. In the Region Items page, set the ID, Style properties as follows
Attribute Set
Click the Finish button to create your data table. Set the Additional Text property on your table to Product Details List. Select the ProdId and Description items in the Structure pane C-198 Oracle Applications Framework - Practices and Solutions
Lab 8: Lines: Search . o Set their Search Allowed properties to True Select the Uom and SugPrice items in the Structure pane o Set their Search Allowed and Selective Search Criteria properties to True. 5.5 Make the Product Id Search Item an LOV When we first created the Product Number item, we set its style to messageTextInput (a standard text entry field). Now, we need to configure it to include an LOV. Select the SearchProdNum item in the CustomSimpleSearch panel. Change its Item Style property to messageLovInput. When you set the Item Style property to messageLovInput, JDeveloper automatically creates an inline LOV region (region style listOfValues ) and a default LOV mapping. Set the External LOV property to /<yourname>/oracle/apps/demxx/lov/webui/ProductLovRN. Note: When we change this property, JDeveloper displays a confirmation message indicating that children of our base field, such as the inline LOV region, will be removed by the change. Confirm the change (select the OK button). Once you confirm, the inline LOV region is removed and the new external LOV region appears in the hierarchy (grayed out because it cannot be edited directly in your page). Verify if its Disable Validation property to False . Note: Per the OA Framework View Coding Standards, validation should always be enabled on an LOV field unless the user should be able to enter partial values, as is often the case in a search criteria field. 5.6 Define LOV Mappings Create mappings between base page items and LOV items. The mappings identify the data input/output relationships between base page items and LOV items. Select the default LOV mapping, ID labeled as lovMap1, and set the following properties: o Change the LOV Region Item property by selecting ProdId field from the poplist. o Change the Return Item property by selecting SearchProdNum field from the poplist. o Change the Criteria Item property by selecting SearchProdNum field from Oracle Applications Framework - Practices and Solutions C-199
Appendix C: Practices and Solutions the poplist. Right-click lovMappings in the Structure panel, and select New > lovMap from the context menu. Select the default LOV mapping, ID labeled as lovMap2, and set the following properties: o Change the LOV Region Item property by selecting Description field from the poplist. o Change the Return Item property by selecting SearchDesc field from the poplist. 5.7 Make the Description Search Item an LOV When we first created the SearchDesc item, we set its style to messageTextInput (a standard text entry field). Now, we need to configure it to include an LOV. Select the SearchDesc item in the CustomSimpleSearch panel. Change its Item Style property to messageLovInput. When you set the Item Style property to messageLovInput, JDeveloper automatically creates an inline LOV region (region style listOfValues ) and a default LOV mapping. Set the External LOV property to /<yourname>/oracle/apps/demxx/lov/webui/ProductLovRN . Verify if its Disable Validation property to True . 5.8 Define LOV Mappings Create mappings between base page items and LOV items. The mappings identify the data input/output relationships between base page items and LOV items. Select the default LOV mapping, ID labeled as lovMap3, and set the following properties: o Change the LOV Region Item property by selecting Description field from the poplist. o Change the Return Item property by selecting SearchDesc field from the poplist. o Change the Criteria Item property by selecting SearchDesc field from the poplist. C-200 Oracle Applications Framework - Practices and Solutions
Lab 8: Lines: Search . Right-click lovMappings in the Structure panel, and select New > lovMap from the context menu. Select the default LOV mapping, ID labeled as lovMap4, and set the following properties: o Change the LOV Region Item property by selecting ProdId field from the poplist. o Change the Return Item property by selecting SearchProdNum field from the poplist. 5.9 Test Your Work Test your work. Your base page (the Orders Search page) should appear as shown in the figure above. When you select the list of values icon, your LOV windows should appear as shown in Figures 5 (a/b). Warning: You cannot run and test the LOV page directly. You must run your base page, and then select the list of values icon to invoke the LOV.
6.1 Add a "Goto Order Search" Button to Your Search Page First, you need to revise the LinesSearchPG to include a Goto Order Search button above the results table. To do this, you will need to add a tableAction component to the Results table that you created in the Lines Search Exercise. Select the ResultsTable region in the Structure pane, right-click and select New > tableActions from the context menu. JDeveloper automatically creates a flowLayout region for you. Change this region's ID to ButtonLayout. Select the ButtonLayout region, right-click and select New > Item. Set this item's properties as follows:
Value Goto SubmitButton /oracle/apps/fnd/attributesets/Buttons/Go Goto Order Search Select to query an order
Select the LinesSearchPG, right-click and select Run LinesSearchPG.xml. Your page should appear as shown in Figure 1. 6.2 Add " Goto Order Search" Button Press Handler to Your Search Page When the user presses the Goto Order Search submitButton, you need processFormRequest() code to determine that this button has been pressed and navigate the user to the OrderSearchPG. First, create a controller and associate with the PageLayoutRN region in the LinesSearchPG. Select the PageLayoutRN region in the LinesSearchPG, right-click and select Set New Controller ... from the context menu. In the Package Name <yourname>.oracle.apps.demxx.orderentry.webui. In the Name field enter LinesSearchCO . C-202 Oracle Applications Framework - Practices and Solutions field enter
Lab 8: Lines: Search . Select the OK button to create your controller. Then, add the following code to the LinesSearchCO.processFormRequest( ) method:
import oracle.apps.fnd.framework.webui.OAWebBeanConstants; ... public void processFormRequest(OAPageContext pageContext, OAWebBean webBean) { // Always call this first super.processFormRequest(pageContext, webBean); if (pageContext.getParameter("Goto")!=null) { // Navigate to the Order Search Page while retaining the AM. // Note the use of KEEP_MENU_CONTEXT as opposed to GUESS_MENU_CONTEXT // since we know the current tab should remain highlighted.
pageContext.setForwardURL("OA.jsp?page=/<yourname>/oracle/apps/demxx/ orderentry/webui/OrderSearchPG", null, OAWebBeanConstants.KEEP_MENU_CONTEXT, null, null, //HashMap false, // Retain AM OAWebBeanConstants.ADD_BREAD_CRUMB_YES, OAWebBeanConstants.IGNORE_MESSAGES); } }
6.3 Compile and Save Your Work Select the LinesSearchPG, right-click and select Run LinesSearchPG.xml. Your page should appear as shown in Figure 1.
At this point, your Goto Order Search button click should navigate to Orders Search page.
public void initQuery (String orderNumber) { if ((orderNumber != null) && (!("".equals(orderNumber.trim())))) { setWhereClause(null); setWhereClauseParams(null); executeQuery(); Number ordNum = null; try { ordNum = new Number(orderNumber); } catch(Exception e) { throw new OAException("DEMXX", "ORDLINES_INVALID_LINE_NUMBER"); }
7.2 Add an initLinesDetails( ) Method to Your OrderEntryAMImpl Class You will invoke this method from your UI controller.This method delegates to the initQuery() method that you just created on the LinesSearchVOImpl class.
7.3 Save and Compile Your Work Select the JDeveloper main menu option File > Save All. Select your project, right-click and select Rebuild OrderEntry.jpr to compile everything
8.3 Test Your Work Test your work. Run the OrderSearchPG, query for orders and navigate to Order Details Page. Select the Order Link which is configured as a link to query the Lines Search Page with the lines details for the order chosen. Note: The LinesSearchPG cannot be used to query other information when it is used as a drilldown. To query different order-lines for various orders Rebuild OrderEntry.jpr and Run LinesSearchPG explicitly.
Appendix C: Practices and Solutions In the Entity Objects page, select the LinesEO in the Available list and shuttle it to the Selected list. Select the Next button. In the Attributes page, select the following attributes from the Available list and shuttle them to the Selected list. From LinesEO: o OrderId o OrderLineNum o ProductId o GlAccountCcId o OrderedQuantity o AttributeCategory o Attribute1 o Attribute2 o Attribute3 o Attribute4 o Attribute5 o Attribute6 o Attribute7 o Attribute8 o Attribute9 o Attribute10 o RowID Select the Next button twice. At this point the query should look like the following in the Query page (without the formatting we've used here to improve readability):
SELECT LinesEO.ORDER_ID, LinesEO.ORDER_LINE_NUM, LinesEO.PRODUCT_ID, LinesEO.GL_ACCOUNT_CC_ID, LinesEO.ORDERED_QUANTITY,
FROM
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
SELECT LinesEO.ORDER_ID, LinesEO.ORDER_LINE_NUM, LinesEO.PRODUCT_ID, LinesEO.GL_ACCOUNT_CC_ID, LinesEO.ORDERED_QUANTITY, LinesEO.ATTRIBUTE_CATEGORY, LinesEO.ATTRIBUTE1, LinesEO.ATTRIBUTE2, LinesEO.ATTRIBUTE3, LinesEO.ATTRIBUTE4, LinesEO.ATTRIBUTE5, LinesEO.ATTRIBUTE6, LinesEO.ATTRIBUTE7, LinesEO.ATTRIBUTE8, LinesEO.ATTRIBUTE9, LinesEO.ATTRIBUTE10, LinesEO.ROWID, DemProd.DESCRIPTION, DemProd.SUGGESTED_PRICE, DemProd.UNIT_OF_MEASURE, LinesEO.ORDERED_QUANTITY * DemProd.SUGGESTED_PRICE AS TOTAL_PRICE FROM DEM_ORDER_LINES LinesEO, DEM_PRODUCTS DemProd WHERE LinesEO.PRODUCT_ID = DemProd.PRODUCT_ID
When you are finished with your editing, select the Test button to ensure your syntax is correct. Select the Next button. In the Attribute Mappings page, verify that your view object attributes map to the Oracle Applications Framework - Practices and Solutions C-211
Appendix C: Practices and Solutions correct query columns. If you need to make any changes, place your cursor into the incorrect View Attributes field and select the correct value from the poplist. Select the Next button. In the Java page, o Select the Generate Java File for View Object Class: LinesDetailsVOImpl (you don't need to add any code to this view object). o Do select the Generate Java File for View Row Class: LinesDetailsVORowImpl to comply with OA Framework coding standards. Select the Finish button to create your VO. Now verify that your VO attribute settings match the aliases in your SQL query: Select the LinesDetailsVO in the Navigator, right-click and select Edit LinesDetailsVO... from the context menu to open the View Object wizard. Navigate to the Attributes section for your attributes and verify that any aliases in your query are shown correctly. Make any necessary changes and select Apply. Navigate to the Attribute Mappings page and verify that all the mappings are correct. Make any necessary changes and select Apply. Select the OK button to finish editing your VO. Note: Do not add your LinesDetailsVO to OrderEntryAM immediately. We will add it a bit later.
1.2 Create a OrderToLinesVL View Link (VL) Create a new view link in the <yourname>.oracle.apps.demxx.orderentry.server package: Select the <yourname>.oracle.apps.demxx.orderentry.server BC4J package in the Navigator, right-click and select New View Link... from the context menu to open the View Object wizard. If the Welcome page appears, select Next. In the Name page, specify OrderToLinesVL as the view link's name and verify that the Package is <yourname>.oracle.apps.demxx.orderentry.server. Select the Next button. In the View Objects page, o Select the OrderDetailsVO as Source view object. C-212 Oracle Applications Framework - Practices and Solutions
Lab 9: Lines: Create . o Select the LinesDetailsVO as Destination view object. o Select Next to proceed. In the Source Attributes page, o Select the association object OrderToLinesAO and click the button to shuttle the source attribute to the Selected Attributes list on the right. o Verify that OrderId appears in the selected attributes list. o Select Next to proceed.
Figure 2: View Link Wizard showing use of an association to obtain the source view object join attribute In the Destination Attributes page, o Verify that OrderId appears as the Destination attribute in the selected attribute list. o Select Next to proceed. In the View Link SQL page, o Review the WHERE clause that BC4J is going to create for you to ensure that it is Oracle Applications Framework - Practices and Solutions C-213
Figure 3: View Link Wizard showing a generated WHERE clause In the View Link Properties page, o Verify that the cardinality is 1 to * o Select Generate Accesor for both the View Objects Select Finish to create your view link.
1.3 Add the LinesDetailsVO to OrderEntryAM Select the LinesDetailsVO via OrderToLinesVL view object on the left. Select the OrderDetailsVO view object on the right. Now shuttle LinesDetailsVO via OrderToLinesVL to the right.(as shown in figure 4 below) Change the instance name on the right bottom from LinesDetailsVO1 to LinesDetailsVO. C-214 Oracle Applications Framework - Practices and Solutions
Property ID Region Style AM Definition Window Title Title Warn About Changes AutoFooter
Value PageLayoutRN pageLayout <yourname>.oracle.apps.demxx.orderentry.server.OrderEntryAM Order Entry Tutorial: Labs <your name> Lines: Create True True
2.3 Add a Product Branding Image Add the product-branding image, FNDTAPPBRAND.gif , to your page. 2.4 Add Page-Level Apply and Cancel Buttons Per the BLAF UI guidelines, all page-level buttons render twice on the page: below the page title, and below the ski. However, you only need to add them once using a special pageButtonBar region. First, select the PageLayoutRN in the Structure pane, then right-click and select New > Region from the context menu. Set the following properties for this region: Property ID Region Style Value PageButtons pageButtonBar
Lab 9: Lines: Create . Second, add a Cancel button. Right-click PageButtons in the Structure pane, and select New > Item from the context menu. Set or verify the following properties for this item: Property ID Item Style Attribute Set Disable Server Side Validation Disable Client Side Validation Prompt Warn About Changes Additional Text Value Cancel submitButton /oracle/apps/fnd/attributesets/Buttons/Cancel (Always use the standard OA Framework attribute sets for common buttons.) True (So the user can leave the page by selecting this button without encountering server- side validation errors .) True (So the user can leave the page by selecting this button without encountering client- side validation errors.) Cancel (Set automatically when you specify the attribute set.) False (So the user can leave the page by selecting this button without being warned about pending changes.) Select to cancel this transaction. (This is required per the accessibility coding standards ).
Third, add an Apply button. Right-click PageButtons in the Structure pane, and select New > Item from the context menu. Set or verify the following properties for this item:
Value Apply submitButton /oracle/apps/fnd/attributesets/Buttons/Apply Apply (Set by the attribute set.) Select to save this Line.
2.5 Create the Content Region To achieve the correct indentation of our display fields, add a advancedTable region to your PageLayoutRN. Oracle Applications Framework - Practices and Solutions C-217
Appendix C: Practices and Solutions Select PageLayoutRN in the Structure pane, right-click and select New > Region from the context menu. Set the following properties for the new region Property ID Item Style Value AdvTblHdrRN hideShowHeader
Select AdvTblHdrRN in the Structure pane, right-click and select New > Region from the context menu. Set the folowing properties for the new region
Property ID Item Style View Instance Text Additional Text Records Displayed Width
Value LinesAdvTblRN AdvancedTable LinesDetailsVO Order Lines Table Lines Entry for Orders 10 100%
Select LinesAdvTblRN in the Structure pane, right-click and select New > Column from context menu. Set the ID property to OrdIdCol Select OrdIdCol in the Structure pane, right-click and select New > Item Set the following properties for the new item
Property ID Item Style Data Type View Attribute Prompt CSS Class
Select the columnHeader component, right-click and select New > sortableHeader C-218 Oracle Applications Framework - Practices and Solutions
Lab 9: Lines: Create . Set the ID property to OrdIdHdr Set the Prompt to Order Number Set the Required Indicator property to Yes Select LinesAdvTblRN in the Structure pane, right-click and select New > Column from context menu. Set the ID property for the new column OrdLineCol Select OrdLineCol in the Structure pane, right-click and select New > Item Set the following properties for the new item
Property ID Item Style Required Data Type Maximum Length View Attribute Prompt CSS Class Length
Select the columnHeader component, right-click and select New > sortableHeader Set the ID property to OrdLineHdr Set the Prompt to Line Set the Required Indicator property to Yes Select LinesAdvTblRN in the Structure pane, right-click and select New > Column from context menu. Set the ID property for the new column ProdCol Select ProdCol in the Structure pane, right-click and select New > Item Set the following properties for the new item
Property
Value
Appendix C: Practices and Solutions ID ProductId Item Style messageTextInput Required yes Data Type NUMBER Maximum Length 15 View Attribute ProductId Prompt Number CSS Class OraFieldText Length 8 Select the columnHeader component, right-click and select New > sortableHeader Set the ID property to ProdHdr Set the Prompt to Number Set the Required Indicator property to Yes
Select LinesAdvTblRN in the Structure pane, right-click and select New > Column from context menu. Set the ID property for the new column DescCol Select DescCol in the Structure pane, right-click and select New > Item Set the following properties for the new item
Property ID Item Style Required Data Type Maximum Length View Attribute Prompt CSS Class
Select the columnHeader component, right-click and select New > sortableHeader Set the ID property to DescHdr Set the Prompt to Description Set the Required Indicator property to Yes C-220 Oracle Applications Framework - Practices and Solutions
Lab 9: Lines: Create . Select LinesAdvTblRN in the Structure pane, right-click and select New > Column from context menu. Set the ID property for the new column OrdQuantCol Select OrdQuantCol in the Structure pane, right-click and select New > Item Set the following properties for the new item
Property ID Item Style Data Type Maximum Length View Attribute Prompt CSS Class
Select the columnHeader component, right-click and select New > sortableHeader Set the ID property to OrdQuantHdr Set the Prompt to Quantity Ordered Select LinesAdvTblRN in the Structure pane, right-click and select New > Column from context menu. Set the ID property for the new column UomCol Select UomCol in the Structure pane, right-click and select New > Item Set the following properties for the new item
Property ID Item Style Disabled Data Type Maximum Length View Attribute Prompt CSS
Appendix C: Practices and Solutions Select the columnHeader component, right-click and select New > sortableHeader Set the ID property to UomHdr Set the Prompt to UOM
Select LinesAdvTblRN in the Structure pane, right-click and select New > Column from context menu. Set the ID property for the new column SuggPriceCol Select SuggPriceCol in the Structure pane, right-click and select New > Item Set the following properties for the new item
Property ID Item Style Disabled Data Type Maximum Length View Attribute Prompt CSS Class
Select the columnHeader component, right-click and select New > sortableHeader Set the ID property to SuggPriceHdr Set the Prompt to Price
Select LinesAdvTblRN in the Structure pane, right-click and select New > Column from context menu. Set the ID property for the new column TotPriceCol Select TotPriceCol in the Structure pane, right-click and select New > Item Set the following properties for the new item Property ID Item Style Value TotalPrice messageTextInput
Lab 9: Lines: Create . Disabled True View Attribute TotalPrice Prompt Total Price CSS Class OraDataText
Select the columnHeader component, right-click and select New > sortableHeader Set the ID property to TotPriceHdr Set the Prompt to Total Price
Select LinesAdvTblRN in the Structure pane, right-click and select New > Column from context menu. Set the ID property for the new column DffCol Select DffCol in the Structure pane, right-click and select New > Item Set the following properties for the new item
Select the columnHeader component, right-click and select New > sortableHeader Set the ID property to DffHdr Set the Prompt to [..] Select LinesAdvTblRN in the Structure pane, right-click and select New > Column from context menu. Set the ID property for the new column KeyFlexCol Select KeyFlexCol in the Structure pane, right-click and select New > Item Set the following properties for the new item
Appendix C: Practices and Solutions Property Value ID GlAccountCcId Item Style messageTextInput View Attribute GlAccountCcId CSS Class OraFieldText Select the columnHeader component, right-click and select New > sortableHeader Set the ID property to AccHdr Set the Prompt to Account
2.6 Set up Your LOVs The ProductId and description items have to be configured as LOVs. Use the ProductLovRN you already created in the Search page to configure them as LOVs For ProductId Item
Value MessageLovInput /<yourname>/oracle/apps/demxx/lov/webui/ProductLovRN You must create LOV mappings for the following: LOV Map 1 ID: ProdIdMap Lov Region Item: ProdId Return Item: ProductId Criteria Item: ProductId LOV Map 2 ID: DescMap Lov Region Item: Description Return Item: Description LOV Map 3 ID: UomMap Lov Region Item: Uom Return Item: UnitOfMeasure LOV Map 4 ID: SuggPriceMap Lov Region Item: SugPrice Return Item: SuggestedPrice
Property
Value
Lab 9: Lines: Create . Item Style messageLovInput External LOV /<yourname>/oracle/apps/demxx/lov/webui/ProductLovRN LOV Mappings You must create LOV mappings for the following: LOV Map 1 ID: DescMap1 Lov Region Item: Description Return Item: Description Criteria Item: Description LOV Map 2 ID: ProdIdMap1 Lov Region Item: ProdId Return Item: ProductId LOV Map 3 ID: UomMap1 Lov Region Item: Uom Return Item: UnitOfMeasure LOV Map 4 ID: SuggPriceMap1 Lov Region Item: SugPrice Return Item: SuggestedPrice
2.7 Add a Add Another Row Button and a Recalculate Total Price Button The following steps describe how to display an Add Another Row button to the footer of an advanced table. Select your LinesAdvTblRN, right-click and select New > footer from the context menu. OA Extension creates an advancedTables Components folder containing a footer named child, that contains a tablefooter container (labeled tableFooter1). Change the ID to TableFooter. Select the TableFooter and choose New > addTableRow from the context menu. Select addTableRow1 and set/verify the following properties o ID to AddAnotherRow o Insert Rows Automatically to True o Add Rows Label to Add Another Row.
The following steps help us in creating a Recalculate Total Price button to the footer of an advanced table. Select the TableFooter and choose New > total from the context menu. Select totalRow1 and set/verify the following properties Oracle Applications Framework - Practices and Solutions C-225
Appendix C: Practices and Solutions o ID to TotalRow o Recalculate Totals Label to Recalculate Total Price. o Additional Text to Click to recalculate net price. Now, select TotPriceCol in Structure Pane o Set Total Value to True
2.8 Add a Multiple Selection with a Delete Button Select the LinesDetailsVO from the <yourname>.oracle.apps.demxx.orderentry.server package, right-click and select Edit LinesDetailsVO. Select the Attributes Tab and click on the New button. Set the following attributes o Name o Type o Updatable : SelectRow : String : Always
Select the OK button Go to the Attribute Mappings Tab and verify if the mapping is correct. Select the OK button to create the transient attribute.
Now add a MultipleSelection Bean and a Delete Button Select the LinesCreatePG from the navigator pane. Select advancedTable Components, multipleSelection from context menu Set or verify the following properties o ID to MultipleSelection o View Attribute to SelectRow o Text to Select Object: Select MultipleSelection, right-click and select New > flowLayout from context menu C-226 Oracle Applications Framework - Practices and Solutions right-click and select New >
Lab 9: Lines: Create . Set its ID to ButtonLayoutRN Select the ButtonLayoutRN, right-click and select New > Item from context menu Set or verify the following properties o ID to Delete o Item Style to submitButton o Attribute Set to /oracle/apps/fnd/attributesets/Buttons/Delete o Additional Text to Select to delete a row o Disable Client Side Validation to True o Disable server Side Validation to True
2.9 Add an "Indicates Required Field" Region The "Indicates Required Field" region should render on the same line as the page-level action/navigation buttons. To achieve this, always add page-level keys like this to a pageStatus component. Select the PageLayoutRN, right-click and select New > pageStatus. Select the flowLayout region that JDeveloper creates for you beneath the pageStatus component and set its ID to PageStatusRN. Select PageStatusRN, right-click and select New > Region . Set the following properties for this region (whenever you need a BLAF-standard "Indicates Required Field" key in your page, you can simply extend the common OA Framework region shown below).
2.10 Add an initQuery() to LinesDetailsVO Add the following code to your LinesDetailsVO to execute the querybased on a Boolean value coming in as a parameter. Oracle Applications Framework - Practices and Solutions C-227
2.11 Add the initTableQuery() to OrderEntryAMImpl Add the following code to your OrderEntryAMImpl to invoke the initQuery() method in the LinesDetailsVO with a boolean parameter passed.
public void initTableQuery(Boolean executeQuery) { LinesDetailsVOImpl vo = getLinesDetailsVO(); vo.initQuery(executeQuery); }
2.12 Set the Controller for the PageLayoutRN Select the PageLayoutRN , right-click and select Set New Controller from context menu Set the package to <yourname>.oracle.apps.demxx.orderentry.webui Set the Name to LinesCreateCO
2.13 Add LinesAdvTblRN Initialization to LinesDetailsCO processRequest() To account for the Add Another Row button click we add the following logic to our LinesDetailsCO controller's processRequest() method. This invokes the initTableQuery() method coded in the OrderEntryAMImpl.
2.14 Configure OrderLines Button Click When the user presses the OrderLines button in the Orders page, you need to navigate to the Lines Create page. Append the following code to your processFormRequest() in the OrderCreateCO
import oracle.apps.fnd.framework.webui.beans.message.OAMessageTextInputBean; import oracle.apps.fnd.framework.webui.beans.message.OAMessageChoiceBean; . . . /************* Handling the OrderLines Button ***************/ if (pageContext.getParameter("OrderLinesButton")!=null) {
Lab 9: Lines: Create . 2.15 Save and Test Your Work Select OrderEntry.jpr, right-click and select Rebuild OrderEntry.jpr. Select the OrderSearchPG, right-click and select Run OrderSearchPG.xml. Select the Create Order button. In the Create Order Page fill in appropriate fields and click the Order Lines Button and check up if it navigates to our LinesCreatePG. At this point your Lines Create page would look similar to this.
3: Implement Browser Back Button Safe Page Initialization and create/rollback Methods
3.1 Add a createOrderLineEntry( ) Method to Your OrderEntryAMImpl Class Add the following method to your OrderEntryAMImpl class for creating a new order-line in the LinesDetailsVO view object (the call to vo.createRow() ultimately calls a create( ) method in your LinesEOImpl entity object that you will be coding a bit later).
... /** ******************************************************* * Creates a new Order Line ******************************************************* */ public void createOrderLineEntry() { OAViewObject orderLineEntryVO = (OAViewObject)getLinesDetailsVO(); if(orderLineEntryVO != null) { OARow orderLineEntryRow =(OARow)orderLineEntryVO.createRow(); if(orderLineEntryRow != null) { orderLineEntryVO.executeQuery(); orderLineEntryVO.insertRow(orderLineEntryRow); orderLineEntryRow.setNewRowState(orderLineEntryRow.STATUS_INITIALIZED); orderLineEntryVO.setCurrentRow(orderLineEntryRow); } } }
3.2 Add a rollbackOrderLine( ) Method to Your OrderEntryAMImpl Class Add the following method to your OrderEntryAMImpl class for rolling back the database and the middle tier (you will see how you are going to use this a bit later). Note that we call getTransaction() here to use an oracle.jbo.Transaction instead of calling getOADBTransaction() to get an OAF subclass oracle.apps.fnd.framework.server.OADBTransaction because the superclass has the behavior we need, and as a rule, you should always instantiate the class that includes the behavior you want to use. Avoid instantiating subclasses if the additional behavior is not required.
/** ********************************************************************* * Executes a rollback including the database and the middle tier. ********************************************************************* */ public void rollbackOrderLine() { Transaction txn = getTransaction(); // This small optimization ensures that we don't perform a rollback // if we don't have to. if (txn.isDirty()) { txn.rollback(); } } // end rollbackOrderLine()
3.3 Add Back Button Handling to the OrderCreateCO processRequest( ) To account for various Back button navigation patterns between the Lines Create and the Create Order, add the following logic to your OrderCreateCO controller's processRequest() method. This ensures that any unfinished order line objects are cleared from the middle tier cache when the user navigates back to the Orders Create page using the browser Back button, and then tries to create a new order line.
... /*********** Back Navigation from Lines Page **************/ OAApplicationModule am = pageContext.getApplicationModule(webBean); // page // // // // with // // // // // // The following checks to see if the user navigated back to this without taking an action that cleared an "in transaction" indicator. If so, we want to rollback any changes that he abandoned to ensure they aren't left lingering in the BC4J cache to cause problems subsequent transactions. For example, if the user navigates to the Create Lines page where you start a "create" transaction unit, then navigates back to this page using the browser Back button and selects the OrderLines button again, the OA Framework detects this Back button navigation and steps through processRequest() so this code is executed before you try to create another new order line.
3.4 Test Your Work Select OrderEntry.jpr, right-click and select Rebuild OrderEntry.jpr. Select the OrderSearchPG, right-click and select Run OrderSearchPG.xml.
The following table summarizes the order business rules to be implemented in this lab. 4.1 Lay down your Business Needs
Business Rules
Should be available from the Master Table DEM_ORDERS (that is should be available from Orders Page) OrderLineNum Required; cannot be null ProductId Required; cannot be null Description Required; cannot be null OrderedQuantity Decides the Total Price Must be a valid numeral entered (>0) UnitOfMeasure Value implicitly provided based on product chosen SuggestedPrice Value implicitly provided based on product chosen TotalPrice Total Price should be calculated based on Ordered Quantity Account Should be modelled a key-flex field DescFlex A Descriptive Flexfield should be provided to capture additional data
4.2 Include Create Page Initialization This page includes logic to ensure that the user does not encounter errors due to navigation using the browser Back button. Then, add the following code in bold to your pre-existing code(which is not in bold) in your processRequest() method of LinesCreateCO to be called when the page is initialized:
import oracle.apps.fnd.framework.webui.OADialogPage; import oracle.apps.fnd.framework.server.OADBTransaction; import oracle.apps.fnd.framework.webui.TransactionUnitHelper; ... public void processRequest(OAPageContext pageContext, OAWebBean webBean) { // Always call this first. super.processRequest(pageContext, webBean);
table.queryData(pageContext, true); // If isBackNavigationFired = false, we're here after a valid // navigation (the user selected the OrderLines button) and we should // proceed normally and initialize new order-lines. if (!pageContext.isBackNavigationFired(false)) { // We indicate that we are starting the create transaction (this // is used to ensure correct Back button behavior). TransactionUnitHelper.startTransactionUnit(pageContext, "ordLineCreateTxn"); // // // // // This test ensures that we don't try to create a new order line if we had a JVM fail over, or if a recycled application module is activated after passivation. If these things happen, BC4J will be able to find the row that you created so the user can resume work.
if (!pageContext.isFormSubmission() && !("update".equals(pageContext.getParameter(EVENT_PARAM)))) { am.invokeMethod("createOrderLineEntry", null); } } else { if (!TransactionUnitHelper.isTransactionUnitInProgress(pageContext, "ordLineCreateTxn", true)) { // We got here through some use of the browser "Back" button, so we // want to display a stale data error and disallow access to the // page. // If this were a real application, we would probably display a
4.3 Add Validation Logic to the setOrderedQuantity( ) Method; Add the following import statements to your LinesEOImpl class:
import import import import import import oracle.apps.fnd.framework.OAAttrValException; oracle.apps.fnd.framework.OARowValException; oracle.apps.fnd.framework.server.OADBTransaction; oracle.apps.fnd.framework.OAException; oracle.jbo.RowIterator; oracle.jbo.server.EntityImpl;
Add a validateOrderedQuantity( ) Method Add the following validation logic to the setOrderedQuantity() method in the LinesEO02Impl class. In this case, we are delegating to a validateOrderedQuantity() method because we ultimately want to perform the order quantity validation again at the entity level, so we want to be able to exercise that validation independent of the attribute setting.
/** **************************************************************** * Sets <code>value</code> as the attribute value for DateOrdered **************************************************************** */ public void setOrderedQuantity(Number value) { validateOrderedQuantity(value); setAttributeInternal(ORDEREDQUANTITY, value); } // setOrderedQuantity()
The validateOrderedQuantity() method is protected because the LinesEOImpl class is the only expected caller, but we want to ensure that subclasses can also leverage this. Tip: Since the entity object classes can be large, it is helpful to co-locate related code.
/** *********************************************************************** ****** * Verifies that the order's Quantity Ordered is valid. *
4.4 Save and Test Your Work Select OrderEntry.jpr, right-click and select Rebuild OrderEntry.jpr. Navigate to your LinesCreatePG as usual. Verify the behavior of setOrderedQuantity().
// Pressing the "Apply" button means the transaction should be // validated and committed. if (pageContext.getParameter("Apply") != null) { // Generally we have illustrated // all BC4J interaction on the server (except for the AMs, of course). // Here, we are dealing with the VO directly so the comments about the // reasons why we are obtaining values from the VO and not the request // make sense in context. OAViewObject vo = (OAViewObject)am.findViewObject("LinesDetailsVO"); Row row = vo.getCurrentRow(); if (row != null) {
5.2 Programmatically Set the Page Title Text Per the BLAF UI Guidelines on Header Components, you need to display the current selected customers name in the Order Lines page title. To do this, add the following code to your controller's processRequest() method. Note that this assumes a message (ORDLINES_LINESHDR_TEXT) has already been created in the database with the following content: Order Lines &CUST_NAME, &ORD_NUM .
import oracle.apps.fnd.common.MessageToken; import oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean; import oracle.apps.fnd.framework.webui.beans.OAMessageStyledTextBean; ... public void processRequest(OAPageContext pageContext, OAWebBean webBean) { // Already existing code /*********** Setting the page title text ********************/ String custName = pageContext.getParameter("CustomerName"); OAMessageStyledTextBean orderId = (OAMessageStyledTextBean)webBean.findChildRecursive("OrderId"); String ordNum = (String) orderId.getValue(pageContext); // Always use a translated value from Message Dictionary when // setting strings in your controllers. MessageToken[] Tokens = { new MessageToken("CUST_NAME", custName), new MessageToken("ORD_NUM", ordNum) }; // Now, get the translated message text including the token value. String pageHeaderText = pageContext.getMessage("DEMXX","ORDLINES_LINESHDR_TITLE", Tokens); // Set the order-specific page title. Note that we know this // controller is associated wit the pageLayout region, which is why // we cast the webBean to an OAPageLayoutBean before calling setTitle. ((OAPageLayoutBean)webBean).setTitle(pageHeaderText);
5.3 Handle Line Number Uniqueness As the Order Line Number and Order Number combination has to be unique, we need to ensure that the various Order Line Numbers are unique for each Order under consideration. We can implement this uniqueness check by adding the following code in the processFormRequest() method of the LinesCreateCO. Note that this portion of the code has to be added with the Apply Button handling code, before we call the apply method wich commits to the database.
... /********************* Eliminating Line Number Duplication *************/ // Append code after you get the handle to the LinesDetailsVO that is, // after OAViewObject vo = (OAViewObject) // am.findViewObject("LinesDetailsVO"); int i=0; for (i=0; i < vo.getFetchedRowCount();i++) { Row row = vo.getRowAtRangeIndex(i); Row[] rows = vo.getFilteredRows("OrderLineNum",row.getAttribute("OrderLineNum")); if(rows.length > 1) { throw new OAException("DEM966","ORDLINES_LINE_ID_UNIQUE"); } }
5.4 Handle Delete Button In order to delete Order-Lines, we need to add functionality to the Delete button. Add the following code to the processFormRequest() method of the LinesCreateCO.
import oracle.jbo.Row;
5.5 Test Your Work Select OrderEntry.jpr, right-click and select Rebuild OrderEntry.jpr. Select the OrderSearchPG, right-click and select Run OrderSearchPG.xml Select the Create Order button. In the OrderCreatePG fill in the details and navigate to the LinesCreatePG. Enter an order line, and select the Apply button. The confirmation message should display in the LinesSearchPG as shown in Figure 8. Also try navigating to the LinesCreatePG and selecting the Cancel button. Test the functionality of Delete button by selecting a few rows and deleting.
Figure 2: A Closer look at the PPR Items and Quantity Ordered field before firing PPR
Figure 3: Note the difference in the PPR items after firing PPR event on Quantity Ordered field
Lab 10: Lines: Partial Page Rendering (PPR) . Set the following properties for the OrdereQuantity item in your Create page:
Property Disable Server Side Validation Disable Client Side Validation Action Type Event Submit
/******************* Multiply the 2 nos. ******************/ if ((num1 != null) && (num2 != null)) { Number num3 = num2.multiply(num1); if(dbRow!=null) { row.setAttribute("TotalPrice", num3); } } disableTotalPrice(); } } /** ***************************************************************** * PPR for TotalPrice, Suggested Price and Unit of Measure Enable ***************************************************************** */ public void enableTotalPrice() { OAViewObject vo = (OAViewObject)findViewObject("OrderEntryPVO");
4.2 Modify init( ) Method in the OrderEntryAM Add the following code in bold to your init() in the OrderEntryAMImpl ensures that your OrderEntryPVO which includes a single row and initializes the application properties VOdefines the default values of totalPrice transient attribute when the page renders.
/** ******************************************************************** * Initializes the transient application properties VO. ******************************************************************** */ public void init()
4.3 Call the init( ) Method from processRequest( ) Add the following code to your LinesCreateCO processRequest() method after the call to am.invokeMethod("createOrderLineEntry"). This ensures that your application properties VO is properly initialized when the page renders.
// Add the following code after am.invokeMethod("createOrderLineEntry") // Initialize the application properties VO for PPR. am.invokeMethod("init");
Appendix C: Practices and Solutions 4.4 Handle PPR Event Add the following code to your existing LinesCreateCO processFormRequest()to route a call to your PPR handler coded in the AM if their PPR event has been fired.
/*********** PPR Event Handling for Total Price************/ String event = pageContext.getParameter(EVENT_PARAM); if(event.equalsIgnoreCase("priceEvent")) { String eventSrcParam = pageContext.getParameter(EVENT_SOURCE_ROW_REFERENCE); Serializable[] rowParam = {eventSrcParam}; am.invokeMethod("changeTotalPrice",rowParam); }
4.5 Test Your Work Select OrderEntry.jpr, right-click and select Rebuild OrderEntry.jpr. Select the OrderSearchPG, right-click and select Run OrderSearchPG.xml Select the Create Order button. Navigate to LinesCreatePG as usual and check the PPRs behavior by entering different values for Ordered Quantity field.
Select the AdvTblHdrRN in TabOneRN, expand the LinesAdvTblRN Select the KeyFlexCol column, right click and select Delete.
Appendix C: Practices and Solutions Select the AdvTblHdrRN1 in TabTwoRN, expand the LinesAdvTblRN1 Select the OrdQuantCol1 column, right click and select Delete. Select the UomCol1 column in the System, right click and select Delete. Select the SuggPriceCol1 column, right click and select Delete. Select the TotPriceCol1 column, right click and select Delete.
Select LinesAdvTblRN1 in TabTwoRN, right-click and select New > formValue Set the following properties for this formValue item
We repeat the same to create another formValue item. Select LinesAdvTblRN1 in TabTwoRN, right-click and select New > formValue Set the following properties for this formValue item
Select the AdvTblHdrRN1 in TabTwoRN, expand the LinesAdvTblRN1 Expand the ProdCol1 column and select the ProductId1.
Select the ProdIdMap2 in the lovMappings. Set the Return Item property to ProductId1 C-254 Oracle Applications Framework - Practices and Solutions
Lab 11: Lines: Layout . Set the Criteria Item property to ProductId1 Select the DescMap2 in the lovMappings. Set the Return Item property to Description1
Select the UomMap2 in the lovMappings. Set the Return Item property to UomFV
Select the SuggPriceMap1 in the lovMappings. Set the Return Item property to SuggPriceFV
Expand the DescCol1 column and select the Description1 . Select the DescMap11 in the lovMappings. Set the Return Item property to Description1 Set the Criteria Item property to Description1
Select the ProdIdMap11 in the lovMappings. Set the Return Item property to ProductId1
Select the UomMap11 in the lovMappings. Set the Return Item property to UomFV
Select the SuggPriceMap11 in the lovMappings. Set the Return Item property to SuggPriceFV
Select the KeyFlexCol1 column in the LinesAdvTblRN1, right click and select New > tableLayout Oracle Applications Framework - Practices and Solutions C-255
Appendix C: Practices and Solutions Set the ID for the new region to TableLayoutRN Select TableLayoutRN in the Structure pane, right-click and select New > rowLayout Set the ID for the new region to RowFlexRN. Select RowFlexRN in the Structure pane, right-click and select New > cellFormat Set the ID for the new region to FlexCell Drag and drop the Account1 item into FlexCell as child. Set the Column Span property of FlexCell to 4.
Select the SubTabRN , right click and select New > subTabs Select the subTabBar1 which appears, right click and select New > link Set the following properties for item1.
Select the subTabBar1 which appears, right click and select New > link Set the following properties for item1.
1.2 Modify the LinesCreateCO Controller Now you need to change the logic in the LinesCreateCO controller to properly initialize both the advanced tables in both subtabs. Append the following logic to your processRequest()below your call to the initTableQuery() method in the AM.
...
1.3 Delete Button Handling Now you need to slightly alter the logic in the LinesCreateCO controller to handle the Delete buttons in both the advanced tables (in two subtabs). Make this change in the processFormRequest() of your LinesCreateCO. Note that the change that needs to be done is given in bold.
... /***************** Handle Delete Button ***********************/ if ((pageContext.getParameter("Delete") != null) || (pageContext.getParameter("Delete1") != null))
1.4 Rebuild and Test Your Work Rebuild your project and run the OrderSearchPG. Navigate to your Lines Create Page. At this point, your Lines Create Page should contain two subtabs as illustrated in the figure below. Make an entry and try to save it to the database and verify if it is saved.
Appendix C: Practices and Solutions Select the LinesUpdatePG page's PageLayoutRN region in the JDeveloper structure pane to open the property inspector. Change its Controller Class property value from <yourname>.oracle.apps.demxx.orderentry.webui.LinesCreateCO to <yourname>.oracle.apps.demxx.orderentry.webui.LinesUpdateCO. Change its Title property value to Update Order Lines . 1.3 Compile and Save Your Work Rebuild your project and save your work.
2.2 Modify the LinesUpdateCO Controller Now you need to change the logic in the LinesUpdateCO controller to properly support the update action and page flow. Create logic needs to be removed. Delete the logic in your processRequest() method and add the following instead:
public void processRequest(OAPageContext pageContext, OAWebBean webBean) { // Always call this first. super.processRequest(pageContext, webBean); OAApplicationModule am = (OAApplicationModule)pageContext.getApplicationModule(webBean); Boolean executeQuery = BooleanUtils.getBoolean(false); Serializable[] parameters = { executeQuery }; Class[] paramTypes = { Boolean.class }; am.invokeMethod("initTableQuery", parameters, paramTypes);
table.queryData(pageContext, true); TransactionUnitHelper.startTransactionUnit(pageContext, "ordLineUpdateTxn"); /************ Setting the dynamic page title text ******************/ String custName = pageContext.getParameter("CustomerName"); OAMessageStyledTextBean orderId = (OAMessageStyledTextBean)webBean.findChildRecursive("OrderId"); String ordNum = (String) orderId.getValue(pageContext); // // // // Always use a translated value from Message Dictionary when setting strings in your controllers. Instantiate an array of message tokens and set the value for the CUST_NAME token and ORD_NUM token.
MessageToken[] Tokens = { new MessageToken("CUST_NAME", custName), new MessageToken("ORD_NUM", ordNum) }; // Now, get the translated message text including the token value. String pageHeaderText = pageContext.getMessage("DEMXX","ORDLINES_LINESHDR_TITLE", Tokens); // // // // Set the order-specific page title (which also appears in the breadcrumbs). Note that we know this controller is associated wit the pageLayout region, which is why we cast the webBean to an OAPageLayoutBean before calling setTitle.
Change the name of the "in transaction indicator" in the processFormRequest() method from ordLineCreateTxn to ordLineUpdateTxn, and change the confirmation message name from ORDLINES_LINES_CREATE_CONFIRM to ORDLINES_LINES_UPDATE_CONFIRM . C-262 Oracle Applications Framework - Practices and Solutions
Lab 12: Lines: Update . 2.3 Configure OrderLines Button Click When the user presses the OrderLines button in the Orders Update page, you need to navigate to the Lines Update page. Append the following code to your processFormRequest() in the OrderUpdateCO
import oracle.apps.fnd.framework.webui.beans.message.OAMessageTextInputBean; import oracle.apps.fnd.framework.webui.beans.message.OAMessageChoiceBean; . . . /*********** Handling the OrderLines Button in UpdatePG *******/ // Navigate from Order Update to Order Lines Update Page // while retaining the AM. if (pageContext.getParameter("OrderLinesButton")!=null) { OAViewObject vo = (OAViewObject)am.findViewObject("OrderDetailsVO"); String payType = String)vo.getCurrentRow().getAttribute("PaymentType"); /************ Validation for Credit Card Type *******************/ if (payType.equalsIgnoreCase("CHARGE")) { OAMessageChoiceBean ccType = (OAMessageChoiceBean)webBean.findChildRecursive("CcType"); if (ccType !=null) { String cc = (String)ccType.getValue(pageContext); // valid CcType value and not null if (cc==null) { throw new OAException("DEM966","ORDLINES_CCTYPE_INVALID"); } } } /***************** Validation for Cheque Number ******************/ else if (payType.equalsIgnoreCase("CHECK")) { OAMessageTextInputBean chkNum = (OAMessageTextInputBean)webBean.findChildRecursive("CheckNumber"); if (chkNum != null) { String chNum = (String)chkNum.getValue(pageContext); if (chNum == null) { throw new OAException("DEM966","ORDLINES_CHECK_NO_BAD"); }
2.4 Rebuild and Test Your Work Rebuild your project and run the LinesSearchPG At this point, your Update column should appear in your results table. Select it to open and test your new update page.
In this exercise, you will be implementing Descriptive Flexfields(DFFs) in your Orders and Lines pages. Warning: This lab assumes that you have completed the Create Orders and Create Lines Exercises and builds on this work. If you have not completed this exercise, please do so before proceeding.
Property ID Item Style View Instance Prompt CSS Class Appl Short Name Name Type Display Context Field
Value DescFlex Flex OrderDetailsVO Descriptive Flexfield OraFieldText DEM (or whichever application DFF is registered to) DEM_ORDERS Descriptive False
Now, drag and drop the DescFlexLayout between OrderNoteLayout and ButtonLayout. Select your DescFlexLayout document in Structure pane, right-click and select Copy. C-266 Oracle Applications Framework - Practices and Solutions
Lab 13: Flexfields . Choose the OrderUpdatePG in System Navigator, select the FooterRN in the Structure pane; right-click and select Paste. Drag-drop the DescFlexLayout to position it between OrderNoteLayout and ButtonLayout.
1.2 Compile and Test Your Work Rebuild your project and save your work. Navigate to your Orders Create page and verify that the DFF renders.
Now, select DescFlex in Structure pane, right-click and select Copy. Select the DescFlexCol1 (present in the TabTwoRN) in Structure pane. Delete the item ( DescFlex1) present in this column. Select DescFlexCol1, right-click and select Paste Choose the LinesUpdatePG in System Navigator, select the DescFlexCol in the Structure pane; Delete the item (DescFlex) present in this column. Select DescFlexCol, right-click and select Paste. Similarly, select the DescFlexCol1 (present in the TabTwoRN) in LinesUpdatePG. Delete the item (DescFlex1) present in this column. Select DescFlexCol1, right-click and select Paste.
Lab 13: Flexfields . 2.2 Compile and Test Your Work Rebuild your project and save your work.
Navigate to your Lines Create page and verify that the DFF renders.
Call:
Add the function to a menu. Add this Menu to a responsibility (which has Self Service Web Applications Radio-button enabled) Add the responsibility to your user.
Lab 14: Deploying the project in Oracle Applications . Import all your pages and regions (*PG.xml, *RN.xml) to the Metadata repository, which you want to deploy. For eg: OrderSearchPG o Run the following statement from command prompt at <JDEV_USER_HOME>\bin o import <JDEV_USER_HOME >\myprojects\<yourname>\oracle\apps\<demxx>\orderentry\ webui\LinesCreatePG.xml -rootdir < JDEV_USER_HOME>\myprojects -username <apps_user> -password <passwd > -dbconnection "(description = (address_list = (address = (community = tcp.world)(protocol = tcp)(host = <hostname>)(port = <port number>)))(connect_data = (sid = <sid>)))" o example: import D:\Jdev11510RUP4\jdev\myprojects\apvv\oracle\apps\dem04\orderentry\webui\Lines CreatePG.xml -rootdir D:\Jdev11510RUP4\jdev\myprojects -username apps password apps -dbconnection "(description = (address_list = (address = (community = tcp.world)(protocol = tcp)(host = 152.69.170.147)(port = 1550)))(connect_data = (sid = CRM9729)))" o Similarly, import the other pages like Order Details/Create/Update and Lines Search/Lines/Create/Update and regions for the LOVs. Now you can launch the OA Page from Oracle Applications, and test the Order Entry functionality o Login to Oracle Applications o Switch to your responsibility and launch the Search Page from the respective menu entry.
Note: If Oracle Applications version R11i is used for deployment we may get an error while trying to save order lines to the database due to the following reason: In the Lines EO, for the ROWID database column the SQLType attribute is set to RowID. But SQLType=ROWID is acceptable for BC4J version 10.1.3 only (R12). This change is not backwards compatible with BC4J 9.0.3 used in 11i codeline. As a workaround, the following can be done on similar lines to the solution in Metalink note 397512.1: EO Level Changes Right Click on your LinesEO and select Edit LinesEO Oracle Applications Framework - Practices and Solutions C-271
Appendix C: Practices and Solutions Expand the Attributes section and select RowID Change the attribute Type from RowID to String. Change the Type in the Database column section from RowID to VARCHAR2(20) Click on Apply and OK o Make sure this change is reflected in the LinesEO.xml by verifying that the SQLType of Rowid Column has changed to VARCHAR.(If not, edit this xml file manually to make this change) VO Level Changes Make the following changes to the LinesDetailsVORowImpl and LinesSearchVORowImpl class: Change the return type and typecast in method getRowID() from RowID to String:
public String getRowID() { return (String)getAttributeInternal(ROWID); }
2. Do a fifteen-minute user interface review of the form belonging to the team with the next lower team number (Team 01 review the highest-numbered team). Use your manuals and your class notes to help you. List some things the team can do to improve the user interface (especially cosmetics) of their form. Discuss your findings with that team when you finish. a ________________________________________________ b ________________________________________________ c ________________________________________________ d ________________________________________________