O A Framework Guide Comsbined 3

Download as pdf or txt
Download as pdf or txt
You are on page 1of 339

Oracle Applications Framework Demo Order Entry Workshop

Draft 1B 30 December 2006

Author V R Dhinesh Raaj

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

Reviewers Dileep Raghavan Sameer Manglm

A
...

Order Entry Workshop

Appendix A: Order Entry Workshop

A-2 Oracle Applications Framework - Order Entry Workshop

Order Entry Workshop Project .

Order Entry Workshop Project


For your laboratory exercises, youll build an order entry application. Database objects and data in tables already exist OBJECT NAME DEM_CUSTOMERS DEM_CUSTOMERS_U1 DEM_ORDERS DEM_ORDERS_S DEM_ORDERS_TEMP DEM_ORDERS_U1 DEM_ORDER_LINES DEM_ORDER_LINES_U1 DEM_PRODUCTS DEM_PRODUCTS_U1 DEM_SALES_REPS DEM_SALES_REPS_U1 OBJECT TYPE TABLE INDEX TABLE SEQUENCE TABLE INDEX TABLE INDEX TABLE INDEX TABLE INDEX

. Oracle Applications Framework - Order Entry Workshop A-3

Appendix A: Order Entry Workshop

Order Page
The workshop has two entities essentially, Orders and Order Lines

Figure 1 Orders Window

A-4 Oracle Applications Framework - Order Entry Workshop

Order Page .

Order Page Specifications


Customer Number, Customer Name, Salesperson Name and Currency Code use LOVs. Order Date and Ship Date use Message Dictionary to give an error message if the date shipped comes before the order date. Make the Order Date update-protected. Currency code field controls currency format in Order Lines window. Order Lines button opens the Order Lines window. Payment Method region includes conditional fields controlled by an option group. The behavior of fields in the Payment Type region depends on which payment type is selected. o If Cash is selected, all other fields in the region are disabled. o If Check is selected, the Number field is enabled. Rest disabled. o If Credit Card is selected, the cctype, number and expiration date fields are enabled. o Further, if the credit card type is Visa, the Approval Code is enabled and required. Order Date and Ship Date provide the Calendar Order Date by default should be current date. Order Date should only be current or later dates (that is must protect from making orders on a date that has already passed).

. Oracle Applications Framework - Order Entry Workshop A-5

Appendix A: Order Entry Workshop

Order Lines Page

Fig: Order Lines Window

Order Lines Page Specifications


Window title is context-dependent on the order, and dynamically displays the order number and customer name A view-link provides master-detail coordination control Product description and number have related LOVs Automatically calculate Total Price and a button to calculate the Grand Total.

A-6 Oracle Applications Framework - Order Entry Workshop

Order Lines Page .

Order Lines Sub- Tab Region

Figure 2 Order Lines tabs Alternative regions within tabbed region contain several items o Quantity, Units, and Prices o Account

. Oracle Applications Framework - Order Entry Workshop A-7

Appendix A: Order Entry Workshop

Order Page Inquiry Features


The end product should contain additional features to allow easy inquiry on orders and order lines.

Fig: Orders Search Window Provide only those criteria likely to be used frequently Order number Order status Ship Date Customer information Salesperson name

A-8 Oracle Applications Framework - Order Entry Workshop

Tables and Predefined Data: Salespeople .

Tables and Predefined Data: Salespeople


The following scripts create your tables, indexes, views, and data. DECLARE ln_found NUMBER(1); BEGIN SELECT 1 INTO ln_found FROM user_tables WHERE table_name = 'DEM_SALES_REPS'; EXCEPTION WHEN NO_DATA_FOUND THEN EXECUTE IMMEDIATE ' CREATE TABLE DEM_SALES_REPS ( ' sales_rep_id NUMBER (15) NOT NULL ' ,last_update_date DATE NOT NULL ' ,last_updated_by NUMBER (15) NOT NULL ' ,creation_date DATE NOT NULL ' ,created_by NUMBER (15) NOT NULL ' ,last_update_login NUMBER (15) NOT NULL ' ,last_name VARCHAR2 (50) NOT NULL ' ,first_name VARCHAR2 (50) NOT NULL ' ,start_date DATE ' ,commission_plan_code VARCHAR2 (1) ' ,attribute_category VARCHAR2 (30)
' ,attribute1 '|| VARCHAR(150)

'|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '||

' ,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;

. Oracle Applications Framework - Order Entry Workshop A-9

Appendix A: Order Entry Workshop


/****************************************************************** * Populate Salespeople * ******************************************************************/ DECLARE ln_cnt NUMBER; BEGIN SELECT COUNT(*) INTO ln_cnt FROM dem_sales_reps; IF (ln_cnt = 0) THEN --1 INSERT INTO dem_sales_reps (SALES_REP_ID, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, LAST_NAME, FIRST_NAME, START_DATE, COMMISSION_PLAN_CODE) VALUES (1001, '23-JUN-95', 1, '23-JUN-95', 1, 1, 'Magee', 'Colin', '14-MAY-90', 'A'); --2 INSERT INTO dem_sales_reps (SALES_REP_ID, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, LAST_NAME, FIRST_NAME, START_DATE, COMMISSION_PLAN_CODE) VALUES (1002, '23-JUN-95', 1, '23-JUN-95', 1, 1, 'Giljum', 'Henry', '18-JAN92', 'A'); --3 INSERT INTO dem_sales_reps (SALES_REP_ID, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, LAST_NAME, FIRST_NAME, START_DATE, COMMISSION_PLAN_CODE) VALUES (1003, '23-JUN-95', 1, '23-JUN-95', 1, 1, 'Sedeghi', 'Yasmin', '18-FEB91', 'A'); --4 INSERT INTO dem_sales_reps (SALES_REP_ID, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, LAST_NAME, FIRST_NAME, START_DATE, COMMISSION_PLAN_CODE) VALUES (1004, '23-JUN-95', 1, '23-JUN-95', 1, 1, 'Nguyen', 'Mai', '22-JAN-92', 'A'); --5 INSERT INTO dem_sales_reps (SALES_REP_ID, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, LAST_NAME, FIRST_NAME, START_DATE, COMMISSION_PLAN_CODE)

A-10 Oracle Applications Framework - Order Entry Workshop

Tables and Predefined Data: Salespeople .


VALUES (1005, '23-JUN-95', 1, '23-JUN-95', 1, 1, 'Jones', 'Robert', '23-JUN95', 'B'); --6 INSERT INTO dem_sales_reps (SALES_REP_ID, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, LAST_NAME, FIRST_NAME, START_DATE, COMMISSION_PLAN_CODE) VALUES (1006, '23-JUN-95', 1, '23-JUN-95', 1, 1, 'Dumas', 'Andre', '09-OCT-91', 'A'); --7 INSERT INTO dem_sales_reps (SALES_REP_ID, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, LAST_NAME, FIRST_NAME, START_DATE, COMMISSION_PLAN_CODE) VALUES (1007, '23-JUN-95', 1, '23-JUN-95', 1, 1, 'Lee', 'Vicki', '10-OCT-92', 'A'); --8 INSERT INTO dem_sales_reps (SALES_REP_ID, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, LAST_NAME, FIRST_NAME, START_DATE, COMMISSION_PLAN_CODE) VALUES (1008, '23-JUN-95', 1, '23-JUN-95', 1, 1, 'Stratton', 'Ruth', '27-JUN93', 'B'); COMMIT; END IF; END;

. Oracle Applications Framework - Order Entry Workshop A-11

Appendix A: Order Entry Workshop

Tables and Predefined Data: Customers


DECLARE ln_found NUMBER(1); BEGIN SELECT 1 INTO ln_found FROM user_tables WHERE table_name = 'DEM_CUSTOMERS'; EXCEPTION WHEN NO_DATA_FOUND THEN EXECUTE IMMEDIATE ' CREATE TABLE DEM_CUSTOMERS ( '|| ' customer_id NUMBER (15) NOT NULL '|| ' ,last_update_date DATE NOT NULL '|| ' ,last_updated_by NUMBER (15) NOT NULL '|| ' ,creation_date DATE NOT NULL '|| ' ,created_by NUMBER (15) NOT NULL '|| ' ,last_update_login NUMBER (15) NOT NULL '|| ' ,name VARCHAR2 (50) NOT NULL '|| ' ,phone VARCHAR2 (25) '|| ' ,address VARCHAR2 (400) '|| ' ,city VARCHAR2 (30) '|| ' ,state_code VARCHAR2 (20) '|| ' ,country VARCHAR2 (30) '|| ' ,postal_code VARCHAR2 (75) '|| ' ,credit_rating VARCHAR2 (9) '|| ' ,sales_rep_id NUMBER (15) '|| ' ,region_id NUMBER (15) '|| ' ,comments VARCHAR2 (255) '|| ' ,attribute_category VARCHAR2 (30) '|| ' ,attribute1 VARCHAR(150) '|| ' ,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 '|| A-12 Oracle Applications Framework - Order Entry Workshop

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;

. Oracle Applications Framework - Order Entry Workshop A-13

Appendix A: Order Entry Workshop


/****************************************************************** * Populate Customers * ******************************************************************/ DECLARE ln_cnt NUMBER; BEGIN SELECT COUNT(*) INTO ln_cnt FROM dem_customers; IF (ln_cnt = 0) THEN --1 INSERT INTO dem_customers (CUSTOMER_ID, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, NAME, PHONE, ADDRESS, CITY, STATE_CODE, POSTAL_CODE, COUNTRY, CREDIT_RATING, SALES_REP_ID, REGION_ID, COMMENTS) VALUES (201, '23-JUN-95', 1, '23-JUN-95', 1, 1, 'Unisports', '55-2066101', '72 Mill Water','Milpitas', 'CA', '95035', 'USA', 'EXCELLENT', 1001, 2, 'Brother of owner!'); --2 INSERT INTO dem_customers (CUSTOMER_ID, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, NAME, PHONE, ADDRESS, CITY, STATE_CODE, POSTAL_CODE, COUNTRY, CREDIT_RATING, SALES_REP_ID, REGION_ID, COMMENTS) VALUES (202, '23-JUN-95', 1, '23-JUN-95', 1, 1, 'Womansport','1-206-104-0103', '3281 King Street','Seattle', 'WA', '98101', 'USA', 'GOOD', 1001, 2, ''); --3 INSERT INTO dem_customers (CUSTOMER_ID, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, NAME, PHONE, ADDRESS, CITY, STATE_CODE, POSTAL_CODE, COUNTRY, CREDIT_RATING, SALES_REP_ID, REGION_ID, COMMENTS) VALUES (203, '23-JUN-95', 1, '23-JUN-95', 1, 1, 'Tornado Sports', '1-913-6619699', '11629 West 113th Street','Overland Park', 'KS', '66210', 'USA', 'GOOD', 1005, 3, 'Windy Accounts Payable Clerk'); --4 INSERT INTO dem_customers (CUSTOMER_ID, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, NAME, PHONE, ADDRESS, CITY, STATE_CODE, POSTAL_CODE, COUNTRY, CREDIT_RATING, SALES_REP_ID, REGION_ID, COMMENTS) VALUES (204, '23-JUN-95', 1, '23-JUN-95', 1, 1, 'Big Johns Sports', '1-415-5556281', '4783 18th Street','San Francisco', 'CA', '94117', 'USA', 'EXCELLENT', 1002, 3, ''); --5 INSERT INTO dem_customers (CUSTOMER_ID, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, NAME, PHONE, ADDRESS, CITY, STATE_CODE, POSTAL_CODE, COUNTRY, CREDIT_RATING, SALES_REP_ID, REGION_ID, COMMENTS)

A-14 Oracle Applications Framework - Order Entry Workshop

Tables and Predefined Data: Customers .


VALUES (205, '23-JUN-95', 1, '23-JUN-95', 1, 1, 'Ski USA', '1-913-555-2637', '10 Ward Parkway','Kansas City', 'MO', '66214', 'USA', 'POOR', 1004, 3, 'Insist upon cash'); COMMIT; END IF; END;

. Oracle Applications Framework - Order Entry Workshop A-15

Appendix A: Order Entry Workshop

Tables and Predefined Data: Products


DECLARE ln_found NUMBER(1); BEGIN SELECT 1 INTO ln_found FROM user_tables WHERE table_name = 'DEM_PRODUCTS'; EXCEPTION WHEN NO_DATA_FOUND THEN EXECUTE IMMEDIATE ' CREATE TABLE DEM_PRODUCTS ( ' product_id NUMBER (15) NOT NULL ' ,last_update_date DATE NOT NULL ' ,last_updated_by NUMBER (15) NOT NULL ' ,creation_date DATE NOT NULL ' ,created_by NUMBER (15) NOT NULL ' ,last_update_login NUMBER (15) NOT NULL ' ,description VARCHAR2(255) NOT NULL ' ,suggested_price NUMBER (25) ' ,unit_of_measure VARCHAR2 (25) ' ,attribute_category VARCHAR2 (30) ' ,attribute1 VARCHAR(150) ' ,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_products_u1 ' ON dem_products(product_id) '; END;

'|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '|| '||

/****************************************************************** * Populate Products *

A-16 Oracle Applications Framework - Order Entry Workshop

Tables and Predefined Data: Products .


******************************************************************/ DECLARE ln_cnt NUMBER; BEGIN SELECT COUNT(*) INTO ln_cnt FROM dem_products; IF (ln_cnt = 0) THEN --1 INSERT INTO dem_products (PRODUCT_ID, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, DESCRIPTION, SUGGESTED_PRICE, UNIT_OF_MEASURE) VALUES (10011, '23-JUN-95', 1, '23-JUN-95', 1, 1, 'Beginner ski boot', 150.00, 'Pair'); --2 INSERT INTO dem_products (PRODUCT_ID, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, DESCRIPTION, SUGGESTED_PRICE, UNIT_OF_MEASURE) VALUES (10012, '23-JUN-95', 1, '23-JUN-95', 1, 1, 'Ace Ski Boot -- Intermediate ski boot', 200.00, 'Pair'); --3 INSERT INTO dem_products (PRODUCT_ID, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, DESCRIPTION, SUGGESTED_PRICE, UNIT_OF_MEASURE) VALUES (10013, '23-JUN-95', 1, '23-JUN-95', 1, 1, 'Pro Ski Boot -- Advanced ski boot', 410.00, 'Pair'); --4 INSERT INTO dem_products (PRODUCT_ID, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, DESCRIPTION, SUGGESTED_PRICE, UNIT_OF_MEASURE) VALUES (10021, '23-JUN-95', 1, '23-JUN-95', 1, 1, 'Bunny Ski Pole -- Beginners ski pole', 16.25, 'Pair'); --5 INSERT INTO dem_products (PRODUCT_ID, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, DESCRIPTION, SUGGESTED_PRICE, UNIT_OF_MEASURE) VALUES (10022, '23-JUN-95', 1, '23-JUN-95', 1, 1, 'Ace Ski Pole -- Intermediate ski pole', 21.95, 'Pair'); --6 INSERT INTO dem_products (PRODUCT_ID, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, DESCRIPTION, SUGGESTED_PRICE, UNIT_OF_MEASURE) VALUES

. Oracle Applications Framework - Order Entry Workshop A-17

Appendix A: Order Entry Workshop


(10023, '23-JUN-95', 1, '23-JUN-95', 1, 1, 'Advanced ski pole', 40.95, 'Pair'); --7 INSERT INTO dem_products (PRODUCT_ID, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, DESCRIPTION, SUGGESTED_PRICE, UNIT_OF_MEASURE) VALUES (10031, '23-JUN-95', 1, '23-JUN-95', 1, 1, 'Ultra Ski Goggles -- UVblocking ski goggles', 30.95, 'Pair'); COMMIT; END IF; END;

A-18 Oracle Applications Framework - Order Entry Workshop

Tables and Predefined Data: Orders .

Tables and Predefined Data: Orders


DECLARE ln_found NUMBER(1); BEGIN SELECT 1 INTO ln_found FROM user_tables WHERE table_name = 'DEM_ORDERS'; EXCEPTION WHEN NO_DATA_FOUND THEN EXECUTE IMMEDIATE ' CREATE TABLE DEM_ORDERS( '|| ' order_id NUMBER (15) NOT NULL '|| ' ,last_update_date DATE NOT NULL '|| ' ,last_updated_by NUMBER (15) NOT NULL '|| ' ,creation_date DATE NOT NULL '|| ' ,created_by NUMBER (15) NOT NULL '|| ' ,last_update_login NUMBER (15) NOT NULL '|| ' ,customer_id NUMBER (15) NOT NULL '|| ' ,sales_rep_id NUMBER (15) '|| ' ,payment_type VARCHAR2 (6) NOT NULL '|| ' ,currency_code VARCHAR2 (15) NOT NULL '|| ' ,order_status VARCHAR2 (1) NOT NULL '|| ' ,date_ordered DATE '|| ' ,date_shipped DATE '|| ' ,check_number NUMBER (15) '|| ' ,cc_type VARCHAR2 (1) '|| ' ,cc_number VARCHAR2 (30) '|| ' ,cc_expiration VARCHAR2 (5) '|| ' ,cc_approval_code VARCHAR2 (15) '|| ' ,order_note VARCHAR2 (2000) '|| ' ,attribute_category VARCHAR2 (30) '|| ' ,attribute1 VARCHAR(150) '|| ' ,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 '|| . Oracle Applications Framework - Order Entry Workshop A-19

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;

A-20 Oracle Applications Framework - Order Entry Workshop

Tables and Predefined Data: Orders .


