Professional Documents
Culture Documents
u se
e to
n s
i ce
b l el
a f er
Oracle Fusion s
an Middleware
- t r
on ฺApplications with
11g: nBuild
ADF
s a I ide
) a
h t Gu
i l ฺ comtudeActivity
n Guide
g ma is S
o@ th
ฺvin
C (ac
d A
n o
Vi
D53979GC20
Edition 2.0
July 2010
D68162
Copyright © 2010, Oracle and/or its affiliates. All rights reserved.
Disclaimer
This document contains proprietary information and is protected by copyright and other intellectual property laws. You may copy and
print this document solely for your own use in an Oracle training course. The document may not be modified or altered in any way.
Except where your use constitutes "fair use" under copyright law, you may not use, share, download, upload, copy, print, display,
perform, reproduce, publish, license, post, transmit, or distribute this document in whole or in part without the express authorization
of Oracle.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2011, Oracle and/or its affiliatesฺ
The information contained in this document is subject to change without notice. If you find any problems in the document, please
report them in writing to: Oracle University, 500 Oracle Parkway, Redwood Shores, California 94065 USA. This document is not
warranted to be error-free.
If this documentation is delivered to the United States Government or anyone using the documentation on behalf of the United
States Government, the following notice is applicable:
fe ra
a n s
Authors
n - tr
Kate Heap, Patrice Daux
a no eฺ
h a s uid
m) ent G
Technical Contributors and Reviewers
Joe Greenwald, Glenn Maslen ฺco
a il Stud
g m is
o@ using:
This book was published th Oracle Tutor
v i n
( acฺ
d AC
Vi no
Table of Contents
Practices for Lesson 2: Getting Started with JDeveloper – Discovering the Shopping Cart Application ........2-3
Practice 2-1: Setting IDE Preferences............................................................................................................2-4
Practice 2-2: Creating a JDeveloper Application and Project .........................................................................2-6
Practice 2-3: Initializing the Project and Creating a Database Connection ....................................................2-8
Practice 2-4: Examining the Course Application ............................................................................................2-10
r a
Practice 4-1: Creating Read-Only View Objects.............................................................................................4-4
fe
a n s
Practice 4-2: Creating Multiple Read-Only View Objects at Once ..................................................................4-7
n - tr
Practice 4-3: Creating Entity Objects Based on Database Views...................................................................4-9
a no eฺ
Practice 4-4: Creating Multiple Entity Objects at Once...................................................................................4-11
Practice 4-5: Creating Associations ...............................................................................................................4-12
h a s uid
Practice 4-6: Creating Updatable View Objects .............................................................................................4-14
m ) nt G
Practice 4-7: Refactoring Associations and Links ..........................................................................................4-17
l ฺ o
c tude
a i
Practices for Lesson 5 ........................................................................................................
S .............................5-1
g
Practices for Lesson 5: Exposing mData tois
Clients...........................................................................................5-3
Practice 5-1: Creatingoan@ApplicationtModule h to Display Categories .............................................................5-4
i n
( a c v an Application Module to Display the Shopping Cart ..................................................5-5
Practice 5-2: ฺCreating
Oracle Fusion Middleware 11g: Build Applications with ADF I Table of Contents
i
Practices for Lesson 8 .....................................................................................................................................8-1
Practices for Lesson 8: Validating User Input ................................................................................................8-3
Practice 8-1: Adding Declarative Validation: List Validator .............................................................................8-4
Practice 8 -2: Adding Declarative Validation: Unique Key Validator ...............................................................8-7
Practice 8-3: Adding Programmatic Validation: Method Validator ..................................................................8-9
Practice 8-4: Creating and Using a Domain for Validation .............................................................................8-12
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2011, Oracle and/or its affiliatesฺ
n - tr
Practice 11-4: Renaming a Page ...................................................................................................................11-13
a no eฺ
Practices for Lesson 12 ....................................................................................................... ............................12-1
ha t Guis d
Practices for Lesson 12: Planning the User Interface ....................................................................................12-3
Practice 12-1: Creating an Unbounded Task Flow ) .........................................................................................12-4
Practice 12-2: Creating Bounded Task Flows
l ฺ c om e n
................................................................................................12-10
d
Practice 12-3: Extracting Part of aa i tu
g m Task Flow s
................................................................................................12-16
S
Practices for Lesson 13@
o thi
.......................................................................................................
............................13-1
i n
cฺvCreating a Table with Row Selection ......................................................................................13-4
Practices for Lesson 13: Adding Functionality to Pages ................................................................................13-3
Practice a
13-1:
(
C 13-2: Creating a Search Page ..........................................................................................................13-10
d APractice
Vi no Practice 13-3: Creating a Read-Only Form ....................................................................................................13-16
Practice 13-4: Creating a Sortable Table .......................................................................................................13-18
Practice 13-5: Creating a Category Tree ........................................................................................................13-20
Practice 13-6: Creating LOVs ........................................................................................................................13-24
Practice 13-7: Setting Up the UI Project for Internationalization ....................................................................13-28
Oracle Fusion Middleware 11g: Build Applications with ADF I Table of Contents
ii
Practice 15-4: Creating New Pages with Required Layout .............................................................................15-12
Practice 15-5: Setting Conditional Display .....................................................................................................15-20
Practice 15-6: Implement PPR to Coordinate Products Display with Selected Subcategory .........................15-25
Practice 16-2: Creating a Page Template and Applying It to Existing Pages .................................................16-7
Practice 16-3: Creating a Page Template and Applying It to a New Page .....................................................16-13
Practice 16-4: Using Bounded Task Flows as a Region on a Page ...............................................................16-20
r a ble
Practices for Lesson 18: Responding to Application Events ..........................................................................18-3
Practice 18-1: Defining Task Flow Parameters ..............................................................................................18-4
s fe
Practice 18-2: Creating a Helper Method to Evaluate EL ...............................................................................18-5
n
n - tra
Practice 18-3: Creating the Producer (Payload) Method ................................................................................18-9
a no eฺ
Practice 18-4: Initiating the Contextual Event ................................................................................................18-12
Practice 18-5: Creating the Consumer (Handler) Method ..............................................................................18-14
h a s uid
Practice 18-6: Mapping the Contextual Event ................................................................................................18-16
Practice 18-7: Passing Values Through Region m Parameters
G
) nt.........................................................................18-19
Practice 18-8: Modifying the JSF LifeilCycle
o
ฺc (Optional e
dExercise) ...................................................................18-21
a t u
g m is S
Practices for Lesson 19 ...................................................................................................................................19-1
Practices for Lessono @ t h
ฺ v in 19:theImplementing Transactional Capabilities ................................................................19-3
(
Practice
c Updating, Deleting, and Displaying
Practice 19-1:
a19-2: Saving Shopping Cart .......................................................................................................19-4
Details of Shopping Cart Items ........................................19-5
C
n o d APractice 19-3: Controlling Transactions in the CheckoutFlow ........................................................................19-12
V i Practice 19-4: Adding CRUD Functionality for Suppliers (Optional Exercise) ................................................19-13
Oracle Fusion Middleware 11g: Build Applications with ADF I Table of Contents
iii
Practices for Appendix B ................................................................................................................................22-1
Practices for Appendix B: Deploying ADF BC Applications ............................................................................22-3
Practice B-1: Creating Deployment Profiles ...................................................................................................22-4
Practice B-2: Using a WebLogic Server Data Source ....................................................................................22-6
Practice B-3: Creating an Application Server Connection ..............................................................................22-9
Practice B-4: Deploying the Application from JDeveloper ..............................................................................22-10
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2011, Oracle and/or its affiliatesฺ
Practice B-5: Deploying the Application from the WebLogic Server Administration Console .........................22-12
u se
e to
n s
i ce
b l el
fe r a
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
Oracle Fusion Middleware 11g: Build Applications with ADF I Table of Contents
iv
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2011, Oracle and/or its affiliatesฺ
u se
e to
n s
i ce
b l el
f er a
Practicestfor s
anLesson 1
n - r
Chaptern1o
s a ideฺ
) a
h t Gu
i l ฺ comtuden
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
f er a
Practicestfor s
anLesson 2
n - r
Chaptern2o
s a ideฺ
) a
h t Gu
i l ฺ comtuden
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
JDeveloper application, project, and database connection. You then view the course application
in a browser and identify the functionality of the pages.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
b. In the Select Role dialog box, select the Default Role option and click OK.
c. In the Migrate User Settings dialog box, click No.
d. JDeveloper starts by displaying the Tip of the Day. Deselect the “Show tips at
startup” check box, and then click Close.
e. Close the Start page by clicking the X at the right of its tab. (The X is not visible until
you position the cursor over the tab.)
2. Set the global naming preferences for your ADF BC objects. Entity objects, view objects,
and application modules should, by default, have the suffixes EO, VO, and AM, u se
respectively, and should be created in the entity, uiview, and module packages, e to
n s
respectively.
i ce
a. From the JDeveloper menu, select Tools > Preferences > Business Components >
b l el
Object Naming.
fe ra
b. In the dialog box, set suffixes as follows:
a n s
Entity n - tr
no eฺ
EO
View Object VOa
h a s uid
Application Module ) AM G
ฺ c o m
d e nt
m ail Stu
o@g this
c ฺ vin
( a
A C
n o d
V i
c. Select Packages in the list at the left and set the following values:
Entity entity
View Object uiview
Application Module module
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
d. Click OK. a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
4) Click o @
Next. th
a. i n
ฺv “Name your project” page of the wizard:
On the
(a c
1) Enter StorefrontModel as the project name.
A C
n o d 2) On the Project Technologies tab, shuttle ADF Business Components and
Vi Database (Offline) from the Available list to the Selected list. (This also selects
the Java technology.)
3) Click Finish.
b. Note that the Application Navigator displays your application and project.
c. Also, note that the application overview page, Storefront Overview, is open in the
editor. This page enables you to see all the aspects of your application at a glance, to
obtain related help, and to create new objects. You can spend some time exploring this
overview if you want to, but it is not used in these practices.
Copyright © 2010, Oracle and/or its affiliates. All rights reserved.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
1. Initialize the StorefrontModel project for business components. This requires a database
connection, so create that as part of this initialization.
a. Double-click the StorefrontModel project (or right-click it and select Project
Properties).
b. In the Project Properties dialog box, select Business Components from the tree at the
left.
c. In the Business Components panel, select the Initialize Project for Business
Components check box.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
d. Click Create a new database connection no to the ฺright of the Connection field.
s abox:uid
e
e. a
In the Create Database Connection dialog
h tG
1) Supply the information inm the)table below.
Connection Namei l ฺ co tuden FOD
m a S
g
Connection Type this
o @ Oracle (JDBC)
ฺ in
vUsername fod (or follow the instructions given by
( a c your instructor if you are using a shared
A C database)
n o d
Vi Password fusion
Save Password Select the check box.
2) In the lower half of the page, Oracle (JDBC) Settings, leave the Driver field at its
default, thin, and enter the Host Name, JDBC Port, and SID as given to you by the
instructor if using a shared database, or localhost, 1521, and XE if using a local
XE database.
3) Click Test Connection. You should see that the Status box displays the word
Success!.
f. Click OK to dismiss the Create Database Connection dialog box and return to the
Business Components page of the Project Properties dialog box.
g. Click OK to set the project properties and dismiss the Project Properties dialog box. u se
e to
h. Click Save All to save your work. You should get into the habit of frequently n s
i ce
saving your work.
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
OR if there is an open application, you can invoke the drop-down application
l i ce list by
Navigator, and then selecting Open Application… r a ble
clicking the down arrow at the right of the application name in the Application
n s fe
n - tra
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
i n
v Open on the JDeveloper menu toolbar…
OR ฺclick
C (ac
d A
n o
Vi
OR select File > Open from the JDeveloper main menu.
b. When you select to open a new application, a file dialog box enables you to navigate to
the directory where the application resides:
1) Navigate to your course’s \Labs directory and open the Storefront-
CompletedApp folder.
2) Select Storefront-CompletedApp.jws and click Open.
Copyright © 2010, Oracle and/or its affiliates. All rights reserved.
step 1(e)).
e. Test the connection, and if successful, click OK.
f. Click OK to close the Project Properties Editor and save the settings.
5. To run the application, in the adfc-config diagram, right-click the
FODShoppingDashboard view and select Run. Test the functionality of the shopping
application.
a. JDeveloper starts an integrated Oracle WebLogic Server, deploys the application to it,
and runs the requested page in a browser. A tree of categories appears at the left, with u se
a table of categories and descriptions at the right. In the tree, expand the Media e to
category and click the Music subcategory. n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
b. A list of Music h
o@productstappears in the right panel. Note that there are breadcrumbs
alongฺ v i
then top of the table that enable you to navigate to the Media subcategory, or to
a c
(the main-level list of categories if you click Store. For now, click the name of one of
A C the products.
n o d
Vi
d. On the Search page, enter Pla in the ProductName field and click Search. A list of u se
products beginning with Pla is returned.
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
e. g maPortable
Click the Playstation i s Slink to display details about this product.
o@ t h
ฺv i n
C (ac
d A
n o
Vi
g. The shopping cart is displayed. It is populated with the shopping cart items of a default
user, and the Playstation Portable has been added. Resize the right panel of the page
so that the line total is visible, and then change the quantity of the Playstation Portable
to 2. Click Update to show the updated line total.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
h. With the Playstation Portable selected, click
o toฺ remove it from your cart.
nDelete
s a i d e
a
) h nt G u
m
co tude
i l ฺ
g ma is S
o@ th
ฺv i n
(ac
d AC
Vi no i. Click Details to display details about the selected product in a separate pop-up
window.
j. Click OK to close the pop-up window, and then click Checkout to begin the checkout
process.
Copyright © 2010, Oracle and/or its affiliates. All rights reserved.
u se
e to
n s
l. ce to
The second page of the checkout process displays the billing information.liNavigate
n s fe
n - tra
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
ฺv i n
C (ac
d A
n o
Vi
and the billing department, and sending an email confirmation to the customer. This
functionality is outside the scope of the course application.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
6. Test the functionality of a i S
g mmanaging i s suppliers.
d. The new row appears at the top of the list, with a supplier ID that is automatically
assigned. Click Delete to delete the supplier.
u se
e to
n s
i ce
b l el
fe ra
a n s
e. - tr
Click the SupplierId of one of the suppliers in the list.
n
f.
a no eฺ
On the Update Supplier page, change the Status of the supplier and click Save.
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d g. The supplier is shown in the list with the updated status.
V i
u se
e to
j. The application is undeployed when the log window displays the message: [Application n s
i ce
Storefront-CompletedApp stopped and undeployed from Server Instance Instance
IntegratedWebLogicServer]. b l el
7. Close the Storefront-CompletedApp application. You should continue to work in the fe ra
Storefront application that you created. a n s
n - tr
a. Invoke the application menu by clicking the right-most down arrow at the top of the
Application Navigator. a no eฺ
a
b. Select Close Application from the IDE.
h s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
f er a
Practicestfor s
anLesson 3
n - r
Chaptern3o
s a ideฺ
) a
h t Gu
i l ฺ comtuden
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
Components.
In this practice, you create a business model by using the wizards that are built into JDeveloper.
You see how to build a default model without any coding. In subsequent lessons and practices,
you learn to build and customize components to meet your specific application requirements.
If you successfully completed all sections of the previous practice, you can continue working in
the same project. However, if you prefer to start with a clean application that contains everything
completed up to the start of this lesson, open Storefront-03.jws and edit the database
information as described in step 4 of Practice 2-4.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
b. Select Business Tier > ADF Business Components in the Categories list.
c. Select Business Components from Tables in the Items list.
d. Click OK.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
2. In the “Create Business Components from Tables” Wizard, create entity objects for the
ORDERS, ORDER_ITEMS, and PERSONS tables. Name them OrderEO, OrderItemEO, and
PersonEO.
a. On the Entity Objects page of the wizard, ensure that the schema from the connection
that you created previously is the selected schema.
b. Ensure that the package name is oracle.fod.storefront.entity.
c. Enter ORD in the Name Filter field. Click Query to see the available tables (ORDERS
and ORDER_ITEMS).
A C
n o d
Vi b. Ctrl-click to select the OrderEO and OrderItemEO entities.
u se
e to
f. Click Next.
n s
g. The next page is for creating read-only view objects. These are based on SQL queries i ce
rather than on entity objects. For now, you will not create read-only VOs, so click Next. b l el
4. Continuing in the “Create Business Components from Tables” Wizard, create an applicationfe ra
n
module to provide access to your components. You will later create application modules
a s
- tr
that are customized for your application, but you can use a default application module for
n
no eฺ
testing your components. Create an application module named TestAM in the
a
oracle.fod.storefront.test package.
h a s uid
a.
check box is selected. ฺco
m ent G ensure that the Application Module
On the Application Module page )of the wizard,
d AC
i n o
V
d. Click Next.
5. Complete the wizard to finish creating the business components. Do not create a business
components diagram.
a. On the Diagram page of the wizard, ensure that the Business Components Diagram
check box is not selected.
b. Click Next.
u se
e to
d. Click Finish to create the business components. This may take a few moments. n s
i ce
e. Click Save All to save your work.
b l el
f. The StorefrontModel project in the Applications Navigator should look like this:
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
Note that the wizard created not only EOs, VOs, and an AM, but also two associations
and a view link based on the foreign key relationships that are defined in the database.
b. Click the Attributes tab or panel to see the attributes. From this view, you can double-
click any of the attributes to open the Attribute Editor.
c. Each of the other panels (General, Business Rules, Java, Business Events, and View
Accessors) shows different aspects of the OrderEO entity. Click and examine each
panel.
d. Click the Source tab at the bottom of the editor to view and examine the XML source.
2. Test the default components by running the application module in the Business
Components Browser.
u se
a. In the Application Navigator, right-click the application module (TestAM) in the
e to
oracle.fod.storefront.test package and select Run.
n s
b. The Business Components Browser may take a few minutes to appear, and l i citemay
appear behind other windows. You can click its icon bleto display it.
on the taskbar
r a
n s fe can be in a
The Browser should initially look similar to the following (the objects
different order):
n - tra
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
ฺv i n
C (ac
d A
n o
Vi c. Under the ShoppingCart1 node, double-click the OrderItemsOrdersFkLink1 to open
a page that shows the order items that belong to an order. Because this is a shopping
application, an order is contained in a shopping cart and order items are referred to as
shopping cart items.
u se
d. In the top portion of the page, click Move to the next row to navigate through rowsto
in the Orders view. Note that the order items change as you move to a new order. n s e
e. Open the other views and examine the contents as you choose. l i ce
f. When you have finished, close the Business Components Browser.
r a ble
n s fe
n - tra
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
ฺv i n
C (ac
d A
n o
Vi
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
f er a
Practicestfor s
anLesson 4
n - r
Chaptern4o
s a ideฺ
) a
h t Gu
i l ฺ comtuden
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
Now you begin to create components that are more customized for your application. First you
determine the LOVs that your application requires, and you create read-only view objects to
support those LOVs. Next you create entity objects for tables that the application will update,
and you also create updatable view objects based on these. You also create and refactor
associations and view links. For now, you place all of the view objects and links in the TestAM
application module so that you can test them; in the next set of practices, you create custom
application modules that are designed for your application.
If you successfully completed all sections of the previous practice, you can continue working in
u se
the same project. However, if you prefer to start with a clean application that contains everything
e to
completed up to the start of this lesson, open Storefront-04.jws and edit the database
n s
information as described in step 4 of Practice 2-4. i ce
This practice contains some optional steps that are similar to steps already done. If you want to b l el
build the entire application yourself, you can complete the optional steps. However, in the fe ra
n s
interest of time, you may want to skip them. If you do so, you must begin the practices for the
a
- tr
next lesson by opening the starter application for that lesson.
n
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
• Create View Object Wizard: Creates view objects individually; you must write the query
• Business Components from Tables Wizard: Creates multiple view objects at once; you
select the table for the query that is automatically generated
1. Create a single read-only view object to query the LOOKUP_CODES table by using a bind
variable for LOOKUP_TYPE. Name the view object LookupCodeVVO. Create it in the
oracle.fod.storefront.view package. Put the view object in your TestAM
application module. Use the following query statement for the VO: (You can copy the code
from LookupCodes.txt in the \files subdirectory of your \labs directory for this u se
course.) e to
n s
i ce
el
SELECT
LOOKUP_CODES.LOOKUP_TYPE LOOKUP_TYPE,
a b l
LOOKUP_CODES.LOOKUP_CODE LOOKUP_CODE, fe r
a n s
LOOKUP_CODES.MEANING MEANING,
n - tr
no eฺ
LOOKUP_CODES.DESCRIPTION DESCRIPTION,
a
LOOKUP_CODES.LANGUAGE LANGUAGE
h a s uid
FROM
m ) nt G
LOOKUP_CODES
l ฺ o
c tude
i
WHERE
g ma is S
@ th
LOOKUP_CODES.LANGUAGE = SYS_CONTEXT('USERENV', 'LANG') AND
ฺ v ino
LOOKUP_CODES.LOOKUP_TYPE = :BindLookupType
a. In c
a the Application Navigator, right-click the StorefrontModel project and select New
C (from the context menu.
d A
i n o b. In the New Gallery, expand the Business Tier node in the Categories list and select
V ADF Business Components. Select View Object in the Items list and click OK.
c. On the Name page of the Create View Object Wizard:
1) Change the package name to oracle.fod.storefront.view and enter
LookupCodeVVO as the view object name. (Note that the suffix is VVO rather
than VO that you used for the updatable view objects, and that you are placing the
read-only VOs in a separate package.)
3) Click Next. u se
d. On the Query page of the wizard: e to
n s
1) Enter the query statement shown in step 1. (You can copy from
i ce
LookupCodes.txt, or click Query Builder to build the query if desired, but make
b l el
sure that the finished query is as shown above.)
fe ra
2) Click Test to verify that the query is valid.
a n s
3) Click Next. n - tr
e. no eฺ
On the Bind Variables page of the wizard:
a
1) Click New.
h a s uid
m ) nt G
2) On the Variable tab in the lower section of the page, enter BindLookupType as
l ฺ o
c tude
the name for the variable, leaving all other values at their defaults.
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
3) Click Next.
f. Continue clicking Next until you reach the Application Module page:
1) Select the Application Module check box.
2) Click Browse next to the Package field.
3) Click the Hierarchy tab in Package Browser and browse to and select the oracle
> fod > storefront > test package. Click OK.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
g. Save your work. a no eฺ
2. Test the query: h a s uid
m
a. Run TestAM as you did previously.
) nt G
l ฺ o
c Browser,
d edouble-click the LookupCodeV1 node.
i
b. In the Business Components t u
g madialogisbox,
c. In the Bind Variables
S enter a Value such as SHIPPING_CLASS_CODE and
click OK. o@ t h
i n
( a cฺv through the rows to see all the payment type codes. Note that all fields are
d. Navigate
f. When you have finished testing, close the Business Components Browser.
o@ th
ฺv i n
C (ac
d A
n o
Vi
4) Click Next.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
designate a primary key for such EOs. You can do that with the Create Entity Object Wizard.
In this practice, you create several database view–based entity objects and designate their
primary keys.
1. Create an entity object named ProductCategoryEO and base it on the
Product_Categories database view. Set the CategoryId to be its primary key.
a. To invoke the Entity Object Wizard, you could use the New Gallery. However, there is
an even easier way to invoke the wizards:
1) In the Application Navigator, expand the StorefrontModel project. u se
e to
2) Expand the Application Sources and oracle.fod.storefront nodes.
n s
3) Right-click the entity node and select New Entity Object. i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
b. i
On the Name page ofathe Create S Entity Object Wizard:
g m i s
1) Ensure @
o th
that oracle.fod.storefront.entity is the package name.
i n
v ProductCategoryEO as the entity object name.
2) ฺEnter
a c
(3) Ensure that the Database Schema Object option is selected and that the
A C database schema is FOD.
n o d
Vi 4) Click Browse to the right of the Schema Object field.
a) In the Select Schema Object dialog box, select the Views object type and
deselect Tables.
b) Click Query.
c) In the list of schema objects, select PRODUCT_CATEGORIES. Note that you
cannot multiselect more than one schema object, because you are creating
only one entity object with this wizard.
d) Click OK.
5) If the schema object is not automatically populated in the field, enter
PRODUCT_CATEGORIES. Click Next.
c. On the Attributes page, click Next to accept all columns. This wizard enables you to
remove or add attributes if necessary.
d. On the Attribute Settings page:
1) Select CategoryId from the Select Attribute drop-down list.
2) Select the Primary Key check box.
3) Click Finish to create your ProductCategoryEO entity object.
Copyright © 2010, Oracle and/or its affiliates. All rights reserved.
u se
e to
n s
i ce
b l el
fe ra
a n s
2. n - tr
Optional step (If you choose not to create these objects, you must begin the
no eฺ
practices for the next lesson by opening the starter application.)
a
a s uid
Similarly, create the following entity objects that are based on database views:
h
EO o m
Based e n t G View
) on Database Primary Key
a ilฺc PERSON_INFORMATION
S t u d
gm thisPRODUCTS
PersonInformationEO CustomerId
ProductEO @
ino
ProductId
ฺ v
C (ac
d A
n o
Vi
EO Based on
AddressEO ADDRESSES
AddressUsageEO ADDRESS_USAGES
CountryEO COUNTRY_CODES
LOOKUP_CODES
se
LookupCodeEO
PaymentOptionEO PAYMENT_OPTIONS to u
SUPPLIERS n s e
ce
SupplierEO
WAREHOUSES eli
WarehouseEO
a b l
WarehouseStockLevelEO WAREHOUSE_STOCK_LEVELS fe r
a n s
n - tr
Note: Creating all of these entity objects is optional. You can create them all if you
a no eฺ
want to, but you may choose to create only the first two. If you create only a
subset of the objects, you must begin the practices for the next lesson by opening
the starter application.
h a s uid
m ) nt G
a. In the Application Navigator, right-click the oracle.fod.storefront.entity package, and
l ฺ o
c tude
select New Business Components from Tables.
i
ma is S
b. On the Entity Objects page of the Business Components from Tables Wizard, check
g
@ th
whether the package name is oracle.fod.storefront.entity and the schema is
o
c ฺ vin
FOD. Click Query.
a
c. (As you did in an earlier practice, Ctrl-click to select multiple tables for which to create
C
A entity objects, and rename the entity objects, according to the table shown above.
n o d d. Click Finish to create the entity objects.
V i
root categories (those without a parent category), and another that displays the subcategories.
A view link is also required to set up this master-detail relationship.
1. In the oracle.fod.storefront.uiview package, create two view objects that are based on
ProductCategoryEO: RootCategoryVO for those rows whose ParentCategoryId is null, and
SubCategoryVO. Place the view objects in your TestAM application module.
a. In the Application Navigator, right-click the oracle.fod.storefront.uiview
package and select New View Object from the context menu.
b. On the Name page of the Create View Object Wizard: u se
1) Ensure that the package is oracle.fod.storefront.uiview. e to
n s
2) Enter RootCategoryVO as the view object name.
i ce
3) Select the Updatable access through entity objects option.
b l el
4) Click Next. fe ra
c. On the Entity Objects page: a n s
n -
1) Expand the oracle.fod.storefront.entity package node.
tr
a no eฺ
2) Shuttle ProductCategoryEO into the Selected pane.
3) Click Next. h a s uid
m ) nt G
d. On the Attributes page:
l ฺ o
c tude
i
1) Click Add All g ma to shuttle
i s S all attributes into the Selected pane.
2) Click o @
Next. t h
e.
i n
ฺv Attribute Settings page, click Next.
On the
C (ac
d A
n o
Vi
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
3) Click Next. a no eฺ
g. Navigate through the subsequent pagesh a suntil youu idreach the Application Module page:
1) Add the view object to them
o TestAM
e t G module as you have been doing.
) napplication
ilฺctheSupdatable
2) Click Finish to create
a t ud view object.
h. mSubCategoryVO
Similarly, creategthe is view object based on the same
o @
ProductCategoryEO t h
entity object, with all attributes.
i n
v the following WHERE clause:
1) ฺUse
(ac ProductCategoryEO.PARENT_CATEGORY_ID IS NOT NULL
d ACthe view object in your TestAM application module.
Place
Vi no 2. The two view objects that you just created should be related by
ProductCategoriesSubProductCategoriesAssoc in a view link named
RootCategoriesSubCategoriesLink. Create this view link.
a. Right-click the oracle.fod.storefront.uiview package and select New View Link.
b. On the Name page of the Create View Link Wizard, enter a name of
RootCategoriesSubCategoriesLink, and then click Next.
c. From the Select Source Attribute list, select oracle.fod.storefront.uiview >
RootCategoryVO > ProductCategoriesSubProductCategoriesAssoc.
d. From the Select Destination Attribute list, select oracle.fod.storefront.uiview >
SubCategoryVO > ProductCategoriesSubProductCategoriesAssoc.
u se
f. Click Next several times until you reach the Application Module page. Select the
e to
Application Module check box and browse to select the TestAM application module n s
in the oracle.fod.storefront.test package. Click Finish to create the view link. i ce
3. Optional step (If you choose not to create this object, you must begin the practices b l el
for the next lesson by opening the starter application.) fe ra
Similarly, create one more updatable view object named SupplierVO in the a n s
n - tr
oracle.fod.storefront.uiview package. Base it on SupplierEO, including all
no eฺ
attributes. Do not include a WHERE clause. Add the view object to the TestAM application
a
module.
h a s uid
4. m ) nt G
Save your work, and then test the view objects and view link that you just created.
l ฺ o
c tude
a. Run TestAM as before. i
ma is S
b. Check whether the RootCategory1 view object instance displays the data you expect
g
@ th
(only those categories without a ParentCategoryId should display).
o
ฺ vin
c. Check whether the SubCategory1 view object instance displays the data you expect
c
( a(only those categories with a ParentCategoryId).
A C
d. Test that RootCategoriesSubCategoriesLink displays the master-detail relationship
n o d between root categories and subcategories, similar to the following:
V i
e. Close the Business Components Browser when you have finished testing.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
a
c. (In the Move Business Components dialog box, enter the Package name of
C
A oracle.fod.storefront.assoc and click OK.
n o d
V i
d. Confirm that you would like to create the package by clicking Yes.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
2. In a similar manner, move all viewmlinks G
) into nthet oracle.fod.storefront.link
o e
ilฺctheSuiview
package. Refactor links in both
a t ud and the view packages.
g m is
o@ th
v i n
( acฺ
d AC
Vi no
3. Test the application module to ensure that all view links still function correctly.
u se
e to
n s
i ce
b l el
f er a
Practicestfor s
anLesson 5
n - r
Chaptern5o
s a ideฺ
) a
h t Gu
i l ฺ comtuden
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
also the VO for the subcategories, accessed through the view link.
a. Right-click the oracle.fod.storefront package and select New Application Module.
b. On the Name page of the Create Application Module Wizard, ensure that the package
name is oracle.fod.storefront.module. Enter the name FODCategoryAM and
click Next.
c. On the Data Model page, in the Available View Objects pane, expand
oracle.fod.storefront.uiview and RootCategoryVO.
d. Select RootCategoryVO and shuttle it to the Data Model. u se
e to
e. With RootCategoryVO1 selected in the Data Model panel, shuttle SubCategoryVO
n s
via RootCategoriesSubCategoriesLink to the Data Model. i ce
f. Click Finish to create the application module. b l el
g. Save your work. fe ra
2. Test the application module and then close the Business Components Browser when you a n s
have finished. n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
f er a
Practicestfor s
anLesson 6
n - r
Chaptern6o
s a ideฺ
) a
h t Gu
i l ฺ comtuden
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
the same project. However, if you prefer to start with a clean application that contains everything
completed up to the start of this lesson, open Storefront-06.jws and edit the database
information as described in step 4 of Practice 2-4.
This practice contains some optional steps that are similar to steps already done. If you want to
build the entire application yourself, you can complete the optional steps. However, in the
interest of time, you may want to skip them. If you do so, you must begin the practices for the
next lesson by opening the starter application for that lesson.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
u se
eto
n s
Note: Whether or not the instructions specifically direct you to do so, you
l i cethese
can use
a
practices, as you would need to do for a real application. However,
r blein the interest
a text resource in a resource bundle for any translatable text throughout
2. Optional step: Similarly, edit OrderItemEO to format UnitPrice as Currency and set its
Label Text to have a space between words.
3. Test the changes by running TestAM in the oracle.fod.storefront.test package.
a. Double-click ShoppingCart1 > OrderItemsOrdersFkLink1.
b. Look at the labels and formatting that you defined.
c. Position the cursor over OrderTotal, OrderDate, and OrderShippedDate to see the
tool tip text.
u se
d. Close the Business Components Browser when you have finished. e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
o@ th
c ฺ vin
a. In the Application Navigator, double-click SupplierEO to open it in the editor.
b. Click the Attributes tab.
( a
C
A Select the SupplierId attribute and click Edit
c. .
d
V ino d. In the Edit Attribute dialog box, select Entity Attribute in the list at the left.
e. Select DBSequence from the Type drop-down list. (If not in the list, click Browse and
select it in the oracle.jbo.domain package.)
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
Value 0 a no eฺ
While New h a s uid
Selected
m ) nt G
Persistent
l ฺ o e
c tudSelected
i
Primary Key
g ma is S Selected
Queryable o@ th Selected
i n
cฺv
Insert
(a Selected
d AC
g. Click OK.
n o
Vi
automatically.
1. In the SupplierEO entity object, designate the following columns as history columns and
ensure that they are automatically populated at run time: CreatedBy, CreationDate,
LastUpdatedBy, LastUpdateDate, and ObjectVersionId.
a. In the Application Navigator, double-click SupplierEO to open it in the editor, or click
its tab if it is already open.
b. Click the Attributes tab.
u se
c. Select the CreationDate attribute and click Edit .
e to
d. In the Edit Attribute dialog box, select Entity Attribute in the list at the left. n s
i ce
e. Select the History Column check box and select created on from the drop-down list.
b l el
f. Click OK.
fe ra
g. s
Similarly, edit the following attributes by selecting the History Column check box and
a n
n - tr
choosing the following values from the drop-down list:
a no eฺ
h a s uid
Attribute Name
o m e n t GColumn value
) History
LastUpdateDate
a ilฺc Stud modified on
ObjectVersionIdg
m is
o @ th version number
c ฺ vin
h.
C (a
To populate the history columns for “created by” and “modified by,” there must be a
d A logged-in user. You later designate these attributes as history columns, but to test with
i n o the Business Components Tester with no logged-in user, you simply give these
V columns default values. Set the default Value of the CreatedBy and LastUpdatedBy
attributes to anonymous. (Ensure that Literal is selected as the option for Value Type.)
2. Optional step: (If you choose not to complete this step, you must begin the practices
for the next lesson by opening the starter application.)
Similarly, modify the same five attributes for OrderItemEO and for OrderEO.
3. Save your work.
4. Test SupplierVO to ensure that you can actually insert and commit a record.
c. Click Insert .
d. Ensure that a temporary SupplierId appears (it should be a negative number) and that
the history columns are populated.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2011, Oracle and/or its affiliatesฺ
u se
e to
n s
i ce
b l el
e. Enter a SupplierName, such as ABC Plumbing, and a SupplierStatus, such as
fe ra
ACTIVE.
a n s
n - tr
f. Click Save .
a no eฺ
g.
h a s from
Ensure that the SupplierId value is populated
u idthe database sequence.
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
ฺv i n
C (ac
d A
n o
Vi
5. Optional step: (Perform this step only if you added history columns to these entities.)
Test OrderEO and OrderItemEO, making sure that when you insert a record the history
columns are populated.
a. Double-click ShoppingCart1 > OrderItemsOrdersFkLink1.
u se
e to
n s
li ce
l e
b to delete the
f. Click Delete in the lower and then in the upper sections of the
e r apanel
new rows without committing them.
a n sf
g. Close the Business Components Browser when youthave
n - r finished.
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
ฺv i n
C (ac
d A
n o
Vi
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
d. s theuCriteria
In the Create View Criteria dialog box, click
h a id Definition tab and click the
Add Item button.
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
ฺv i n
C (ac
d A
n o
Vi
Operator Equal to
Operand Bind Variable
Parameter Click New and define a variable named
PersonId of type Number.
Validation Optional
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
f. Click OK to create the named query.
2. Test the query by applying the view criteria in the Business Components Browser, using
values 110, 114, 117, or 119 for the bind variable.
a. Run TestAM in the Business Components Browser.
b. Double-click PaymentOptionV1.
c. In the PaymentOptionV1 window, click Specify View Criteria .
d. In the Business Component View Criteria dialog box, select
PaymentOptionVVOCriteria in the Available list and shuttle it to the Selected list, and
then click Find.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
f. The payment options for customer 110
h a sshould be
u iddisplayed.
g. You can test with other valuesmif )
you would
n G to do so. Some other valid values are
t like
114, 117, and 119. ilฺc
o d e
a t u
S Browser when you have finished testing.
h. Close the Business
g mComponents
i s
o@ t h
ฺv i n
C (ac
d A
n o
Vi
information, which is part of PersonEO. To accomplish this, you can include PersonEO in the
view object as a reference entity, creating a join view.
You can create join views when using the Create View Object Wizard. If you already have a
view object to which you want to add a reference entity, you can do so by editing the view object
to create the join view. That is what you do in this practice.
1. Add all the attributes from PersonEO as an inner join to be used as reference in the
ShoppingCartVO view object.
a. In the Application Navigator, in the oracle.fod.storefront.uiview package, u se
double-click the ShoppingCartVO view object to open it in the editor. e to
n s
b. Click the Entity Objects tab to the left of the editor.
i ce
c. Expand oracle.fod.storefront.entity and shuttle PersonEO to the Selected list.
b l el
d. Select PersonEO in the Selected list. Ensure that the Association is set to fe ra
OrdersPersonsFkAssoc.Person and that the Join Type is set to inner join. Ensure
a n s
- tr
that the Updatable check box is not selected, and that the Reference check box is
n
selected.
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
3) Click OK. a no eฺ
h
2. Optional step: (If you choose not to createa s theseuobjects,
id you must begin the
practices for the next lesson by m
opening the
G application.)
) nt starter
o e
ilฺc andSattributes
Similarly, add reference entities
a t ud to ShoppingCartItemVO as follows:
Entity Object@g
m is
o th Attributes
ฺ vin
ProductEO
c ProductId
( a ProductName
A C
n o d Description
Vi AdditionalInfo
ListPrice
ProductCategoryEO CategoryId
CategoryName
a. In the Application Navigator, double-click the ShoppingCartItemVO view object in the
oracle.fod.storefront.uiview package to open it in the editor.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
3. Optional step: (Perform this step only
m ) if you
n G history columns to the
t added
ShoppingCartItemEO entity.): o
ฺc tud e
a
Delete the history attributes
ilfrom S
ShoppingCartItemVO. You do not need these mandatory
g m because i s
attributes in the view
o @ object th you have set their values in the entity object.
inalready open, double-click the ShoppingCartItemVO view object in the
a. If it isvnot
ฺ
( a c
oracle.fod.storefront.uiview package of the Application Navigator to open it in the
C editor.
A b.
d Click the Attributes tab and delete the following attributes: CreatedBy,
V ino CreationDate, LastUpdatedBy, LastUpdateDate, and ObjectVersionId.
c. Save your work.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
a
e. (In the List of Values dialog box:
A C
n o d 1) On the Configuration tab:
V i a) Select OrderItemEO.ProductVVO1 as the List Data Source. (Click OK in
the Information dialog box.)
b) Select ProductId as the List Attribute.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
@ th
3)
ฺ v inoOK.
Click
( ac
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
c. Change the initial product to some other product.
a n s
d.
n - tr
Double-click OrderItemsOrdersFkLink1 under ShoppingCart1.
e. no eฺ
Query for the same order that appears in the ShoppingCartItem1 window (order 1034
a
s uid
in the example shown above). The corresponding shopping cart item should show the
h a
change that you made in the other window. View objects that display the same data
) nt G
o m
remain in sync throughout the application.
c tude
i l ฺ
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
f er a
Practicestfor s
anLesson 7
n - r
Chaptern7o
s a ideฺ
) a
h t Gu
i l ฺ comtuden
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
steps, you can continue working in the same project. However, if you prefer to start with a clean
application that contains everything completed up to the start of this lesson, open
Storefront-07.jws and edit the database information as described in step 4 of Practice 2-4.
This practice contains some optional steps that are similar to steps already done. If you want to
build the entire application yourself, you can complete the optional steps. However, in the
interest of time, you may want to skip them. If you do so, you must begin the practices for the
next lesson by opening the starter application for that lesson.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
d. Save your work.
h a s uid
2. Generate the Entity Object Java class) for OrderEO
o m e n t Gfrom
and add the following method for
g mthe entity
i s S
a. Similarly, generate
o @ t h object class for OrderEO.
b. Clickv i n
ฺ the Entity Object Class link to open OrderEOImpl.java in the editor.
( a c
A C
n o d
Vi
c. Note that the Structure window shows the methods that are included in the class. (If
the Structure window is not visible—that is, the default location is at the lower left of the
IDE—then you can select View > Structure to open it.) You can see accessors (getters
and setters) for all the OrderEO attributes. You can double-click any method to
d. In the editor, scroll to the bottom of the file and just above the closing right brace, add u se
the code shown below. You can copy the code from the addItemToOrder.txt file in
e to
the \files subdirectory of your \labs directory. n s
i ce
/**
b l el
* Add an item to the order. Typically used to add items to the
fe ra
shopping cart.
a n s
*
n - tr
* @param productId
a no eฺ
*/
h a s uid
m ) nt G
public void addItemToOrder(Number productId) {
l ฺ o
c tude
i
if (productId == null) {
g ma is S
System.err.println("NO PRODUCT ID!!!");
o@ th
throw new NullPointerException();
c ฺ vin
}
( a
A C
d RowIterator orderItems = getOrderItem();
V ino assert orderItems != null;
OrderItemEOImpl row;
boolean found = false;
for (row = (OrderItemEOImpl)orderItems.first(); row != null;
row = (OrderItemEOImpl)orderItems.next()) {
if (row.getProductId().equals(productId)) {
found = true;
break;
}
}
if (found) {
Number qty = row.getQuantity();
if (qty == null)
Copyright © 2010, Oracle and/or its affiliates. All rights reserved.
OrderItemEOImpl newItem =
(OrderItemEOImpl)orderItems.createRow();
EntityDefImpl productEODef =
EntityDefImpl.findDefObject("oracle.fod.storefront.entity.Produc
tEO");
EntityImpl productEO =
productEODef.findByPrimaryKey(getDBTransaction(), new Key(new
u se
Object[] { productId }));
e to
Number unitPrice =
n s
(Number)productEO.getAttribute("ListPrice");
i ce
b l el
newItem.setProductId(new Number(productId));
fe ra
newItem.setQuantity(new Number(1));
a n s
newItem.setUnitPrice(unitPrice); n - tr
try { a no eฺ
h a s uid
getDBTransaction().validate();
m ) nt G
l ฺ o
} catch (TxnValException e) {
c tude
i
ma is S
System.out.println(e.getMessage());
g th
for (Throwable t : e.getExceptions()) {
@
o
vin
System.out.println(t.getMessage());
a c ฺ }
C ( } catch (JboException e) {
d A
i n o System.out.println(e.getMessage());
V }
}
}
sequence value as the default value for an attribute. No database trigger is required, but if the
record is never committed, this results in gaps in the numbers. In this practice, you implement
this “eager” assignment of values from a database sequence.
1. Set OrderItemEO to use a database sequence for the line item ID by supplementing the
initDefaults() method with the following code: (You can copy the code from the
initDefaults.txt file in the \files subdirectory of your \labs directory.)
SequenceImpl seq = new SequenceImpl("ORDER_ITEMS_SEQ",
getDBTransaction()); u se
e to
populateAttributeAsChanged(LINEITEMID, seq.getSequenceNumber());
n s
a. Double-click the OrderItemEOImpl.java file in the Application Navigator
l i ctoeopen
the source file—it is located under the OrderItemEO node.
a b le
b. From the context menu, select Source > Override Methods.fe r
c. In the Override Methods dialog box, select the check box a n s
next to the method
initDefaults() : void and click OK (whereas n r
-tin the Override Methods dialog
o
bar). s a n idtoenavigate
box, you can just start entering the method name ฺ to it, or use the scroll
) ha t Gu
i l ฺ comtuden
g ma is S
o@ th
ฺv i n
C (ac
d A
n o
Vi
f. Right-click the method name initDefaults, and then select the Quick JavaDoc option
from the context menu. JDeveloper displays an explanation of the method. Click
outside of the doc window to close it.
g. Right-click the editor and select Make and make sure that no compilation errors are u se
reported in the Compiler Log pane. e to
n s
h. Save your work. i ce
2. Test the assignment of the line item ID. b l el
a. Run the FODShoppingCartAM application module. fe ra
b. Double-click OrderItemsOrdersFkLink1. This opens the master-detail window for a n s
Orders and OrderItems. n - tr
a no eฺ
c. Click Insert a new row s paneuofidthe window (the OrderItems
in the bottom
h a
section).
m ) nt G
d. Note that the row is created
l ฺ o d e
c withtauLineItemId value defaulted from the database
sequence ORDER_SEQ. a i
g m is S
o@ th
ฺv i n
C (ac
d A
n o
Vi
e. Because there are a number of mandatory columns, do not commit the new row.
f. Close the BC Browser without committing the row.
In this practice, you add code to entity objects to automatically populate the CreatedBy and
LastUpdatedBy history columns.
1. In SupplierEO, modify the CreatedBy and LastUpdatedBy columns as follows:
a. Open the SupplierEO entity object, and click the Attributes tab.
b. For both attributes, delete the anonymous default value.
c. Designate the column as a history column with the appropriate value:
u se
Attribute Name History Column value
e to
n s
CreatedBy created by
i ce
LastUpdatedBy modified by
b l el
fe ra
2. Optional step: (If you choose not to complete this step, you must begin the practices
a n s
n - tr
for the next lesson by opening the starter application.)
no eฺ
Similarly, designate the same columns as history columns in OrderEO and OrderItemEO.
a
3. s uid
As you did previously for OrderEO and OrderItemEO, generate the entity object class for
h a
SupplierEO.
m ) nt G
4.
l ฺ o
c tude
In the entity object class for SupplierEO, override the
i
g ma is S
getHistoryContextForAttribute() method with the following code, which you can
copy from the getHistoryContextForAttribute.txt file in the \files subdirectory
@ th
ฺ v ino
of your \labs directory:
a c
(attributeDefImpl)
protected Object getHistoryContextForAttribute(AttributeDefImpl
A C {
n o d Object value =
V i super.getHistoryContextForAttribute(attributeDefImpl);
// If value is null and is modify user or create user
// history column then return "anonymous"
if (value == null && (attributeDefImpl.getHistoryKind() ==
AttributeDefImpl.HISTORY_MODIFY_USER ||
attributeDefImpl.getHistoryKind() ==
AttributeDefImpl.HISTORY_CREATE_USER))
{
return "anonymous";
}
return value; }
a. Open the Java class in the editor.
b. From either the main menu or the context menu, select Source > Override Methods.
u se
e to
n s
i ce
d. Substitute the code shown above for the generated code. You can copy the code from b l el
the getHistoryContextForAttribute.txt file in the \files subdirectory of
fe ra
your \labs directory.
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i 5. Optional step: (If you choose not to complete this step, you must begin the practices
for the next lesson by opening the starter application.)
Similarly, override the getHistoryContextForAttribute() method with the same
code in the entity object classes for OrderEO and OrderItemEO.
6. Run the TestAM application module and perform the same tests as you did in step 4 of
practice 6-3, (Supplier1 and also ShoppingCart1>OrderItemsOrdersFKLink1) except
that if you test the shopping cart, you will not be able to see how the history columns
appear in the shopping cart item record because the history columns are no longer part of
the ShoppingCartItemVO view object.
add the following code: (You can copy it from the TestClient.txt file in the \files
subdirectory of your \labs directory.)
System.out.println("The table contains " +
vo.getEstimatedRowCount() + " rows:");
vo.executeQuery();
while (vo.hasNext()){
Row paymentOptionRow = vo.next();
System.out.println(" CustomerID: " + u se
e to
paymentOptionRow.getAttribute("CustomerId") +
n s
" Payment Type Code: " +
i ce
paymentOptionRow.getAttribute("PaymentTypeCode"));
b l el
}
fe ra
Your code should look like the following: a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
In the Java class that you create in this practice, the customer name is hard coded to simulate a
name that would ordinarily be retrieved from a login module.
1. Create a new Java Class named BaseApplicationModuleImpl in the
oracle.fod.storefront.module package, extending the default base application
module.
a. Right-click the oracle.fod.storefront.module package and select New.
b. In the New Gallery:
1) Select General in the Categories list. u se
e to
2) Select Java Class in the Items list.
n s
3) Click OK. i ce
c. In the Create Java Class dialog box: b l el
1) Enter a name of BaseApplicationModuleImpl. fe ra
a n s
2) tr
Ensure that the package name is set to oracle.fod.storefront.module.
n -
3) Next to the Extends field, click Browse. no
a) In the Class Browser dialog box,
a s eฺ tab and enter AMI
aclick theidSearch
(uppercase) in the Match) h Name
Class G ufield, which displays a list of matching
classes. om den t
i l ฺ c u
g ma is St
b) Select the ApplicationModuleImpl(oracle.jbo.server) class and click OK.
o@ th
ฺv i n
C (ac
d A
n o
Vi
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
4. Compile and save the code. h a s uid
a. Right-click the editor and selectm )
Make. nt
G
o e
ilฺc displays
b. Ensure that the log window
a S t u dno compilation errors. It should display the
g m compilation:
message: Successful i s 0 errors, 0 warnings.
@ t h
c. Save your
ฺ v inowork. The default preference in the IDE is to automatically save before
compiling.
( ac
d AC
Vi no
BaseApplicationModuleImpl.
a. Open FODShoppingCartAM in the editor.
b. Click the Java tab.
c. Click Edit next to Java Classes.
d. In the Select Java options dialog box:
1) Select the Generate Application Module Class check box.
2) Because you must use the method in the BaseApplicationModuleAMImpl class
that you created earlier, this application module class must extend that one, so u se
click Classes Extend. e to
n s
3) In the Override Base Classes dialog box:
i ce
a) Click Browse next to the Object field.
b l el
b) In the Find Superclass dialog box, click the Search tab and enter BA in the fe ra
n
Match Class or Package Name field. This should populate Matching Classes
a s
and Packages. n - tr
no eฺ
c) Select the BaseApplicationModuleImpl class and click OK.
a
a s uid
d) Click OK again to close the Override Base Classes dialog box.
h
e. m ) nt G
Click OK to generate the application module class.
l ฺ o
c tude
f. Save your work. i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
b. You can see that the view objects and some operations are exposed to the client. Now u se
you add some service methods and expose them to the client as well. e to
n s
2. Add a method to the shopping cart application module to initialize the shopping cart to that
i ce
of the current user of the application (remember that you hard coded the username in
b l el
BaseApplicationModuleImpl.java). The code is shown here: (You can copy the code
fe ra
from the ShoppingCartInit.txt file in the \files subdirectory of your \labs
a n s
directory.)
n - tr
public void init() {
a no eฺ
a s uid
DBTransactionImpl trx = (DBTransactionImpl)getDBTransaction();
h
ApplicationModuleImpl am =
m ) nt G
ฺ o
c tude
(ApplicationModuleImpl)trx.getRootApplicationModule();
l
i
ma is S
String user = am.getUserPrincipalName().toUpperCase();
g
@ th
System.out.println("The session user is: " + user);
o
c ฺ vin
ViewObjectImpl vo;
( a vo = getShoppingCart1();
A C String bindUser =
n o d (String)vo.getNamedWhereClauseParam("CurrentUser");
V i if (! user.equals(bindUser)) {
vo.setNamedWhereClauseParam("CurrentUser", user);
/* The ShoppingCart is guaranteed to only have one row.
* However, we may not always properly initialize this
* from the UI because the actual row from ShoppingCart is
* not really needed. The following initializes the view
* object so that the view link to the shopping cart items
* properly works.
*/
vo.executeQuery();
Row cart = vo.first();
if (cart == null) {
cart = vo.createRow();
// TODO: Need to finish this off.
}
}
a. In the Application Navigator, expand FODShoppingCartAM and double-click
FODShoppingCartAMImpl.java to open it in the editor.
b. Add the code shown above just before the closing right brace.
c. Press Alt + Enter if prompted to import the following:
oracle.jbo.Row
oracle.jbo.server.DBTransactionImpl u se
oracle.jbo.server.ApplicationModuleImpl
e to
3. Now add a method that adds an item to the user’s shopping cart. This method should call n s
i ce
an entity object method that you added earlier to OrderEOImpl.java. Use the following
b l el
code (you can copy from addItemToCart.txt):
fe ra
public void addItemToCart(Number productId) {
a n s
init();
n - tr
no eฺ
ViewObject shoppingCartVO = getShoppingCart1();
a
assert shoppingCartVO != null;
h a s uid
m ) nt G
l ฺ o
c tude =
i
ViewRowImpl shoppingCartRow
ma is S
(ViewRowImpl)shoppingCartVO.first();
g
assert@ th
o shoppingCartRow != null;
ฺv i n
C (ac OrderEOImpl orderEO =
d A (OrderEOImpl)shoppingCartRow.getEntity(0);
n o
Vi
orderEO.addItemToOrder(productId);
}
a. Insert the code just before the closing brace in FODShoppingCartAMImpl.java.
b. Press Alt + Enter if prompted, to import the following:
oracle.jbo.ViewObject
oracle.jbo.server.ViewRowImpl
oracle.fod.storefront.entity.OrderEOImpl.
c. The code shows an error when calling the addItemToOrder() method. To fix it,
manually add the following import statement to the import section of the file:
import oracle.jbo.domain.Number;
d. Right-click the editor and select Make.
e. Save your work.
4. Now that you have written the service methods to initialize and add items to the shopping
cart, expose the new methods to the client interface.
a. Examine the Data Controls panel again. It looks the same as before. The new methods
are not yet available to the client interface.
Copyright © 2010, Oracle and/or its affiliates. All rights reserved.
2. Test the shopping cart. Execute the init() method, but do not supply a value for the bind
variable, because that comes from the init() method.
a. Run FODShoppingCartAM.
Copyright © 2010, Oracle and/or its affiliates. All rights reserved.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
e. i
Double-click ShoppingCart1.
f. g madialogisbox,
In the Bind Variables
S click Cancel, because the init() method already
assigned o@
the t h
value to the bind variable.
ฺ v i n
C (ac
d A
n o
Vi
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
a i S
h.
g mwindow.
Close the Browser
i s
o@ t h
ฺv i n
C (ac
d A
n o
Vi
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
f er a
Practicestfor s
anLesson 8
n - r
Chaptern8o
s a ideฺ
) a
h t Gu
i l ฺ comtuden
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
If you have successfully completed all sections of the previous practice, including the optional
steps, you can continue working in the same project. However, if you prefer to start with a clean
application that contains everything completed up to the start of this lesson, open
Storefront-08.jws and edit the database information as described in step 4 of Practice 2-4.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
e. On the Failure Handling tab, check whether the Validation Failure Severity option
button is set to Error, and then, to define a translatable string in a resource bundle,
click in the Message Text section. If you do not choose to do so, in the interest of
time, you can simply enter the text rather than clicking to define a text resource. If
you choose this option, enter ”You have entered an invalid value” in the
Message Text field and skip step (f) below.
f. If you choose to define a text resource, simply click this option . In the Select Text
Resource dialog box:
u se
1) In the Display Value field, enter: You have entered an invalid value
e to
2) In the Key field, enter: INVALID_VALUE n s
i ce
3) In the Description field, enter: Error message for invalid value
b l el
4) Click Save and Select.
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
g. Click OK to save your validation definition, and then click OK to close the Attribute
Editor if you used it to invoke the Add Validation Rule dialog box.
2. Save your work. You will test this validation after all validations are defined.
a. In the Entity Object Editor for the OrderEO entity, select the Business Rules node.
b. In the Business Rules section, select Entity Validators, and then click Create new
validator to add a new rule. (Note that this is another way to define attribute
validation if you expand the Attributes node and select an attribute.)
u se
e to
n s
i ce
b l el
fe ra
c. In the Add Validation Rule dialog box:
a n s
- tr
1) Select UniqueKey from the Rule Type drop-down list.
n
2) Select OrdersPk(ORDER_ID) in thea nolist.eฺ
Keys
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
ฺv i n
C (ac
d A
n o
Vi
u se
e to
n s
i ce
b l el
4) fe
Click OK to save your validation definition. You should see the new validation rule ra
in the Validation Rules section of the OrderEO editor. a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d2. Save your work. You will test this validation after all validations are defined.
V i
u se
e to
n s
i ce
b l el
d. On the Failure Handling tab:
fe ra
n s
1) Check whether the Validation Failure Severity option button is set to Informational
a
Warning. n - tr
no eฺ
2) As before, add, save, and use the message Order shipped date must not
a
a s uid
be prior to order date, using a Key of SHIP_DATE_TOO_SOON and a
h
) nt G
Description of Warning message for validation of shipping date.
m
ฺ o
c tude
Click Save and Select. Alternatively, you can just enter the message in the
l
i
ma is S
Message Text field.
g
o@ th
c ฺ vin
( a
A C
n o d
V i
e. Click OK to save your validation definition. (Click OK again to dismiss the Attribute
Editor if you used it to invoke the Add Validation Rule dialog box.)
f. In the Application Navigator, expand the OrderEO node and double-click
OrderEOImpl.java to open it in the editor (by adding the Method validator, this file
would have been automatically generated if it did not already exist).
g. In the Structure window, double-click the validateShippedDateAfterOrderDate
method to locate it in the editor.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
i.
j.
Right-click and select Make.
a no eฺ
Save your work. You will test this validation after all validations are defined.
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
a. In the Application Navigator, right-click the oracle.fod.storefront node and select New
Domain.
b. On the Name page of the Create Domain Wizard:
1) Set the package name to oracle.fod.storefront.domain.
2) Set the Name to PhoneNumber.
3) Ensure that the Domain for an Oracle Object Type check box is not selected.
4) Click Next.
c. On the Settings page of the wizard: u se
1) Select String from the Type drop-down list. e to
n s
2) Click Next, and then click Finish. i ce
d. In the Application Navigator, double-click PhoneNumber.java to open it in the editor. It b l el
is located under the oracle.fod.storefront > domain > PhoneNumber node.
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
e. In the Structure window, double-click the validate():void node to navigate to that
3) Click OK.
3. Save your work.
u se
d. Click OK to acknowledge the error. e to
n s
e. Change the OrderId back to its original value so that you can navigate out of the field.
i ce
3. While still in FODShoppingCartAM, test the Method validator that you defined for the
b l el
OrderEO entity object.
fe ra
a. Enter a value in Order Shipped Date that is later than the value in Order Date. You
a n s
should be able to tab out of the field with no error.n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
b. main Order
Enter the same value
g is SShipped Date that is in Order Date. You should be able
to tab out of@ t
the field withh no error.
ฺ v ino
C (ac
d A
n o
Vi c. Enter a value in Order Shipped Date that is earlier than the value in Order Date. You
should receive the warning message that you defined. (The JBO key is different if you
entered hard-coded message text rather than defining a text resource.)
o@ th
ฺv i n
C (ac
d A
n o
Vi
u se
e to
n s
i ce
b l el
f er a
Practicestfor s
anLesson 9
n - r
Chaptern9o
s a ideฺ
) a
h t Gu
i l ฺ comtuden
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
Web application. In the practices for this lesson, you debug a client method in an application
module, and you explore the features of the JDeveloper Debugger.
Note: This practice is optional, and does not affect subsequent practices. Do this practice only if
you have extra time.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
@ th
ฺ v ino
c. Tocset a breakpoint, click in the left margin of the code editor next to the first line of
a
(executable code in the init() method.
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
3. View all the breakpoints that are set on the s id
application.
h a u
a. From the JDeveloper main menu,) select View
o m e n t G> Breakpoints (or use the shortcut key
ilฺc Stud
combination Ctrl + Shift +R).
a
g m is
o@ th
v i n
( acฺ
d AC
Vi no b. The Breakpoints window shows the breakpoints that you have set, in addition to those
persistent breakpoints that are set by default.
c. Right-click the Breakpoints window to see the options that are available in the context
menu (but do not make any changes).
u se
e to
n s
li ce
l e
binvoked in the
b. Before the Business Components Browser appears, the debugger
e r ais
JDeveloper IDE. Examine the information in the IDE.
a n sf
1) BaseApplicationModuleImpl.java is shown in-the
n tr editor with a watchpoint icon
is because the application has hit the a nosetting
and a pointer displayed to the left of the line
watchpoint e ฺ
mCurrentUser to null. This
breakpoint that you set on this
a s u i d
variable.
m ) h nt G
i l ฺ co tude
g ma is S
o@ th
ฺv i n
C (ac
d A
n o
Vi 2) If the Stack window is not visible, from the JDeveloper main menu, select View >
Debugger > Stack. You can see in the Stack window that the
BaseApplicationModuleImpl class is in the process of being initialized, and
that it was called by the initialization of FODShoppingCartAMImpl.
c. Step through the code and use the debugger features to figure out the problem.
3) Click Resume on the toolbar to continue the execution until the next time a u se
breakpoint is encountered. No breakpoint is encountered, so the Business
e to
Components Browser appears. n s
i ce
4) Now set up the shopping cart as you have done before by executing the init()
method—double-click FODShoppingCartAM in the browser, select the init() b l el
method from the Method drop-down list, and then click Execute. The control fe ra
passes to the debugger again, so click back within the JDeveloper window to
a n s
continue the actions. n - tr
5) a no eฺ
FODShoppingCartImpl.java is shown in the editor with a source breakpoint icon
a s uid
and a pointer displayed to the left of the line in the init() method where you set
h
the breakpoint.
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
c ฺ vin
( a
A C
n o d
V i
6) If you step into the code at this point, you would need to have the ADF source
because ADF source classes are called in the next lines. Because you do not have
the source, click Step Over to advance to the next line of code in this class—
everything still executes, but you just do not step into the called classes. Note: Be
sure to click Step Over and not Step To End of Method, whose icon looks similar.
7) Click Step Over again to advance to the line of code that assigns a value to the
user variable. This assignment calls the getUserPrincipalName() method of
the application module base class, which is overridden in
BaseApplicationModuleImpl.java.
8) You are interested in two variable values: user and mCurrentUser. Click the
Smart Data tab. (If it is not available, use the View > Debugger menu to invoke
it.)
u se
e to
n s
i ce
The Watches tab now shows both the this.mCurrentUser and user variables
so that you can easily track their values. b l el
f e r a
10) Click Step Into to step into the getUserPrincipalName()n s
awhen method in
BaseApplicationModuleImpl.java. Note-that t r you do so, on the
Watches tab the user variable has question n onmarksฺ for value and type because it
is out of scope. s a ide
) a
hThe pointer
G u
11) Click Step Into again twice.
o t
m en should now be on the line that assigns
l
a value to mCurrentUser,
i ฺ c but
t u dthat line of code has not yet been executed. You
a
m valueisof the
can see that the S variable userPrincipal is about to be assigned to
g t h
i n othe@Smart Data tab and notice that the value of userPrincipal is
mCurrentUser.
v
12) ฺClick
14) In the Modify Value dialog box, change the value to DRAPHEAL, which is the
correct spelling for the username of the user whose shopping cart you want to
display, and then click OK.
21) Click Resume , and then in the Business Components Browser, double-click
ShoppingCart1. Click Cancel in the Bind Variables dialog box so that the value
set by the init method is used. You should see that the correct record appears
now.
You have seen some features of the debugger and how being able to view variable and
parameter values as the code runs can help you to figure out a coding problem. This
code was so simple that you probably could have easily figured it out just by looking at it,
but the debugger can be very useful for troubleshooting complex code. You were able to
change a value while code execution was paused, so that you could see the outcome.
Of course, you would also have to fix the code itself instead of just changing a variable
value in the debugger, but that is not part of this exercise.
Copyright © 2010, Oracle and/or its affiliates. All rights reserved.
u se
e to
n s
i ce
b l el
f er a
Practicestfor s
anLesson 10
- r
on ฺ
Chaptern10
s a ide
) a
h t Gu
i l ฺ comtuden
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
f er a
Practicestfor s
anLesson 11
- r
on ฺ
Chaptern11
s a ide
) a
h t Gu
i l ฺ comtuden
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
Even if you successfully completed all sections of previous practices, do not continue working
in the same project, because there was no time to create all the elements required for the UI.
You must open Storefront-11.jws and then edit the database information as described in
step 4 of Practice 2-4.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
a. With your StorefrontUI project selected in the Application Navigator, select File > New
to invoke the New Gallery. (Alternatively, you can right-click StorefrontUI and select
New from the context menu, or click New on the toolbar.)
b. In the Categories list, select Web Tier > JSF. Select JSF Page in the Items list and
click OK.
c. In the Create JSF Page dialog box:
1) Enter a file name of Products.
2) To the default Directory path, add \oracle\storefront\ui\pages. u se
3) Ensure that Create as XML Document (*.jspx) is selected, and then click OK. e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
2. After the designer initializes, the new blank page opens in the editor. Add to the page two
databound tables for product categories and subcategories as master-detail tables.
a. In the Data Controls panel, expand FODProductAMDataControl >
BrowseCategory1.
u se
e to
n s
i ce
b l el
3. By default, all attributes of the view objects were added to the tables. You want to display
fe ra
n
only the category name and description. Delete the ones that you do not want to display,
a s
and set the master table to enable row selection.
n - tr
no eฺ
a. To edit the master table, select the top table (BrowseCategory) in either the visual
a
h a s uid
editor or the Structure window and click Edit in the Property Inspector. (If the Property
Inspector is not visible, use the View menu to display it.)
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
b. Delete the columns that you do not want to display by selecting them and clicking
Delete , and you can use the arrows at the right of the Edit Table Columns dialog
box to reorder the columns. Set the column list to match the following:
CategoryName
CategoryDescription
Hint: When you select an attribute, it is best to select the first column, Display Label,
because that is the only column that does not invoke a pop-up list.
c. Make sure that Row Selection is selected in the Enable ADF Behavior section at the
top of the window, and then click OK to apply the changes.
u se
e to
n s
i ce
b l el
fe ra
d. Select the second table (BrowseSubCategory1) in either the visual editor or the
a n s
n - tr
Structure window and click Edit in the Property Inspector.
e. no eฺ
Set the column list to match the following (remove the extra columns and reorder as
needed): a
h a s uid
CategoryName
m ) nt G
CategoryDescription
l ฺ o
c check d e and click OK. The page should now look
i t u
mascreenshot,
f. Deselect the Row Selection box
g
similar to the following i s S in which some of the extra white space has been
cut out: o@ t h
c ฺ vin
C (a
d A
n o
Vi
u se
e to
e n s
Note that the table does not fill the page. In the practice for the lesson titledc“Achieving
l i
d. Leave the browser window open to refer to in the next task. r ble
the Required Layout,” you modify the layout so that the table fills the page.
a
n s fe
n - tra
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
ฺv i n
C (ac
d A
n o
Vi
u se
e to
n s
i ce
b l el
fe ra
a n s
For example, select the first column in the upper table in the JDeveloper editor, and then
n - tr
look at the Property Inspector. What is the Header Text property set to?
no eฺ
__________________________________________________________________
a
h a s uid
__________________________________________________________________
) nt G
Answer: #{bindings.BrowseCategory1.hints.CategoryName.label}
m
2. ฺ o
c tude
Select the CategoryName output text under the column header. What is its value?
l
i
ma is S
__________________________________________________________________
g
@ th
__________________________________________________________________
o
ฺ vin
Answer: #{row.CategoryName}
c
3.
a
The( reference to row is to a variable that is defined on the table.
A C
n o d Select the table in the Structure window, and then click the Source tab in the editor. How
V i is the row variable defined?
__________________________________________________________________
__________________________________________________________________
Answer:
var="row" value="#{bindings.BrowseCategory1.collectionModel}"
4. At run time, what appears in the browser for the first column’s heading?
__________________________________________________________________
__________________________________________________________________
Answer: The column heading is Category Name.
5. In JDeveloper, in the StorefrontModel project, open the ProductCategoryEO entity object
and edit the CategoryName attribute. Where does the Category Name label in the UI
come from?
__________________________________________________________________
__________________________________________________________________
Answer: Office, Electronics, and Media are the category names in the rowset;
they are the input values for the category names in the rows.
7. In the Application Navigator, right-click the page and select Go to Page Definition. What is
the name of the page definition file? (You can also view data bindings by clicking the
Bindings tab of the page itself.)
__________________________________________________________________
Answer: ProductsPageDef.xml
u se
8. In the Model section of the page definition file, trace the source of the BrowseCategory1
binding. Where does the data come from? e to
n s
__________________________________________________________________ i ce
__________________________________________________________________ b l el
Answer: The data comes from the BrowseCategory1 view object instance in the fe ra
FODProductAMDataControl. The data is held in the entity object on which the a n s
n - tr
BrowseCategory view object is based, and the values ultimately come from the
database.
a no eฺ
9. a s uid
At the top of the page, click the link to the Data Binding Registry. What is the name of this
h
file?
m ) nt G
l ฺ o
c tude
__________________________________________________________________
i
ma is S
__________________________________________________________________
g
o @ th
Answer: DataBindings.cpx
10. ฺ vin
When does this data binding registry file get created? Hint: The answer is right at the top of
c
( a
the Overview page for the data binding registry file.
A C __________________________________________________________________
n o d
V i __________________________________________________________________
Answer: The file is created the first time that you bind a UI component to data in the
application.
11. What does the Page Mappings section of this file show?
__________________________________________________________________
__________________________________________________________________
Answer: It shows the mapping of pages to the IDs of their associated page definition
files.
12. What does the Page Definition Usages of this file show?
__________________________________________________________________
__________________________________________________________________
Answer: It shows the mapping of page definition file IDs to paths of their page definition
files.
13. What does the Data Control Usages section of this file show?
__________________________________________________________________
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
a
d. (From the Create menu, select Table > ADF Read-only Table.
C
A e. Do not enable Row Selection.
n o d
V i f. Include the following attributes in order, deleting the other attributes, and then click OK:
ProductName
Description
ListPrice
2. Run the page to test it. Now, when you run the page, the log window shows that the
application is undeployed and then redeployed to the default server.
b. Close the browser when you have finished and undeploy the application as described
in step 6(i) of Practice 2-4.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
a. Shut down JDeveloper, saving any unsaved work and terminating any running
processes if prompted.
b. Open Windows Explorer and navigate to your application directory.
c. In the StorefrontUI\public-html\oracle\storefront\ui\pages directory,
change the name of Products.jspx to ProductCatalog.jspx.
2. Test the ProductCatalog page.
a. Reopen JDeveloper, and then open the ProductCatalog.jspx page in the editor.
b. Run ProductCatalog.jspx. u se
c. The browser displays error messages, but does not display any data. e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
d. When you haveg ma close
finished, i s Sthe browser and undeploy the application as described
t h
@Practice 2-4.
in step 6(i)oof
i n
ฺv Denied” error that you received is indicative of a problem with data bindings.
( a c
3. The “Access
Fix the problem without re-creating the tables on the page.
A C
a. Click the Bindings tab in the editor of the ProductCatalog page to see that there are
n o d
Vi b.
no data bindings for the page.
In the Application Navigator, navigate to StorefrontUI > Application Sources >
oracle.storefront.ui and open DataBindings.cpx.
c. Map the existing page definition file to the renamed page: In the Page Mappings
section of DataBindings.cpx, edit the path. Change Products in the path to
ProductCatalog. You can do this by selecting the page mapping, and then editing
the path in the Property Inspector.
u se
e to
n s
i ce
4.
d. Save your work.
Test the ProductCatalog page again. b l el
fe ra
a. Close and reopen ProductCatalog.jspx in the editor.
a n s
n - tr
b. Click the Bindings tab. You should see data bindings, and the Page Definition File
no eฺ
should be listed as oracle/storefront/ui/pages/ProductsPageDef.xml.
a
h a s uid
c. Run the page. The data should now be displayed correctly.
) nt G
d. Close the browser when finished, and undeploy the application as described in step
m
6(i) of Practice 2-4.
l ฺ o
c tude
i
5.
new name of the page. g ma is S
If you have time, as an optional exercise, rename the page definition file to match the
o @ th
c ฺ vin
a. Close JDeveloper, saving any unsaved work and terminating any running processes if
prompted.
( a
A C
b. In Windows Explorer, navigate to your application directory.
d. Reopen JDeveloper.
e. In the Application Navigator, navigate to StorefrontUI > Application Sources >
oracle.storefront.ui > pages and select ProductCatalogPageDef.xml.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
This changes the ID of the page definition. Alternatively, you could change the ID in the
Property Inspector. a no eฺ
h. a s uid
In the Application Navigator, navigate to StorefrontUI > Application Sources >
h
m ) nt G
oracle.storefront.ui and open DataBindings.cpx.
l ฺ o
c tude
i. i
Map the renamed page definition file to the path of the existing page: In the Page
ma is S
Definition Usages section of DataBindings.cpx, select the path, and then in the
g
@ th
Property Inspector, change the value of the path from ProductsPageDef to
o
ฺ vin
ProductCatalogPageDef.
c
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
3) In the <pageDefinitionUsages><page> section, change the id to be the same as s
tr a
the usageId in the previous section. The red squiggly line should disappear.n
n -
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
(4)a If desired, retest the page.
A C
n o d
V i
u se
e to
n s
i ce
b l el
f er a
Practicestfor s
anLesson 12
- r
on ฺ
Chaptern12
s a ide
) a
h t Gu
i l ฺ comtuden
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
In the practices for this lesson, you create both unbounded and bounded task flows, along with
various types of activities and control flows for each. You also extract part of an unbounded task
flow into its own flow, and convert an unbounded task flow to a bounded one.
If you successfully completed all sections of the previous practice, you can continue working in
the same project. However, if you prefer to start with a clean application that contains everything
completed up to the start of this lesson, open Storefront-12.jws and edit the database
information as described in step 4 of Practice 2-4.
This practice contains some optional steps that are similar to steps already done. If you want to u se
build the entire application yourself, you can complete the optional steps. However, in the e to
interest of time, you may want to skip them. If you do so, you must begin the practices for the n s
i ce
next lesson by opening the starter application for that lesson.
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
rest of the application, add the ProductCatalog page to the application’s unbounded task
flow.
a. Open the unbounded adfc-config.xml task flow. For convenience, JDeveloper
displays a node for this task flow in two places in the Application Navigator. Expand
StorefrontUI and WebContent. You can then open adfc-config.xml from the
node located under WEB-INF or the one located under Page Flows.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c fromtthe
d e
b. i
Drag ProductCatalog.jspx u Application Navigator to the task flow that is open
in the editor.
g ma is S
o@ th
ฺv i n
C (ac
d A
n o
Vi
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
2. Create two additional view activities in theh a s uidtask flow named ProductSearch
unbounded
and ProductDetails. m ) nt G
l ฺ o d eADF Task Flow is selected in the drop-down list
censuretuthat
a. In the Component Palette,
a i S category and drag a View activity to the editor.
at the top. Expandmthe Components
s
g t h i
i n o@
v
( acฺ
d AC
Vi no
b. Change the name of the view activity to ProductSearch by entering the new name
either directly on the diagram or in the Property Inspector.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c. c ฺ vin
Similarly, add another view activity named ProductDetails.
( a
A C
n o d
V i
Note the yellow warning symbol on the view activities that you just created. This
means that they do not yet point to pages.
u se
e to
n s
i ce
b l el
c. Enter detail as the name of the case. You can enter directly on the diagram, or it fe ra
may be easier to use the Property Inspector and enter the name as the from- a n s
outcome of the control flow case. n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
4. In the same way, add a Control Flow Case from ProductDetails to ProductSearch and
name it search.
6. You can move the view activities to make the diagram look better. For example, you can
arrange the view activities as shown:
u se
e to
n s
i ce
b l el
f er a
7. Add a control flow case named detail from ProductCatalog
s
anto ProductDetails.
- t r
on ฺ to ProductCatalog.
8. Add a control flow case named shop from ProductDetails
n
s a ide
) a
h t Gu
i l ฺ comtuden
g ma is S
o@ th
v i n
( acฺ
d AC
Vi no
9. Create a fourth View activity named ProductCategory. The page is to display a category
tree for user navigation.
10. Finally, create a View activity called FODShoppingDashboard. The page for this view
activity will be the main page of the application from which all parts of the application are
accessed.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
d. In the Create Taskm Flow
i
a dialogSbox:
1) Set File @ g
Name to t h is
intheodirectory path, add \oracle\storefront\ui\flow. This is the path you
ShoppingCartFlow.
v
2) ฺTo
C (ac should use for all task flows.
d A 3) Ensure that Create as Bounded Task Flow is selected.
n o
Vi 4) Ensure that Create with Page Fragments is not selected.
5) Click OK.
u se
e to
n s
i ce
b l el
f. The Shopping Cart flow opens in the editor. Add a view activity and name it
fe ra
ShoppingCart.
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d Note that the view activity is surrounded with a green halo. This indicates that it is the
V i default activity, or entry point, of the task flow. A bounded task flow must have one, and
only one, default activity. Only bounded task flows show default activities, because
unbounded task flows do not have a defined entry point.
g. Add a Task Flow Return and name it Shop.
u se
e to
n s
i ce
b l el
fe ra
a n s
i. - tr
Add a Control Flow Case from ShoppingCart to the Shop task flow return activity
n
and name it too as shop.
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
k. s ufrom
Add a control flow case also named checkout
h a id ShoppingCart to Checkout.
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
ฺv i n
C (ac
d A
n o
Vi
u se
e to
n s
3) A task flow return activity named Cancel whose outcome is also named
l i ce done
r a ble
n s fe
n - tra
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
ฺv i n
C (ac
d A
n o 4) A wildcard control flow rule
Vi
u se
e to
n s
i ce
b l el
f er a
b. In the same way, create the ShowSuppliersFlow in the n s
a view activity named
\oracle\storefront\ui\flow subdirectory, n -
withtrone
BrowseSuppliers.
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
ฺv i n
C (ac
d A
n o
Vi
( a
A C
n o d
V i
d. On the Extract Task Flow warning, click Yes to accept and proceed.
u se
e to
n s
i ce
b l el
fe ra
a n s
f. - tr
In the editor, arrange the ShoppingFlow activities in a visually pleasing manner, such
n
as shown below:
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
g. Right-click the ProductCatalog view activity and select Mark Activity > Default
Activity.
u se
e to
n s
i ce
b l el
The ProductCatalog activity is now surrounded with a green halo indicating that it is the
fe ra
default activity, or entry point, for the task flow.
a n s
- tr
h. When you extract a bounded task flow, a task flow call activity is created on the task
n
a no eฺ
flow from which the bounded task flow was extracted. (You may need to look for it in
the diagram, if not visible.) This is not needed, so you can delete it from the adfc-config
task flow. h a s uid
m ) nt G
l ฺ o
1) Open or switch to adfc-config.xml.
c tude
i
g ma is S
2) In the visual editor, right-click the ShoppingFlow activity and select Delete, or you
can delete task-flow-call-ShoppingFlow in the Structure window.
o @ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
f er a
Practicestfor s
anLesson 13
- r
on ฺ
Chaptern13
s a ide
) a
h t Gu
i l ฺ comtuden
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i 2. Create a read-only table on the page to display the user’s cart, showing the product name,
list price, quantity, and line total of items that are ordered. Users should be able to use a
mouse to select a line item.
a. The ShoppingCart page opens in the editor. From the Data Controls panel, drag
FODShoppingCartAMDataControl > ShoppingCart1 > ShoppingCartItem1 to the
page as a Table > ADF Read-only table.
u se
e to
n s
b. Ensure that Row Selection is enabled.
i ce
c. Delete all but the following attributes and arrange them in order:
b l el
ProductName
fe ra
a n s
ListPrice
n - tr
no eฺ
Quantity
LineTotal a
s uid
h a
) nt G
o m
c tude
i l ฺ
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
Note: Select and remove the other attributes by clicking Delete. You can reorder the
attributes by selecting an attribute and using the up and down arrows as required.
Hint: An easy way to reorder many attributes is to first select the last attribute that you
want in the display (in this case, LineTotal) and click the top arrow, which places the
attribute at the top of the list. Then select the next-to-last attribute (in this case
Quantity) and place it at the top of the list. Continue with all the attributes, from last to
first. Finally, select all the other attributes and delete them.
d. Click OK.
3. Test the page.
Copyright © 2010, Oracle and/or its affiliates. All rights reserved.
Note: You receive this message because you are running the page directly instead of
running it within the context of the bounded task flow. You do not need to use the ADF
u se
Controller in this case because you are not using any control flows to test this single
e to
page. In most cases, however, you should run pages from a task flow rather than
n s
running them directly. i ce
You also receive several compilation warnings: XML-24521: (Error) Element not b l el
fe
completed: 'view', because you have created several activities in task flows that have ra
n
not been completed, such as view activities without corresponding pages. You can
a s
safely ignore these warnings.
n - tr
c. no eฺ
The page runs, but does not show any data. ShoppingCart is tied to a specific user;
a
h a s uid
however, you have not yet told it what user.
m ) nt G
l ฺ o
c tude
i
g ma is S
d. Close theo
n @ whenthyou have finished and undeploy the application as described
browser
i
ฺv 6(i) of Practice 2-4.
in step
a c
4. Add( to the page an invocation of the application module’s init() method that initializes
d ACthe application to show shopping cart data for a specific user. The method interrogates the
n o system user (a hard-coded name is used until security is implemented in a later practice)
Vi and uses that name as the username for the shopping cart. Hint: This involves adding a
method action binding and an invoke action binding to the page definition.
a. Click the Bindings tab in the editor for the ShoppingCart page.
b. Add a Method Action binding to the init() method in the
FODShoppingCartAMDataControl:
2) In the Insert Item dialog box, select methodAction and click OK.
u se
e to
n s
i ce
3) In the Create Action Binding dialog box, select b l el
FODShoppingCartAMDataControl, choose init() from the Operation drop-
fe ra
down list, and then click OK.
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
2) In the Insert Item dialog box, select invokeAction, and then click OK.
3) In the Insert invokeAction dialog box:
Enter an ID of invokeInit, select init from the Binds drop-down list, and click
OK. u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
4) In the Property Inspector, set Refresh ton o ฺ
ifNeeded.
s a i d e
a
) h nt G u
m
co tude
i l ฺ
g ma is S
o@ th
i n
(a cฺv
C 5) In the Executables panel, drag the invokeInit executable to the top position, so
d A that the init() method is invoked before the iterator.
n o
Vi
e. Close your browser when you have finished and undeploy the application as described
in step 6(i) of Practice 2-4.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i 2. Add a query component to the ProductSearch page to query for products. The search
results should appear in a table that shows product name, category name, list price, and
description. The user should be able to select a row.
a. The ProductSearch page opens in the editor. Drag FODProductAMDataControl >
BrowseProduct > Named Criteria > SearchByName to the page in the editor and
select Query > ADF Query Panel with Table from the context menu.
u se
e to
n s
i ce
b. In the Edit Table Columns dialog box:
b l el
1) Enable Row Selection.
fe ra
2) Include only the following four attributes in this order:
a n s
ProductName
n - tr
CategoryName
a no eฺ
ListPrice
h a s uid
Description m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
u se
3. Test the functionality of the ProductSearch page. e to
n s
a. Right-click the editor for the ProductSearch page and select Run. (Do not run the i ce
page from the task flow because the default activity of the task flow does not yet have
b l el
the ability to navigate to the ProductSearch page.)
fe ra
NOTE: Although this page is represented as a view activity on the bounded task flow
a n s
n - tr
that is not the default activity, you can still run the page separately when you are not
individual pages. a no eฺ
running it from the task flow. It is the task flow that has a single entry point, not
h a s uid
b. The page runs and looks similar to the following:
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
Note that the table does not fill up the page. You must scroll to see all the columns.
You later improve the look of the table in the practice for the lesson titled “Achieving the
Required Layout.”
c. Experiment with the functionality of the page.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
2) Resize columns in the table
o m e n t Gthe lines between the column headers.
)by dragging
c tabletubyddragging column headers.
ilฺthe
3) Reorder columns in
a
m is S
g th
i n o@
ฺv
C (ac
d A
n o
Vi 4)
5)
Click Advanced to enable more search options.
Select Contains from the operators drop-down list.
u se
7) Select “Does not contain” from the operators drop-down list and click Search.
e to
Now the table displays only those products that do not contain the string “Pla.”
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
9) For the Price criterion, select “Greater than” from the operators drop-down list,
b l el
enter a value of $1000 (ListPrice is formatted as currency), and then click Search.
fe ra
n s
Now the table displays only those products that do not contain the string “Pla” and
a
whose list price is more than $1000.
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
10) When you have finished, close the browser and undeploy the application as
described in step 6(i) of Practice 2-4.
added navigation yet. The page should look similar to the following, displaying only one
record, which may not be the same as the record shown:
4. When you have finished, close the browser and undeploy the application as described in
step 6(i) of Practice 2-4.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
b. Test that you are able to sort columns and select rows.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
c. When you have finished, close the browser a no eฺ the application as described
and undeploy
in step 6(i) of Practice 2-4. h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
ฺv i n
C (ac
d A
n o
Vi
b. You may have to scroll in the diagram to see the existing views, and then either
double-click the ProductCategory view, or right-click it and select Create Page.
u se
e to
n s
i ce
c. Create a .jspx page in the directory where you are creating pages
b l el
(\oracle\storefront\ui\pages).
fe ra
2. Add a tree to the ProductCategory page to display categories and subcategories.
a n s
- tr
a. From the Data Controls panel, drag to the page FODCategoryAMDataControl >
n
RootCategory1 as a Tree > ADF Tree.
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
page.
g. The page should look similar to the following:
u se
e to
n s
3. Convert the output text to a command link. i ce
a. On the ProductCategory page, select af:outputText in either the Structure window b l el
or the visual editor. (You must keep expanding the af:tree node all the way to find fe ra
a n s
b.
af:outputText.)
n - tr
Right-click af:outputText and select Convert To.
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
g
attribute when mthea userisselects
accessor, and that the value will be
S a value from the list. returned to the SupplierStatus
th where you can see that the attribute appears as a Choice
othe@UI Hints tab,
2) Clicki n
v containing the LookupCode and Description.
(a cฺList
d AC 3) Click Cancel.
Open SupplierEO under the StorefrontModel > Application Sources >
Vi no h. oracle.fod.storefront > entity node.
i. Click the View Accessors tab.
j. Select LookupCodeVVO1, and then click Edit.
l. Click Cancel to close the window, and then close the EO and VO editors.
2. In the ManageSupplierFlow task flow, create the SupplierUpdate page, using an LOV for
the SupplierStatus attribute. Place this page in a \supplier subdirectory where you have
been creating pages (\oracle\storefront\ui\pages). The form needs to show only
one record. u se
a. Open the ManageSupplierFlow task flow from the Application Navigator if it is not e to
n s
already open.
i ce
b. Create the SupplierUpdate page, placing it in a supplier subdirectory
b l el
\oracle\storefront\ui\pages\supplier.
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
d. Select only the following fields:
i ce
SupplierName
b l el
SupplierStatus
fe ra
a n s
PhoneNumber
n - tr
noButton.
Email
a s a
Do not include Navigation Controls or a Submit
i d eฺ
) h t Gu
i l ฺ comtuden
g ma is S
o@ th
ฺv i n
C (ac
d A
n o
Vi Click OK. Note that the “Component to Use” field for the SupplierStatus attribute is
ADF Select One Choice; this is determined by the setting in the ADF BC model.
Although you can change the setting here, it is better to let the model determine the list
type.
The page should look something like the following:
f. When you have finished, close the browser and undeploy the application as described
in step 6(i) of Practice 2-4.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
a. Right-click the StorefrontUI project in the Application Navigator and select Project
Properties, or just double-click the node to open the Project Properties editor.
b. In the list at the left of the Project Properties editor, select Resource Bundle. Make
sure that the Resource Bundle Type property is set to Properties Bundle and select
the One Bundle Per Project option. If necessary, set the Default Project Bundle Name
to oracle.storefront.ui.StorefrontUIBundle.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
(a
C
A c. Click OK.
n o d
V i
u se
e to
n s
i ce
b l el
f er a
Practicestfor s
anLesson 14
- r
on ฺ
Chaptern14
s a ide
) a
h t Gu
i l ฺ comtuden
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
cancel. Add a Cancel button to the page in the task flow to implement this global rule.
Create the label for the button as a translatable string.
a. Open the ManageSupplierFlow task flow by double-clicking it in the Application
Navigator. (The task flows are located under the Web Content > Page Flows > oracle
> storefront > ui > flow node.)
b. Double-click the SupplierUpdate view activity to open the page in the editor.
c. In the Component Palette, ensure that ADF Faces is selected from the drop-down list,
and drag a Button to the page just inside the top of the form in the editor. u se
(You may find it easier to drag it to the Structure window—expand af:form and drag e to
the button just above af:panelFormLayout.) n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
The page o should th to the following:
@ look similar
v i n
( acฺ
AC
d
V ino
d. To define text for the button label and store it in a resource bundle, in the Property
Inspector, click the arrow to the right of the Text property and select Select Text
Resource from the context menu.
(Alternatively, you can right-click the button in the editor or in the Structure window and
select Select Text Resource for > Text from the context menu.)
Copyright © 2010, Oracle and/or its affiliates. All rights reserved.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
f. o @ th
The label of the button changes to Cancel.
c ฺ vin
Note: The label of the button may appear at design time as the EL expression
( a
A C #{storefrontuiBundle.CANCEL}.
n o d
V i
g. Select the button and in the Property Inspector, click the Action drop-down list and
select cancel.
h. To enable users to cancel and leave the form without entering the required fields, set
the Immediate property to true on the Behavior panel of the Property Inspector.
2. Optional step: (If you choose not to create this button, you must begin the practices
for the next lesson by opening the starter application.) u se
The ManageSupplierFlow task flow has a control flow rule from SupplierUpdate to the Save e to
task flow return activity whose from-outcome is save. Follow a similar series of steps to n s
i ce
add a Save button just to the right of the Cancel button on the SupplierUpdate page to
implement this navigation. Create the label for the button as a new translatable string and b l el
select the save action. Do not change the default value of the Immediate property for thisfe ra
button. a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
ice
b l el
4. Optional step: (If you choose not to create these buttons, you must begin the fe ra
practices for the next lesson by opening the starter application.)
a n s
- tr
Following a similar series of steps, add the following buttons for navigation, optionally using
n
a text resource for the label of each:
a no eฺ
Task Flow Page
h a s Buttonu idLabel Button
m ) nt G Action
l ฺ o
c tude Search (use the
i
ma is S
ShoppingFlow ProductDetails search
ino
ShoppingFlow
ฺ v ProductDetails Shop (create a text shop
( ac resource entry)
c. The file should look similar to the following (not all of these entries are present if you
skipped any optional steps):
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
Note: Although subsequent practices ) nspecify
t G the use of a resource bundle to
store translatable strings,oinm the interest of time, you may choose to just enter
i
the strings as hard-codedl ฺ c text.tude
d. Close all editor g ma is S
windows.
o@ th
ฺv i n
C (ac
d A
n o
Vi
products. Convert the ProductName on the ProductSearch page to a link that implements
this navigation. Clicking the link should not select a row.
a. Open the ProductSearch page.
b. Turn off automatic row selection on the table:
1) Select af:table in the Structure window or in the breadcrumbs at the bottom of the
editor.
2) Click Edit on the Property Inspector.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) box, n G
tdeselect
3) In the Edit Table Columnso
c tud dialog e the Row Selection check box, and
then click OK. ailฺ
c. g m isto S
Change the ProductName be a link that calls the ADF method that sets the row and
@ t h
noStructure
then navigates
vithe
1)cฺIn
to the detail page:
window, expand the first af:column under af:table.
C (a
2) Right-click af:outputText for ProductName in the Structure window and select
d A Surround With.
n o
Vi
u se
e to
n s
i ce
4) In the Property Inspector, remove the value in the Text property of the
b l el
af:commandLink and set Action to detail.
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
a
d. (If you run the page from the task flow at this point (see step f below for how to do that if
C
A you want to try), the link navigates to the detail page but always displays details for the
n o d
V i first product. The reason for this behavior is that when you disabled row selection you
also disabled row concurrency. Add a method called setCurrentRowWithKey that
sets the row of the Product iterator to whatever the current row is on the page.
1) In the Data Controls panel, expand FODProductAMDataControl >
BrowseProduct > Operations.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
3) Click OK to closeathe EditS Action Binding dialog box.
g m i s
4) In the Confirm th Rebinding dialog box, select the Keep Current Value
@ forComponent
oboxes
i n
check
ฺv the text and action properties. Click OK.
C (ac
d A
n o
Vi
C (ac
d A
n o
Vi
4) If you did not complete the optional steps of defining additional buttons, click the
Back button of your browser, otherwise perform the following actions:
a) On the detail page, click Search to return to the search page to try another
link.
b) On the ProductDetails page, click Shop to return to the ProductCatalog page.
5) When you have finished, close the browser and undeploy the application as
described in step 6(i) of Practice 2-4.
3. Coordinating the ProductCatalog and ProductDetails pages is made more complex by the
fact that the two pages use different iterators. The ProductDetails page uses the top-level
BrowseProduct iterator, whereas the ProductCatalog page uses the BrowseProduct1
iterator that is a detail of BrowseCategory > BrowseSubCategory. Therefore, you must use
the setCurrentRowWithKeyValue() method from the BrowseProduct data control to
coordinate the pages.
a. In the Data Controls panel, expand FODProductAMDataControl > BrowseProduct >
Operations.
c o m en
tell it which row is current. The argument for setting the current row of Product is ProductId.
ฺ
ail tableSfor d
tuthis page, you excluded the ProductId because you
When you created them Product
do not want to display
@ g t
it. Because
s
hi it was excluded, it is not in the page bindings. Before you
o
ฺvinit to theasbindings.
can use ProductId
haveatocadd
an argument to the setCurrentRowWithKeyValue method, you
After you add it, you can set the NDValue property of
(
d ACsetCurrentRowWithKeyValue.
Vi no a. Go to the Overview tab of the ProductCatalog page definition, or to the Bindings tab
of the page.
b. In the Bindings section, select the BrowseProduct1 binding and click Edit.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
page. It simply makes thec o m) available
Note: This adds the attribute to the
attribute e n tG
bindings, but it does not add it to the table on the
to the page.
d. a ilฺ Stud method uses an argument (ND or Named Data)
The setCurrentRowWithKeyValue
g m is The argument for setting the current row of Product is
to tell it which row
@ h
is current.
t
In c ฺ
the
ino window, select bindings > setCurrentRowWithKeyValue > rowKey
ProductId.
vStructure
C (a
and set the NDValue property to #{row.ProductId}. Be sure to tab out of the field or
f. Click Shop to return to the ProductCatalog page to try different links. (If you did not
define the Shop button in the optional steps, use the browser’s Back button to return to
the ProductCatalog page.)
u se
Note: If the Products table at the bottom shows no data, you can test the links after
e to
you coordinate the Products table with the Subcategories table in a later practice.
n s
i ce
el
g. When you have finished, close the browser and undeploy the application as described
in step 6(i) of Practice 2-4.
a b l
5. On the ShowSuppliersFlow task flow, create a task flow call activity to invoke the fe r
ManageSupplierFlow task flow, a control flow case named update from BrowseSuppliers a n s
n - tr
to ManageSupplierFlow, and a control flow case named done from ManageSupplierFlow to
no eฺ
BrowseSuppliers. You want users to be able to click the SupplierId to be able to update the
a
h a s uid
supplier. Convert the SupplierId on the BrowseSuppliers page to a link that implements this
) nt G
navigation. You do not need to disable row selection for this table.
m
o
c tude
a. Open the ShowSuppliersFlow task flow.
l ฺ
i
ma is S
b. From the Application Navigator, drag ManageSupplierFlow to the diagram to create a
g
o @ th
task flow call activity.
c ฺ vin
( a
A C
n o d
V i
c. Create a control flow case from BrowseSuppliers to ManageSupplierFlow and set its
from-outcome to update.
d. Create a control flow case from ManageSupplierFlow to BrowseSuppliers and set its
from-outcome to done. (It should default to done because that is the outcome of the
task flow return activities in ManageSupplierFlow.)
u se
e to
n s
3) In the Surround With dialog box, select ADF Faces > Link and click iOK.
l ce
4) In the Property Inspector of the af:commandLink:
r a ble
a) Remove the value in the Text property
n s fe
b) Set the Action to update
n - tra
5) On the Behavior tab, set the PartialSubmit
a noproperty
e ฺ
to true.
g. Test the page by running BrowseSuppliers
a s from
u i the
d ShowSuppliersFlow
h t toGthe supplier update page.
When you click a link, you should) navigate
task flow.
m
co tuden
i l ฺ
g ma is S
i
However, n othe@page doesthnot yet commit any updates you may make for the selected
v
( acฺ you implement that in a later practice.
supplier;
AC
h. When you have finished, close the browser and undeploy the application as described
d in step 6i of Practice 2-4.
V ino
u se
e to
n s
i ce
b l el
f er a
3. Drag three Navigation Items to the af:breadCrumbs component. an s
- t r
n a resource bundle to change its
4. Select the first af:commandNavigationItem andouse
Text property to Store, or optionally, just entera n
the text. eฺ
h
5. You will not be able to test the navigation a s
until after u idadd the dynamic breadcrumbs
you
functionality in a later practice. Form
o now,
e t Gthe other two navigation items as they
) justnleave
are.
a ilฺc Stud
g m is
o@ th
v i n
( acฺ
d AC
Vi no
train component to the first page in the train. In the later practice for the lesson titled “Ensuring
Reusability,” you use a page template for the pages.
1. From the StorefrontUI project, invoke the New Gallery.
2. Select Web Tier > JSF > ADF Task Flow and click OK.
3. In the Create Task Flow dialog box:
a. Enter a File Name of CheckoutFlow.
b. To the Directory path, append \oracle\storefront\ui\flow.
u se
c. Ensure that Create as Bounded Task Flow is selected.
e to
d. Ensure that Create with Page Fragments is not selected. n s
i ce
e. Select the Create Train check box.
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
f. Click OK.
C (ac
d A
n o
Vi
u se
2) Click OK. e to
n s
e. Now that you have a reference to the init() method, you can add it to the i ce
Executables list:
b l el
1) Click Add in the Executables section. fe ra
2) Select Generic Bindings > invokeAction and click OK. a n s
n - tr
3) In the Insert InvokeAction dialog box, set id to invokeInit, and set Binds to init,
and then click OK. a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
a
(4) In the Property Inspector, set the Refresh property to ifNeeded.
C
A Note: By setting the Refresh property to ifNeeded, the framework refreshes the
n o d
V i executable when it has not been refreshed to this point. For example, when you have
an accessor hierarchy in which a detail is listed first in the page definition, the master
could be refreshed twice (once for the detail and again for the master's iterator). Using
ifNeeded avoids duplicate refreshes.
5) Drag the invokeInit action so that it is first in the list of executables.
9. Add the ability to navigate to the next page by adding a Train component to the page. The
Train component shows the user’s relative position in the train. It has train stops (small
boxes) for each of the pages in the train. The current position is highlighted with a slightly
larger box. The Train component can also be used for navigation. The user can click the
previous or next train stop to navigate to that page.
b. In the Bind Train dialog box, click OK to accept the default trainModel to bind to.
10. Add a train button bar to the page. A train button bar displays Back and Next buttons to
navigate to the next or previous train stop.
a. Drag a Train Button Bar from the Component Palette to the Structure window just
after the af:train.
u se
b. In the Bind trainButtonBar dialog box, click OK to accept the default trainModel to
e to
bind to. n s
Note: Ensure that the train button bar appears in the Structure window between the i ce
train and the panel form layout. The Structure window should look like this (if not, drag b l el
components to rearrange them):
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d11. Add labels for the train stops: Shipping, Billing, and Confirmation. JDeveloper
V i currently does not provide a way to use a text resource from a resource bundle file, so you
can just enter the text directly.
a. Open the CheckoutFlow task flow.
b. In the Structure pane, expand the view CheckoutShipping node.
c. Right-click the Train Stop and select Insert inside train-stop > Display Name from
context.
are going to delete them after testing the train, for now just create a temporary page for
each with only an output text item on it. Do not add any data binding. You can just create
the pages in the default directory to separate them from the more permanent pages that are
in your \oracle\storefront\ui\pages directory.
a. Double-click each view activity in turn (CheckoutPayment and CheckoutConfirm)
and click OK to accept the defaults in the Create JSF Page dialog box.
b. When the page opens in the designer, drag an Output Text to the page.
c. In the Property Inspector, change the Value of the Output Text item to reflect the title of u se
the page—Checkout Payment or Checkout Confirm. You do not need to place
e to
that text in the resource bundle because you do not use it on the permanent page that n s
i ce
el
you create later. You use this Output Text value only to be able to determine which
page appears at run time for the next step.
a b l
d. Run the CheckoutShipping page from the task flow to see the results. The navigation fe r
n s
train and button bar appear, with labels for each train stop. You can use either the
a
- tr
Billing link or the Next button to navigate to the payment page.
n
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d However, because you have added the train component and train button bar to only the
V i first page, you cannot navigate to the other pages from the payment page. You take
care of that problem when you create the real pages.
e. When finished, close the browser and undeploy the application as described in step
6(i) of Practice 2-4.
f. Delete the two temporary pages:
1) In the CheckoutFlow task flow, select the CheckoutPayment and
CheckoutConfirm view activities and delete the value in their page property.
2) In the Application Navigator, multiselect the CheckoutConfirm and
CheckoutPayment pages. Right-click and select Delete.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
d. Delete the other search control flow rule.a nodiagram
The e ฺ should now look similar to the
following screenshot: a s
h t Gu i d
)
i l ฺ comtuden
g ma is S
o@ th
ฺv i n
C (ac
d A
n o
Vi
e. Select one of the detail control flow rules and in the Property Palette, change its
from-activity-id to the wildcard rule by selecting it from the drop-down list.
f. Delete the other detail control flow rule. The diagram should now look similar to the
following screenshot:
g. Select the shop control flow rule and in the Property Palette, change its from-activity-
id to the wildcard rule by selecting it from the drop-down list.
u se
h. Rearrange the items on the diagram to look similar to the following screenshot:
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
a toSthe ShoppingFlow:
mactivities
2. Add three task flow call
• @ g
To call theocheckout this
flow
• ฺ vin the shopping cart
Tocdisplay
C
•
(a
To add an item to the cart
d A a. From the Application Navigator, drag CheckoutFlow to the ShoppingFlow task flow
Vi no diagram in the editor to create a task flow call activity.
u se
e to
n s
e. i
Drag a Control Flow Case from the wildcard to AddShoppingCart and lname ce the
outcome add.
r a ble
n s fe
n - tra
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
i n
f. (a cฺv
From the Application Navigator, again drag ShoppingCartFlow to the ShoppingFlow
A C task flow diagram in the editor to create a task flow call activity.
d
V ino g. In the Property Inspector, change the Activity ID of the task flow call activity to
DisplayShoppingCart. Do not change the ID in the Task Flow Reference section.
h. Drag a Control Flow Case from the wildcard to DisplayShoppingCart and name the
outcome cart.
You later add logic to the application so that there is a difference between displaying
the cart and adding an item to the cart.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m
3) Test the navigation with the
o
)Show Cart
e n tG button by running the ProductCatalog
ฺ c
page from the ShoppingFlow d
task flow.
m ail Stu
@ g this
ฺ v ino
C (ac
d A
n o
Vi 4) The Cart content should display now:
5) When you have finished, close the browser and undeploy the application as
described in step 6(i) of Practice 2-4.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
f er a
Practicestfor s
anLesson 15
- r
on ฺ
Chaptern15
s a ide
) a
h t Gu
i l ฺ comtuden
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
appealing. In this set of practices, you use layout components and techniques to enhance the
appearance of the application, and you implement partial page rendering to coordinate products
with a selected subcategory.
If you successfully completed all sections of the previous practice, including the optional steps,
you can continue working in the same project. However, if you prefer to start with a clean
application that contains everything completed up to the start of this lesson, open
Storefront-15.jws and edit the database information as described in step 4 of Practice 2-4.
This practice contains some optional steps that are similar to steps already done. If you want to u se
build the entire application yourself, you can complete the optional steps. However, in the
e to
interest of time, you may want to skip them. If you do so, you must begin the practices for the n s
next lesson by opening the starter application for that lesson. i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
se
ProductCatalog Subcategories table
ProductCatalog Products table
to u
ProductSearch (optional) Search results table n s e
i ce
ShoppingCart (optional) Items table
b l el
BrowseSuppliers (optional) Suppliers table
f er a
n s
apage.
a. In the Application Navigator, select the ProductCatalog
- t r
b. In the Structure window or in the editor, select the
n onaf:table
ฺ
– masterDetail1
component.
s a ide
c. a
h t Gu> Width to 100%. Tab out or click in any
In the Property Inspector, set the Appearance
)
other field to apply the new o m Youecan
c value. n see the effects of table stretching in the
i l ฺ
editor, as the table boundaries
a d
tu fill the horizontal space in the editor.
expand to
d. m
Select last fromgthe Column S
s Stretching drop-down list.
icolumn
You can see o @the effectst h
of stretching in the editor, as the last column expands
upin
to fillฺv the space.
C (ac
d A
n o
Vi
e. Apply the same type of stretching to the other two tables on the page: the one for
subcategories and the one for products. However, in the Products table (table2),
stretch the middle column (column3), because it is the one that contains a large
amount of text. To do so, follow these steps:
1) Select the middle column and give it the Id of Description.
2) Optional: (You may get errors when nondefault values of Id and TestId are not
identical. To avoid this possibility, reset the TestId to its default value.)
3) Select the table and set Column Stretching to column:Description.
f. Save your work.
g. Optional step: (If you choose not to complete this step, you must begin the
practices for the next lesson by opening the starter application.)
Copyright © 2010, Oracle and/or its affiliates. All rights reserved.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
Vi nod 3)
you use a resource bundle.
Similarly, set the Text property for the af:panelHeader – BrowseSubCategory1
to Subcategories.
2. On the ProductCatalog page, two of the tables and panel headers are grouped under an
af:panelGroupLayout component. Enable this component to display scroll bars when the
browser is too small to display all of its contents, and place the third table in the same panel
group layout.
a. In the Structure window, select af:panelGroupLayout.
b. In the Structure window, expand jsp:root > f:view > af:document > af:form >
af:panelGroupLayout-scroll.
c. In the Structure window, right-click af:table and select Surround With.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
o deADF Faces > Panel Header and click OK.
d. In the Surround Witha ilฺc box,
dialog t u
select
g m foristheSpanel header, set the Text property to Products,
e. In the Property th bundle.
Inspector
@ a resource
ousing
i n
optionally
f. (a cฺvyour work.
Save
2.AC
On the ProductDetails page, place the Product form, which is contained by default in a
n o d panel form layout, into a panel header titled Product Detail. Add a toolbar for the existing
Vi buttons.
a. Open the ProductDetails page.
b. In the Structure window, expand jsp:root > f:view > af:document > af:form.
c. Right-click af:panelFormLayout and select Surround With.
d. In the Surround With dialog box, select ADF Faces > Panel Header and click OK.
e. In the Property Inspector for the panel header, set the Text property to Product
Detail, optionally using the resource bundle.
f. In the Structure window, expand af:panelHeader > Panel Header facets.
u se
e to
h. Drag the existing Search and Shop buttons to the toolbar, in either the Structure n s
window or in the editor. i ce
b l el
fe ra
a n s
n - tr
i. Save your work. When you have finished,a
o ฺ look similar to this…
thenpage should
a s i d e
) h nt G u
m
co tude
i l ฺ
g ma is S
o@ th
ฺv i n
C (ac
d A
n o
Vi …and the Structure window should look similar to this:
a. Surround the Panel Form Layout with a Panel Header, but do not change the Text
(heading).
b. Add a Toolbar component and move the existing buttons to the toolbar facet of the
panel header.
c. For now, do not change the text of the panel header, because later you add a
conditional text display.
d. Using the Style property group and the Box tab, set the Width of the panel header to
500 pixels.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
e. Save your work. When you o m
have
)finished,
e n ttheGpage should look like this…
a ilฺc Stud
g m is
o@ th
ฺv i n
C (ac
d A
n o
Vi
…and the Structure window should look like this:
u se
e to
n s
i ce
b l el
fe ra
a n s
a. Open the CheckoutFlow task flow.
n - tr
b.
a no eฺ
Double-click the CheckoutPayment view activity to create the page. Ensure that you
h a s uid
create it in the \oracle\storefront\ui\pages directory.
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
c. Drag a Panel Group Layout from the Component Palette to the page and set its
Layout property to scroll.
d. Drag two Panel Headers to the page, one below the other and both within the panel
group layout. You may find it easier to drag the panel headers to the
af:panelGroupLayout in the Structure window.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
@ th
ฺ v ino
b.( a c it as a
Create Form > ADF Form.
C
A Include the following attributes in order, deleting others:
c.
n o d
V i Address1
Address2
City
StateProvince
PostalCode
CountryId
d. Do not include Navigation Controls or a Submit Button.
e. Click OK.
u se
e to
n s
3. In a similar manner, add the payment options. i ce
a. Drag the FODCheckoutAMDataControl > ShoppingCart1 > PaymentOption1 data b l el
control to the second panel header on the page and add it as an ADF Form.
fe ra
b. Include the following attributes in order, deleting others: a n s
n - tr
no eฺ
PaymentTypeCode
CardTypeCode a
s uid
AccountNumber h a
) nt G
ExpireDate
o m
c tude
i l ฺ
ma is S
CheckDigits
g th
RoutingIdentifier
@
ฺ v ino
InstitutionName
c. Docnot include Navigation Controls or a Submit Button.
a
C
d.
(Click OK.
d A
i n o e. Save your work. Now the page should look like this:
V
this:
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
o
a. In the CheckoutFlowatask t ude double-click the CheckoutConfirm view
ilฺcflowSdiagram,
mCheckoutConfirm
activity to creategthe
directory. o@ this page in the \oracle\storefront\ui\pages
ฺ inComponent Palette, drag a Panel Group Layout to the page and set its
vthe
b. c
From
(a
Layout property to scroll.
d AC
c. Drag a Panel Header to the Panel Group Layout and set its Text property to Payment
n o
Vi d.
Options, optionally using an existing text resource.
Drag a second Panel Group Layout to the first one, and set its Layout property to
horizontal and its StyleClass on the Style and Theme tab to AFStretchWidth.
e. Drag two Panel Headers to the horizontal Panel Group Layout. Set the Text of the first
to Shipping Address, and of the second to Billing Address, optionally using
existing text resources in the resource bundle.
f. Drag a spacer to the separator facets of each of the two Panel Group Layouts.
g. Drag another Panel Header to the outermost Panel Group Layout (the one with the
scroll layout) and set its Text to Order Items.
u se
e to
n s
i ce
5. Now that you have defined the layout, you can create databound components on the page.
b l el
Create a read-only table of shopping cart items on the Order Items panel header, and read-
fe ra
only forms for shipping address, billing address, and payment options on their respective
a n s
panel headers.
n - tr
a no eฺ
a. Drag the FODCheckoutAMDataControl > ShoppingCart1 > PaymentOption1 to the
Payment Options panel header as Form > ADF Read-only Form.
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d 1) Include the following attributes in order, deleting others:
V i Meaning
Meaning1
AccountNumber
ExpireDate
CheckDigits
RoutingIdentifier
InstitutionName
Note : Meaning and Meaning1 are the displayable values for PaymentTypeCode
and CardTypeCode, respectively. These attribute names are the default attribute
names for the view object. This is why it is important to take the time to relabel
them to something meaningful, as has been done in the LookupCodeEO entity
object control hints. You see the new labels at run time.
2) Do not include Navigation Controls or a Submit Button.
b. Drag the FODCheckoutAMDataControl > ShoppingCart1 > ShippingAddress to the
Shipping Address panel header as a Form > ADF Read-only Form.
PostalCode
CountryId
2) Do not include Navigation Controls or a Submit Button.
c. Drag the FODCheckoutAMDataControl > ShoppingCart1 > PaymentOption1 >
BillingAddress to the Billing Address panel header as a Form > ADF Read-only
Form.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
o m e t G order:
) in thensame
1) Include the following attributes
Address1
Address2 ma
ilฺc Stud
City @
g this
ฺ v ino
StateProvince
C (ac PostalCode
d A CountryId
n o
Vi d.
2) Do not include Navigation Controls or a Submit Button.
Drag FODCheckoutAMDataControl > ShoppingCart1 > ShoppingCartItem1 to the
Order Items panel header on the page as a Table > ADF Read-only Table.
1) Enable Sorting.
2) Include the following attributes in order:
ProductName
Quantity
UnitPrice
LineTotal
3) Set the Width of the table to 100% and enable last column stretching.
e. Save your work. The page should look like this…
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
hasliket this:
…and the Structure window should) look G u id
o m e n
a ilฺc Stud
g m is
o@ th
v i n
( acฺ
AC
d
V ino
6. Optional Step: To test your checkout pages, you must add the same train components to
the second and third train stops. In the lesson titled “Ensuring Reusability,” you define a
page template to use for all these pages, and the train components are on it rather than on
the individual pages. However, for now you temporarily add them to each page for testing.
Copyright © 2010, Oracle and/or its affiliates. All rights reserved.
u se
e to
n s
i ce
b l el
fe ra
a n s
e. Open the CheckoutPayment page.
n - tr
f.
g. Right-click af:form and select Paste.a no eฺ
In the Structure window, expand jsp:root > f:view > af:document > af:form.
h a s uid
h.
m ) nt G
Drag af:train and af:trainButtonBar above the af:panelGroupLayout.
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
In this practice, you work on the CheckoutPayment page to set the attributes to be visible only
when they are needed, based on the Payment Type. You add Expression Language to the
components that you want to conditionally display, and you use partial page rendering to refresh
only those components, rather than the entire page.
The Payment Type codes are listed below.
CC Credit Card
DD Direct Debit
IN Invoice u se
e to
PP PayPal
n s
l i
1. The PaymentTypeCode is a choice list and its default binding gives you the positionce of the
selected value in the list, not the value. On the CheckoutPayment page,
a le an attribute
bcreate
value named PaymentTypeCodeValue for the value of the payment r
fe type code.
n s
a. Click the Bindings tab on the CheckoutPayment.jspx
n - tra page.
b. In the Bindings section, click Add .
a no eฺ
c. Select Generic Bindings > attributeValues.
h a s uid
d. Click OK.
m ) nt G
ฺ
e. In the Create Attribute lBindingo
c tdialog d ebox:
i u
g ma is S
1) Select FODCheckoutAMDataControl.PaymentOption1 as the Data Source and
@
PaymentTypeCode
oOK. t has the Attribute.
v i n
2) ฺClick
( ac
C
n o dA
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
c. a no eฺ which is the ID of the
Now set the PartialTriggers property to PaymentType,
triggering component. h a s uid
1) On the Behavior panel,oclick m e n tG
) the small down arrow next to the PartialTriggers
ฺ c tud
text box and selectilEdit.
g ma dialog
2) In the Edit Property i s Sbox, select selectOneChoice – PaymentType and
shuttle t h
oit@to the Selected list. (This means that when the PaymentType component
i n
ฺv an autosubmit, it refreshes this data control. When it does, the code in the
forces
a c
( Visible property executes. If the code evaluates to true, the data control
A C appears.)
n o d
Vi
#{bindings.PaymentTypeCodeValue.inputValue eq 'CC'}
If this expression evaluates to true, the attribute is visible in the UI.
Note: You can use the Expression Builder to help build the expression. To get to
Expression Builder, click the arrow icon to the right of the Visible property on the
Advanced tab of the Property Inspector and select Expression Builder.
In the list at the left of the Expression Builder, select ADF Bindings > bindings >
PaymentTypeCodeValue > inputValue, which inserts
#{bindings.PaymentTypeCodeValue.inputValue} into the expression. You u se
then can add the condition to the end of the expression and click OK. e to
n s
Note : Ensure that you select the PaymentTypeCodeValue attribute binding and not
i ce
the PaymentTypeCode binding.
b l el
c. Now set the PartialTriggers property to PaymentType, which is the ID of the
fe ra
triggering component.
a n s
- tr
1) On the Behavior panel, click the small down arrow next to the PartialTriggers
n
text box and select Edit.
a no eฺ
h a s uid
2) In the Edit Property dialog box, select selectOneChoice – PaymentType and
) nt G
shuttle it to the Selected list.
m
o
c tude
5. In the same way, set CheckDigits to be visible only if the value is CC.
l ฺ
a. Select af:inputText
i
a for CheckDigits
S attribute in either the visual editor or the
g m i s
Structure window.
o @ th
b. Repeat i n
v steps (4b)–(4c) and code are similar.
acฺ
6. Set(RoutingIdentifier and InstitutionName to be visible only if the value is DD.
C
A Hint: Remember to set the expression for the Visible property and select PaymentType for
n o d the PartialTriggers property for these attributes.
Vi 7. Run CheckoutShipping from the CheckoutFlow task flow and navigate to the
CheckoutPayment page to test your work.
a. Test changing the Payment Type value to see the results. You should see that different
attributes appear depending on the value that you set.
b. When you have finished, close the browser and undeploy the application as described
in step 6(i) of Practice 2-4. u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
master-detail.)
1. Set the SubCategory table to be the triggering component for PPR.
a. Open the ProductCatalog page and select the af:table within the subcategories
panelHeader.
b. Set Id to SubCategory.
c. Verify that Row Selection is selected for this table. Use the table Edit icon in the
Property Inspector. (Do not just change the Row Selection property in the property
u se
inspector.)
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
2. Set the Products table to be the PPR target that is refreshed when the selected
subcategory changes.
a. Select the Products table (table2).
b. In the Property Inspector, select Edit to set the Partial Triggers property to
SubCategory.
u se
e to
n s
i ce
b l el
fe ra
a n s
d. Click OK.
n - tr
3. Test the page.
a no eฺ
a. Run the page, either directly or from a
h stask flow.
the
u id
b. Select Category, then SubCategory
m ) andntcheckG that the correct products appear.
o e
6(i)a
described in step m
i c Syour
c. When you have finished,lฺclose
of Practice
udbrowser and undeploy the application as
t2-4.
@ g this
ฺ v ino
( ac
C
n o dA
V i
u se
e to
n s
i ce
b l el
f er a
Practicestfor s
anLesson 16
- r
on ฺ
Chaptern16
s a ide
) a
h t Gu
i l ฺ comtuden
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
each page is exactly the same. For example, you want navigation buttons to appear in exactly
the same location on pages that are used in series, such as CheckoutFlow. To make the layout
cleaner and reusable, you create and apply a template to the pages.
The FODShoppingDashboard page is meant to be the main page of the application. Other
applications that will be developed for this company should use a similar look, so you create a
page template that imposes a certain layout. You then create the FODShoppingDashboard
page, using this page template.
The bounded task flows that you have created so far have used pages, not page fragments.
This enabled you to test them independently. However, now you incorporate these task flows as u se
regions on the main FODShoppingDashboard page. To do so, you must first convert the
e to
bounded task flows to use page fragments. n s
i ce
If you successfully completed all sections of the previous practice, including the optional steps,
you can continue working in the same project. However, if you prefer to start with a clean b l el
application that contains everything completed up to the start of this lesson, open fe ra
a
Storefront-16.jws and edit the database information as described in step 4 of Practice 2-4. n s
n - tr
This practice contains some optional steps that are similar to steps already done. If you want to
a no eฺ
build the entire application yourself, you can complete the optional steps. However, in the
a s uid
interest of time, you may want to skip them. If you do so, you must begin the practices for the
h
) nt G
next lesson by opening the starter application for that lesson.
m
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
3. There is only one full page left, which is ProductCategory.jspx. This is a page on the
unbounded task flow. Extract this page into its own bounded task flow named
ProductCategoryFlow, and then convert it to use page fragments as well.
u se
e to
n s
i ce
b l el
a. Open adfc-config.xml. Make sure that the views appear in the diagram. fe ra
b. a n
Right-click the ProductCategory view activity and select Extract Task Flow. Click
s
Yes in the Warning dialog box. n - tr
c. no eฺ
In the Extract Bounded Task Flow dialog box:
a
a s uid
1) Enter ProductCategoryFlow as the File Name.
h
m ) nt G
2) Append \oracle\storefront\ui\flow to the Directory path.
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
3) Click OK.
d. The task flow opens in the editor. Right-click the ProductCategory view activity and
mark it as the default activity.
e. Convert ProductCategoryFlow to use page fragments as you did the other task flows.
u se
e to
g. Save your work. n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
To avoid this unnecessary duplication, you now create a template that manages the train
components for each of the pages. The template also contains a Panel Group Layout and a
Panel Header to provide additional layout structure for the checkout pages.
1. Create a new page template named CheckoutPageTemplate, with a content facet and
a required title attribute.
a. In the Application Navigator, right-click the directory where you have been filing pages
and select New.
b. In the New Gallery, select Web Tier > JSF > JSF Page Template. u se
e to
c. Set the following properties for the new page template:
n s
i ce
File Name: CheckoutPageTemplate.jspx
b l el
Directory: <ProjHome>\public_html\oracle\storefront\ui\
fe ra
pages\templates
a n s
Page Template Name: n - tr
no eฺ
CheckoutPageTemplate
a
sicon touadd
id the facet.)
Facet Definitions tab a
(Click thehAdd
Name:
o m )content
e n tG
a ilฺc Stud
g m is
o@ th
v i n
( acฺ
d AC
i n o d. Click the Attributes tab to specify the following:
V
Attributes tab (Click the Add icon to add the attribute.)
title java.lang.String required
e. Click OK.
f. Expand the af:panelHeader > Panel Header facets node in the Structure pane.
g. Add a Toolbar to af:panelHeader > Panel Header facets > toolbar.
h. Add a Button to af:toolbar.
1) Set the Text to Cancel, optionally using the resource bundle. u se
e to
2) Enter cancel for the Action property.
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
3) Set the Immediate property )to true. t G
m en
ctooaf:toolbar
i. Add a Train Button Bar
a i l ฺ t u d inside the af:panelHeader toolbar facet
property to S
and set the Valuem
@ g t h is
ino Button to af:toolbar inside the af:panelHeader toolbar facet.
#{controllerContext.currentViewPort.taskFlowContext.trainModel}.
j. v
Addฺanother
C (ac
d A
n o
Vi
u se
e to
n s
i ce
b l el
f er a
Note: If you use the Expression Builder, it displays
s
athen code as if it were an error.
- t r
It has context for the trainModel, but does notnunderstand .next in the
expression. You can ignore the error. a n
o ฺ
a s i d ethe following…
3. Save your work. The page template should look
) h nt G u
similar to
m
co tude
i l ฺ
g ma is S
o@ th
v i n
( acฺ
AC
d
V ino …and the Structure window should look similar to the following:
template.
d. Back in the Source editor, replace the highlighted code with the following: (You can
copy the code from PageTemplate.txt in your files directory.)
<af:pageTemplate
viewId="/oracle/storefront/ui/pages/templates/CheckoutPageTempla
te.jspx">
se
<f:facet name="content"/>
<f:attribute name="title"/>
to u
</af:pageTemplate>
n s e
i ce
The error will be solved in the following steps.
b l el
e. Click the Design tab. fe ra
f. Note that in the Structure window, there is now an af:pageTemplate, an a n s
n - tr
f:attribute, and a content facet. Set the Value property of f:attribute to
no eฺ
Shipping, optionally using the resource bundle.
a
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i 5. The template contains the outermost Panel Group Layout (which holds the train, buttons,
and the Panel Header). Therefore, when you apply the template to your page, you must
move the content to the template content facet.
a. Using the Structure window, drag af:panelHeader – Shipping Address to the
content facet.
6. Apply the template to the other pages in the checkout flow, using Billing as the title for the
CheckoutPayment page and Confirmation as the title for the CheckoutConfirm page.
a. Open CheckoutPayment.jsff.
Copyright © 2010, Oracle and/or its affiliates. All rights reserved.
c. Open CheckoutConfirm.jsff.
d. Repeat the steps above, changing the value of the title attribute to Confirmation.
(The content area of this page is in the outermost panelGroupLayout.) u se
7. Save your work. e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
available.
In this practice, you create a page template to be used on the main page of any of the
company’s applications. You then create the FODShoppingDashboard page and base it on this
template. The layout of the template should be as follows:
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
1.
c ฺ vin
In the templates subdirectory of your directory for pages, create a new page template
named MainPageTemplate. Define content areas named companyLogo, tab1Content,
( a
tab2Content, and mainContent. Define required attributes called companyName,
A C
tab1Title, and tab2Title.
n o d
V i a. In the Application Navigator, right-click the directory where you have already created a
page template and select New.
b. In the New Gallery, select Web Tier > JSF > JSF Page Template.
c. Set the following properties for the new page template, and then click OK:
File Name MainPageTemplate.jspx
Directory <ProjHome>\public_html\oracle\storefront\ui\p
ages\templates
Page Template Name MainPageTemplate
Facet Definitions tab companyLogo
(Click the Add icon to tab1Content
add each facet.) tab2Content
mainContent
2. The new template opens in the editor. Add a component with resizable vertical panes, so
that page developers can resize it to fit the size of the image that they add to the top pane.
u se
The component should be one that automatically stretches its children. Stretch it to fit the
e to
browser vertically and horizontally.
n s
i ce
el
a. Drag a Panel Splitter to the page. Ensure that it appears above af:xmlContent in the
Structure window.
a b l
1) Set its Orientation to vertical. fe r
a n s
2) Set its SplitterPosition to 125.
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
3.
a
You( want the company logo image and the company name to be arranged horizontally in
C
A the top portion of the page. Add a layout component to accomplish that, and add the
n o d
V i company logo and name.
a. In the Structure window, expand af:panelSplitter and Panel Splitter facets.
b. Drag a Panel Form Layout to the first facet and set the following properties:
1) Set Rows to 1 (so that the components you add are in one horizontal row).
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
d. Drag a spacer to the af:panelFormLayout, a nothat etheฺ company name that you add in
so
the next step is not right up against the
h a slogo. uid
e. Drag an Output Text component
o m e tG
)to the naf:panelFormLayout.
a ilฺc Stud
1) Set its Value to #{attrs.companyName}. (You can use the Expression Builder
and select JSP
g m Objects
i s > attrs > companyName.) Designers of pages that use
o@
this template can t h
supply a value for the companyName attribute.
2) ฺIn i n
v the Style > Text section of the Property Inspector, set Color to Blue, Size to
C (ac xx-large, Italic to italic, and Bold to bold.
d A
n o
Vi
4. Below the header section that has the company logo and name, you want two resizable
panels that consume the remainder of the browser area. The left panel should contain two
tabs where page designers can place content, and the right panel should contain the main
content area. Add the layout and components for this area.
a. Drag a Panel Splitter to the second facet of the root af:panelSplitter and set its
Orientation property to horizontal.
b. Expand af:panelSplitter >Panel Splitter facets for the panel splitter that you just
added.
c. Drag a Panel Tabbed component to the first panel splitter facet.
Copyright © 2010, Oracle and/or its affiliates. All rights reserved.
g.
facet name.
a no eฺ
Drag a Facet Ref to the second facet of the af:panelSplitter and select mainContent
h a s uid
as the facet name. This provides a spot for page designers to place the main content of
the application. m ) nt G
l ฺ o
c tude
h. i
Your template should look like the following:
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
i. Save your work. You must save a page template before you can use it.
5. On the main unbounded task flow for the application, create the FODShoppingDashboard
page, applying the template that you just created.
a. Open adfc-config.xml.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
a i S to customize the page for the Storefront application.
6. Use the attributes ofg mpage
the i s
template
Supply values t h
ofor@the attributes of the template. The company name should be Storefront
Demo c
i n
ฺvthe tabs should be labeled Categories and Suppliers. The IDE does not provide
(
a wayatoand
use a resource bundle, so you can enter hard-coded strings in this case.
C
A a. Set the attribute values in FODShoppingDashboard. In the editor, click the
n o d
Vi b.
FODShoppingDashboard tab, or reopen that file if you have closed it.
In the Structure window, select af:pageTemplate.
c. In the Property Inspector, set the following values:
companyName: Storefront Demo
tab1Title: Categories
tab2Title: Suppliers
u se
e to
n s
i ce
d. Add the company logo to the page.
b l el
1) In the page design, drag an Image component from the Component Palette to the
fe ra
companyLogo facet.
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
@ th
2)
ฺ inoInsert
In the
v
navigate to
Image dialog box, click the arrow next to Source, click Edit, and
the \images subdirectory of your Labs main directory.
(3) ac Select store.gif and click OK.
A C
n o d 4) In the Image Location Problem warning box, click Yes to copy the image into the
V i document root of your project.
a. Select the FODShoppingDashboard page in the editor, and then in the Structure
window, click Freeze View .
b. From the Application Navigator, drag ProductCategoryFlow to the tab1Content facet
in the Structure window.
c. Create the flow as a Region.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i 2. Add the tab2 content. You should display the ShowSuppliersFlow in this area.
a. From the Application Navigator, drag ShowSuppliersFlow to the tab2Content facet in
the editor.
b. Create the flow as a Region.
layout to the page to improve its appearance: Change the heading of the table to Search
Products and place all components under a root panel header with scrollbars.
a. Open the ProductSearch page fragment.
b. In the existing af:panelHeader, use the resource bundle to change the text from
ProductEO to Search Products.
c. Move af:table to the af:panelHeader.
u se
e to
n s
i ce
b l el
fe ra
a n s
d. n - tr
Drag a toolbar to the toolbar facet of the panel header.
e. a no eฺ
Drag a toolbar button to the toolbar facet and set the following properties on the
button: h a s uid
o m
Text (use the resource bundle)
) Shop
e n tG
Action a ilฺc Stud shop
g m is
o@
The Structure th look like this:
window should
ฺv i n
C (ac
d A
n o
Vi
f. Run FODShoppingDashboard again from the unbounded task flow to ensure that the
Shop button on the Product Search page navigates back to the shopping flow (Product
Catalog page).
u se
e to
n s
i ce
b l el
f er a
Practicestfor s
anLesson 17
- r
on ฺ
Chaptern17
s a ide
) a
h t Gu
i l ฺ comtuden
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
Initially the Categories table should appear. When the user clicks the name of a category, the
Subcategories table should display the subcategories for the category that the user clicked.
Then if the user clicks a subcategory, the Products table should display the products for that
subcategory.
You accomplish this by using parameters. In the practices for this lesson, you modify the
ProductCatalog page to display specific tables and data based on those parameters.
If you successfully completed all sections of the previous practice, including the optional steps,
you can continue working in the same project. However, if you prefer to start with a clean u se
application that contains everything completed up to the start of this lesson, open e to
n s
Storefront-17.jws and edit the database information as described in step 4 of Practice 2-4.
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
u se
d. Deselect Row Selection and click OK. e to
n s
Note: By using the editor, JDeveloper removes the Row Selection and whatever i ce
listeners were required. If you just remove the row selection manually in the Property
b l el
Inspector, the listeners still remain.
fe ra
e. Select the SubCategory table and remove Row Selection in the same way.
a n s
2. Now you add page parameters. n - tr
no eฺ
Set page parameters on the ProductCatalog page to accept parameters named
a
a s uid
param_CategoryId, param_SubCategoryId, param_CategoryName, and
h
param_SubCategoryName.
m ) nt G
l ฺ o
c tude
The page parameters should get their values from pageFlowScope variables named
i
ma is S
CategoryId, SubCategoryId, CategoryName, and SubCategoryName.
g
a. Open the Page
o th for the ProductCatalog page (right-click the page and
@ Definition
i n
selectvGo to Page Definition, or click the Bindings tab).
ฺ
b. (Addc the following parameters to the page definition:
a
d AC
i n o
V
id Value
param_CategoryId #{pageFlowScope.CategoryId}
param_SubCategoryId #{pageFlowScope.SubCategoryId}
param_CategoryName #{pageFlowScope.CategoryName}
param_SubCategoryName #{pageFlowScope.SubCategoryName}
Leave the page definition file open for the next step.
3. There is a method named setCurrentCategory() in the FODProductAM application
module. This method takes two arguments: a category ID and a subcategory ID. It
reexecutes the BrowseCategory, BrowseSubcategory, and BrowseProduct view object
queries based on the values that are passed to it.
Edit the bindings for the ProductCatalog page so that this method is executed upon u se
loading the page. Pass to the method two of the parameters that you have just defined e to
above. n s
i ce
a. Still in the page definition of the ProductCatalog page, click the Bindings and
b l el
Executables tab, then in the Bindings section, click the Create Control Binding green
fe ra
plus sign and add a methodAction.
a n s
b. n - tr
In the Create Action Binding dialog box, select the FODProductAMDataControl Data
no eฺ
Collection, and then confirm that setCurrentCategory appears in the Operation
a
drop-down list.
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
c. In the Create Action Binding dialog box, in the Parameters section, set these values
for the following parameters:
Name Value
categoryId #{bindings.param_CategoryId}
subCategoryId #{bindings.param_SubCategoryId}
(You can use Expression Builder; the parameters are shown under ADF Bindings >
bindings.)
The Parameters section of the Create Action Binding Editor should look like the
following:
u se
e to
n s
i ce
b l el
fe ra
Click OK.
a n s
d. Add an InvokeAction to the Executables.
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
e. Set the id to@ th
o invokeSetCurrentCategory and bind it to setCurrentCategory.
f. i n
v Refresh property to ifNeeded.
Set ฺthe
a c
(Make sure that invokeAction is the first executable in the list. This ensures that the
g.
C
dA method is executed first when the page is loaded. (If you must move it, drag it to the
h. Save your work, and leave the page definition file open for the next step.
4. You have defined parameters that take their values from pageFlowScope variables. But
how do those values get stored in the pageFlowScope variables? In this step, you store
these values.
1) Still in the page definition file for ProductCatalog, edit the BrowseCategory1
binding and add CategoryId as a display attribute. Hint: Click the
BrowseCategory1 binding; click Edit; select the rule in the Tree Binding editor;
shuttle the CategoryId from Available to Display Attributes.
u se
The Tree Binding editor should look like the following:
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
2) Repeat this step for BrowseSubCategory1 because you are going to use the
CategoryId that is selected in the SubCategories table to set the
subcategory-related parameters.
b. On the ProductCatalog page, convert the CategoryName field in the Categories
table to be a link. When a user clicks the link, the page should use setActionListeners
to set the pageFlowScope parameters.
1) Click the Design tab and in the Structure window for the ProductCatalog page,
and expand af:table - masterDetail1.
u se
e to
n s
li ce
l e
b following
6) Insert two setActionListeners operations inside the Link with
e r athe
properties.
a n sf
From To
n - tr
#{row.CategoryId} a no eฺ
#{pageFlowScope.CategoryId}
s uid
#{row.CategoryName} ha#{pageFlowScope.CategoryName}
m
Note: You use the CategoryName
o
) nand
e t GSubCategoryName parameters when
you set breadcrumbs
a ilฺcin theSnext
t udsection.
c. Repeat the stepsg m is
for the SubCategory table. (Make sure to pay close attention to the
@ t h
i no
pageFlowScope
ฺ v
variable names in each setActionListener.)
1)c Expand af:table - SubCategory in the second panel header.
C (a
2) Expand the first af:column node and click af:outputText for CategoryName
d A and copy (Ctrl + C) the Value property.
n o
Vi 3) Right-click af:outputText for CategoryName and select Convert To.
4) Select Link, and then click OK in the Confirm Convert dialog box.
5) Paste into the Text property the value that you copied a moment ago. The value
should be #{row.CategoryName}.
6) Insert two setActionListeners inside the Link with the following properties.
From To
#{row.CategoryId} #{pageFlowScope.SubCategoryId}
#{row.CategoryName} #{pageFlowScope.SubCategoryName}
5. Modify the rendering of the tables so that only a single table appears at a time.
Hint: If both category and subcategory parameters are null, the Categories table
should appear (no links have been clicked to set the parameters). If only the
categoryId parameter is set, the Subcategories table should appear because the
user clicked a link on the Categories table to set the category ID. If both parameters
are set, the Products table should be displayed (both Category and Subcategory links
have been clicked, so both parameters have been set).
Copyright © 2010, Oracle and/or its affiliates. All rights reserved.
b. Select the second af:table (SubCategory) and set the Rendered property so that u se
the table appears if the CategoryId parameter is set but the SubCategoryId e to
parameter is null. (This means that the page set a category, but not a subcategory.) n s
i ce
The EL code is:
b l el
#{bindings.param_CategoryId ne null and
fe ra
bindings.param_SubCategoryId eq null}
a n s
c.
n - tr
Select the third af:table - table2 (Products) and set the Rendered property so
a no eฺ
that the table appears if there is a categoryId and a subCategoryId. (This means
that the page has set a Category and subcategory.) The EL code is:
h a s uid
) nt G
#{bindings.param_CategoryId ne null and
m
o
c tudepage so that all tables are under a single panel
bindings.param_SubCategoryId ne null}
l ฺ
i
6. Modify the layout of the ProductCatalog
g ma depending
header whose title changes i s S on the table that appears.
t h
o@ window for the ProductCatalog page, select af:table –
a. In the Structure
ฺv i n in the second af:panelHeader and drag it to the first
( a c
SubCategory
header.
1) Expand Panel Header facets.
2) Drag a toolbar to the toolbar facet.
3) Drag the Search and Show Cart buttons to the toolbar.
4) The Structure should now look something like:
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
C
7.A Test the page.
n o d
Vi a.
b.
Run FODShoppingDashboard from the adfc-config task flow.
In the right pane, the page should initially display categories. Click one of the category
names.
c. The page should now display subcategories. (The title of the panel header still says
Categories.) Click one of the subcategory names.
d. The page should now display products, and the title of the panel header changes to
Products. Note that there is no way to navigate back to the Categories table. You
fix this in the next practice.
e. Close the browser when finished, and undeploy the application as described in step
6(i) of Practice 2-4.
parameters to display the correct section of the page, so in this practice, you just set those
parameters based on which breadcrumb is clicked.
1. For the first breadcrumb, you want the Categories table to appear; therefore, reset all the
parameters to null.
Hint: Remember that the parameters get their values from the pageFlowScope variables.
a. On the ProductCatalog page, select the first af:commandNavigationItem—the one
labeled Store.
u se
b. Add four setActionListeners operations with the following properties:
e to
From To n s
i ce
#{null} #{pageFlowScope.CategoryId}
b l el
#{null} #{pageFlowScope.CategoryName}
fe ra
#{null} #{pageFlowScope.SubCategoryId}
a n s
n - tr
nyouo could
#{null} #{pageFlowScope.SubCategoryName}
a s a
Hint: After you add the first setActionListener,
i d eฺ use the Source tab to copy,
paste, and then modify the code.
) h t Gu
i l ฺ comtuden
g ma is S
o@ th
ฺv i n
(ac
d AC
Vi no 2. Set the second breadcrumb to appear only if the user has clicked a category name in the
Categories table. Label the breadcrumb with the Category name that the user clicked in the
Categories table. Set the second breadcrumb to display the Subcategory table when
a user clicks it.
a. Select the second of the three navigation items in the Structure window.
b. Set the Text property to #{bindings.param_CategoryName}. You can use
Expression Builder to set this (ADF Bindings > bindings > param_CategoryName).
c. Set the Rendered property to
#{bindings.param_CategoryId ne null}.
d. If a user clicks the second breadcrumb, he or she wants to see SubCategories. You
use the setActionListeners to reset just the SubCategory parameters.
Add two setActionListeners with the following properties:
From To
#{null} #{pageFlowScope.SubCategoryId}
#{null} #{pageFlowScope.SubCategoryName}
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
c. In the Edit Action Binding dialog box, set the Value of the productId parameter to
#{pageFlowScope.ProductId}, and then click OK.
d. Add a Control Flow Case from addItemToCart to ShoppingCart and label it done.
(You can later change this to include a commit function, but for now you simply want to
go to the cart after the method call.)
e. In the addItemToCart method call, change the fixed-outcome property to done.
c. Create two Control Flow Cases from ChooseAction: one to addItemToCart named
add, and the other to ShoppingCart named display.
u se
e to
n s
i ce
b l el
fe ra
a n s
d. - tr
Add two expressions to the ChooseAction router that evaluate
n
a no eฺ
pageFlowScope.Action. If the value is Add, use the add outcome. If it is Display,
use the display outcome. Hint: The add expression is:
h a s uid
#{pageFlowScope.Action == 'Add'}
m ) nt G
o
c tude
Note: The ChooseAction property is in the Cases section on the General tab of the
l ฺ
Property Inspector. i
e. g ma is S
Set the display outcome to be the default outcome of the router.
o @ th
c ฺ vin
( a
A C
n o d
V i
4. The shopping cart flow is expecting parameters named Action and optionally,
ProductId. Modify the shopping flow to send the correct parameters.
a. Open the ShoppingFlow diagram.
b. Select DisplayShoppingCart. Two parameters have been added to the
DisplayShoppingCart task flow call in the Parameters section of the Property
Inspector. Set a value for the Action parameter as follows:
Name Value
Action Display
ProductId Leave blank (or empty)
c. In the ShoppingFlow, the same two parameters have been added to the
AddShoppingCart task flow call; select AddShoppingCart and in the parameters
section, set the values as follows:
Name Value
Action Add
u se
ProductId #{requestScope.ProductId}
e to
n s
The ShoppingFlow is now set up to send the Action parameter and, if needed,
l i ce to
send the ProductId as well.
r a ble
5. Finally, you must get the productId from the calling page and put itfe into the requestScope
variable ProductId. The call to add the item to the cart should a n s
be placed on the
ProductDetails page. Hint: There is currently no binding - t r
a. Open the ProductDetails page fragment. a n
on forฺ ProductId.
a s header’s e facet and label it Add Item
idtoolbar
b. Add a button to the toolbar of the h panel
) nt G u
to Cart. Set its Action to add.
o m
c tude
i l
c. Add a binding for ProductId. ฺ
g ma tab.is S
1) Click the Bindings
o @ th
i n
v the Bindings section, click Add .
2) ฺIn
a c
(3) Add an attributeValues binding whose Data Source is
A C FODProductAMDataControl.BrowseProduct and whose Attribute is
n o d
Vi
ProductId.
d. Return to the Design of the page and add a setActionListener to the Add Item to
Cart button and set the value of From to #{bindings.ProductId.inputValue}
and the value of To #{requestScope.ProductId}.
Hint: Right-click af:commandButton, select Insert inside > ADF Faces > Set
Action Listener and set the From and To values. Make sure to put the correct
1. Modify the manage supplier flow to accept the following input parameter:
Name Value Required
SupplierAction #{pageFlowScope.SupplierAction} True
a. Open ManageSupplierFlow.
b. Click the task-flow-definition in the Structure window.
c. Select Parameters in the Property Inspector.
u se
d. Click Add to add the parameter shown above. e to
n s
i ce
b l el
fe ra
a n s
n - tr
2. Add a method call to the ManageSupplierFlow task
a noflow etoฺcall the CreateInsert operation
h a s uidactivity when finished.
for a new supplier and connect it to the SupplierUpdate
a. Open the ManageSupplierFlow)task flow.t G
m FODSupplierAMDataControl
coexpand e n
b. In the Data Controls panel,
a i l ฺ t u d > Supplier1 >
g m is S
Operations and drag the CreateInsert operation to the task flow diagram to create a
method call activity.
o@ th
c. Change
ฺ v i n
fixed-outcome of the CreateInsert method call activity to done.
d. (a c
Drag a Control Flow Case from CreateInsert to SupplierUpdate. from-outcome
C
A should default to done.
o d
n 3. Set up the task flow so that a new supplier is created when a parameter passed to it has a
Vi value of New, or that an existing supplier is updated when the parameter value is Update.
a. Add a Router to the flow and name it ChooseAction.
b. Right-click the ChooseAction router and mark the activity as the default activity for
the page flow.
c. Create two Control Flow Cases from ChooseAction: one to SupplierUpdate named
update, and the other to CreateInsert named new.
d. Add two expressions to the ChooseAction router that evaluate
pageFlowScope.SupplierAction. If the value is New, use the new outcome. If it is
Update, use the update outcome. Hint: The new expression is:
#{pageFlowScope.SupplierAction == 'New'}
Note: You define these expressions in the Cases section under the Common tab of
the Property Inspector.
4. The manage suppliers flow is expecting a parameter named SupplierAction. Modify the
show suppliers flow to send the correct parameter.
a. Open the ShowSuppliersFlow diagram.
b. Add a parameter to the ManageSupplierFlow task flow call activity using the
Parameters section of the Property Inspector. (The parameter should be there by u se
default because you have set it on the ManageSupplierFlow task flow, so just set its e to
value in the task flow call activity.) n s
i ce
Name Value
b l el
fe ra
SupplierAction #{requestScope.SupplierAction}
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
5. Set the requestScope variable SupplierAction. The calls to create a new supplier or
update an existing one should be placed on the BrowseSuppliers page.
a. Open the BrowseSuppliers page.
b. Add a toolbar to the panel header’s toolbar facet.
c. Add a toolbar button to the toolbar and label it New Supplier. Set its Action to
update.
d. Add a setActionListener to the New Supplier button that sets the value of
#{requestScope.SupplierAction} to New when the button is clicked.
Set the From property to #{'New'} and the To property to
#{requestScope.SupplierAction}.
u se
e to
f. Set the From property to #{'Update'}. Set the To value to n s
#{requestScope.SupplierAction} to Update when the link is clicked. li ce
b l e
f e a
6. Finally, change the panel header text of the SupplierUpdate page to rconditionally display
either Update Supplier or New Supplier, depending on the valuesof the parameter that is
passed.
- t r an
a. On the SupplierUpdate page, select the panel o
n n
header.
b. If you are not using resource bundle forstext, a changed ฺ Text to the expression
ethe
a
h t==G'New' i
u ? 'New Supplier' :
#{pageFlowScope.SupplierAction
'Update Supplier'} (alloon
)
mone line.)n
i l ฺ c d e
c. If you are using a resource
m a bundle S tufor text:
g
1) You must make some
@ s
thientries to the resource bundle: Although you can edit it
o
directly, it may be easier to change
in bundle (use UPDATE_SUPPLIER_TITLE the Display to Update Supplier, using the
ฺ v
( ac change it again to New Supplier, using the resourceasbundle
resource the key), and save it. Then
(use
A C NEW_SUPPLIER_TITLE as the key).
n o d
Vi 2) Now that you have the text resources entered in the resource bundle, you can use
them in a conditional expression to define the title based on the parameter. Enter
the following in the Text property (all on one line):
#{pageFlowScope.SupplierAction == 'New' ?
storefrontuiBundle.NEW_SUPPLIER_TITLE :
storefrontuiBundle.UPDATE_SUPPLIER_TITLE}
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
f er a
Practicestfor s
anLesson 18
- r
on ฺ
Chaptern18
s a ide
) a
h t Gu
i l ฺ comtuden
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
enables your page to accept values from outside the task flow as well.
In addition to changing the display based on what the user clicks on the page, you also want to
change the display depending on what the user clicks in the category tree in the left region of
the containing page. When a user clicks a category in the tree, its subcategories should appear
in the shopping region. If the user clicks a subcategory in the tree, then the shopping region
should display its products.
You accomplish this by defining a contextual event that passes parameters from the
ProductCategory (tree) region to the ShoppingFlow region. First, you define the task flow u se
parameters on the ShoppingFlow, and then you enable the category tree to pass parameters
e to
(through the use of a bean) to the Shopping flow. You use a contextual event to coordinate this n s
interaction between the regions on the main page. i ce
If you successfully completed all sections of the previous practice, you can continue working in b l el
fe
the same project. However, if you prefer to start with a clean application that contains everything ra
completed up to the start of this lesson, open Storefront-18.jws and edit the database a n s
information as described in step 4 of Practice 2-4. n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
pageFlowScope variables from outside the task flow, the task flow must be able to receive
values that are set in another region. In this practice, you define input parameters on the
ShoppingFlow task flow as the first step in setting up a contextual event.
1. Define four parameters on the ShoppingFlow task flow: CategoryId, CategoryName,
SubCategoryId, and SubCategoryName. Store them in pageFlowScope variables of
the same name.
a. Select the ShoppingFlow in the Application Navigator.
b. Select the task-flow-definition – ShoppingFlow node in the Structure window. u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
c. no eฺto create the following input
Use the Parameters section of the Property Inspector
parameters: a
h a s uid
Name Value
m ) nt G
l ฺ o d e
c #{pageFlowScope.CategoryId}
CategoryId i t u
CategoryName g ma is#{pageFlowScope.CategoryName}
S
o@ t h
ฺ v i n
SubCategoryId #{pageFlowScope.SubCategoryId}
c
(aSubCategoryName #{pageFlowScope.SubCategoryName}
n o d
Vi
Note that this is just another way to set the pageFlowScope variables in the
ShoppingFlow task flow. The values are set either by clicking links on the
ProductCatalog page, as you defined in the previous set of practices, or they can be
set by receiving values via these input parameters on the task flow. After the values are
received, they have the same effect of setting the correct table to appear and setting
the breadcrumbs.
In the remaining practices in this lesson, you use a contextual event to pass values to
these parameters when a node in the category tree is clicked.
C (ac
d A
n o /**
Vi * Provides various utility methods that are handy to
* have around when working with ADF.
*/
public class ADFUtil {
/**
* When a bounded task flow manages a transaction (marked as
* requires-transaction, requires-new-transaction, or
* requires- existing-transaction), then the task flow must
* issue any commits or rollbacks that are needed.
* This is essentially to keep the state of the transaction
* that the task flow understands in synch with the state
* of the transaction in the ADFbc layer.
* Use this method to issue a commit in the middle of a task
* flow while staying in the task flow.
Copyright © 2010, Oracle and/or its affiliates. All rights reserved.
FacesContext.getCurrentInstance().getExternalContext().getSessio
nMap();
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2011, Oracle and/or its affiliatesฺ
BindingContext context =
(BindingContext)sessionMap.get(BindingContext.CONTEXT_ID);
String currentFrameName =
context.getCurrentDataControlFrame();
DataControlFrame dcFrame =
context.findDataControlFrame(currentFrameName);
u se
e to
dcFrame.commit(); n s
i ce
dcFrame.beginTransaction(null);
b l el
}
fe ra
a n s
/**
n - tr
* Programmatic evaluation of EL.
a no eฺ
*
h a s uid
* @param el EL to evaluate
m ) nt G
l ฺ o
c tude
i
* @return Result of the evaluation
*/
g ma is S
o @ th
public static Object evaluateEL(String el) {
V i ExpressionFactory expressionFactory =
facesContext.getApplication().getExpressionFactory();
ValueExpression exp =
expressionFactory.createValueExpression(elContext,
el, Object.class);
return exp.getValue(elContext);
}
/**
* Programmatic invocation of a method that an EL evaluates
* to. The method must not take any parameters.
*
* @param el EL of the method to invoke
* @return Object that the method returns
/**
* Programmatic invocation of a method that an EL evaluates to.
*
* @param el EL of the method to invoke
* @param paramTypes Array of Class defining the types of the
* parameters
se
* @param params Array of Object defining the values of the
* parametrs
to u
* @return Object that the method returns
n s e
*/
i ce
public static Object invokeEL(String el,
b l el
Class[] paramTypes, Object[] params) { fe ra
a n s
FacesContext facesContext =
n - tr
no eฺ
FacesContext.getCurrentInstance();
a
ELContext elContext = facesContext.getELContext();
s uid
h a
) nt G
ExpressionFactory expressionFactory =
o m
c tude
i l ฺ
ma is S exp =
facesContext.getApplication().getExpressionFactory();
g
MethodExpression
th
i n o@expressionFactory.createMethodExpression(elContext,
ฺv
C (ac el, Object.class, paramTypes);
return exp.invoke(elContext, params);
d A
n o }
Vi
/**
* Sets a value into an EL object. Provides similar
* functionality to
* the <af:setActionListener> tag, except the
* <code>from</code> is
* not an EL. You can get similar behavior by using the
* following...<br>
* <code>setEL(<b>to</b>, evaluateEL(<b>from</b>))</code>
*
* @param el EL object to assign a value
* @param val Value to assign
*/
public static void setEL(String el, Object val) {
FacesContext facesContext =
Copyright © 2010, Oracle and/or its affiliates. All rights reserved.
facesContext.getApplication().getExpressionFactory();
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2011, Oracle and/or its affiliatesฺ
ValueExpression exp =
expressionFactory.createValueExpression(elContext,
el, Object.class);
exp.setValue(elContext, val);
}
}
6. Right-click anywhere in the code editor and select Make to compile the class.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
(JUCtrlHierNodeBinding)ADFUtil.evaluateEL("#{node}");
Row nodeRow = node.getRow();
categoryId =
(Number)nodeRow.getAttribute("CategoryId");
categoryName =
(String)nodeRow.getAttribute("CategoryName");
subCategoryId = null;
subCategoryName = null;
se
} else {
// Sub-category selected
to u
categoryId =
n s e
(Number)parentRow.getAttribute("CategoryId");
i ce
categoryName =
b l el
(String)parentRow.getAttribute("CategoryName"); fe ra
a n s
subCategoryId =
n - tr
no eฺ
(Number)nodeRow.getAttribute("CategoryId");
subCategoryName =a
s uid
h a
) nt G
(String)nodeRow.getAttribute("CategoryName");
} o m
c tude
i l ฺ
g ma is S
th
setCategoryId(categoryId);
@
ฺv inosetSubCategoryId(subCategoryId);
( ac setCategoryName(categoryName);
AC setSubCategoryName(subCategoryName);
d
V ino return this;
}
3. JDeveloper prompts you to import the supporting packages. Make sure that you have the
following imports statements:
oracle.jbo.Row;
oracle.jbo.domain.Number;
oracle.jbo.uicli.binding.JUCtrlHierNodeBinding;
oracle.storefront.ui.common.ADFUtil;
Important Note: If you are not prompted for the oracle.jbo.domain.Number
package, add it to the imports manually. Otherwise, the code will use the wrong Number
class and you will get errors when you call it.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
c. Click OK to accept the default values on the Confirm Component Rebinding page.
2. ( a
Add an event to the page named FODSelectCategory that will be registered when the user
A C
clicks the node.
n o d a. While still on the ProductCategory page, click the Bindings tab.
V i b. Expand Bindings in the Structure window.
c. Insert events (an event list) inside onNodeClicked (use the context menu).
u se
e to
n s
i ce
b l el
f er a
s
ainnthe Category Tree calls the
You now have specified that clicking a node at run time
- t r
n on ฺ
onNodeClicked() method and raises the FODSelectCategory event.
s a ide
) a
h t Gu
i l ฺ comtuden
g ma is S
o@ th
ฺv i n
C (ac
d A
n o
Vi
• Sets the requestScope variables to reflect which Category was selected in the tree
• Encapsulates the requestScope variables in a bean that is used by the consumer of
the event (the ProductCatalog page)
To create this handler method, perform the following steps:
1. Create a new Java class for the bean as you did for the producer bean. Name the class
FODShoppingDashboardBean and put it in the oracle.storefront.ui.bean
package. Make it public and use the Constructors from Superclass option.
2. Add the refreshCategory() method. This method uses an ADFUtil method to set the u se
requestScope variables to hold the category and subcategory ID and name: (You can
e to
copy it from refreshCategory.txt in the \files subdirectory of the Labs directory.) n s
i ce
/**
b l el
* Used as a consumer to a contextual event, changes the
fe ra
* parameter values passed to the local area region and forces
a n s
* a refresh in that area.
n - tr
*
a no eฺ
a
* @param category Selected category
h s uid
*/ m ) nt G
l ฺ o
c tude
i
public void refreshCategory(FODCategoryBean category) {
/* g ma is S
o @ th
vin
* For the selected category, set requestScope
a c ฺ * variables.
C ( * These variables are used as parameters to the local
d A
i n o * area region.
V */
ADFUtil.setEL("#{requestScope.CategoryId}",
category.getCategoryId());
ADFUtil.setEL("#{requestScope.SubCategoryId}",
category.getSubCategoryId());
ADFUtil.setEL("#{requestScope.CategoryName}",
category.getCategoryName());
ADFUtil.setEL("#{requestScope.SubCategoryName}",
category.getSubCategoryName());
4. As you did with the other bean, compile the class and create a data control from it. The
Data Control panel should now look like this:
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
e. Click OK again.
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
The region parameters have the same name as the task flow parameters that you defined in the
first practice for this lesson. So the values come through the event to requestScope variables
and are passed to region parameters. The region parameter values are passed to the task flow
parameters, which in turn set the pageFlowScope variables that the ProductCatalog page uses
to conditionally render tables and breadcrumbs, as you defined in an earlier practice.
1. One of the tasks accomplished by the refreshCategory() method in the
FODShoppingDashboard bean is to set a Boolean requestScope variable named
refreshLocalArea to true. Set a refresh condition in the ShoppingFlow region to make u se
use of the value of this variable, so that the region is refreshed only if refreshLocalArea
e to
is set to true. n s
i ce
a. Still in the FODShoppingDashboard page definition (the Binding tab of the page),
b l el
select Executables > ShoppingFlow1 in the Structure window.
fe ra
b. Set RefreshCondition to #{requestScope.refreshLocalArea}.
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
C
2.A Set region parameter values to the requestScope values that are set by the
n o d
Vi refreshCategory() method in the FODShoppingDashboard bean.
a. Click the Parameters tab in the Property Inspector. Note that the task flow binding
parameters are listed.
b. Set the value property of the parameters to the following values.
Name Value
CategoryId #{requestScope.CategoryId}
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
A C
f. Modify the getPhaseId() method to return the PhaseId of whatever life-cycle phase
String viewId =
phaseEvent.getFacesContext().getViewRoot().getViewId();
if (storedViewId != null &&
!viewId.equalsIgnoreCase(storedViewId)) {
System.out.println("Changing pages");
}
storedViewId = null;
}
u se
}
e to
2. Register the new phase listener with JavaServer Faces. n s
i ce
a. Open faces-config.xml in the editor by double-clicking it in the Application
b l el
Navigator (under WebContent > WEB-INF).
fe ra
b. Click the Overview tab.
a n s
c. On the Life Cycle tab, click Add n - tr
to add a Phase Listener.
d. no eฺ
Enter the complete path to the phase listener and the class name:
a
h a s uid
oracle.storefront.ui.common.StorefrontPhaseListener.
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
3. Test the functionality by invoking the application and changing views. Because you have
only one view activity in the application, with all others being part of a region on the same
page, you must add another page to the application to test it.
a. Open adfc-config and add a view activity called Start.
b. Add a control flow case from Start to FODShoppingDashboard whose from-
outcome is start.
c. Create the Start.jspx page by double-clicking the Start view activity in the editor.
Select the Blank Page option.
Copyright © 2010, Oracle and/or its affiliates. All rights reserved.
h. When you have finished, close the browser and undeploy the application as described
in step 6(i) of Practice 2-4.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
f er a
Practicestfor s
anLesson 19
- r
on ฺ
Chaptern19
s a ide
) a
h t Gu
i l ฺ comtuden
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
b. From the Data Controls panel, drag the Commit operation from
FODShoppingCartAMDataControl > Operations to the ShoppingCartFlow page flow.
c. Set the fixed-outcome property to done.
d. On the diagram, select the done control flow case and in the property inspector,
change its to-activity-id to Commit.
e. Add a Control Flow Case labeled done from Commit to ShoppingCart. Set the from-
outcome property to done.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
2. Test a
( the functionality:
C
A a. Run FODShoppingDashboard from the adfc-config task flow.
n o d
V i b. Add an item to the cart; it should remain in the cart when you redisplay it and when
you rerun the application.
c. When you have finished, close the browser and undeploy the application as described
in step 6(i) of Practice 2-4.
Name FODCommitDeleteBean
Class oracle.storefront.ui.bean.FODCommitDeleteBean
Scope request
Copyright © 2010, Oracle and/or its affiliates. All rights reserved.
buttons should relate to the rows of the table. Add a panel collection around the table to
contain the buttons.
a. Open the ShoppingCart page fragment.
b. Surround the af:table with a Panel Collection.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
c. Insert a toolbar inside Panel Collection
h a s facetsu>idtoolbar.
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
ฺv i n
C (ac
d A
n o
Vi
d. Drag the FODShoppingCartAMDataControl > Commit operation to the toolbar as an
ADF Toolbar Button. This adds the button and also adds the Commit operation to the
u se
e to
n s
i ce
e. Set the following properties on the toolbar button:
b l el
Id updateMenu
fe ra
a n s
Text (optionally use
the resource bundle)
Update
n - tr
Action <default> a no eฺ
h a s uid
Disabled ) default
Reset to
m n G
t value
o e
f. Add a second toolbar a ilฺc Stotthe
button udtoolbar. This time add it from the Component
m and select
Palette, or right-click
g is insert inside.
g. o @
Set the following t h
properties on the second toolbar button:
ฺv i n
C (aIdc deleteMenu
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
a
e. (In the Property Inspector, change the InstanceName to
C
A FODShoppingCartAMDataControl.ShoppingCart.ShoppingCartItem1.
n o d6.
V i Use partial page rendering to refresh the table to show the changes when the user clicks
either Update or Delete.
a. Click the Design tab in the editor.
b. Select af:table in ShoppingCart.jsff and using the Edit option, set PartialTriggers
on the table to include up dateMenu and deleteMenu.
u se
e to
n s
i ce
b l el
7. Enable the quantity to be updated.
fe ra
a. With af:table still selected, click the Edit Component Definition icon on the
a n s
- tr
Property Inspector and ensure that the Row Selection check box is selected, and click
n
OK.
a no eฺ
h a s uid
b. Select af:outputText - #{rowQuantity} and convert it to an Input Text.
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
c. Remove the value from the Label attribute on the Input Text.
8. Test the functionality.
a. Run FODShoppingDashboard, add an item to the cart, update a quantity or two,
delete an item by using the Delete button (be sure to leave at least one item in the
cart), and so on. (The only button that you have not yet connected is the details
button—you do this next.)
When you update a quantity and click the Update button, you should notice that the
line item total also changes.
b. When you have finished, close the browser and undeploy the application as described
in step 6(i) of Practice 2-4.
9. Use a pop-up window to display the details of the item when a user clicks the Details
button.
u se
e to
n s
i ce
b l el
fe ra
10. Test the functionality.
a n s
- tr
a. When you click Details on the ShoppingCart page, the productDetails pop-up should
n
display the dialog box.
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
b. When you have finished, close the browser and undeploy the application as described
in step 6(i) of Practice 2-4.
b. On the Behavior panel of the Property Inspector, set the Transaction property to
Always Begin New Transaction. This means that when this flow is called, it starts a
new transaction.
u se
e to
n s
li ce
l e
b property to
c. Select the SubmitOrder task flow return and set the End Transaction
e r a
commit.
a n sf
d. Select CancelOrder task flow return and set the End
n - trTransaction property to
rollback.
a no eฺ
2. Run the FODShoppingDashboard page tostest the checking
id madeouttosteps. When you click
ha t you
Submit on the Confirmation page, any) changes u
G application, this could, for example,
have the shipping and billing
information are committed. In a o m
real n
SOA-integrated
ilฺc back-end
commit an order and startasome t u deprocessing.
g m is S
o@ th
v i n
( acฺ
AC
d
V ino
This practice is optional because the steps are similar to what you have done previously.
If you choose not to add CRUD functionality for Suppliers, you must begin the practices
for the next lesson by opening the starter application.
1. Add transaction control to the ManageSupplierFlow task flow as you did with the
ShoppingCartFlow, with the commit and rollback functionality.
a. Open ManageSupplierFlow in the editor.
b. In the Structure window, select task-flow-definition – ManageSupplierFlow.
c. In the Property Inspector, click the Behavior tab and set transaction to Always Begin
New Transaction. u se
e to
d. In the editor, select the Save task flow return and set its End Transaction property to
n s
commit. i ce
e. In the editor, select the Cancel task flow return and set its End Transaction property b l el
to rollback.
fe ra
f. Save your work. a n s
n - tr
2. Add the ability to delete a supplier to the BrowseSuppliers page fragment.
a no eฺ
a. Open the BrowseSuppliers page fragment in the editor.
h a s uid
b. Check whether the table has row selection enabled by selecting af:table in the
Structure window, and theno m ) Editnt Gin the Property Inspector. Ensure that the
clicking
Row Selection check i l ฺ cis selected.
u d e
a box
mpanel, t
S FODSupplierAMDataControl > Supplier1 >
c. g
In the Data Control
t h i s
expand
Operations
i n o@and drag the Delete operation to the toolbar in the toolbar facet of the
PanelฺvHeader on the page, creating an ADF Toolbar Button.
C (ac
d A
n o
Vi
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
e. The onDeleteItem() method callsa
h s uid
bindings.Delete.execute and
bindings.Commit.execute. When ) G
yout added the delete operation as a button, the
Delete binding was added,
l ฺ omtheredisenon Commit binding. Add a Commit binding to
cbut
the page definition. a i S tu
g m s
1) Click the
o @ hi
Bindingsttab.
n Bindings section, click Create control binding .
vithe
2)cฺIn
C (a
3) In the Insert Item dialog box, select action and click OK.
f. To improve the appearance of the buttons, return to the Design view, and change the
Width of the Panel Header to 500 Pixels.
u se
e to
n s
i ce
h. Save your work. b l el
3. Test the functionality. fe ra
a n s
n - tr
a. Run FODShoppingDashboard from the adfc-config task flow.
h a s uid
c. Select the supplier that you previously added and click Delete. You should see that the
m
supplier is removed from the row.
) nt G
l ฺ o
c tude
i
d. Close the browser. In the JDeveloper log pane, click the Target URL link to rerun the
page. g ma is S
o @ th
e. Click the Suppliers tab. You should see that the supplier you deleted is no longer in
ฺ vin
the table even when the data is required.
c
( a
f. When finished, close the browser and undeploy the application as described in step
A C 6(i) of Practice 2-4.
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
f er a
Practicestfor s
anLesson 20
- r
on ฺ
Chaptern20
s a ide
) a
h t Gu
i l ฺ comtuden
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
roles in an identity store, and you assign permissions to roles. You also create login and error
pages. You then use ADF security to manage access to pages, task flows, and entity objects,
and you programmatically access the security context by using global security expressions and
a security proxy bean.
If you successfully completed all sections of the previous practice, you can continue working in
the same project. However, if you prefer to start with a clean application that contains everything
completed up to the start of this lesson, open Storefront-20.jws and edit the database
information as described in step 4 of Practice 2-4.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
2. Invoke the Configure ADF Security Wizard and configure the application to use ADF u se
security for both authentication and authorization. e to
n s
a. With the StorefrontUI project selected in the Application Navigator, from the main
i ce
menu, select Application > Secure > Configure ADF Security.
b l el
b. On the ADF Security page of the wizard, select the ADF Authentication and
fe ra
Authorization option, and then click Next.
a n s
- tr
c. On the Authentication Type page of the wizard, select the Form-Based
n
no eฺ
Authentication option and the Generate Default Pages check box. Click Next.
a
h a s uid
d. On the Automatic Policy Grants page of the wizard, select the No Automatic Grants
option, and then click Next. ) nt G
o m
c tude
e. On the Authenticated Welcome page, select Redirect upon successful
i l ฺ
g ma is S
authentication, and on the welcome page, select the
/oracle/storefront/ui/pages/FODShoppingDashboard.jspx page. Click
Next. o @ th
c ฺ vin
f. The Summary page of the wizard displays a list of files that will be changed or created.
( a
Click Finish to create the security configuration.
A C
n o d
V i
4. If you look in the file system, you can compare the modified dates to see which files have
been changed.
a. First, using Windows Explorer, look in the Storefront-20 > .adf > META-INF
u se
subdirectory of your application resource descriptor. You could see that the adf-
e to
config.xml file has just been changed.
n s
b. i ce
Next, look in the Storefront-20 > src > META-INF subdirectory of your application
l
resource descriptor. You should see that all files except for weblogic-
a b le
application.xml have been changed.
fe r
n s
c.
n
application. You can see that web.xml and weblogic.xml- tra subdirectory
Finally, look in the StorefrontUI > public-html > WEB-INF of your
have been changed.
(Actually, weblogic.xml is a new file.) a n
o ฺ
a s i d e
) h nt G u
m
co tude
i l ฺ
g ma is S
o@ th
ฺv i n
C (ac
d A
n o
Vi
u se
e to
n s
li ce
l e
bthe Configure ADF
e. Note that the changed files are the ones that the Summary page of
e r a
Security Wizard reported to be created or changed.
a n sf
5. In the JDeveloper Application Resources panel, double-click
n - tra newly
jazn-data.xml to open it,
and then click the Source tab to examine the entries.
n o ฺIt is created file that contains:
• The default realm name for the optionalsXML a identity
i d estore
• The policy store for the Storefront-20
a u
) h application,
G consisting of application roles and a
m
o de
policy. The policy grants permissions onn t
resources (task flows and pages) to the
application roles. i l ฺ c tu
m a S
6. g
Similarly, using the Source tab,
@ t s
hi examine:
o
c ฺ vin and the context
a. jps-config.xml:
instances,
Definitions have been added for service providers, service
for Java Platform Security.
( a
AC
b. adf-config.xml: The JaasSecurityContext entry has been added, specifying
d that both authentication and authorization are enforced.
V ino 7. Similarly, from the Application Navigator, open web.xml and weblogic.xml (StorefrontUI
> Web Content > WEB-INF):
a. web.xml has added initialization parameters for JpsFilter, along with a definition
for the adfAuthentication servlet, a security constraint, the login configuration
(form-based with the login and error pages), and a security role (valid-users).
b. weblogic.xml is a newly created file that assigns the principal name users to the
valid-users security role.
b. Click the Users tab and in the Users pane, click Add to create new users.
c. In the Add User form, enter the name (such as DRAPHEAL) and the credentials
(welcome1).
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
Repeat steps b g
ma each i s S
d.
o @ and c for
t h user; the users appear in the Users list. Instead of
pgamer,
ฺ v inyou can add your own name if you would prefer to.
C (ac
d A
n o
Vi
• Clerks in the company must be able to read, update, and delete supplier information,
but they do not need to access the shopping portal.
• Customers must be able to shop and to view the list of suppliers, but do not need to
update or enter new suppliers.
• Application developers must be able to temporarily access everything for testing
purposes. There is currently one developer working on the application.
1. Create the enterprise roles manager, clerk, customer, and developer.
u se
a. Click the Enterprise Roles tab, and then click Add in the Roles panel. e to
n s
b. In the Add Role dialog box, enter the Name manager.
i ce
c. Repeat steps a and b to add the other three roles; the roles appear in the Enterprise
b l el
Roles list along with the test-user role that the security configuration created.
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
developer
a. In the Enterprise Roles pane, click the Members tab.
b. In the Enterprise Roles list, select manager.
c. On the Member tab, from the Add list, select Add User.
d. In Select Users, select sking and click OK.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
e. Repeat steps b, c, and d foroeach eindicated above.
i l ฺ c turole
d
m a correspond
3. Create application roles that S to the identity store roles (manager, clerk,
g s
customer, and developer)hiprefixed by fod_, such as fod_customer. Also create a
t
@ called fod_user.
n
fifth application
i orole
a. a
( cฺvApplication Roles at the left, and then click the Add icon in the Application
Select
A C Roles panel.
Vi nod b. Add the same roles as you did in the enterprise roles, prefacing the role name with
fod_, such as fod_manager.
c. Add another application role named fod_user.
u se
e to
n s
i ce
b l el
e. Then add clerk, customer, manager, and developer to fod_user.
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
a box,Sselect the check boxes for fod_manager, fod_clerk,
c. In the Select Roles dialog
g m
and fod_developer, andhthen is click OK.
@ t
allothe roles do not appear in the Select Roles dialog box, close jazn-
Note: Ifin
ฺ v
( ac
data.xml and reopen it. The roles should then appear.
AC
d
V ino
Note: If you encounter an error when running the application, undeploy the application
and then terminate the default server. You do this the same way you undeploy an
application, except that you select IntegratedWebLogicServer instead of an application.
Then rerun the application.
c. On the login page, enter a fake username and password, and then click Submit.
u se
e to
n s
i ce
b l el
The error page should display the message:
fe ra
a n s
n - tr
a no eฺ
Note: When using Internet Explorer, you
a s may receive
u i d an HTTP error instead of seeing
the error page.
m ) h nt G
2. Test authorization.
i l ฺ co tude
m a button.
a. Click the browser’s Back S
b. On the login@ g
page, enter
t h is username
the sking, a valid user who is not authorized to
use thein o the password welcome1, and then click Submit.
c
The ฺ v shopping application. Enter
FODShoppingDashboard page appears, but the shopping application is not
( a
A C visible. You see data only when you click the Suppliers tab.
Vi nod Note: If you encounter an error when you enter the login information after using the
Browser’s Back button, rerun the application.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
g.
c ฺ vin
When finished, close the browser and undeploy the application as described in step
6(i) of Practice 2-4.
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
c.
fe
In the Edit Security dialog box, enable security on all operations, and then click OK. ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d d. In the Structure window, right-click SupplierEO and select Edit Authorization.
V i
Privileges Roles
Read fod_user
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2011, Oracle and/or its affiliatesฺ
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
f. Click OK.
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
b. In the login dialog box, enter the username DRAPHEAL, whose customer role has
read-only access to SupplierEO. Enter the password welcome1 and click Submit.
c. Click the Suppliers tab. You should note that the Delete button is disabled.
d. Click New Supplier. You should receive an authorization error.
u se
e to
n s
i ce
e. Close the browser and run the application again, this time logging in as sking, who
has the manager role. Click the Suppliers tab. You should see that the Delete button b l el
is disabled. However, when you click New Supplier, or when you click a supplier ID fe ra
a
link, you should be able to navigate to the New Supplier or the Update Supplier n s
window. n - tr
f. a no eฺ
Close the browser and click the target URL in the Running Log pane to relaunch the
application in your browser.
h a s uid
g. m ) nt G
This time log in as bernst, who has the clerk role, or as pgamer, who has the
l ฺ o
c tude
i
developer role. Click the Suppliers tab. You should see that the Delete button is
ma is S
now enabled. Also, when you click New Supplier, or when you click a supplier ID link,
g
@ th
you should be able to navigate to the New Supplier or the Update Supplier window.
o
h.
c ฺ vin
Close the browser and undeploy the application.
( a
A C
n o d
V i
s a
b. Expose the added methods to the client interface
d e ฺ application
module. a
h t Gu i
1) In the Application Navigator,
)
m double-click
n FODShoppingCartAM to open it in the
ฺ c o d e
editor.
a il Stu
m
g tab.this
2) Click the Java
3) Ininthe
@
o Client Interface section, click Edit .
ฺ v
( ac4) In the Edit Client Interface dialog box, shuttle getUserName():String and
C isUserInRole(String):boolean from the Available list to the Selected list, and
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
e. Select isUserInRole from l ฺ o
cthe Method
d edrop-down list and enter customer as the
i t u
maYouisshould
Value. Click Execute.
g S see the Return value of true.
f. Change the @ th and click Execute. The Return value should be false.
o Value to manager
ฺv i n
C (ac
d A
n o
Vi
logged-in user does not have permission to run the task flow.
1. You know that customers do not have the view permission for the ManageSupplierFlow
task flow. Set a property on the button that invokes that task flow so that it does not appear
for customers.
a. Open BrowseSuppliers.jsff in the editor.
b. Click the New Supplier button and using the Expression Builder, set the Rendered
property to #{!securityContext.userInRole['fod_customer']}.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
2. Test the new functionality:
a. Run thein o@page andthlog in as a customer (DRAPHEAL). Click the Suppliers
Start
( a cฺv New Supplier button should not appear.
tab—the
d AC
Vi no
b. Run the application again and log in as a user in one of the other roles, such as
sking. The button should appear now.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
b. Open or switch to BrowseSuppliers.jsff ina noeditor.
the
eฺproperty to
c. a
Click the New Supplier button and set s i d
the Rendered
h t Gu and then paste the complete
)
m quotationn marks.
#{securityContext.taskflowViewable['']},
cosingle
task flow name betweenlฺthe
i u d e
g ma is St
o@ th
ฺv i n
(ac
4.AC
Ensure that the button appears if authentication security is not enabled. Instead of using a
n o d global security expression, write a security proxy bean to check the security. Name the
Vi bean FODSecurityBean.
a. Create a new Java class, accepting default values, named FODSecurityBean in the
oracle.storefront.ui.bean package with the following code: (You can copy the code
from SecurityBean.txt in the \files subdirectory.)
package oracle.storefront.ui.bean;
import oracle.adf.share.ADFContext;
A C
n o d
Vi
c. Test the functionality as before, making sure that the button appears for clerks,
managers, or developers, and that it does not appear for customers.
b. Click the pink box in the right margin of the code to go to the TODO item.
c. Replace the hard-coded username with a call to getUserName().
u se
e to
n s
i ce
d. Delete the commented TODO lines. b l el
e. Add a clause that sets the userPrincipal variable to the hard-coded string if fe ra
security is not implemented. Change the line: a n s
n - tr
to
String userPrincipal = getUserName();
a no eฺ
h a s uid
String userPrincipal;
m ) nt G
if
l ฺ o
c tude
i
ma is S
(ADFContext.getCurrent().getSecurityContext().isAuthorizationEna
bled())
@ g th
o
vin
userPrincipal = getUserName();
a c ฺ
else
C ( userPrincipal = "DRAPHEAL";
d A
i n o
V
u se
e to
n
e tos
d. l
Double-click ShoppingCart1 and click Cancel in the Bind Variables dialog i cbox
accept the values that were set in the init() method.
r a ble
e. The shopping cart for DRAPHEAL should be shown.
n s fe
n - tra
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o@ th
ฺv i n
C (ac
d A
n o
Vi
3. Close the Business Components Browser when you have finished.
4. Disable security by running the Configure ADF Security Wizard (Application > Secure >
Configure ADF Security) and selecting the option to Remove ADF Security
Configuration. Click Finish.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
f er a
Practicestfor s
anAppendix A
- r
on ฺ
Chaptern21
s a ide
) a
h t Gu
i l ฺ comtuden
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
This practice is optional and does not affect any of the other practices. You should work on it
only if you have extra time.
If you choose to work on this practice, start with a clean application by opening Storefront-
A.jws and editing the database information as described in step 4 of Practice 2-4.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
c. Expand the FOD node to view
l ฺ o
c tude of database objects that the schema contains.
the types
2. Create a new database diagram i
a named S FODSchema and put it in the
g m s
@
oracle.fod.storefront.design
o t hi package.
c
from ฺ vtheincontext menu.
a. In the Application Navigator, right-click the StorefrontModel project and select New
C (a
b. In the New Gallery:
d A i) Expand the General node if it is not already expanded.
n o
Vi ii) Select Diagrams.
iii) In the Items panel, select Database Diagram.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
iv) Click OK.
h a s uid
c. In the Create Database Diagram)dialog box:
o m e n tG
i) Change the name of
a i lฺcyour diagram
t u d to FODSchema.
ii) Change the package
g S
m itosoracle.fod.storefront.design.
o@ t h
ฺv i n
C (ac
d A
n o
Vi
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
c. In the Specify Location dialog box, changeathe
o database
noffline ฺ name to FodDB, and
s d e
then click OK to copy the database objects
)
and to place them on your diagram. ha t toGtheui new offline database in your project
i l ฺ comtuden
g ma is S
o@ th
ฺv i n
C (ac
d A
n o
Vi
d. The two tables are depicted on your diagram. Notice that the table icon has two
compartments. The top compartment displays the column names and their data types,
and the bottom compartment displays information about primary and foreign keys. Your
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d e. You can modify the column information in the diagram, although you should not modify
V i any of the table information at this time. To modify the column information, you can
click a column in the Orders table to select it, and then click again. You can modify
the name, data type, and size of the column in the diagram. Alternatively, you can
double-click the table itself to invoke the Edit Table dialog box, where you can make
more detailed modifications to columns and other table information. Do not modify any
columns for this practice.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i c. In the Component Palette, click Table and drag it to the schema diagram.
d. In the Specify Location dialog box, accept the default location of the FodDB offline
database and click OK.
e. In the name area at the top of the table icon, enter Shippers.
u se
5) Similarly, add a Shipper_Name column, with the default values for data type and e to
size. This is not a mandatory column. n s
i ce
6) In the list at the left of the Edit Table dialog box, select Primary Key and set the
b l el
primary key as follows:
fe ra
a) Select SHIPPER_ID in the Available Columns list.
a n s
n - tr
7)
b) Click Add
a no eฺ
to shuttle SHIPPER_ID to the Selected Columns list.
Click OK. The diagram should look similar to this:
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
2. A C
Generate the DDL for adding the new table to the database, but do not actually add the
n o d table.
V i a. Right-click the SHIPPERS table in the diagram, and from the context menu, select
Synchronize with Database > Generate To > SQL Script. (You can also choose to
generate to FOD, which brings up the same dialog box with different default options
that you can change.)
b. In the Generate SQL from Database Objects Wizard:
1) Click Back until you are on the Specify Source page.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
3) Select the SQLScript option)on
asSpecify
hthe G u id page, and click Next.
Target
o m e n tSHIPPERS
4) The Object Picker page
i l ฺ c tud
should show in the Selected list. Click Next.
5) On the Choose a
mOperation Spage, select the Create option and click Next.
g i s
h page, change the name of the SQL file to
6) On the @
i n oSQL Script tOptions and click Next.
c ฺ v
CreateShippersTable.sql
(a
7) Click Finish to generate the script.
d AC
c. When the wizard is complete, the script file opens in the editor. Note the three tabs:
n o Source, SQL worksheet, and History. Examine the file contents.
Vi d. Do not run the script, but note that if you select a connection in the upper-right
corner, then you can right-click the script and select Run Script from the context menu,
or click Run Script .
e. Save your work.
f. When you have finished, close the script file and the database diagram. To close all
the open windows at once, right-click one of the tabs and select Close All.
u se
e to
n s
i ce
b l el
f er a
Practicestfor s
anAppendix B
- r
on ฺ
Chaptern22
s a ide
) a
h t Gu
i l ฺ comtuden
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
Finally, you deploy the application to the stand-alone Oracle WebLogic Server, and you test the
deployment.
This practice is optional and does not affect any of the other practices. You should work on it
only if you have extra time.
If you choose to work on this practice, start with the completed application by opening
Storefront-B.jws and editing the database information as described in step 4 of
Practice 2-4.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
profile for the StorefrontUI project. Create a new deployment profile called
myStorefrontUI that specifies a context root of Storefront.
a. In the Application Navigator, select the StorefrontUI project, and then select File >
New.
b. In the New Gallery, select General > Deployment Profiles > WAR File.
c. In the Create Deployment Profile dialog box, enter a Deployment Profile Name of
myStorefrontUI and click OK.
u se
d. In the Edit WAR Deployment Profile Properties dialog box, select the Specify Java EE
Web Context Root option and enter a context root of Storefront. e to
n s
i ce
b l el
fe ra
a n s
n - tr
e. Click OK twice. a no eฺ
h a s ufor
2. Create a deployment profile named myStorefront
idthe application, specifying that it
m ) WAR file
n G the JAR file for the StorefrontModel
t and
o
should contain the myStorefrontUI e
project. a ilฺc Stud
g m menu
a. Invoke the Application is and select Application Properties.
@ t h
ฺ v ino
( ac
d AC
Vi no
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
1. Set up a data source named FODLocal in the basic_domain domain of the stand-alone
Oracle WebLogic Server, setting the JNDI name to jdbc/FODDS. Set other properties so
that it connects to the same schema that you have been using.
a. From the Windows Start menu, select Programs > Oracle Fusion Middleware > User
Projects > MyWLS_domain > Admin Server Console. The console application
deploys and then runs.
Note: If the Administration Server Console does not run, make sure that the WebLogic
Server is running. If it is not running, invoke the same menu except select as the final u se
item Start Admin Server for WebLogic Server Domain. After the server has started,
e to
you can minimize the startWebLogic command window. n s
i ce
b. Log in to the Administration Server Console with the username of weblogic and the
password of weblogic. b l el
fe ra
c. In the Domain Structure menu at the left of the window, expand the Services and
a n s
n - tr
JDBC nodes, and then click the Data Sources node.
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
d. On the “Summary of JDBC Data Sources” page, click New.
e. In the “Create a New JDBC Data Source” Wizard, set the following properties:
Property Value
Name FODLocal
JNDI Name jdbc/FODDS
Database Type Oracle
Database Driver Oracle's Driver (Thin)
Versions:9.0.1,9.2.0,10,11
Database Name XE
Host Name localhost
u se
e to
n s
b. In the Structure window:
i ce
1) Expand DataBindings > dataControlUsages.
b l el
2) Select each application module data control usage, and in the Property Inspector,
fe ra
n s
set its Configuration to be the Web configuration that you just defined, such as
a
FODProductAMWeb.
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
3) Repeat steps 1 and 2 for all five application server data control usages.
a. From the JDeveloper menu, select View > Application Server Navigator.
b. Right-click the Application Servers node and select New Application Server.
c. In the Create Application Server Connection Wizard, enter the following settings,
leaving others at their default values:
Property Value
Connection Name myWLS
u se
Password weblogic
e to
Deploy Password Checkbox selected n s
i ce
Port 7001
b l el
WLS Domain myWLS_domain fe ra
a n s
d.
n - tr
On the last page of the wizard, click Test, and then click Finish if the connection is
successful.
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i
e. The connection appears in the Application Server Navigator. Expand the myWLS and
deployments nodes so that you can see what is already deployed.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a noIt may
The log window displays deployment messages.
e ฺ take a few minutes to finish the
s
ha t the
deployment; wait until the window displays i d
umessage that the deployment is
finished. ) G
i l ฺ comtuden
g ma is S
o@ th
ฺv i n
C (ac
d A
n o
Vi
b. In the Application Server Navigator, click Refresh to see the myStorefront deployment.
c. When you have finished, close the browser and undeploy the application as follows:
1) On the Application Server Navigator, click Refresh .
2) Right-click the myStorefront deployment and select Undeploy.
u se
e to
n s
i ce
b l el
fe ra
a n s
n - tr
a no eฺ
h a s uid
m ) nt G
l ฺ o
c tude
i
g ma is S
o @ th
c ฺ vin
( a
A C
n o d
V i