/****************************************************************** * Populate Orders * ******************************************************************/ DECLARE ln_cnt NUMBER; BEGIN SELECT COUNT(*) INTO ln_cnt FROM dem_orders; IF (ln_cnt = 0) THEN --1 INSERT INTO dem_orders (ORDER_ID, LAST_UPDATE_DATE, LAST_UPDATED_BY,CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, CUSTOMER_ID, SALES_REP_ID, PAYMENT_TYPE, CURRENCY_CODE, ORDER_STATUS, DATE_ORDERED, DATE_SHIPPED, CHECK_NUMBER, CC_TYPE, CC_NUMBER, CC_EXPIRATION, CC_APPROVAL_CODE) VALUES (1, '17-SEP-95', -1, '23-AUG-95', 1236, 0, 201, 1001,'CASH', 'USD', 'F', '23-AUG-95', '', '', '', '', '', ''); --2 INSERT INTO dem_orders (ORDER_ID, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, CUSTOMER_ID, SALES_REP_ID, PAYMENT_TYPE, CURRENCY_CODE, ORDER_STATUS, DATE_ORDERED, DATE_SHIPPED, CHECK_NUMBER, CC_TYPE, CC_NUMBER, CC_EXPIRATION, CC_APPROVAL_CODE) VALUES (2, '17-SEP-95', -1, '23-AUG-95', 1236, 0, 202, 1001, 'CHECK', 'ZZZ', 'N', '23-AUG-95', '', '1201', '', '', '', ''); --3 INSERT INTO dem_orders (ORDER_ID, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, CUSTOMER_ID, SALES_REP_ID, PAYMENT_TYPE, CURRENCY_CODE, ORDER_STATUS, DATE_ORDERED, DATE_SHIPPED, CHECK_NUMBER, CC_TYPE, CC_NUMBER, CC_EXPIRATION, CC_APPROVAL_CODE) VALUES (3, '29-AUG-95', -1, '29-AUG-95', -1, 0, 202, 1005, 'CHARGE', 'USD', 'F', '02-JUL-95', '03-JUL-95', '', 'V', '1234 5678 9012', '05/97', '01'); --4 INSERT INTO dem_orders (ORDER_ID, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, CUSTOMER_ID, SALES_REP_ID, PAYMENT_TYPE, CURRENCY_CODE, ORDER_STATUS, DATE_ORDERED, DATE_SHIPPED, CHECK_NUMBER, CC_TYPE, CC_NUMBER, CC_EXPIRATION, CC_APPROVAL_CODE) VALUES (5, '29-AUG-95', -1, '29-AUG-95', -1, 0, 201, 1006, 'CASH', 'USD', 'N', '29-AUG-95', '', '', '', '', '', ''); --5 INSERT INTO dem_orders

. Oracle Applications Framework - Order Entry Workshop A-21

Appendix A: Order Entry Workshop


(ORDER_ID, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, CUSTOMER_ID, SALES_REP_ID, PAYMENT_TYPE, CURRENCY_CODE, ORDER_STATUS, DATE_ORDERED, DATE_SHIPPED, CHECK_NUMBER, CC_TYPE, CC_NUMBER, CC_EXPIRATION, CC_APPROVAL_CODE) VALUES (6, '31-AUG-95', -1, '31-AUG-95', -1, 0, 201, 1004,'CHARGE', 'USD', 'N', '31-AUG-95', '', '', 'E', '1234 5678 9012', '09 97', ''); --6 INSERT INTO dem_orders (ORDER_ID, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, CUSTOMER_ID, SALES_REP_ID, PAYMENT_TYPE, CURRENCY_CODE, ORDER_STATUS, DATE_ORDERED, DATE_SHIPPED, CHECK_NUMBER, CC_TYPE, CC_NUMBER, CC_EXPIRATION, CC_APPROVAL_CODE) VALUES (7, '31-AUG-95', -1, '31-AUG-95', -1, 0, 204, 1005, 'CASH', 'USD', 'N', '31-AUG-95', '', '', '', '', '', ''); --7 INSERT INTO dem_orders (ORDER_ID, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, CUSTOMER_ID, SALES_REP_ID, PAYMENT_TYPE, CURRENCY_CODE, ORDER_STATUS, DATE_ORDERED, DATE_SHIPPED, CHECK_NUMBER, CC_TYPE, CC_NUMBER, CC_EXPIRATION, CC_APPROVAL_CODE) VALUES (8, '31-AUG-95', -1, '31-AUG-95', -1, 0, 202, 1008, 'CASH', 'USD', 'N', '31-AUG-95', '', '', '', '', '', ''); --8 INSERT INTO dem_orders (ORDER_ID, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, CUSTOMER_ID, SALES_REP_ID, PAYMENT_TYPE, CURRENCY_CODE, ORDER_STATUS, DATE_ORDERED, DATE_SHIPPED, CHECK_NUMBER, CC_TYPE, CC_NUMBER, CC_EXPIRATION, CC_APPROVAL_CODE) VALUES (13, '17-SEP-95', -1, '17-SEP-95', -1, 0, 203, 1005,'CHECK', 'USD', 'F', '11-SEP-95', '17-SEP-95', '751', '', '', '', ''); --9 INSERT INTO dem_orders (ORDER_ID, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, CUSTOMER_ID, SALES_REP_ID, PAYMENT_TYPE, CURRENCY_CODE, ORDER_STATUS, DATE_ORDERED, DATE_SHIPPED, CHECK_NUMBER, CC_TYPE, CC_NUMBER, CC_EXPIRATION, CC_APPROVAL_CODE) VALUES (14, '17-SEP-95', -1, '17-SEP-95', -1, 0, 205, 1008, 'CHARGE', 'USD', 'N', '12-AUG-95', '21-AUG-95', '', 'V', '3456 7654 2345 9087', '07/97', '101'); COMMIT; END IF; END;

A-22 Oracle Applications Framework - Order Entry Workshop

Tables and Predefined Data: Order Lines .

Tables and Predefined Data: Order Lines


DECLARE ln_found NUMBER(1); BEGIN SELECT 1 INTO ln_found FROM user_tables WHERE table_name = 'DEM_ORDER_LINES'; EXCEPTION WHEN NO_DATA_FOUND THEN EXECUTE IMMEDIATE ' CREATE TABLE DEM_ORDER_LINES( '|| ' order_id NUMBER (15) NOT NULL '|| ' ,order_line_num NUMBER (15) NOT NULL '|| ' ,last_update_date DATE NOT NULL '|| ' ,last_updated_by NUMBER (15) NOT NULL '|| ' ,creation_date DATE NOT NULL '|| ' ,created_by NUMBER (15) NOT NULL '|| ' ,last_update_login NUMBER (15) NOT NULL '|| ' ,product_id NUMBER (15) NOT NULL '|| ' ,gl_account_cc_id NUMBER (38) '|| ' ,ordered_quantity NUMBER (15) '|| ' ,attribute_category VARCHAR2 (30) '|| ' ,attribute1 VARCHAR(150) '|| ' ,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_order_lines_u1 '|| ' ON dem_order_lines(order_id,order_line_num) '; END;

. Oracle Applications Framework - Order Entry Workshop A-23

Appendix A: Order Entry Workshop


/****************************************************************** * Populate Order-Lines * ******************************************************************/ DECLARE ln_cnt NUMBER; BEGIN SELECT COUNT(*) INTO ln_cnt FROM dem_order_lines; IF (ln_cnt = 0) THEN --1 INSERT INTO dem_order_lines (ORDER_ID, ORDER_LINE_NUM, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, PRODUCT_ID, ORDERED_QUANTITY) VALUES (1, 1, '29-AUG-95', -1, '23-AUG-95', 1236, 0, 10011, 1); --2 INSERT INTO dem_order_lines (ORDER_ID, ORDER_LINE_NUM, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, PRODUCT_ID, ORDERED_QUANTITY) VALUES (2, 1, '30-AUG-95', -1, '23-AUG-95', 1236, 0, 10021, 3); --3 INSERT INTO dem_order_lines (ORDER_ID, ORDER_LINE_NUM, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, PRODUCT_ID, ORDERED_QUANTITY) VALUES (2, 2, '29-AUG-95', -1, '23-AUG-95', 1236, 0, 10031, 2); --4 INSERT INTO dem_order_lines (ORDER_ID, ORDER_LINE_NUM, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, PRODUCT_ID, ORDERED_QUANTITY) VALUES (3, 1, '29-AUG-95', -1, '29-AUG-95', -1, 0, 10022, 2); --5 INSERT INTO dem_order_lines (ORDER_ID, ORDER_LINE_NUM, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, PRODUCT_ID, ORDERED_QUANTITY) VALUES (3, 2, '29-AUG-95', -1, '29-AUG-95', -1, 0, 10013, 4); --6 INSERT INTO dem_order_lines

A-24 Oracle Applications Framework - Order Entry Workshop

Tables and Predefined Data: Order Lines .


(ORDER_ID, ORDER_LINE_NUM, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, PRODUCT_ID, ORDERED_QUANTITY) VALUES (3, 3, '29-AUG-95', -1, '29-AUG-95', -1, 0, 10012, 7); --7 INSERT INTO dem_order_lines (ORDER_ID, ORDER_LINE_NUM, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, PRODUCT_ID, ORDERED_QUANTITY) VALUES (5, 1, '29-AUG-95', -1, '29-AUG-95', -1, 0, 10012, 2); --8 INSERT INTO dem_order_lines (ORDER_ID, ORDER_LINE_NUM, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, PRODUCT_ID, ORDERED_QUANTITY) VALUES (6, 1, '31-AUG-95', -1, '31-AUG-95', -1, 0, 10013, 3); --9 INSERT INTO dem_order_lines (ORDER_ID, ORDER_LINE_NUM, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, PRODUCT_ID, ORDERED_QUANTITY) VALUES (6, 2, '31-AUG-95', -1, '31-AUG-95', -1, 0, 10011, 5); --10 INSERT INTO dem_order_lines (ORDER_ID, ORDER_LINE_NUM, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, PRODUCT_ID, ORDERED_QUANTITY) VALUES (6, 3, '31-AUG-95', -1, '31-AUG-95', -1, 0, 10031, 1); --11 INSERT INTO dem_order_lines (ORDER_ID, ORDER_LINE_NUM, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, PRODUCT_ID, ORDERED_QUANTITY) VALUES (7, 1, '31-AUG-95', -1, '31-AUG-95', -1, 0, 10013, 1); --12 INSERT INTO dem_order_lines (ORDER_ID, ORDER_LINE_NUM, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, PRODUCT_ID, ORDERED_QUANTITY) VALUES (8, 1, '31-AUG-95', -1, '31-AUG-95', -1, 0, 10013, 2); --13 INSERT INTO dem_order_lines

. Oracle Applications Framework - Order Entry Workshop A-25

Appendix A: Order Entry Workshop


(ORDER_ID, ORDER_LINE_NUM, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, PRODUCT_ID, ORDERED_QUANTITY) VALUES (13, 1, '17-SEP-95', -1, '17-SEP-95', -1, 0, 10031, 1); --14 INSERT INTO dem_order_lines (ORDER_ID, ORDER_LINE_NUM, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, PRODUCT_ID, ORDERED_QUANTITY) VALUES (13, 2, '17-SEP-95', -1, '17-SEP-95', -1, 0, 10013, 3); --15 INSERT INTO dem_order_lines (ORDER_ID, ORDER_LINE_NUM, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, PRODUCT_ID, ORDERED_QUANTITY) VALUES (14, 1, '17-SEP-95', -1, '17-SEP-95', -1, 0, 10012, 10); --16 INSERT INTO dem_order_lines (ORDER_ID, ORDER_LINE_NUM, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, PRODUCT_ID, ORDERED_QUANTITY) VALUES (14, 2, '17-SEP-95', -1, '17-SEP-95', -1, 0, 10023, 10); COMMIT; END IF; END;

A-26 Oracle Applications Framework - Order Entry Workshop

Register Flexfield Tables .

Register Flexfield Tables


You may have to do this at a later stage if a Descriptive Flexfield has to be registered to your custom Application (which you will register in the next step).
REM+=============================================================+ REM This script only registers the DEM_ORDERS and DEM_ORDER_LINES REM tables, as they are the only tables with flexfield columns REM that are actually used in the class (even though the other REM tables have flexfield columns) REM+=============================================================+ REM ************************************************************** REM Delete registration of columns in Orders table REM ************************************************************** EXECUTE EXECUTE EXECUTE EXECUTE EXECUTE EXECUTE EXECUTE EXECUTE EXECUTE EXECUTE EXECUTE EXECUTE EXECUTE EXECUTE EXECUTE EXECUTE EXECUTE EXECUTE EXECUTE EXECUTE EXECUTE EXECUTE EXECUTE EXECUTE ad_dd.delete_column('DEMXX', ad_dd.delete_column('DEMXX', ad_dd.delete_column('DEMXX', ad_dd.delete_column('DEMXX', ad_dd.delete_column('DEMXX', ad_dd.delete_column('DEMXX', ad_dd.delete_column('DEMXX', ad_dd.delete_column('DEMXX', ad_dd.delete_column('DEMXX', ad_dd.delete_column('DEMXX', ad_dd.delete_column('DEMXX', ad_dd.delete_column('DEMXX', ad_dd.delete_column('DEMXX', ad_dd.delete_column('DEMXX', ad_dd.delete_column('DEMXX', ad_dd.delete_column('DEMXX', ad_dd.delete_column('DEMXX', ad_dd.delete_column('DEMXX', ad_dd.delete_column('DEMXX', ad_dd.delete_column('DEMXX', ad_dd.delete_column('DEMXX', ad_dd.delete_column('DEMXX', ad_dd.delete_column('DEMXX', ad_dd.delete_column('DEMXX', 'DEM_ORDERS', 'DEM_ORDERS', 'DEM_ORDERS', 'DEM_ORDERS', 'DEM_ORDERS', 'DEM_ORDERS', 'DEM_ORDERS', 'DEM_ORDERS', 'DEM_ORDERS', 'DEM_ORDERS', 'DEM_ORDERS', 'DEM_ORDERS', 'DEM_ORDERS', 'DEM_ORDERS', 'DEM_ORDERS', 'DEM_ORDERS', 'DEM_ORDERS', 'DEM_ORDERS', 'DEM_ORDERS', 'DEM_ORDERS', 'DEM_ORDERS', 'DEM_ORDERS', 'DEM_ORDERS', 'DEM_ORDERS', 'ORDER_ID'); 'LAST_UPDATE_DATE'); 'LAST_UPDATED_BY'); 'CREATION_DATE'); 'CREATED_BY'); 'LAST_UPDATE_LOGIN'); 'CUSTOMER_ID'); 'SALES_REP_ID'); 'PAYMENT_TYPE'); 'CURRENCY_CODE'); 'ORDER_STATUS'); 'DATE_ORDERED'); 'DATE_SHIPPED'); 'CHECK_NUMBER'); 'CC_TYPE'); 'CC_NUMBER'); 'CC_EXPIRATION'); 'CC_APPROVAL_CODE'); 'ORDER_NOTE'); 'ATTRIBUTE_CATEGORY'); 'ATTRIBUTE1'); 'ATTRIBUTE2'); 'ATTRIBUTE9'); 'ATTRIBUTE10');

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',

. Oracle Applications Framework - Order Entry Workshop A-27

Appendix A: Order Entry Workshop


EXECUTE ad_dd.register_column('DEMXX', 'DATE', 9, 'N', 'N'); EXECUTE ad_dd.register_column('DEMXX', 'NUMBER', 15, 'N', 'N'); EXECUTE ad_dd.register_column('DEMXX', 'DATE', 9, 'N', 'N'); EXECUTE ad_dd.register_column('DEMXX', 'NUMBER', 15, 'N', 'N'); EXECUTE ad_dd.register_column('DEMXX', 'NUMBER', 15, 'N', 'N'); EXECUTE ad_dd.register_column('DEMXX', 'NUMBER', 15, 'N', 'N'); EXECUTE ad_dd.register_column('DEMXX', 'NUMBER', 15, 'Y', 'N'); EXECUTE ad_dd.register_column('DEMXX', 'VARCHAR2', 6, 'N', 'N'); EXECUTE ad_dd.register_column('DEMXX', 'VARCHAR2', 15, 'N', 'N'); EXECUTE ad_dd.register_column('DEMXX', 'VARCHAR2', 1, 'N', 'N'); EXECUTE ad_dd.register_column('DEMXX', 'DATE', 9, 'Y', 'N'); EXECUTE ad_dd.register_column('DEMXX', 'DATE', 9, 'Y', 'N'); EXECUTE ad_dd.register_column('DEMXX', 'NUMBER', 15, 'Y', 'N'); EXECUTE ad_dd.register_column('DEMXX', 1, 'Y', 'N'); EXECUTE ad_dd.register_column('DEMXX', 'VARCHAR2', 30, 'Y', 'N'); EXECUTE ad_dd.register_column('DEMXX', 'VARCHAR2', 5, 'Y', 'N'); EXECUTE ad_dd.register_column('DEMXX', 'VARCHAR2', 15, 'Y', 'N'); EXECUTE ad_dd.register_column('DEMXX', 'VARCHAR2', 2000, 'Y', 'N'); EXECUTE ad_dd.register_column('DEMXX', 'VARCHAR2', 30, 'Y', 'N'); EXECUTE ad_dd.register_column('DEMXX', 'VARCHAR2', 150, 'Y', 'N'); EXECUTE ad_dd.register_column('DEMXX', 'VARCHAR2', 150, 'Y', 'N'); ... EXECUTE ad_dd.register_column('DEMXX', 'VARCHAR2', 150, 'Y', 'N'); EXECUTE ad_dd.register_column('DEMXX', 'VARCHAR2', 150, 'Y', 'N'); COMMIT; 'DEM_ORDERS', 'LAST_UPDATE_DATE', 2, 'DEM_ORDERS', 'LAST_UPDATED_BY', 3, 'DEM_ORDERS', 'CREATION_DATE', 4, 'DEM_ORDERS', 'CREATED_BY', 5, 'DEM_ORDERS', 'LAST_UPDATE_LOGIN', 6, 'DEM_ORDERS', 'CUSTOMER_ID',7, 'DEM_ORDERS', 'SALES_REP_ID',8, 'DEM_ORDERS', 'PAYMENT_TYPE',9, 'DEM_ORDERS', 'CURRENCY_CODE', 10, 'DEM_ORDERS', 'ORDER_STATUS',11, 'DEM_ORDERS', 'DATE_ORDERED',12, 'DEM_ORDERS', 'DATE_SHIPPED',13, 'DEM_ORDERS', 'CHECK_NUMBER',14, 'DEM_ORDERS', 'CC_TYPE',15, 'VARCHAR2', 'DEM_ORDERS', 'CC_NUMBER',16, 'DEM_ORDERS', 'CC_EXPIRATION', 17, 'DEM_ORDERS', 'CC_APPROVAL_CODE', 18, 'DEM_ORDERS', 'ORDER_NOTE', 19, 'DEM_ORDERS', 'ATTRIBUTE_CATEGORY', 20, 'DEM_ORDERS', 'ATTRIBUTE1',21, 'DEM_ORDERS', 'ATTRIBUTE2',22,

'DEM_ORDERS', 'ATTRIBUTE9',29, 'DEM_ORDERS', 'ATTRIBUTE10',30,

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');

A-28 Oracle Applications Framework - Order Entry Workshop

Register Flexfield Tables .


EXECUTE EXECUTE EXECUTE EXECUTE EXECUTE EXECUTE EXECUTE EXECUTE EXECUTE EXECUTE EXECUTE ad_dd.delete_column('DEMXX', ad_dd.delete_column('DEMXX', ad_dd.delete_column('DEMXX', ad_dd.delete_column('DEMXX', ad_dd.delete_column('DEMXX', ad_dd.delete_column('DEMXX', ad_dd.delete_column('DEMXX', 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', 'DEM_ORDER_LINES', 'DEM_ORDER_LINES', 'DEM_ORDER_LINES', 'DEM_ORDER_LINES', 'DEM_ORDER_LINES', 'DEM_ORDER_LINES', 'DEM_ORDER_LINES', 'CREATION_DATE'); 'CREATED_BY'); 'LAST_UPDATE_LOGIN'); 'PRODUCT_ID'); 'GL_ACCOUNT_CC_ID'); 'ORDERED_QUANTITY'); 'ATTRIBUTE_CATEGORY'); 'ATTRIBUTE1'); 'ATTRIBUTE2'); 'ATTRIBUTE9'); 'ATTRIBUTE10');

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;

. Oracle Applications Framework - Order Entry Workshop A-29

Appendix A: Order Entry Workshop

Oracle Applications Setup Register a New Applications User


You may have to first get the Oracle Applications Instance details from your instructor and login as a user with System Administrator responsibility. Select the System Administrator Responsibility Now choose Security : User > Define User Name: DEMxx (xx Unique Identifier such as your Employee ID) Password: welcome (you may have to enter the same password again) Description: Demo Order Entry OAF User In the Direct Responsibilities tab, select System Administrator, Application Developer and Framework Toolbox Tutorial responsibilities. Save and exit. Logout from Oracle Applications Login as DEMxx user and reset your password when prompted

Register a Custom Application


Register your custom application by selecting Application > Register in the Application Developer responsibility. Key in your o Application Name: Order Entry Demo xx (xx- could be a unique identifier such as Employee ID) o Short name: DEMxx o Base path: DEM_TOP (or CUST_TOP as provided by instructor)

A-30 Oracle Applications Framework - Order Entry Workshop

Oracle Applications Setup .

Register Messages in the Message Dictionary


We use the Message Dictionary to display errors, warnings and confirmations. Therefore we have to create our messages in the Message Dictionary before we start with the workshop. Logon to Oracle Apps as sysadmin and add the Application Developer responsibility to your username. Now logon with your username and password and navigate to Application Developer responsibility. Select Application > Messages You can register all your messages here with your Custom Application name MESSAGE NAME ORDLINES_CCAPPCODE_ENTER ORDLINES_CCTYPE_INVALID ORDLINES_DATE_PAST ORDLINES_HDR_TEXT ORDLINES_INVALID_LINE_NUMBER ORDLINES_LINESHDR_TITLE ORDLINES_LINES_CREATE_CONFIRM ORDLINES_LINES_UPDATE_CONFIRM ORDLINES_OBJECT_NOT_FOUND ORDLINES_ORDER_DELETE_WARN ORDLINES_ORDER_ID_UNIQUE ORDLINES_ORDER_NO ORDLINES_ORDER_SHIP_BAD ORDLINES_ORDER_YES ORDLINES_ORDSTATUS_INVALID ORDLINES_ORD_CREATE_CONFIRM ORDLINES_ORD_DELETE_CONFIRM ORDLINES_ORD_ID_NO_UPDATE ORDLINES_ORD_UPDATE_CONFIRM ORDLINES_PAGE_GENERAL ORDLINES_QUANTITY_ORDERED ORDLINES_STATUS_REQUIRED ORDLINES_CHECK_NO_BAD MESSAGE TEXT Please enter your Approval Code for Visa. Please choose a valid Credit Card TYPE from the drop-down. Invalid. DATE from past chosen. Please choose a valid date. Order Details for &CUST_NAME Invalid Order Number Order Lines &CUST_NAME, &ORD_NUM Order Lines created successfully for Order &ORD_NUMBER. Order Lines updated successfully for Order &ORD_NUMBER. Object (&OBJECT_NAME) not found Are you sure you want to delete order &ORD_NUM Order ID must be Unique No Please choose a Ship Date greater than the Order Date. Yes Please enter a valid Order State Order &ORD_NUMBER created successfully. Order &ORD_NUM deleted successfully. Cannot Update Order ID Order &ORD_NUMBER updated successfully. This is the instruction text for the Page. We may include our Page Help details if any here. Please enter a value greater than zero for Quantity Ordered. Order Status is required. Please enter a valid Cheque Number if your

. Oracle Applications Framework - Order Entry Workshop A-31

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

Register Descriptive Flexfields


We use descriptive flexfields (DFF) to display to capture additional information. o In your Application Developer responsibility, select Flexfield : Descriptive> Register. o Query for your Table Name (DEM_ORDERS). o If a DFF already registered in this table name, make note of the Name. (We would need the DFF name and the application name to which it is registered) o If a DFF is not registered for this table, you can register your DFFs here with your Custom Application. (You should first register your flexfield tables DEM_ORDERS and DEM_ORDER_LINES with your application as mentioned in the earlier section). o Application: Order Entry Demo xx A-32 Oracle Applications Framework - Order Entry Workshop

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

. Oracle Applications Framework - Order Entry Workshop A-33

B
...

Practices

Appendix B: Practices

B-2 Oracle Applications Framework - Practices

Lab 1: Building and Running Hello, World! .

Lab 1: Building and Running Hello, World!


1. Set Up Your Development Environment a. Configure JDEV_USER_HOME Environment Variable on Your PC 2. Create a New OA Workspace and Empty OA Project with the New... Dialog 3. Set Run Options in OA Project Settings 4. Create the OA Components Page File 5. Modify the Page Layout (Top-level) Region 6. Create the Second Region (Main Content Region) 7. Create the First Item (Empty Field) 8. Create a Container Region for the Go Button 9. Create the Second Item (Go Button) 10. Save Your Work 11. Run Your Page Using the Run Option 12. Add a Controller 13. Edit Your Controller 14. Build Your Controller 15. Test Your Work Using the Run Option

. Oracle Applications Framework - Practices B-3

Appendix B: Practices

Hello World Page End Product

B-4 Oracle Applications Framework - Practices

Lab 2: Orders: Search .

Lab 2: Orders: Search 1: Create Your Project


1. Create an Oracle Applications (OA) Project 2. Enable Developer Diagnostics 3. Organize Your Project Into Categories

2: Create Your Page's Model Components


1. Create the BC4J Package for Client (UI) Objects 2. Create the BC4J Package for Server (Business Logic) Objects 3. Create Your Root UI Application Module (AM) 4. Enable Passivation for the Root UI Application Module 5. Save Your Work 6. Create an Orders Entity Object (EO) 7. Create an OrderSearchVO View Object (VO) 8. Add Your View Object to the Root UI Application Module

3: Create Your Initial Page


1. Create the OrderSearchPG Page 2. Modify the pageLayout Region 3. Add a Product Branding Image 4. Create the Page Instruction Text 5. Test Your Work

4: Configure a Results-Based Search


1. Add a Query Bean to Your Page 2. Add a Results Data Table to Your QueryRN 3. Set or Verify Your ResultsTable Region Properties 4. Set or Verify OrderId Item Properties 5. Set or Verify OrderStatus Item Properties . Oracle Applications Framework - Practices B-5

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

5: Convert Your Search Region to Use Auto Customization Criteria


1. Change the Query Bean to Use autoCustomizationCriteria 2. Add a Simple Search Region 3. Create an OrderId Search Item 4. Create an Order Status Search Item 5. Create a DateShipped Search Item 6. Create an CustomerId Search Item 7. Create an CustomerName Search Item 8. Create an SalesRepName Search Item 9. Create Search Mappings Between Search Items and ResultsTable 10. Test Your Work

6: Adding a List of Values (LOV) to a Field


1. Create the BC4J Package for Your LOV-Related Model Objects 2. Create a Common LOV Application Module a. Create the Customer LOV View Object b. Add the CustomerLovVO to the OrderEntryLovAM c. Create the SalesRep LOV View Object d. Add the SalesRepLovVO to the OrderEntryLovAM 3. Create the Shared CustomerLovRN LOV Region Add a Table to the LOV Region 4. Create the Shared SalesRepLovRN LOV Region Add a Table to the LOV Region B-6 Oracle Applications Framework - Practices

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

Orders: Search End Product

. Oracle Applications Framework - Practices B-7

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

2: Create the Details Page UI


1. Create the OrderDetailsPG Page 2. Modify the pageLayout Region 3. Add a Product Branding Image 4. Create the Main Content Region 5. Finish Setting MainRN Item Properties 6. Change the Main Region's Style 7. Add a messageLayout 8. Add a "Return to Orders: Search Page" Link 9. Save Your Work

3: Implement the View Object Query


1. Add an initQuery( ) Method to Your OrderDetailsVOImpl Class 2. Add an initDetails( ) Method to Your OrderEntryAMImpl Class 3. Save and Compile Your Work

4: Implement the Drilldown to the OrderDetailsPG


1. Configure the OrderId Item as a Link 2. Create a Controller for the Details Page 3. Add Controller Logic to Initalize Order Query When Page Renders 4. Programmatically Set the Page Title Text 5. Save and Test Your Work

B-8 Oracle Applications Framework - Practices

Lab 3: Orders: Drilldown to Details .

Fig 1: Order Number in Order Search Page configured for drilldown

Fig 2: Drilldown : Order Details Page End Product

. Oracle Applications Framework - Practices B-9

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

2: Create a View Object for the Order Status Poplist


1. Create a Poplist View Object BC4J Package 2. Create the OrderStatusVO in the Poplist BC4J Package 3. Add the OrderStatusVO to the OrderEntryAM 4. Create the CcTypeVO in the Poplist BC4J Package 5. Add the CcTypeVO to the OrderEntryAM 6. Compile and Save Your Work

3: Build the Create Page


1. Create the OrderCreatePG Page 2. Modify the pageLayout Region 3. Add a Product Branding Image 4. Add Page-Level Apply and Cancel Buttons 5. Create the Main Content Region 6. Finish Setting MainRN Item Properties 7. Focus on Layout a. Convert the MainRN Style from defaultSingleColumn to MessageComponentLayout b. Create a new messageComponentLayout Region for PaymentTypeRN c. Create a new messageComponentLayout Region for FooterRN d. Adjusting the Layout for MainRN e. Adjusting the Layout for PaymentTypeRN f. Adjusting the Layout for FooterRN B-10 Oracle Applications Framework - Practices

Lab 4: Orders: Create . 8. Add an "Indicates Required Field" Region

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

5: Implement Order Business Logic


(Part 1: Declarative Validation and Initialization) 1. Lay down your Business Needs 2. Add Import Statements 3. Override the setOrderId( ) Method 4. Override the create( ) Method 5. Save and Test Your Work

6: Implement Order Business Logic


(Part 2: Entity Expert, VAM and VVO Validation) 1. Create an Order Validation Application Module 2. Register the Order Validation Application Module with OrderEO Entity Object 3. Create a OrderStatus Validation View Object 4. Add OrderStatusVVO to OrderVAM Validation Application Module 5. Add an initQuery( ) Method to OrderStatusVVO Validation View Object 6. Create an Entity Expert Class 7. Associate the Entity Expert with the OrderEO Entity Object 8. Add a Convenience Method for Expert Access in OrderEOImpl Class 9. Add the isOrderStatusValid( ) Method to the Entity Expert

10. Add Validation Logic to setOrderStatus( ) Method in OrderEOImpl Class . Oracle Applications Framework - Practices B-11

Appendix B: Practices 11. Compile and Test Your Work

7: Implement Order Business Logic


(Part 3: Miscellaneous Attributes) 1. Add Logic to setDateShipped() Method; 2. Add a validateDateShipped () Method 3. Save and Test Your Work

8: Implement Order Business Logic


(Part 4: Entity-Level Validation) 1. Add Logic to validateEntity() 2. Compile and Save Your Work

9: Implement the Apply and Cancel Button Handling


1. Create an apply( ) Method in Your OrderEntryAMImpl Class 2. Add processFormRequest( ) Logic to Your OrderCreateCO Class 3. Test Your Work

Fig 1: Orders Search Page: Create button included

B-12 Oracle Applications Framework - Practices

Lab 4: Orders: Create .

Fig 2: Orders Create Page End Product

. Oracle Applications Framework - Practices B-13

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

2: Configure the PPR Items to Fire a PPR Action When Changed


1. Set the PPR Properties for Cash RadioButton 2. Set the PPR Properties for Cheque RadioButton 3. Set the PPR Properties for Credit Card RadioButton 4. Set the PPR Properties for Credit Card Type Dropdown

3: Configure the PPR Field Items to React to PPR Events


1. SPEL Bind the needed PPR Field Items

4: Implement PPR Event Handling


1. Add PPR Handling Methods (Enable/Disable) to the OrderEntryAMImpl 2. Add an init( ) Method to the OrderEntryAM 3. Call the init( ) Method from processRequest( ) 4. Handle PPR Event 5. Test Your Work

B-14 Oracle Applications Framework - Practices

Lab 5: Orders: Partial Page Rendering (PPR) .

Figure 1: Create Page Finished Product initially renders as follows

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

Lab 6: Orders: Delete 1: Implement a Delete in Your OrderEOImpl Class


1. Add the remove method( )

2: Implement a Delete Switcher


1. Add an Attribute to the OrderSearchVO View Object 2. Create the Switcher Region 3. Configure the Default Switcher Case 4. Create a New Switcher Case 5. Format the Delete Column 6. Test Your Work

3: Implement the Delete Action


1. Add a deleteOrder( ) Method to the OrderEntryAM 2. Add Delete Selection Handler Code to OrderSearchCO 3. Add Delete Confirmation Handler Code to OrderSearchCO 4. Test Your Work

Figure 1: Order Search page: Delete column Included B-16 Oracle Applications Framework - Practices

Lab 6: Orders: Delete .

Figure 2: Orders Search Page The ResultsTable Region When Queried

Figure 3: Delete Warning Dialog

Figure 4: Delete Confirmation Message

. Oracle Applications Framework - Practices B-17

Appendix B: Practices

Lab 7: Orders: Update 1: Make a Copy of Your OrderCreatePG


1. Copy OrderCreatePG on the File System 2. Copy and Change the Create Page Controller 3. Compile and Save Your Work

2: Add an Update Column to the Search Page


1. Add the "Update" Column to the Results Table 2. Modify the OrderSearchCO Controller 3. Modify the OrderUpdateCO Controller 4. Rebuild and Test Your Work

Fig 1: Order Search Page: Update column included

B-18 Oracle Applications Framework - Practices

Lab 8: Lines: Search .

Lab 8: Lines: Search 1: Create Your Page's Model Components


1. Create a Lines Entity Object (EO) 2. Create an Order to Lines Association Object 3. Create a LinesSearchVO View Object (VO) 4. Add the LinesSearchVO View Object to the OrderEntryAM

2: Create Your Initial Page


1. Create the LinesSearchPG Page 2. Modify the pageLayout Region 3. Add a Product Branding Image 4. Create the Page Instruction Text 5. Test Your Work

3: Configure a Results-Based Search


1. 2. 3. 4. 5. 6. 7. 8. 9. Add a Query Bean to Your Page Add a Results Data Table to Your QueryRN Set or Verify Your ResultsTable Region Properties Set or Verify OrderId Item Properties Set or Verify OrderLineNum Item Properties Set or Verify ProductId Item Properties Set or Verify Description Item Properties Set or Verify GlAccountCcId Item Properties Set or Verify OrderedQuantity Item Properties

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

4: Convert Your Search Region to Use Auto Customization Criteria


Before you proceed with Task 4, arrange your items 1. Change the Query Bean to Use autoCustomizationCriteria 2. Add a Simple Search Region 3. Create an OrderId Search Item 4. Create an OrderLineNum Search Item 5. Create a ProductId Search Item 6. Create a Description Search Item 7. Create Search Mappings Between Search Items and ResultsTable 8. Test Your Work

5: Adding a List of Values (LOV) to a Field


1. Create the Product LOV View Object 2. Add the ProductLovVO to the OrderEntryLovAM 3. Create the Shared ProductLovRN LOV Region 4. Add a Table to the LOV Region 5. Make the Product Id Search Item an LOV 6. Define LOV Mappings 7. Make the Description Search Item an LOV 8. Define LOV Mappings 9. Test Your Work

6: Revise the Search Page to Include a Goto Order Search Button


1. Add a Goto Order Search Button to Your Search Page 2. Add Goto Order Search Button Press Handler to Your Search Page

B-20 Oracle Applications Framework - Practices

Lab 8: Lines: Search . Revise Details Page to Include Link to Lines Search

7: Implement the View Object Query


1. Add an initQuery() Method to Your LinesSearchVOImpl Class. 2. Add an initLinesDetails( ) Method to Your OrderEntryAMImpl Class. 3. Save and Compile Your Work

8: Implement the Drilldown to the LinesSearchPG


1. Configure the OrderId Item as a Link 2. Mofify the Controller Logic to Initalize Order Query When Page Renders 3. Save and Compile Your Work

Figure 1: Lines Search Page End Product

. Oracle Applications Framework - Practices B-21

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

2: Build the Create Page


1. 2. 3. 4. 5. 6. 7. 8. 9. Create the LinesCreatePG Page Modify the pageLayout Region Add a Product Branding Image Add Page-Level Apply and Cancel Buttons Create the Content Region Set up Your LOVs Add a Add Another Row Button and a Recalculate Toal Price Button Add a Single Selection with a Delete Button Add an "Indicates Required Field" Region

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

Lab 9: Lines: Create .

4: Implement Order Business Logic


(Part 1: Declarative Validation and Initialization) 1. Lay down your Business Needs 2. Add Import Statements 3. Add Create Page Initialization 4. Add Validation Logic to the setOrderedQuantity( ) Method; 5. Add a validateOrderedQuantity( ) Method 6. Save and Test Your Work

5: Implement the Apply, Cancel and Delete Button Handling


1. Add processFormRequest( ) Logic to LinesCreateCO Class 2. Programatically Set the Page Title Text 3. Handle Line Number Uniqueness 4. Handle Delete Button 5. Test Your Work

Fig 1: Lines Create Page: End Product

. Oracle Applications Framework - Practices B-23

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

2: Configure OrderedQuantity to Fire a PPR Event


Set the PPR Properties for Quantity Ordered field

3: Configure Items to React to PPR Events


SPEL Bind the necessary PPR field Items.

4: Implement PPR Event Handling


1. Add PPR Logic to the Handle the PPR Action in OrderEntryAM 2. Modify init( ) Method in the OrderEntryAM 3. Call the init( ) Method from processRequest( ) 4. Handle PPR Event 5. Test Your Work

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

B-24 Oracle Applications Framework - Practices

Lab 11: Lines: Layout .

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

Figure 3 Lines Create: Quantity Tab

. Oracle Applications Framework - Practices B-25

Appendix B: Practices

Figure 4 Accounts Tab

B-26 Oracle Applications Framework - Practices

Lab 12: Lines: Update .

Lab 12: Lines: Update 1: Make a Copy of Your LinesCreatePG


1. Copy LinesCreatePG on the File System 2. Copy and Change the Create Page Controller 3. Compile and Save Your Work

2: Modify Search and Update Page Controllers


1. Modify the LinesSearchCO Controller 2. Modify the LinesUpdateCO Controller 3. Rebuild and Test Your Work

. Oracle Applications Framework - Practices B-27

Appendix B: Practices

Lab 13: Flexfields 1: Implement your Orders DFF


1. Setup your Orders Flexfield in Orders Create and Update Pages Create a DFF Layout and column, and set appropriate properties 2. Compile and Test Your Work

Fig: Orders DFF Field Customer Contact Name included

2: Implement your Lines DFF


1. Setup your Order Lines Flexfield in Lines Create and Update Pages Create a DFF Layout and column, and set appropriate properties 2. Compile and Test Your Work

Fig: Lines DFF Field Additional Preference included

B-28 Oracle Applications Framework - Practices

Lab 14: Deploying the project in Oracle Applications .

Lab 14: Deploying the project in Oracle Applications


1. Transfer your class files in zip format to the server 2. Add the classpath entry in jserv.properties 3. Bounce the Apache server 4. In Oracle Apps, create your Function to call the OA Page. 5. Add the function to a menu and responsibility 6. Add the responsibility to your user. 7. Import the pages, which you want to deploy

. Oracle Applications Framework - Practices B-29

Appendix B: Practices

Lab 15: Testing and Reviewing Your Pages


1. Test your form for about fifteen minutes to make sure that your form is built to specifications and that your form features all work correctly. Test for (at least): Querying master and details works correctly. Inserts work correctly Updates work correctly (update only your own inserted records) Deletes of master and/or details work correctly (update only your own inserted records) LOVs all work and appear correctly Order ID populates on insert Tabbed regions work correctly Opening and closing of windows works correctly Flexfields work correctly Messages, validation logic on date fields work correctly Find window on Orders works correctly Function security works correctly 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 yourfindings with that team when you finish. a ________________________________________________ b ________________________________________________ c ________________________________________________ d ________________________________________________

B-30 Oracle Applications Framework - Practices

C
...

Practices and Solutions

Appendix C: Practices and Solutions

C-2 Oracle Applications Framework - Practices and Solutions

OA Framework: DEMO ORDER ENTRY .

OA Framework: DEMO ORDER ENTRY


Overview The Order Entry Workshop introduces developers to the process of building an OA Framework application using Jdeveloper 9i (9.0.3) and deploying it on the web. Fundamental knowledge of OA Framework concepts like MVC Architecture, BC4J (Business Component for Java), Entity Objects (EO), View Objects (VO), Application Modules (AM), OA Controllers is a pre-requisite to help you enhance your understanding in building an OA Framework application. This workshop consists of an Orders page, which captures information about orders placed by the customer and Order Lines page providing lines details for the corresponding order. It helps you build simple pages, which are capable of querying, creating, updating and deleting records in the database. For additional information, it is recommended that you refer the Oracle Applications Framework Developers Guide11.5.10 and Online Help Topics provided by JDeveloper.

Oracle Applications Framework - Practices and Solutions C-3

Appendix C: Practices and Solutions

Lab 1: Building and Running "Hello, World!"


This tutorial leads you through using Oracle9i JDeveloper OA Extension 9.0.3.8 to create a very simple page. This tutorial has minimal explanation and as few steps as possible (and no BC4J). Hello, World Lab Goals After completing this exercise, you should have learned how to: Create an Oracle Applications (OA) JDeveloper9i workspace and project. Configure a project to enable Developer Mode testing and diagnostics. Use the JDeveloper9i OA Extension to create a very simple page. Create a controller and associate it with a region. Handle a submit button press action (an HTTP POST request). Run a page in regular and debug modes. The resulting page has the global links (such as Preferences, Logout, and Return to Portal), a header, footer, a Personalize Region link, one empty field and one Go button. The page does nothing other than display a message when you enter a value in the field and click the Go button. Your final layout looks like the following:

C-4 Oracle Applications Framework - Practices and Solutions

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

C-6 Oracle Applications Framework - Practices and Solutions

Lab 1: Building and Running "Hello, World!" .

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.

C-8 Oracle Applications Framework - Practices and Solutions

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).

Oracle Applications Framework - Practices and Solutions C-9

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.

C-10 Oracle Applications Framework - Practices and Solutions

Lab 1: Building and Running "Hello, World!" .

Oracle Applications Framework - Practices and Solutions C-11

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.

C-12 Oracle Applications Framework - Practices and Solutions

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:

Oracle Applications Framework - Practices and Solutions C-13

Appendix C: Practices and Solutions

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.

C-16 Oracle Applications Framework - Practices and Solutions

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.

Oracle Applications Framework - Practices and Solutions C-17

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 following properties for your item:


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.

Set the Maximum Length to 50.

C-18 Oracle Applications Framework - Practices and Solutions

Lab 1: Building and Running "Hello, World!" .

You can run your page at this point.

Oracle Applications Framework - Practices and Solutions C-19

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

Lab 1: Building and Running "Hello, World!" .

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.

Oracle Applications Framework - Practices and Solutions C-21

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.

C-22 Oracle Applications Framework - Practices and Solutions

Lab 1: Building and Running "Hello, World!" .

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.

Oracle Applications Framework - Practices and Solutions C-23

Appendix C: Practices and Solutions

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;

C-24 Oracle Applications Framework - Practices and Solutions

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:

Oracle Applications Framework - Practices and Solutions C-25

Appendix C: Practices and Solutions

You have finished your first page with Oracle9i JDeveloper and the OA Framework!

C-26 Oracle Applications Framework - Practices and Solutions

Lab 2: Orders: Search .

Lab 2: Orders: Search


Overview In this exercise, we will be implementing a simple search and results page as shown in Figure 1 below. Eventually, we will add the ability to view, create and delete orders.

Figure 1: Search Page Exercise Finished Product

1: Create Your Project


As a prerequisite, ensure that your database connection is ready. If not, do the following: Expand the Connections node in the JDeveloper System Navigator, Then expand the Database node. Right-click on the Database node Select New Connection to open the Connection Wizard. Follow the JDeveloper instructions to define a new database connection for the Oracle Applications database identified: You have to provide a connection name, username and password, and the host/port details given to you by the instructor. 1.1 Create an Oracle Applications (OA) Project This is the project where we will create all our lab work. Note: All the packages and object or file names (directory paths, classes, methods, pages, regions, and UI components) that you specify in the Order Entry exercises must exactly match those given in the instructions, with the exception that <yourname> should be your full name Oracle Applications Framework - Practices and Solutions C-27

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

Field DBC File Name

User Name Password Application Short Name Responsibility Key

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.

Oracle Applications Framework - Practices and Solutions C-29

Appendix C: Practices and Solutions

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.

C-30 Oracle Applications Framework - Practices and Solutions

Lab 2: Orders: Search .

2: Create Your Page's Model Components


In this task, you'll create the initial standards-compliant packages and objects that make up the model in your OrderEntry Model-View-Controller (MVC) application. 2.1 Create the BC4J Package for Client (UI) Objects Create a new Business Components for Java (BC4J) package to contain your user interface (UI) related application modules, view objects and view links. Select the 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.orderentry.server as the package name. For instance:

Fig 4: Create new BC4J package Verify that the radio button Entity Objects mapped to database schema objects is selected. Select Next twice.

Select the Finish button to create the package.

Oracle Applications Framework - Practices and Solutions C-31

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.

C-34 Oracle Applications Framework - Practices and Solutions

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

Oracle Applications Framework - Practices and Solutions C-35

Appendix C: 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 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.

Oracle Applications Framework - Practices and Solutions C-37

Appendix C: Practices and Solutions

3: Create Your Initial Page


For this task, you will build and run a page with just the Orders : Search page title and the instruction text 3.1 Create the OrderSearchPG Page Create a new UI page in the <yourname>.oracle.apps.demxx.orderentry.webui package. 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 Page in the OA Components Items list. Select the OK button to continue. In the New Page dialog, enter OrderSearchPG in the Name field and <yourname>.oracle.apps.demxx.orderentry.webui in the Package field. This package will be created and the page will be created under this package Warning: You MUST use this name and package or your page will not run properly. In fact, if any package, Java file, region name, item name, etc. is specified in the exercise instructions, you must match it exactly in your work. Select the OK button to create your page. 3.2 Modify the pageLayout Region Select your OrderSearchPG in the Structure pane and select the region1 that JDeveloper created for you. Verify and set (if necessary) the following properties: Property ID Region Style AM Definition WindowTitle Title AutoFooter Value PageLayoutRN pageLayout <yourname>.oracle.apps.demxx.orderentry.server.OrderEntryAM Order Entry Tutorial: Labs <your name> Orders : Search True (This ensures that the standard footer, including the Oracle copyright and privacy notice, render in the page).

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.

Oracle Applications Framework - Practices and Solutions C-39

Appendix C: Practices and Solutions

4: Configure a Results-Based Search


In this section, you will create a simple "results-based" search by leveraging the OA Framework query region. You will see how to enable the user-personalizable Views panel, the Simple Search panel, and the Advanced Search panel without explicitly creating the UIs for these regions. In the next task, you will change from a "results-based" search to an "auto customization criteria" search so you can take a bit more control of the UI that displays in the Search region. Tip: See the Search topic in Chapter 4 of the OA Framework Developer's Guide for additional information about implementing searching in your pages. The finished region should appear as shown in Figure 5 below when you've completed all the steps in this task.

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

C-40 Oracle Applications Framework - Practices and Solutions

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

ID OrderId OrderStatus CustomerId CustomerName DateShipped SalesRepName

Prompt Order Number Order Status Customer Number Customer Name Ship Date Salesperson Name

Style messageStyledText messageStyledText messageStyledText messageStyledText messageStyledText messageStyledText

Data Type NUMBER VARCHAR2 NUMBER VARCHAR2 DATE VARCHAR2

Attribute Set

Oracle Applications Framework - Practices and Solutions C-41

Appendix C: Practices and Solutions Click the Finish button to create your data table.

4.3 Set or Verify Your ResultsTable Region Properties

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.

Oracle Applications Framework - Practices and Solutions C-45

Appendix C: Practices and Solutions

5: Convert Search Region to Use Auto Customization Criteria


We have to add an LOV to our search region, we cannot just use the simple "results-based" search because it generates search items automatically based on the columns in our results table. So, we need to convert our query bean to run in "auto customization criteria mode" (that is, we want to customize our search criteria by adding an LOV). The finished region should appear as shown in Figure 6 below (the LOV icon appears after you finish Task 6).

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

C-46 Oracle Applications Framework - Practices and Solutions

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.

Select this item, and set or verify its properties as follows


Property ID Item Style Selective Search Criteria Data Type Maximum Length Prompt CSS Class Length Value SearchOrdNum messageTextInput True NUMBER 15 Order Number OraFieldText 15

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.

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 SearchOrdStatus messageTextInput True VARCHAR2 Order Status OraFieldText 15

5.5 Create a DateShipped 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 Value ID SearchDateShipped Item Style messageTextInput Selective Search Criteria True Data Type DATE Oracle Applications Framework - Practices and Solutions C-47

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.

Select this item, and set or verify its properties as follows


Property ID Item Style Selective Search Criteria Data Type Prompt CSS Class Length Value SearchCustId messageTextInput (we will change this to LOV later) True NUMBER Customer Number OraFieldText 15

5.7 Create an CustomerName 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 Length Value SearchCustName messageTextInput (we will change this to LOV later) True VARCHAR2 Customer Name OraFieldText 15

5.8 Create an SalesRepName 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


C-48 Oracle Applications Framework - Practices and Solutions

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 new mapping and set its properties as follows:


Property ID Search Item Results Item Value CustNameMap SearchCustName CustomerName

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

Lab 2: Orders: Search .

6: Adding a List of Values (LOV) to a Field


In this section, you will create a reusable list of values (LOV) that you will then configure for use in the Search page (you will use this same LOV later in the Create page). LOVs covered in this section are for Customer Number, Customer name and salesperson name. The finished LOVs should appear as shown in Figure 7(a,b,c).

Figure 7a: Customer Number LOV Window

Figure 7b: Customer Name LOV Window Oracle Applications Framework - Practices and Solutions C-51

Appendix C: Practices and Solutions

Figure 7c: Salesperson LOV Window

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.

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

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.

Oracle Applications Framework - Practices and Solutions C-61

Appendix C: Practices and Solutions

Lab 3: Orders: Drilldown to Details


Overview In this exercise, we will be extending the simple Orders search page you created in the Search Page Exercise to include a drilldown to a Details page that queries a single order. Warning: This lab assumes that you have completed the Search lab, and builds on this work. If you have not completed this exercise, please do so before proceeding.

Figure 1: Order Number in Search Page Links to Details Page

Figure 2: Details Page Finished Product C-62 Oracle Applications Framework - Practices and Solutions

Lab 3: Orders: Drilldown to Details .

1: Create the Details Page View Object


1.1 Create the OrderDetailsVO View Object Create a detail-level view object including all the attributes that we need to create (and later) view an order. This view object should leverage the OrderEO that you created in the Search exercise. 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 OrderDetailsVO 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 all the attributes from the Available list and shuttle them to the Selected list (Reason: We may add descriptive flexfields later on (as per the requirement) in which case we do not have to create another VO to capture other details) Select the Next button twice to reach the Query Page. At this point the query should look like the following in the Query page (without the formatting we have used here to improve readability):
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,

Oracle Applications Framework - Practices and Solutions C-63

Appendix C: Practices and Solutions


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 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 (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

C-64 Oracle Applications Framework - Practices and Solutions

Lab 3: Orders: Drilldown to Details .


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(+)

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.

Oracle Applications Framework - Practices and Solutions C-65

Appendix C: Practices and Solutions

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.

C-66 Oracle Applications Framework - Practices and Solutions

Lab 3: Orders: Drilldown to Details .

2: Create the Details Page UI


In this task, you will create a simple view-only page that automatically queries an order when the user navigates to it by selecting an Order Number link as shown in Figure 1. 2.1 Create the OrderDetailsPG Page Create a new UI page in the <yourname>.oracle.apps.demxx.orderentry.webui package. Select 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 Page in the OA Components Items list. Select the OK button to continue. In the New Page dialog, enter OrderDetailsPG in the Name field and <yourname>.oracle.apps.demxx.orderentry.webui in the Package field. Warning: You MUST use this name and package or your page will not run properly. In fact, if any package, Java file, region name, item name, etc. is specified in the exercise instructions, you must match it exactly in your work. Select the OK button to create your page. 2.2 Modify the pageLayout Region Select your OrderDetailsPG in the Structure pane and select the region1 that JDeveloper created.

Verify and set (if necessary) the following properties:


Property ID Region Style AM Definition Window Title Title AutoFooter Value PageLayoutRN pageLayout <yourname>.oracle.apps.demxx.orderentry.server.OrderEntryAM Order Entry Tutorial: Labs <your name> Orders : Drilldown True

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.

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 Order Entry Tutorial

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

C-70 Oracle Applications Framework - Practices and Solutions

Lab 3: Orders: Drilldown to Details . CustomerId Property CSS Class Value OraDataText

SalesRepId Property CSS Class Value OraDataText

PaymentType Property CSS Class Value OraDataText

CurrencyCode Property CSS Class Value OraDataText

OrderStatus Property CSS Class Value OraDataText

DateOrdered Property CSS Class Value OraDataText

DateShipped Property CSS Class Value OraDataText

CheckNumber Property CSS Class Value OraDataText

CcType Oracle Applications Framework - Practices and Solutions C-71

Appendix C: Practices and Solutions Property Value CSS Class OraDataText

CcNumber Property CSS Class Value OraDataText

CcExpiration Property CSS Class Value OraDataText

CcApprovalCode Property CSS Class Value OraDataText

OrderNote Property CSS Class Value OraDataText

CustomerName Property CSS Class Value OraDataText

SalesRepName 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.

C-72 Oracle Applications Framework - Practices and Solutions

Lab 3: Orders: Drilldown to Details .

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

Lab 3: Orders: Drilldown to Details . o CcApprovalCode o OrderNote

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.

Oracle Applications Framework - Practices and Solutions C-75

Appendix C: Practices and Solutions

3: Implement the View Object Query


3.1 Add an initQuery( ) Method to Your OrderDetailsVOImpl Class This method should take an orderId parameter, set the WHERE clause to ORDER_ID = :1, bind the orderId parameter to the WHERE clause, and execute the query (in effect, the view object should be capable of preparing to query and querying itself). Note: Pay attention to the import/use of the oracle.jbo.domain.Number. Whenever you instantiate a Number, you should import this class. If you forget to do this, you may encounter a runtime error complaining about java.lang.Number (the assumed class) being abstract, or you may get class cast exception errors.
import oracle.jbo.domain.Number; import oracle.apps.fnd.framework.OAException; ...

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; ...

C-76 Oracle Applications Framework - Practices and Solutions

Lab 3: Orders: Drilldown to Details .


/********************************************************************** ***** * Initializes the detail order query. *********************************************************************** ****** */ public void initDetails(String orderNumber) { OrderDetailsVOImpl vo = getOrderDetailsVO(); if (vo == null) { MessageToken[] errTokens = { new MessageToken("OBJECT_NAME", "OrderdetailsVO")}; throw new OAException("DEMXX", "ORDLINES_OBJECT_NOT_FOUND", errTokens); } vo.initQuery(orderNumber); } // end initDetails()

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).

Oracle Applications Framework - Practices and Solutions C-77

Appendix C: Practices and Solutions

4: Implement the Drilldown to the OrderDetailsPG


In this section, you will add a link on the OrderId column in the Results table that you added to your OrderSearchPG in the previous lab. This link navigates to the new Details page that you just created. 4.1 Configure the OrderId Item as a Link When the user selects an Order Number link, the Details page should display. As part of this GET request, we also want to: Add orderNumber and customerName parameters to the URL. These parameter values should be sourced from the OrderDetailsVO attributes OrderId and CustomerName respectively. Indicate that the OrderSearchPG's application module instance should be retained when the OrderDetailsPG renders so these pages can share the same root application module. Indcate that breadcrumbs should display in the OrderDetailsPG. To achieve this, select the orderNumber item in the ResultsTable region and set the Destination URI property to:
OA.jsp?page=/<yourname>/oracle/apps/demxx/orderentry/webui/OrderDetails PG &orderNumber={@OrderId} &customerName={@CustomerName} &retainAM=Y&addBreadCrumb=Y

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.

Oracle Applications Framework - Practices and Solutions C-79

Appendix C: Practices and Solutions


MessageToken[] tokens = { new MessageToken("CUST_NAME", Name)}; // Now, get the translated message text including the token value. String pageHeaderText = pageContext.getMessage("DEMXX","ORDLINES_HDR_TEXT", 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.

((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.

C-80 Oracle Applications Framework - Practices and Solutions

Lab 4: Orders: Create .

Lab 4: Orders: Create


Overview In this exercise, we will add a Create Order button to our Orders search page Warning: This lab assumes that you have completed the Search Exercise and the Drilldown to Details Exercise, and builds on that work. If you have not completed these exercises, please do so before proceeding.

Figure 1: Create Page Finished Product

1: Revise the Search Page to Include a Create Order Button


1.1 Add a "Create Order" Button to Your Search Page First, you need to revise the OrderSearchPG to include a Create Order 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 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 Oracle Applications Framework - Practices and Solutions C-81

Appendix C: Practices and Solutions ID to ButtonLayout.

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.

C-82 Oracle Applications Framework - Practices and Solutions

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.

Oracle Applications Framework - Practices and Solutions C-83

Appendix C: Practices and Solutions

2: Create a View Object for the Order Status Poplist


The Create Order page will include a poplist for choosing the order's status. Before creating the page, we need to create a view object to be used for the poplist data. To learn more about poplists (and other standard basic components like text fields, checkboxes, radio buttons, list boxes and so forth), see Standard Web Widgets in the OA Framework Developer's Guide. 2.1 Create a Poplist View Object BC4J Package Per the OA Framework File Standards, all view objects created explicitly for use in poplists must be created in a special, product-level directory. In your OrderEntry.jpr project, create a new business components package with <yourname>.oracle.apps.demxx.poplist.server as the package name. 2.2.1 Create the OrderStatusVO in the Poplist BC4J Package In the <yourname>.oracle.apps.demxx.poplist.server package, create a new view object with OrderStatusVO 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 display value and lookup_code is the internal developer value):

SELECT meaning, lookup_code FROM fnd_lookups WHERE lookup_type = 'ORDER_STATUS_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.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.

Oracle Applications Framework - Practices and Solutions C-85

Appendix C: Practices and Solutions

3: Build the Create Page


In this section, you will create an order Create page as shown in Figure 1 above. 3.1 Create the OrderCreatePG Page Create a new OA Components page in the <yourname>.oracle.apps.demxx.orderentry.webui package called OrderCreatePG. 3.2 Modify the pageLayout Region

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.

Set the following properties for this region:


C-86 Oracle Applications Framework - Practices and Solutions

Lab 4: Orders: Create .

Property ID Region Style

Value PageButtons pageButtonBar

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.

Oracle Applications Framework - Practices and Solutions C-87

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

Oracle Applications Framework - Practices and Solutions C-89

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

CustomerName C-92 Oracle Applications Framework - Practices and Solutions

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

Oracle Applications Framework - Practices and Solutions C-95

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

CcNumber Property Maximum Length CSS Class Value 30 OraFieldText

CcExpiration Property Maximum Length CSS Class Value 5 OraFieldText

CcApprovalCode Property Maximum Length CSS Class Value 15 OraFieldText

OrderNote Property Maximum Length CSS Class Length Value 2000 OraFieldText 110

Oracle Applications Framework - Practices and Solutions C-97

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

C-98 Oracle Applications Framework - Practices and Solutions

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

Appendix C: Practices and Solutions o CheckNumber o CcType o CcNumber o CcExpiration o CcApprovalCode

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

Property Rows Columns

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:

C-102 Oracle Applications Framework - Practices and Solutions

Lab 4: Orders: Create .

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

Oracle Applications Framework - Practices and Solutions C-105

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 SecondRowRN Property Horizontal Alignment Value center

For ThirdRowRN Property Horizontal Alignment Vertical Alignment Value right top

For FourthRowRN Property Horizontal Alignment Value right

For FifthRowRN Property Horizontal Alignment Value right

For SixthRowRN Property Horizontal Alignment Value right

For SecondCell Property Value Oracle Applications Framework - Practices and Solutions C-107

Appendix C: Practices and Solutions Property Value Column Span 2

For ThirdCell Property Vertical Alignment Row Span Value top 5

For SixthCell Property Horizontal Alignment Vertical Alignment Row Span Value right top 4

For SeventhCell Property Horizontal Alignment Value right

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

C-108 Oracle Applications Framework - Practices and Solutions

Lab 4: Orders: Create .

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

Drag-and-drop the OrdNoteVertiSpace before OrderNote


Select ButtonRowRN and set the Horizontal Alignment property to right. Select ButtonRowRN Item, right-click and select New > Item. Set the following properties for the item Property ID Item Style Width Height Value LastRowVertiSpace Spacer 1 35

C-110 Oracle Applications Framework - Practices and Solutions

Lab 4: Orders: Create .

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.

C-112 Oracle Applications Framework - Practices and Solutions

Lab 4: Orders: Create .

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.

Oracle Applications Framework - Practices and Solutions C-113

Appendix C: Practices and Solutions


import oracle.jbo.Transaction; ... /** ********************************************************************* * Executes a rollback including the database and the middle tier. ********************************************************************* */ public void rollbackOrder() { 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 rollbackOrder()

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

C-114 Oracle Applications Framework - Practices and Solutions

Lab 4: Orders: Create .


// selects the Create Orders 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. if (TransactionUnitHelper.isTransactionUnitInProgress(pageContext, "ordCreateTxn", false)) { am.invokeMethod("rollbackOrder"); TransactionUnitHelper.endTransactionUnit(pageContext, "ordCreateTxn"); } }

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

Oracle Applications Framework - Practices and Solutions C-115

Appendix C: Practices and Solutions


{ // Always call this first. super.processRequest(pageContext, webBean); // If isBackNavigationFired = false, we're here after a valid navigation // (the user selected the Create Order button) and we should proceed // normally and initialize a new order. 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, "ordCreateTxn"); // // // // // This test ensures that we don't try to create a new order 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()) { OAApplicationModule am = (OAApplicationModule)pageContext.getApplicationModule(webBean); am.invokeMethod("createOrderEntry", null);

// 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");

OAMessageRadioButtonBean rb2 = (OAMessageRadioButtonBean)webBean.findChildRecursive("checkRB"); rb2.setName("paymentTypeRG"); rb2.setValue("CHECK");

C-116 Oracle Applications Framework - Practices and Solutions

Lab 4: Orders: Create .


OAMessageRadioButtonBean rb3 = (OAMessageRadioButtonBean)webBean.findChildRecursive("creditCardRB"); rb3.setName("paymentTypeRG"); rb3.setValue("CHARGE"); // Make Current Date the Minimum Value for Order Date // The DateOrdered item displays a calendar to choose a date for Order // Date.We should add logic to ensure that customers cannot place an // order based on a date that has already passed.Therefore we make the // current date as the minimum value to choose from the calendar display /*************** Min SYSDATE for ORDERED DATE *********************/ OAMessageDateFieldBean startDateBean = (OAMessageDateFieldBean)webBean.findIndexedChildRecursive("DateOrdered" ); if (startDateBean != null) { OADBTransaction transaction = (OADBTransaction)pageContext.getApplicationModule(webBean).getTransacti on(); java.util.Calendar currCal = java.util.Calendar.getInstance(); currCal.setTime((java.util.Date)transaction.getCurrentDBDate().dateValu e()); currCal.add(java.util.Calendar.DATE, -1); startDateBean.setMinValue(currCal.getTime()); } } } else { if (!TransactionUnitHelper.isTransactionUnitInProgress(pageContext, "ordCreateTxn", 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 more // context-specific message telling the user he can't use the browser // "Back" button and the "Create" page. Instead, we want to illustrate // how to display the Applications standard NAVIGATION ERROR message.

Oracle Applications Framework - Practices and Solutions C-117

Appendix C: Practices and Solutions


OADialogPage dialogPage = new OADialogPage(NAVIGATION_ERROR); pageContext.redirectToDialogPage(dialogPage); } } } // end processRequest

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.

C-118 Oracle Applications Framework - Practices and Solutions

Lab 4: Orders: Create .

5: Implement Order Business Logic


Part 1: Declarative Validation and Initialization The following table summarizes the order business rules to be implemented in this lab. Bolded rules can be implemented using declarative validation. 5.1 Lay down your Business Needs Entity Attribute OrderId Business Rules Defaults when an Order entity object is created using the DEM_ORDERS_S sequence to generate your unique identifier. Must be unique across the system. Required; cannot be null. Cannot be updated on a committed row. Required; cannot be null Defaults to SYSDATE when an Order entity object is created Must be >= sysdate Required; cannot be null Must be a valid status (valid means it exists in the FND_LOOKUPS table) If specified, must be >= START_DATE Required; cannot be null Required; cannot be null Required; cannot be null cashRB (PPR) checkRB (PPR) creditCardRB (PPR) Enable the following Enable the following CheckNumber CcType ----------------- CcNumber CcExpiration Disable the following Disable the following Disable the following CheckNumber CcType CheckNumber CcType CcNumber CcApprovalCode CcNumber CcExpiration CcExpiration CcApprovalCode CcApprovalCode Must be a valid Type(Should not be null) PPR Partial Page Render on CcType If Visa o Enable CcApprovalCode and make it Required Else

DateOrdered

OrderStatus

DateShipped CustomerId CustomerName CurrencyCode PaymentType

CcType

Oracle Applications Framework - Practices and Solutions C-119

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

Oracle Applications Framework - Practices and Solutions C-121

Appendix C: Practices and Solutions


"OrderId", // Attribute Name value, // Attribute value "DEMXX", // Message product short name "ORDLINES_ORDER_ID_UNIQUE"); // Message name } } // Note that this is the point at which the value is actually set on the EO // cache(during the scope of setAttributeInternal processing). If you don't // make this call after you perform your validation, your value will not be // set correctly. Also, any declarative validation that you define for this // attribute is executed within this method. setAttributeInternal(ORDERID, value); } //end setOrderId()

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()

C-122 Oracle Applications Framework - Practices and Solutions

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.

Oracle Applications Framework - Practices and Solutions C-123

Appendix C: Practices and Solutions

6: Implement Order Business Logic


Part 2: Entity Expert, VAM and VVO Validation In this task, you will create an Entity Expert, a Validation Application Module (VAM) and several Validation View Objects (VVO) to be used in OrderStatus. In each of these cases, we have to execute some SQL statements in order to implement the required business rules. This task shows the correct way to implement this. 6.1 Create an Order Validation Application Module Create an application module to hold validation view objects used by your OrderEO and its entity expert. Validation application modules are not used by the UI, so they are created in the same package as your entity object (the "schema" package). In the <yourname>.oracle.apps.demxx.schema.server BC4J package, create a new application module called OrderVAM, and verify that the Package is set to <yourname>.oracle.apps.demxx.schema.server In the Java page, deselect the Generate Java File checkbox (you will not be adding any code to this application module) 6.2 Register the Order Validation Application Module with OrderEO Entity Object Associate the OrderVAM with the OrderEO so you can use certain convenience methods in the OAEntityExpert class (you will need this in a few steps). Select the OrderEO in the Navigator, right-click and select Edit OrderEO... from the context menu. Navigate to the Properties page. Create a new property with the following Name and Value, and select the Add button (note that the case must match exactly): o Name: VAMDef o Value: <yourname>.oracle.apps.demxx.schema.server.OrderVAM Select the OK button to create your new property. 6.3 Create an OrderStatus Validation View Object Validation view objects encapsulate simple validation queries that you would otherwise write directly in your entity object or expert. For example, the OrderStatusVVO simply checks to see if the given status exists in the database. In the <yourname>.oracle.apps.demxx.schema.server BC4J package, create a new view object called OrderStatusVVO and verify that Package is set to <yourname>.oracle.apps.demxx.schema.server C-124 Oracle Applications Framework - Practices and Solutions

Lab 4: Orders: Create . Use the following query:


SELECT lookup_code FROM fnd_lookups WHERE lookup_code = :1 AND lookup_type = 'ORDER_STATUS_LOOKUP'

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.

Oracle Applications Framework - Practices and Solutions C-125

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.

C-126 Oracle Applications Framework - Practices and Solutions

Lab 4: Orders: Create .


*********************************************************************** ****** **/ public boolean isOrderStatusValid(String orderStatus) { boolean isActive = false; // Note that we want to use a cached, declaratively defined VO instead of // creating one from a SQL statement which is far less performant. OrderStatusVVOImpl orderStatusVO = (OrderStatusVVOImpl)findValidationViewObject("OrderStatusVVO"); orderStatusVO.initQuery(orderStatus); // We are just doing a simple existence check. If we don't find a match, //return false. if (orderStatusVO.hasNext()) { isActive = true; } return isActive; } // end isOrderStatusValid()

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

Oracle Applications Framework - Practices and Solutions C-127

Appendix C: Practices and Solutions


value, // Attribute value "DEMXX", // Message product short name "ORDLINES_ORDSTATUS_INVALID"); // Message name } } setAttributeInternal(ORDERSTATUS, value); }

C-128 Oracle Applications Framework - Practices and Solutions

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).

Oracle Applications Framework - Practices and Solutions C-129

Appendix C: Practices and Solutions

7: Implement Order Business Logic


Part 3: Miscellaneous Attributes

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); }

Add the following new method to your OrderEOImpl class.


/** *********************************************************************** * * Verifies that the order's Ship Date is valid. * * Business Rules: * This is an optional value which can be updated at any time. * Cannot be earlier than sysdate. *********************************************************************** * */ protected void validateDateShipped(Date value) { // If a value has been set, validate it. if (value != null) { OADBTransaction transaction = getOADBTransaction(); // Note that we want to truncate these values to allow for the possibility // that we are trying to set them to be the same day. Calling

C-130 Oracle Applications Framework - Practices and Solutions

Lab 4: Orders: Create .


// dateValue() does not include time. Were we to want the time element, // we would call timestampValue(). Finally, we cannot compare // oracle.jbo.domain.Date objects directly. Instead, convert the value to // a long as shown. long dateOrdered = getDateOrdered().dateValue().getTime(); long dateShipped = value.dateValue().getTime(); if (dateShipped < dateOrdered) { throw new OAAttrValException(OAException.TYP_ENTITY_OBJECT, getEntityDef().getFullName(), // EO name getPrimaryKey(), // EO PK "DateShipped", // Attribute Name value, // Attribute value "DEMXX", // Message product short name "ORDLINES_ORDER_SHIP_BAD"); // Message name } } } // end validateDateShipped()

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).

Oracle Applications Framework - Practices and Solutions C-131

Appendix C: Practices and Solutions

8: Implement Order Business Logic


Part 4: Entity-Level Validation All cross-attribute validation must be added to the entity level validateEntity() method in your entity object (you cannot control the sequence in which BC4J calls individual attribute setters, so any validation that you add to a set<AttributeName>() method can refer only to that attribute's value). When values are posted back to the middle tier, BC4J calls each of the appropriate attribute setters, and then calls the validateEntity() method for any "dirty" (changed) entities. So, this logic always executes after all your attribute setters have been called. Add the following logic to the validateEntity() method in your OrderEOImpl class.
/** ****************************************************************** * Add Entity- and Cross-Attribute validation code in this method. ****************************************************************** */ protected void validateEntity() { // Always call this first. super.validateEntity(); if (getOrderStatus() == null) { throw new OAAttrValException(OAException.TYP_ENTITY_OBJECT, getEntityDef().getFullName(), // EO name getPrimaryKey(), // EO PK "OrderStatus", // Attribute Name getOrderStatus(), // Attribute value "DEMXX", // Message product short name "ORDLINES_STATUS_REQUIRED"); // Message name } /************* Ensuring CcType is entered if Credit Card is chosen ********/ if ((getPaymentType().equalsIgnoreCase("CHARGE")) && (getCcType() == null)) { throw new OAAttrValException(OAException.TYP_ENTITY_OBJECT, getEntityDef().getFullName(), // EO name getPrimaryKey(), // EO PK "CcType", // Attribute Name getCcType(), // Attribute value "DEMXX", // Message product short name "ORDLINES_CCTYPE_INVALID"); // Message name } /******** Ensuring ApprovalCode is entered if CcType is Visa **********/ if ((getPaymentType().equalsIgnoreCase("CHARGE")) && (getCcType().equalsIgnoreCase("V")) && (getCcApprovalCode() == null) )

C-132 Oracle Applications Framework - Practices and Solutions

Lab 4: Orders: Create .


{ throw new OAAttrValException(OAException.TYP_ENTITY_OBJECT, getEntityDef().getFullName(), // EO name getPrimaryKey(), // EO PK "CcApprovalCode", // Attribute Name getCcApprovalCode(), // Attribute value "DEMXX", // Message product short name "ORDLINES_CCAPPCODE_ENTER"); // Message name } /************* Ensuring Check Number is non Negitive *************/

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.

9: Implement the Apply and Cancel Button Handling


When the user presses the Apply button, you need to commit and navigate back to the Search page where you will display a confirmation message. When the user presses the Cancel button, you need to rollback the transaction and navigate back to the Search page (the rollback is required per the Back button guidelines in this particular use case). 9.1 Create an apply( ) Method in Your OrderEntryAMImpl Class Since controller code shouldn't access server-side objects except for the OAApplicationModule interface, we need to create an apply() method in the OrderEntryAMImpl class to actually issue the commit. We will then add controller code to invoke this method on the AM. Add the following method to your OrderEntryAMImpl class. Oracle Applications Framework - Practices and Solutions C-133

Appendix C: Practices and Solutions

/* *********************************************************************** ****** * 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,

C-134 Oracle Applications Framework - Practices and Solutions

Lab 4: Orders: Create .


// 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("OrderDetailsVO"); // Note that we have to get this value from the VO because the EO will // assemble it during its validation cycle. // For performance reasons, // we don't want to do this // on the client so we are illustrating the interface-appropriate call. If // we implement this code in the AM where it belongs, we would use the // other approach. // We need to get a String so we can pass it to the MessageToken array // below. Note that we are getting this value from the VO (we could also // get it from the Bean as shown in the Drilldown to Details) because the // item style is messageStyledText, so the value is not put on the request // like a messaqeTextInput value is. Number orderNumber = (Number)vo.getCurrentRow().getAttribute("OrderId"); String orderNum = String.valueOf(orderNumber.intValue()); // Simply telling the transaction to commit will cause all the Entity // Object validation to fire. // Note: there's no reason for a developer to perform a rollback. This is // handled by the framework if errors are encountered. am.invokeMethod("apply"); // Assuming the "commit" succeeds, navigate back to the "Search" page with // the user's search criteria intact and display a "Confirmation" message // at the top of the page. MessageToken[] tokens = { new MessageToken("ORD_NUMBER", orderNum) }; OAException confirmMessage = new OAException("DEMXX", "ORDLINES_ORD_CREATE_CONFIRM",tokens,OAException.CONFIRMATION, null); // Per the UI guidelines, we want to add the confirmation message at the

Oracle Applications Framework - Practices and Solutions C-135

Appendix C: Practices and Solutions


// top of the search/results page and we want the old search criteria and // results to display. pageContext.putDialogMessage(confirmMessage);

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.

C-136 Oracle Applications Framework - Practices and Solutions

Lab 4: Orders: Create .

Figure 2: Orders Search Page with Create Confirmation Message You are now finished with this exercise.

Oracle Applications Framework - Practices and Solutions C-137

Appendix C: Practices and Solutions

Lab 5: Orders: Partial Page Rendering (PPR)


Overview In this exercise, we will modify the Create Order page to implement a dynamic user interface using partial page rendering (PPR) for the payment type radio-button value changes. When the user clicks the any one of the radio-buttons (Cash, Cheque or CreditCard) we need to disable the fields listed below the other two. For instance, if the user initially clicks on Creditcard and fills out details, then decides he wants to pay through Cheque and so clicks on Cheque radiobutton we need to clear attribute values set for Creditcard fields (CcType, CcNumber, CcExpiration, CcApprovalCode) and disable these fields. Warning: This lab assumes that you have completed the Create Lab, and builds on that work. If you have not completed this exercise, please do so before proceeding.

Figure 1: Create Page Finished Product initial rendering

C-138 Oracle Applications Framework - Practices and Solutions

Lab 5: Orders: Partial Page Rendering (PPR) .

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

1: Create an "Application Properties" View Object


To enable PPR in this page, you must create an OA Framework standard applications properties view object (PVO) including a transient attribute for tracking the state of the Rendered property for the PPR fields. This view object will ultimately include a single row which you will initialize and update as the user interacts with the page (you will see a bit later how the PPR field binds to this view object attribute to determine whether it should be disabled or not, and you will configure the cashRB, checkRB, creditCardRB and CcType fields to fire PPR events when each of their values change). Note: See the Dynamic User Interface topic in the OA Framework Developer's Guide for additional information about leveraging PPR in your product. The application properties view object should be created in the same package as your module's other UI BC4J components. Note that you should have only one application properties view object per application module (it can include attributes used by different pages that share the same root UI application module). This view object should follow the naming convention: <AssociatedApplicationModuleName >PVO. Since you will be associating your application properties view object with your OrderEntryAM root UI application module, it should be Oracle Applications Framework - Practices and Solutions C-139

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.

Oracle Applications Framework - Practices and Solutions C-141

Appendix C: Practices and Solutions

2: Configure the PPR items to fire a PPR Action when changed


Configure the relevant items to fire a PPR action. They are configured in the following way: 2.1 Set the PPR Properties for Cash RadioButton Set the following properties for the cashRB item in your Create page: Property Disable Server Side Validation Value True (Ignore any server-side validation errors when this radiobutton changes and the form is submitted. For example, ignore invalid field values )

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

C-142 Oracle Applications Framework - Practices and Solutions

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.

Oracle Applications Framework - Practices and Solutions C-143

Appendix C: Practices and Solutions

3: Configure the PPR field items to react to PPR Events


Set the value of the Disabled property to the following SPEL ("Simplest Possible Expression Language") syntax indicating that the property value should be obtained from the OrderEntryPVO instance's transient attributes. For CheckNumber Item Property Disabled Value ${oa.OrderEntryPVO.checkNumber}

For CcType Item Property Disabled Value ${oa.OrderEntryPVO.creditCardType}

For CcNumber Item Property Disabled Value ${oa.OrderEntryPVO.creditCardNumber}

For CcExpiration Item Property Disabled Value ${oa.OrderEntryPVO.creditCardExpirationDate}

For CcApprovalCode Item Property Disabled Value ${oa.OrderEntryPVO.approvalCode}

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.

C-144 Oracle Applications Framework - Practices and Solutions

Lab 5: Orders: Partial Page Rendering (PPR) .

4: Implement PPR Event Handling


4.1 Add PPR Handling Methods (Enable/Disable) to the OrderEntryAMImpl We have created the application properties VO (OrderEntryPVO), configured the relevant items to fire a PPR event, and we have configured the relevant field's Disabled property to bind to the OrderEntryPVO's transient attributes. Now, we need to add the code to handle the PPR change events and initialize the OrderEntryPVO. Your controller code will invoke the following method whenever a field's PPR event is fired. Add the following code to your OrderEntryAMImpl class. This checks the radio-button clicked and disables/enables the associated OrderDetailsVO attributes. Note: In this case, a transient property set to Boolean.FALSE indicates that the SPEL associated field is enabled and vice versa.

/********************* Coding PPR Handlers ************************/

/********************* 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() {

Oracle Applications Framework - Practices and Solutions C-145

Appendix C: Practices and Solutions


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();

// 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

if(row!=null) row.setAttribute("creditCardType", Boolean.TRUE); if(dbRow!=null) dbRow.setAttribute("CcType", null); // set null to CcType } }

/** ************************************************************ * PPR for CcTpe Enable ************************************************************ */

C-146 Oracle Applications Framework - Practices and Solutions

Lab 5: Orders: Partial Page Rendering (PPR) .


public void enableCcType() { OAViewObject vo = (OAViewObject)findViewObject("OrderEntryPVO"); if (vo != null) { if (vo.getFetchedRowCount() == 0) { vo.executeQuery(); } OARow row = (OARow)vo.first(); if(row!=null) row.setAttribute("creditCardType", Boolean.FALSE); } } /********************* CcNumber ************************/

/** ************************************************************ * 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");

Oracle Applications Framework - Practices and Solutions C-147

Appendix C: Practices and Solutions


if (vo != null) { if (vo.getFetchedRowCount() == 0) { vo.executeQuery(); } OARow row = (OARow)vo.first(); if(row!=null) row.setAttribute("creditCardNumber", Boolean.FALSE); } } /********************* CcExpiration ************************/

/** ************************************************************ * 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

if(row!=null) row.setAttribute("creditCardExpirationDate", Boolean.TRUE); if(dbRow!=null) dbRow.setAttribute("CcExpiration", null); // set null to CcExpiration } }

/** ************************************************************ * PPR for CcExpiration Enable ************************************************************ */ public void enableCcExpiration() { OAViewObject vo = (OAViewObject)findViewObject("OrderEntryPVO"); if (vo != null) {

C-148 Oracle Applications Framework - Practices and Solutions

Lab 5: Orders: Partial Page Rendering (PPR) .


if (vo.getFetchedRowCount() == 0) { vo.executeQuery(); } OARow row = (OARow)vo.first(); if(row!=null) row.setAttribute("creditCardExpirationDate", Boolean.FALSE); } } /********************* CcApprovalCode ************************/ /** ************************************************************ * PPR for CcApprovalCode Disable ************************************************************ */ public void disableCcApprovalCode() { 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("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();

Oracle Applications Framework - Practices and Solutions C-149

Appendix C: Practices and Solutions


if(row!=null) row.setAttribute("approvalCode", Boolean.FALSE); } }

C-150 Oracle Applications Framework - Practices and Solutions

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); } }

Oracle Applications Framework - Practices and Solutions C-151

Appendix C: Practices and Solutions


} // end init()

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");

C-152 Oracle Applications Framework - Practices and Solutions

Lab 5: Orders: Partial Page Rendering (PPR) .


String cc = (String)ccType.getValue(pageContext); if(cc.equalsIgnoreCase("v")) { am.invokeMethod("enableCcApprovalCode"); } else { am.invokeMethod("disableCcApprovalCode"); } }

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.

Oracle Applications Framework - Practices and Solutions C-153

Appendix C: Practices and Solutions

Lab 6: Orders: Delete


Overview In this exercise, you will be revising the simple Orders search page you created earlier to add a Delete image column and implement a delete action including a Warning page dialog. Figure 1 shows the updated Orders page including the Delete column with an image that is enabled based on the order's state.

Figure 1: Delete Finished Product

C-154 Oracle Applications Framework - Practices and Solutions

Lab 6: Orders: Delete .

Figure 2: Revised Orders Search Page showing the ResultTable alone

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.

1: Implement a Delete in Your OrderEOImpl Class


Verify the that you have the following remove() method to your OrderEOImpl class. If not, add it and then compile and save your change.
/* *********************************************************************** ****** * Add entity delete logic here. *********************************************************************** ****** */ public void remove() { super.remove(); } // end remove()

Oracle Applications Framework - Practices and Solutions C-155

Appendix C: Practices and Solutions

2: Implement a Delete Switcher


Switchers can be used in tables to conditionally display alternate content in a column. In this task, you will configure a switcher to display an appropriate Delete image based on the order's status. See Table Content Switchers in the OA Framework Developer's Guide for more information about this feature. 2.1 Add an Attribute to the OrderSearchVO View Object To add a Delete switcher column to our results table, we need to modify our OrderSearchVO to include a decode attribute for this column that implements the following rules: If the order is active, the Delete trashcan is disabled. If the order is inactive, the Delete trashcan is enabled. Note: For simplicity, the business rules assume that the presence of a non-null DATE_SHIPPED implies that the order is inactive, regardless of the DATE_SHIPPED value. Select the OrderSearchVO in the Navigator, right-click and select Edit OrderSearchVO... from the context menu to edit your VO. In the Query Statement text box, modify your query to look like the following query (add the new content in bold). When you finish, select the Test button to ensure your syntax is correct.
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, DECODE(NVL(TO_CHAR(OrderEO.DATE_SHIPPED), 'N'), 'N', 'DeleteDisabled', 'DeleteEnabled') AS DELETE_SWITCHER 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

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

View Instance View Attribute

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.)

Oracle Applications Framework - Practices and Solutions C-157

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.)

C-158 Oracle Applications Framework - Practices and Solutions

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.

Oracle Applications Framework - Practices and Solutions C-159

Appendix C: Practices and Solutions


// NOTE!!! You must call the prepareForRendering() method on the table // *before* formatting columns. Furthermore, this call must be sequenced // *after* the table is queried and *after* you do any control bar // manipulation. table.prepareForRendering(pageContext); DataObjectList columnFormats = table.getColumnFormats(); DictionaryData columnFormat = null; int childIndex = pageContext.findChildIndex(table, "DeleteSwitcher"); columnFormat =(DictionaryData)columnFormats.getItem(childIndex); columnFormat.put(COLUMN_DATA_FORMAT_KEY, ICON_BUTTON_FORMAT); ...

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.

C-160 Oracle Applications Framework - Practices and Solutions

Lab 6: Orders: Delete .

3: Implement the Delete Action


In this task, you'll be adding the code to handle the Delete icon selection. When you query orders, you may see a deleteable entry as shown in Figure 1 above. When the user presses the Delete icon, a warning dialog displays as shown in Figure 3 below. If the user selects the OK button to proceed with the delete action, a confirmation message is displayed at the top of the Orders page as shown in Figure 4.

Figure 3: Delete Warning Dialog

Figure 4: Delete Confirmation Message

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.

C-162 Oracle Applications Framework - Practices and Solutions

Lab 6: Orders: Delete .


Number primaryKey = row.getOrderId(); if (primaryKey.compareTo(ordToDelete) == 0) { // This performs the actual delete. row.remove(); getTransaction().commit(); break; // only one possible selected row in this case } } } // Always close the iterator when you're done. deleteIter.closeRowSetIterator(); } // end deleteOrder

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)};

Oracle Applications Framework - Practices and Solutions C-163

Appendix C: Practices and Solutions


OAException mainMessage = new OAException("DEMXX", "ORDLINES_ORDER_DELETE_WARN", tokens); // Note that even though we are going to make our Yes/No buttons submit a // form, we still need some non-null value in the constructor's Yes/No // URL parameters for the buttons to render, so we just pass empty // Strings for this. OADialogPage dialogPage = new OADialogPage(OAException.WARNING, mainMessage, null, "", ""); // Always use Message Dictionary for any Strings you want to display. String yes = pageContext.getMessage("DEMXX", "ORDLINES_ORDER_YES", null); String no = pageContext.getMessage("DEMXX", "ORDLINES_ORDER_NO", null); // We set this value so the code that handles this button press is // descriptive. dialogPage.setOkButtonItemName("DeleteYesButton"); // The following configures the Yes/No buttons to be submit buttons, // and makes sure that we handle the form submit in the originating // page (the "Order" summary) so we can handle the "Yes" // button selection in this controller. dialogPage.setOkButtonToPost(true); dialogPage.setNoButtonToPost(true); dialogPage.setPostToCallingPage(true); // Now set our Yes/No labels instead of the default OK/Cancel. dialogPage.setOkButtonLabel(yes); dialogPage.setNoButtonLabel(no); // We need to keep hold of the orderNumber and customerName. // The OADialogPage gives us a convenient means // of doing this. Note that the use of the Hashtable is // most appropriate for passing multiple parameters. See the OADialogPage // javadoc for an alternative when dealing with a single parameter. java.util.Hashtable formParams = new java.util.Hashtable(1); formParams.put("ordNum", orderNumber); formParams.put("custName", customerName); dialogPage.setFormParameters(formParams); pageContext.redirectToDialogPage(dialogPage); }

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; ...

/************** Delete Confirmation Code Handler *********************/

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.

Oracle Applications Framework - Practices and Solutions C-165

Appendix C: Practices and Solutions

Lab 7: Orders: Update


Overview In this exercise, you will be implementing an order update transaction. 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.

1: Make a Copy of Your OrderCreatePG


For the most part, a single page update and insert page are identical. Since you already created an insert page, the quickest way to implement a new corresponding update page with the same items and underlying view object is to simply copy the page definition and then make any necessary modifications. Note: We are using the page copy technique shown here to avoid having you recreate a page that is virtually identical to one that you have already created. When developing a real product, however, pages that are this similar should be implemented as a single page with a dynamic user interface. The Partial Page Rendering lab introduces you to this technology; read the Dynamic User Interface topic in the Developer's Guide for additional information about how to leverage this in your development. 1.1 Copy OrderCreatePG on the File System Since the JDeveloper OA Extension does not yet support the ability to "save as" or copy/paste a page document, you need to use the file system for the following task. Save all your work and close JDeveloper. Select your OrderCreatePG.xml document in the Windows Explorer, right-click and select Copy. Select the webui directory node, right-click and select Paste. Your new file will be named Copy of OrderCreatePG. Select the new file in the Explorer, right-click and select Rename. Change the name to OrderUpdatePG. Start JDeveloper, expand the OA Components category in your project, and select the Add File toolbar icon to open the Add Files or Directories to <your project name> dialog. Locate your OrderUpdatePG and select OK to add this file to your project. C-166 Oracle Applications Framework - Practices and Solutions

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.

Oracle Applications Framework - Practices and Solutions C-167

Appendix C: Practices and Solutions

2: Add an Update Column to the Search Page


In this task, you will add an Update image column to your Orders Results table as shown in Figure 1.

Figure 1: Order Search page: Update column included

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))) {

Oracle Applications Framework - Practices and Solutions C-169

Appendix C: Practices and Solutions


// The user has clicked an "Update" icon so we want to navigate // to the first step of the multistep "Update Order" flow. pageContext.setForwardURL("OA.jsp?page=/<yourname>/oracle/apps/demxx/ orderentry/webui/OrderUpdatePG", null, OAWebBeanConstants.KEEP_MENU_CONTEXT, null, null, true, // Retain AM OAWebBeanConstants.ADD_BREAD_CRUMB_NO, OAWebBeanConstants.IGNORE_MESSAGES); }

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 *****************/

C-170 Oracle Applications Framework - Practices and Solutions

Lab 7: Orders: Update .


OAMessageRadioButtonBean rb1 = (OAMessageRadioButtonBean)webBean.findChildRecursive("cashRB"); rb1.setName("paymentTypeRG"); rb1.setValue("CASH");

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.

You are now finished with this exercise.

Oracle Applications Framework - Practices and Solutions C-171

Appendix C: Practices and Solutions

Lab 8: Lines: Search


Overview In this exercise, we will be implementing a simple search and results page as shown in Figure 1 below. Eventually, we will add the ability to view, create and delete orders.

Figure 1: Search Page Exercise Finished Product

1: Create Your Page's Model Components


1.1 Create a Lines Entity Object (EO) Create an entity object (EO) for the DEM_ORDER_LINES 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 LinesEO in the Name field. C-172 Oracle Applications Framework - Practices and Solutions

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

Appendix C: Practices and Solutions o Select Next to proceed.

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,

C-176 Oracle Applications Framework - Practices and Solutions

Lab 8: Lines: Search .


LinesEO.ROWID FROM DEM_ORDER_LINES LinesEO

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.

C-178 Oracle Applications Framework - Practices and Solutions

Lab 8: Lines: Search .

2: Create Your Initial Page


2.1 Create the LinesSearchPG Page Create a new UI page in the <yourname>.oracle.apps.demxx.orderentry.webui package. 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 Page in the OA Components Items list. Select the OK button to continue. In the New Page dialog, enter LinesSearchPG in the Name field and <yourname>.oracle.apps.demxx.orderentry.webui in the Package field. Warning: You MUST use this name and package or your page will not run properly. In fact, if any package, Java file, region name, item name, etc. is specified in the exercise instructions, you must match it exactly in your work. Select the OK button to create your page. 2.2 Modify the pageLayout Region Select your LinesSearchPG in the Structure pane and select the region1 that JDeveloper created for you. Verify and set (if necessary) the following properties: Property ID Region Style AM Definition Window Title Title AutoFooter Value PageLayoutRN pageLayout <yourname>.oracle.apps.demxx.orderentry.server.OrderEntryAM Order Entry Tutorial: Labs <your name> Lines : Search True (This ensures that the standard footer, including the Oracle copyright and privacy notice, render in the page).

Oracle Applications Framework - Practices and Solutions C-179

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:

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)

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).

C-180 Oracle Applications Framework - Practices and Solutions

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

Value PageHelp staticStyledText VARCHAR2 OraInstructionText DEMXX ORDLINES_PAGE_GENERAL

Select your page in either the Structure pane or the Navigator window, right-click and choose Run < file name > from the context menu.

Oracle Applications Framework - Practices and Solutions C-181

Appendix C: Practices and Solutions

3: Configure a Results-Based Search


In this section, you will create a simple "results-based" search by leveraging the OA Framework query region. You will see how to enable the user-personalizable Views panel, the Simple Search panel, and the Advanced Search panel without explicitly creating the UIs for these regions. In the next task, you will change from a "results-based" search to an "auto customization criteria" search so you can take a bit more control of the UI that displays in the Search region. Tip: See the Search topic in Chapter 4 of the OA Framework Developer's Guide for additional information about implementing searching in your pages. The finished region should appear as shown in Figure 3 below when you've completed all the steps in this task.

Figure 3: Task 3-Finished Product

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

Value QueryRN query resultsBasedSearch True True True

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

Appendix C: Practices and Solutions o SuggestedPrice o UnitOfMeasure o TotalPrice

Select the Next button. In the Region Items page, set the ID, Style, and Attribute Set properties as follows

ID OrderId OrderLineNum ProductId GlAccountCcId OrderedQuantity Description SuggestedPrice UnitOfMeasure TotalPrice

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

Click the Finish button to create your data table.

3.3 Set or Verify Your ResultsTable Region Properties Select the ResultsTable region in the Structure pane, and set/verify the following properties:

Property ID Region Style AM Definition

Value ResultsTable table


Make absolutely sure that you have not inadvertently associated an application module here. If you have, please delete it.

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

Lab 8: Lines: Search . Personalization

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

Lab 8: Lines: Search . o Maximum Length to 255

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

Oracle Applications Framework - Practices and Solutions C-187

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.

Oracle Applications Framework - Practices and Solutions C-189

Appendix C: Practices and Solutions

4: Convert your search region to use Auto Customization Criteria


We have to add an LOV to our search region, so, we need to convert our query bean to run in "auto customization criteria mode" (that is, we want to customize our search criteria by adding an LOV). The finished region after Task 4 should appear as shown in Figure 4 below (the LOV icon appears after you finish Task 5).

Figure 4: Task 4-Finished Product

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

Lab 8: Lines: Search . o TotalPrice o GlAccountCcId

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

Property ID Item Style

Value SearchOrdNum messageTextInput

Oracle Applications Framework - Practices and Solutions C-191

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.

Select this item, and set or verify its properties as follows


Property ID Item Style Selective Search Criteria Data Type Maximum Length Prompt CSS Class Length Value SearchProdNum messageTextInput (we will change this to LOV later) True NUMBER 15 Number OraFieldText 15

C-192 Oracle Applications Framework - Practices and Solutions

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.

Oracle Applications Framework - Practices and Solutions C-193

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).

C-194 Oracle Applications Framework - Practices and Solutions

Lab 8: Lines: Search .

5: Adding a List of Values (LOV) to a Field


In this section, you will create a reusable list of values (LOV) that you will then configure for use in the Search page (you will use this same LOV later in the Create page). The finished LOV should appear as shown in Figure 5.

Figure 5a: Product Number LOV Window

Oracle Applications Framework - Practices and Solutions C-195

Appendix C: Practices and Solutions

Figure 5b: Description LOV Window

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,

C-196 Oracle Applications Framework - Practices and Solutions

Lab 8: Lines: Search .


D.SUGGESTED_PRICE FROM DEM_PRODUCTS D ORDER BY PRODUCT_ID, DESCRIPTION

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

ID ProdId Description Uom SugPrice

Prompt Product Number Description UOM Price

Style messageStyledText messageStyledText messageStyledText messageStyledText

Data Type NUMBER VARCHAR2 VARCHAR2 NUMBER

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.

Figure 6: Revised Search Page Finished Product

Oracle Applications Framework - Practices and Solutions C-201

Appendix C: Practices and Solutions

6: Revise the Search Page to include a Goto Order Search button

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:

Property ID Item Style Attribute Set Prompt Additional Text

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.

Oracle Applications Framework - Practices and Solutions C-203

Appendix C: Practices and Solutions

7: Implement the View Object Query


7.1 Add an initQuery( ) Method to Your LinesSearchVOImpl Class This method should take an orderId parameter, set the WHERE clause to ORDER_ID = :1, bind the orderId parameter to the WHERE clause, and execute the query.
import oracle.jbo.domain.Number; import oracle.apps.fnd.framework.OAException; ...

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"); }

setWhereClause(null); setWhereClauseParams(null); setWhereClause("ORDER_ID = :1"); setWhereClauseParam(0,ordNum); executeQuery(); } } // end initQuery() ...

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.

import oracle.apps.fnd.framework.OAException; import oracle.apps.fnd.common.MessageToken; ...

C-204 Oracle Applications Framework - Practices and Solutions

Lab 8: Lines: Search .


/********************************************************************** ******* * Initializes the detail order-lines query. *********************************************************************** ****** */ public void initLinesDetails(String orderNumber) { LinesSearchVOImpl vo = (LinesSearchVOImpl)getLinesSearchVO(); if (vo == null) { MessageToken[] errTokens = { new MessageToken("OBJECT_NAME", "LinesSearchVO") }; throw new OAException("DEMXX", "ORDLINES_OBJECT_NOT_FOUND", errTokens); } vo.initQuery(orderNumber); } // end initLinesDetails()

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

Figure 7a: Configure OrderId Item in OrderDetailsPG as a Drilldown link to LinesSearchPG

Oracle Applications Framework - Practices and Solutions C-205

Appendix C: Practices and Solutions

Figure 7b: LinesSearchPG renders as follows on selecting OrderId

C-206 Oracle Applications Framework - Practices and Solutions

Lab 8: Lines: Search .

8: Implement the Drilldown to the LinesSearchPG


In this section, you will add a link on the OrderId item in the OrderDetailsPG in the previous lab. This link navigates to the LinesSearch page that you just created. 8.1 Configure the OrderId Item as a Link When the user selects an Order Number link, the Lines Search page should display information regarding the corresponding Order. As part of this GET request, we also want to: Add orderNumber parameter to the URL. This parameter value should be sourced from the OrderDetailsVO attributes OrderId. Indicate that the OrderDetailsPG's application module instance should be retained when the LinesSearchPG renders so these pages can share the same root application module. Indicate that breadcrumbs should display in the OrderDetailsPG. To achieve this, select the OrderId item in the OrderDetailsPG and set the Destination URI property to: OA.jsp?page=/<yourname>/oracle/apps/demxx/orderentry/webui/LinesSearchPG &orderNumber={@OrderId} &retainAM=Y&addBreadCrumb=Y Set the CSS Class property to : OraLinkText 8.2 Modify the Controller Logic to Initalize Order Query When Page Renders To automatically query the underlying LinesSearchVO view object when the LinesSearchPG renders, add the following code to the LinesSearchCO.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) {

Oracle Applications Framework - Practices and Solutions C-207

Appendix C: Practices and Solutions


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 lines details. OAApplicationModule am = pageContext.getApplicationModule(webBean); Serializable[] parameters = { orderNumber }; am.invokeMethod("initLinesDetails", parameters); }

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.

You are now finished with this exercise.

C-208 Oracle Applications Framework - Practices and Solutions

Lab 9: Lines: Create .

Lab 9: Lines: Create


Overview In this exercise, we will implement a Create page for the Order Lines and add validation to the OrderLines Button in the Orders Create and Update Pages. The end product of the Lines Create exercise would look like Figure 1 shown below. Warning: This lab assumes that you have completed the Orders Create Exercise and builds on that work. If you have not completed these exercises, please do so before proceeding.

Figure 1: Create Page Finished Product

1: Create a View Object for the Create Page


Step 1.1 Create a LinesDetailsVO View Object (VO) Create a detail-level view object including only those attributes that you need for the Lines create page. This view object is the main view object for your Create page. It should leverage the LinesEO 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 LinesDetailsVO as the view object's name and verify that the Package is <yourname>.oracle.apps.demxx.orderentry.server. Select the Next button. Oracle Applications Framework - Practices and Solutions C-209

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,

C-210 Oracle Applications Framework - Practices and Solutions

Lab 9: Lines: Create .


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 DEM_ORDER_LINES LinesEO

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

Appendix C: Practices and Solutions correct.

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

Lab 9: Lines: Create . Select OK to create the Master-Detail relationship.

Figure 4 : Creating Master-Detail Relationship using View Links

Oracle Applications Framework - Practices and Solutions C-215

Appendix C: Practices and Solutions

2: Build the Create Page


In this section, you will create an order Create page as shown in Figure 1 above. 2.1 Create the LinesCreatePG Page Create a new OA Components page in the <yourname>.oracle.apps.demxx.orderentry.webui package called LinesCreatePG. 2.2 Modify the pageLayout Region Verify and set (if necessary) the following properties for the pageLayout region of your new LinesCreatePG :

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

C-216 Oracle Applications Framework - Practices and Solutions

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:

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 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

Value OrderId messageStyledText NUMBER OrderId Order Number OraDataText

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

Value OrderLineNum messageTextInput yes NUMBER 15 OrderLineNum Line OraFieldText 5

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

Oracle Applications Framework - Practices and Solutions C-219

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

Value Description messageTextInput yes VARCHAR2 255 Description Description OraFieldText

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

Value OrderedQuantity messageTextInput NUMBER 15 OrderedQuantity Quantity Ordered OraFieldText

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

Value UnitOfMeasure messageTextInput True VARCHAR2 25 UnitOfMeasure UOM OraFieldText

Oracle Applications Framework - Practices and Solutions C-221

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

Value SuggestedPrice messageTextInput True NUMBER 25 SuggestedPrice Price OraFieldText

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

C-222 Oracle Applications Framework - Practices and Solutions

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

Property ID Item Style View Attribute Prompt CSS Class

Value DescFlex messageTextInput Attribute2 Order Number OraFieldText

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

Oracle Applications Framework - Practices and Solutions C-223

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

Property Item Style External LOV LOV Mappings

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

For Description Item

Property

Value

C-224 Oracle Applications Framework - Practices and Solutions

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).

Property ID Extends Width

Value RequiredKey /oracle/apps/fnd/framework/webui/OAReqFieldDescRG 100%

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

Appendix C: Practices and Solutions


public void initQuery(Boolean executeQuery) { // Check the executeQuery parameter and explicitly execute // the query if needed. if ((executeQuery != null) && (executeQuery.booleanValue())) { executeQuery(); } }

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.

import import import import import import . . .

oracle.apps.fnd.framework.OAApplicationModule; java.io.Serializable; oracle.apps.fnd.framework.webui.beans.table.OAAdvancedTableBean; oracle.apps.fnd.common.MessageToken; oracle.apps.fnd.framework.OAException; oracle.bali.share.util.BooleanUtils;

public void processRequest(OAPageContext pageContext, OAWebBean webBean)

C-228 Oracle Applications Framework - Practices and Solutions

Lab 9: Lines: Create .


{ super.processRequest(pageContext, webBean); // The special query handling for the table is required per the coding // standards. OAApplicationModule am = pageContext.getApplicationModule(webBean); Boolean executeQuery = BooleanUtils.getBoolean(false); Serializable[] parameters = { executeQuery }; Class[] paramTypes = { Boolean.class }; am.invokeMethod("initTableQuery", parameters, paramTypes); OAAdvancedTableBean table = (OAAdvancedTableBean)webBean.findChildRecursive("LinesAdvTblRN"); if (table == null) { MessageToken[] tokens = { new MessageToken("OBJECT_NAME", "LinesAdvTblRN") }; throw new OAException("DEMXX", "ORDLINES_OBJECT_NOT_FOUND", tokens); } // We pass "true" to the queryData() method because we don't want it to // // // // unconditionally execute the query if the VO has already been queried. In an updateable VO, unconditional query execution would cause the loss of VO state (including user-entered data).

table.queryData(pageContext, true); } // end processRequest()

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) {

Oracle Applications Framework - Practices and Solutions C-229

Appendix C: Practices and Solutions


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"); } } } /***************** Navigate to Lines Create Page ***********************/ // Navigate to the Order Lines 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/or derentry/webui/LinesCreatePG", null, OAWebBeanConstants.KEEP_MENU_CONTEXT, null, null, true, // Retain AM OAWebBeanConstants.ADD_BREAD_CRUMB_YES, OAWebBeanConstants.IGNORE_MESSAGES); }

C-230 Oracle Applications Framework - Practices and Solutions

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.

Fig 5 Lines Create page

Oracle Applications Framework - Practices and Solutions C-231

Appendix C: Practices and Solutions

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.

C-232 Oracle Applications Framework - Practices and Solutions

Lab 9: Lines: Create .


...

/** ********************************************************************* * 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.

if (TransactionUnitHelper.isTransactionUnitInProgress(pageContext, "ordLineCreateTxn", false)) { am.invokeMethod("rollbackOrderLine"); TransactionUnitHelper.endTransactionUnit(pageContext, "ordLineCreateTxn");

Oracle Applications Framework - Practices and Solutions C-233

Appendix C: Practices and Solutions


}

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.

C-234 Oracle Applications Framework - Practices and Solutions

Lab 9: Lines: Create .

4: Implement Order Business Logic


Part 1: Declarative Validation and Initialization

The following table summarizes the order business rules to be implemented in this lab. 4.1 Lay down your Business Needs

Entity Attribute OrderId

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);

OAApplicationModule am = (OAApplicationModule)pageContext.getApplicationModule(webBean); Boolean executeQuery = BooleanUtils.getBoolean(false);

Oracle Applications Framework - Practices and Solutions C-235

Appendix C: Practices and Solutions


Serializable[] parameters = { executeQuery }; Class[] paramTypes = { Boolean.class }; am.invokeMethod("initTableQuery", parameters, paramTypes); OAAdvancedTableBean table = (OAAdvancedTableBean)webBean.findChildRecursive("LinesAdvTblRN"); if (table == null) { MessageToken[] tokens = { new MessageToken("OBJECT_NAME", "LinesAdvTblRN") }; throw new OAException("DEMXX", "ORDLINES_OBJECT_NOT_FOUND", tokens); } // // // // // // We pass "true" to the queryData() method because we don't want it to unconditionally execute the query if the VO has already been queried. In an updateable VO, unconditional query execution would cause the loss of VO state (including user-entered data). See View Objects in Detail -> Initialization guidelines for additional information.

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

C-236 Oracle Applications Framework - Practices and Solutions

Lab 9: Lines: Create .


// // // // more context-specific message telling the user he can't use the browser "Back" button and the "Create" page. Instead, we want to illustrate how to display the Applications standard NAVIGATION ERROR message.

OADialogPage dialogPage = new OADialogPage(NAVIGATION_ERROR); pageContext.redirectToDialogPage(dialogPage); } } } // end processRequest

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. *

Oracle Applications Framework - Practices and Solutions C-237

Appendix C: Practices and Solutions


* Business Rules: * Quantity Ordered should be greater than zero *********************************************************************** ****** **/ protected void validateOrderedQuantity(Number value) { if (value != null) { if (value.intValue()< 0) { throw new OAAttrValException(OAException.TYP_ENTITY_OBJECT, getEntityDef().getFullName(), // EO name getPrimaryKey(), // EO PK "OrderedQuantity", // Attribute Name value, // Attribute value "DEMXX", // Message product short name "ORDLINES_QUANTITY_ORDERED"); // Message name } } }

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().

C-238 Oracle Applications Framework - Practices and Solutions

Lab 9: Lines: Create .

5: Implement the Apply, Cancel and Delete Button Handling


When the user presses the Apply button, you need to commit and navigate to the Lines Search page where you will display a confirmation message. When the user presses the Cancel button, you need to rollback the transaction and navigate to the Lines Search page. 5.1 Add processFormRequest( ) Logic to Your LinesCreateCO Class Add the following code to the LinesCreateCO 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 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.OAException; oracle.apps.fnd.framework.OAViewObject; oracle.apps.fnd.framework.webui.OAWebBeanConstants; oracle.apps.fnd.framework.webui.TransactionUnitHelper; oracle.jbo.Row;

// 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) {

Oracle Applications Framework - Practices and Solutions C-239

Appendix C: Practices and Solutions


// Note that we have to get this value from the VO because the EO will // assemble it during its validation cycle. // For performance reasons, we do not want to do this // on the client so we are illustrating the interface-appropriate // call. If we implement this code in the AM where it belongs, we would // use the other approach. // We need to get a String so we can pass it to the MessageToken // array below. // Note that we are getting this value from the VO row because the item // style is messageStyledText, so the value is not put on the request // like a messaqeTextInput value is. Number orderNumber = (Number)row.getAttribute("OrderId"); String orderNum = String.valueOf(orderNumber.intValue()); MessageToken[] tokens = { new MessageToken("ORD_NUMBER", orderNum)}; OAException confirmMessage = new OAException("DEM966", "ORDLINES_LINES_CREATE_CONFIRM",tokens,OAException.CONFIRMATION, null); // Per the UI guidelines, we want to add the confirmation message at // the top of the search/results page and we want the old search // criteria and results to display. pageContext.putDialogMessage(confirmMessage); } am.invokeMethod("apply"); pageContext.forwardImmediately("OA.jsp?page=/<yourname>/oracle/apps/dem xx/orderentry/webui/LinesSearchPG", null, OAWebBeanConstants.KEEP_MENU_CONTEXT, null, null, true, // retain AM OAWebBeanConstants.ADD_BREAD_CRUMB_NO); } else if (pageContext.getParameter("Cancel") != null) { am.invokeMethod("rollbackOrderLine"); // Indicate that the Create transaction is complete. TransactionUnitHelper.endTransactionUnit(pageContext, "ordLineCreateTxn"); pageContext.forwardImmediately("OA.jsp?page=/<yourname>/oracle/apps/dem xx/orderentry/webui/LinesSearchPG",

C-240 Oracle Applications Framework - Practices and Solutions

Lab 9: Lines: Create .


null, OAWebBeanConstants.KEEP_MENU_CONTEXT, null, null, true, // retain AM OAWebBeanConstants.ADD_BREAD_CRUMB_NO); } }//end processFormRequest()

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);

Oracle Applications Framework - Practices and Solutions C-241

Appendix C: Practices and Solutions


} // end processRequest

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"); } }

Figure 6: Programatically Setting Page Title

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;

C-242 Oracle Applications Framework - Practices and Solutions

Lab 9: Lines: Create .


... /*********************** Handling Delete Button *********************/ if (pageContext.getParameter("Delete") != null) { OAViewObject dbVo =(OAViewObject)am.findViewObject("LinesDetailsVO"); Row row = null; dbVO.reset(); while ((row = dbVO.next()) != null) { String rowSelect = (String) row.getAttribute("SelectRow"); if (rowSelect != null && rowSelect.equals("Y")) { dbVO.removeCurrentRow(); } OAApplicationModule am = (OAApplicationModule)pageContext.getApplicationModule(webBean); am.invokeMethod("apply"); } } Now add the handleSelectionRemove() method which implements the delete

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.

Oracle Applications Framework - Practices and Solutions C-243

Appendix C: Practices and Solutions

Figure 8: Lines Search Page with Create Confirmation Message

You are now finished with this exercise.

C-244 Oracle Applications Framework - Practices and Solutions

Lab 10: Lines: Partial Page Rendering (PPR) .

Lab 10: Lines: Partial Page Rendering (PPR)


Overview In this exercise, we will modify the Create Lines page to implement a dynamic user interface using partial page rendering (PPR) for the changes in Ordered Quantity. When the user enters a value for the Quantity Ordered we need change the value of Total Price column as a product of Suggested Price (which is predetermined based on the product chosen) and the Ordered Quantity which is entered on run-time based on customers need. Warning: This lab assumes that you have completed the Create Lines Lab, and builds on that work. If you have not completed this exercise, please do so before proceeding.

Figure 1: Create Page Finished Product initially renders as follows

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

Oracle Applications Framework - Practices and Solutions C-245

Appendix C: Practices and Solutions

1: Create OrderEntryPVO View Object Attributes


To enable PPR in this page, you must create an OA Framework standard applications properties view object (PVO) including a transient attribute for tracking the state of the Read Only property for the PPR fields. This view object will ultimately include a single row which you will initialize and update as the user interacts with the page (you will see a bit later how the PPR field binds to this view object attribute to determine whether it should be read only or not, and you will configure the OrderedQuantity field to fire PPR events when its value changes). 1.1 Create the Transient Attributes in OrderEntryPVO View Object In the <yourname>.oracle.apps.demxx.orderentry.server package, select your OrderEntryPVO view object, right-click and select Edit OrderEntryPVO. In the Attributes page, select the New... button and create a transient attribute with the following properties: o Name: totalPrice o Type: Boolean o Updateable: Always In the Attributes page, select the New... button and create a transient attribute with the following properties: o Name: suggestedPrice o Type: Boolean o Updateable: Always In the Attributes page, select the New... button and create a transient attribute with the following properties: o Name: uom o Type: Boolean o Updateable: Always You need not generate any Java files for this PVO.

2: Configure OrderedQuantity to Fire a PPR Event


Configure the OrdereQuantity item to fire a PPR action. They are configured in the following way: 2.1 Set the PPR Properties for Quantity Ordered field C-246 Oracle Applications Framework - Practices and Solutions

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

Value True True FirePartialAction priceEvent True

Oracle Applications Framework - Practices and Solutions C-247

Appendix C: Practices and Solutions

3: Configure Items to React to PPR Events


Set the value of the Disabled property to the following SPEL ("Simplest Possible Expression Language") syntax indicating that the property value should be obtained from the OrderEntryPVO instance's transient attributes. 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.

For TotalPrice Item Property Disabled Value ${oa.OrderEntryPVO.totalPrice}

For SuggestedPrice Item Property Disabled Value ${oa.OrderEntryPVO.suggestedPrice}

For UnitOfMeasure Item Property Disabled Value ${oa.OrderEntryPVO.uom}

C-248 Oracle Applications Framework - Practices and Solutions

Lab 10: Lines: Partial Page Rendering (PPR) .

4: Implement PPR Event Handling


4.1 Add PPR Logic to the Handle the PPR Action in OrderEntryAM Now, we need to add the code to handle the PPR change events and initialize the OrderEntryPVO. Your controller code will invoke the following method whenever a field's PPR event is fired. Add the following code to your OrderEntryAMImpl class. Note: In this case, a transient property set to Boolean.FALSE indicates that the SPEL associated field is enabled and vice versa.
import oracle.jbo.Row; .. public void changeTotalPrice(String selectedRowRef) { OAViewObject dbVO = (OAViewObject)findViewObject("LinesDetailsVO"); OARow dbRow = (OARow)dbVO.getCurrentRow(); // handle to CurrentRow enableTotalPrice(); Row row = (Row)findRowByRef(selectedRowRef); if(row != null) { Number num1 = (Number)row.getAttribute("OrderedQuantity"); Number num2 = (Number) row.getAttribute("SuggestedPrice");

/******************* 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");

Oracle Applications Framework - Practices and Solutions C-249

Appendix C: Practices and Solutions


if (vo != null) { if (vo.getFetchedRowCount() == 0) { vo.executeQuery(); } OARow row = (OARow)vo.first(); if(row!=null) { row.setAttribute("totalPrice", Boolean.FALSE); row.setAttribute("suggestedPrice", Boolean.FALSE); row.setAttribute("uom", Boolean.FALSE); } } } /** ******************************************************************* * PPR for TotalPrice, Suggested Price and Unit of Measure Disable ******************************************************************* */ public void disableTotalPrice() { OAViewObject vo = (OAViewObject)findViewObject("OrderEntryPVO"); if (vo != null) { if (vo.getFetchedRowCount() == 0) { vo.executeQuery(); } OARow row = (OARow)vo.first(); if(row!=null) { row.setAttribute("totalPrice", Boolean.TRUE); row.setAttribute("suggestedPrice", Boolean.TRUE); row.setAttribute("uom", Boolean.TRUE); } } }

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()

C-250 Oracle Applications Framework - Practices and Solutions

Lab 10: Lines: Partial Page Rendering (PPR) .


{ 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); // For Order Lines row.setAttribute("totalPrice", Boolean.FALSE); row.setAttribute("suggestedPrice", Boolean.FALSE); row.setAttribute("uom", Boolean.FALSE); } } } // end 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");

Oracle Applications Framework - Practices and Solutions C-251

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.

You are now finished with this exercise.

C-252 Oracle Applications Framework - Practices and Solutions

Lab 11: Lines: Layout .

Lab 11: Lines: Layout


Overview In this exercise, you will be implementing sub-tabs for the Order Lines Page. Warning: This lab assumes that you have completed the Create Lines Exercise and builds on this work. If you have not completed this exercise, please do so before proceeding.

1: Modify your Lines Create Page Layout


1.1 Create the Sub-Tab Layout Region Select LinesCreatePG in the System Navigator pane. Select PageLayoutRN in the Structure pane, right-click and select New > Region from context menu. Set the ID for the new region to SubTabLayoutRN Select Region Style to subTabLayout. Select SubTabLayoutRN in the Structure pane, right-click and select New > Region Set the ID for the new region to TabOneRN Select SubTabLayoutRN in the Structure pane, right-click and select New > Region Set the ID for the new region to TabTwoRN. Select the AdvTblHdrRN hideShowHeader region and drag-and-drop it to TabOneRN as child. Select the AdvTblHdrRN in the Structure pane, right-click and select Copy. Select the TabTwoRN in the Structure pane, right-click and select Paste.

Select the AdvTblHdrRN in TabOneRN, expand the LinesAdvTblRN Select the KeyFlexCol column, right click and select Delete.

Oracle Applications Framework - Practices and Solutions C-253

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

Property ID DataType View Attribute Prompt

Value SuggPriceFV NUMBER SuggestedPrice Suggested Price

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

Property ID View Attribute Prompt

Value UomFV UnitOfMeasure UOM

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.

Property ID Item Style Text

Value QuantityLink link Quantity

Select the subTabBar1 which appears, right click and select New > link Set the following properties for item1.

Property ID Item Style Text

Value AccountsLink link Account

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

C-256 Oracle Applications Framework - Practices and Solutions

Lab 11: Lines: Layout .


OAAdvancedTableBean tableOne = (OAAdvancedTableBean)webBean.findChildRecursive("LinesAdvTblRN1"); if (tableOne == null) { MessageToken[] tokens = { new MessageToken("OBJECT_NAME", "LinesAdvTblRN1")}; throw new OAException("DEMXX", "ORDLINES_OBJECT_NOT_FOUND", tokens); } tableOne.queryData(pageContext, true); ...

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.

Oracle Applications Framework - Practices and Solutions C-257

Appendix C: Practices and Solutions

Fig 1 : Revised Lines Create Page showing Quantity subtab

Fig 2 : Revised Lines Create Page showing Accounts subtab

You are now finished with this exercise.

C-258 Oracle Applications Framework - Practices and Solutions

Lab 12: Lines: Update .

Lab 12: Lines: Update


Overview In this exercise, you will be implementing an order lines update transaction. Warning: This lab assumes that you have completed the Create Lines Exercise and builds on this work. If you have not completed this exercise, please do so before proceeding.

1: Make a Copy of Your LinesCreatePG


For the most part, a single page update and insert page are identical. Since you already created an insert page, the quickest way to implement a new corresponding update page with the same items and underlying view object is to simply copy the page definition and then make any necessary modifications. 1.1 Copy LinesCreatePG on the File System Since the JDeveloper OA Extension does not yet support the ability to "save as" or copy/paste a page document, you need to use the file system for the following task. Save all your work and close JDeveloper. Select your LinesCreatePG.xml document in Windows Explorer, right-click and select Copy. Select the webui directory node, right-click and select Paste. Your new file will be named Copy of LinesCreatePG. Select the new file in Explorer, right-click and select Rename to LinesUpdatePG. Start JDeveloper, expand the OA Components category in your project, and select the Add File toolbar icon to open the Add Files or Directories to <your project name> dialog. Locate your LinesUpdatePG and select OK to add this file to your project. 1.2 Copy and Change the Create Page Controller We need to change the controller associated with your new update page. Open your LinesCreateCO controller in JDeveloper and select File > Save As from the main menu. Name your new file LinesUpdateCO . Change the class name in your new LinesCreateCO file to LinesUpdateCO . Oracle Applications Framework - Practices and Solutions C-259

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.

C-260 Oracle Applications Framework - Practices and Solutions

Lab 12: Lines: Update .

2: Modify Search and Update Page Controllers


2.1 Modify the OrderUpdateCO 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, "ordLineCreateTxn", false)) { am.invokeMethod("rollbackOrderLines"); TransactionUnitHelper.endTransactionUnit(pageContext, "ordLineCreateTxn"); } else if (TransactionUnitHelper.isTransactionUnitInProgress(pageContext, "ordLineUpdateTxn", false)) { am.invokeMethod("rollbackOrderLines"); TransactionUnitHelper.endTransactionUnit(pageContext, "ordLineUpdateTxn"); }

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:

import import import import import ...

oracle.apps.fnd.framework.webui.TransactionUnitHelper; java.io.serializable; oracle.apps.fnd.common.MessageToken; oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean; oracle.apps.fnd.framework.webui.beans.OAMessageStyledTextBean;

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);

Oracle Applications Framework - Practices and Solutions C-261

Appendix C: Practices and Solutions


OAAdvancedTableBean table = (OAAdvancedTableBean)webBean.findChildRecursive("LinesAdvTblRN"); if (table == null) { MessageToken[] tokens = { new MessageToken("OBJECT_NAME", "LinesAdvTblRN") }; throw new OAException("DEMXX", "ORDLINES_OBJECT_NOT_FOUND", tokens); } // // // // We pass "true" to the queryData() method because we don't want it to unconditionally execute the query if the VO has already been queried. In an updateable VO, unconditional query execution would cause the loss of VO state (including user-entered data).

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.

((OAPageLayoutBean)webBean).setTitle(pageHeaderText); am.invokeMethod("init"); } // end processRequest

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"); }

Oracle Applications Framework - Practices and Solutions C-263

Appendix C: Practices and Solutions


} } /***************** Navigate to Lines Create Page ***********************/ pageContext.setForwardURL("OA.jsp?page=/<yourname>/oracle/apps/demxx/or derentry/webui/LinesUpdatePG", null, OAWebBeanConstants.KEEP_MENU_CONTEXT, null, null, true, // Retain AM OAWebBeanConstants.ADD_BREAD_CRUMB_YES, OAWebBeanConstants.IGNORE_MESSAGES); }

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.

You are now finished with this exercise.

C-264 Oracle Applications Framework - Practices and Solutions

Lab 13: Flexfields .

Lab 13: Flexfields


Overview

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.

Fig: Orders DFF Field Customer Contact Name included

Fig: Lines DFF Field Additional Preference included

Oracle Applications Framework - Practices and Solutions C-265

Appendix C: Practices and Solutions

1: Implement your Orders DFF


Before we implement the Flexfield, we need to ensure that the flexfields have already been registered in Oracle Apps. Logon to Oracle Apps and choose Application Developer responsibility. Select Flexfield : Descriptive > Register Query for DEM_ORDERS in the name and make sure it exists. If it does not exist, register your own DEM_ORDERS descriptive flexfield (DFF) with your custom application DEMxx. (You may refer Appendix A for further help) Similarly ensure DEM_ORDER_LINES is present. If not present, you may have to register it to your custom application DEMxx before you proceed. 1.1 Setup your Orders Flexfield in Orders Create and Update Pages Select your OrderCreatePG in the System Navigator pane. Select FooterRN in the Structure Pane, right-click and select New > messageLayout Set the ID for messageLayout1 to DescFlexLayout Select DescFlexLayout in the Structure Pane, right-click and select New > Item Set the following properties for the new item.

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.

Oracle Applications Framework - Practices and Solutions C-267

Appendix C: Practices and Solutions

2: Implement your Lines DFF


In a similar way, we can implement the DFF for Order Lines in the Create and Update pages. 2.1 Setup your Order Lines Flexfield in Lines Create and Update Pages Select your LinesCreatePG in the System Navigator pane. Select DescFlex (under DescFlexCol in TabOneRN ) in Structure Pane. Set the following properties for this item. Property ID Item Style Prompt CSS Class Appl Short Name Name Type Display Context Field Value DescFlex Flex Descriptive Flexfield OraFieldText DEM (or whichever application DFF is registered to) DEM_ORDER_LINES Descriptive False

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.

C-268 Oracle Applications Framework - Practices and Solutions

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.

You are now finished with this exercise.

Oracle Applications Framework - Practices and Solutions C-269

Appendix C: Practices and Solutions

Lab 14: Deploying the project in Oracle Applications


Zip your class files present under <yourname> folder in <JDEV_USER_HOME>/myclasses. Transfer the <yourname>.zip file in binary mode to the UNIX server to any temporary location. Eg: /d01/cust_top Now add the classpath entry in jserv.properties as follows o cd $IAS_ORACLE_HOME/Apache/Jserv/etc o Open the file jserv.properties o Navigate to wrapper.classpath and add the absolute path of the zip file in the temporary folder. Eg: wrapper.classpath=/d01/cust_top/<yourname>.zip Do not alter anything else. Save and exit. Bounce the Apache. o cd $OAD_TOP/admin/scripts/*/ o adapcctl.sh stop o adapcctl.sh start In Oracle Apps, create your Function to call the OA Page. o Type : SSWA JSP o HTML
OA.jsp?page=/<yourname>/oracle/apps/demxx/orderentry/webui/OrderSearchPG

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.

C-270 Oracle Applications Framework - Practices and Solutions

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); }

C-272 Oracle Applications Framework - Practices and Solutions

Lab 15: Testing and Reviewing Your Pages .

Lab 15: Testing and Reviewing Your Pages


1. Test your form for about fifteen minutes to make sure that your form is built to specifications and that your form features all work correctly. Test for (at least): Querying master and details works correctly. Inserts work correctly Updates work correctly (update only your own inserted records) Deletes of master and/or details work correctly (update only your own inserted records) LOVs all work and appear correctly Order ID populates on insert Tabbed regions work correctly Opening and closing of windows works correctly Flexfields work correctly Messages, validation logic on date fields work correctly Find window on Orders works correctly Function security works correctly

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 ________________________________________________

Oracle Applications Framework - Practices and Solutions C-273

You might also like