Oracle® Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework 11g Release 1 (11.1.1) B31974-03 |
|
![]() Previous |
![]() Next |
As a companion to this guide, the StoreFront module of the Fusion Order Demo application was created to demonstrate the use of the Fusion web application technology stack to create transaction-based web applications as required for a web shopping storefront. The demonstration application is used as an example throughout this guide to illustrate points and provide code samples.
Before examining the individual components and their source code in depth, you may find it helpful to install and become familiar with the functionality of the Fusion Order Demo application.
This chapter includes the following sections:
In this sample application, electronic devices are sold through a storefront-type web application. Customers can visit the web site, register, and place orders for the products. In order to register customers and fulfill orders, currently only a single application is in place. In a future release, several applications, will cooperate. For a detailed description of how the application works at runtime, see Section 2.4, "Taking a Look at the Fusion Order Demo Application".
In order to view and run the demo, you need to install Oracle JDeveloper 11g. You then need to download the application for this demonstration. Once the application is installed and running, you can view the code using Oracle JDeveloper. You can view the application at runtime by logging in as an existing customer and placing an order.
Figure 2-1 shows a simplified representation of the schema for the Fusion Order Demo application. The blue shapes in the diagram represent the four core tables. The other tables and views are shown as yellow shapes that sometimes represent several tables to help simplify the diagram. Some of the tables use sequences, but only those used by the core tables are shown.
The core tables represented by the blue diagram elements include:
PERSONS
: This table stores all the users who interact with the system, including customers, staff, and suppliers. The first and last name, email address, and person type code of each user is stored. A user is uniquely identified by an ID. Other IDs provide foreign keys to tables with address information and, in the case of customer's, membership information.
ORDERS
: This table represents activity by specific customers. When an order is created, the date of the order, the total amount of the order, the ID of the customer who created it, and the status of the order are all recorded. After the order is fulfilled, the order status and order shipped date are updated. All orders are uniquely identified by a sequence-assigned ID.
ORDER_ITEMS
: For each order, there may be many order items recorded. The unit price and quantity of each order item are recorded. The order line item and its order ID uniquely identify each order item.
PRODUCTS_BASE
: This table stores all of the products available in the store. For each product, the name and cost are recorded. All products are uniquely identified by a sequence-assigned ID. The image of the product and its description are stored in separate tables, which each reference the product ID. The columns ATTRIBUTE
x
are reserved for future use with descriptive flexfields (commonly required by Oracle E-Business Suite and Fusion application schema).
The sequences that the core tables use include:
PERSON_SEQ
: Populates the ID for for each new person.
ORDER_SEQ
: Populates the ID for each new order.
ORDERS_ITEMS_SEQ
: Populates the ID for each new order item.
PRODUCTS_SEQ
: Populates the ID for each product.
The PL/SQL package USER_CONTEXT_PKG
contains a procedure set_app_user_lang()
used to illustrate a simple example of how to set per-user database state from inside an application module.
Note the SHIPPING_OPTIONS
view is reserved for future use and is not currently used in the Fusion Order Demo.
To support tracking of change history in the Fusion Order Demo, every table contains the history column CREATED_BY
, CREATION_DATE
, LAST_UPDATED_BY
, LAST_UPDATED_DATE
, and OBJECT_VERSION_ID
, as shown in Figure 2-2.
To support localization of the Fusion Order Demo, the AVAILABLE_LANGUAGES
table lists all available languages. In this table, only one row will have the DEFAULT_FLAG
set to Y
corresponding to the current user's language.
Translations exist for the following base tables: PRODUCTS_BASE (PRODUCT_TRANSLATIONS)
, PRODUCT_CATEGORIES_BASE (CATEGORY_TRANSLATIONS)
, SHIPPING_OPTIONS_BASE (SHIPPING_OPTION_TRANSLATIONS)
, MEMBERSHIPS_BASE (MEMBERSHIP_TRANSLATIONS)
and DISCOUNTS_BASE (DISCOUNT_TRANSLATIONS)
.
Taking the Shipping Options group, as shown in Figure 2-3: SHIPPING_OPTION_TRANSLATIONS
is fully populated so that each product has one row for each language. The column LANGUAGE
holds the translation language identifier. The entry itself may not yet be translated, in which case the SOURCE_LANGUAGE
column holds the language that the entry is currently in. When a value has been translated, SOURCE_LANGUAGE
and LANGUAGE
will hold the same value. The PL/SQL package USER_CONTEXT_PKG
creates the custom USERENV('CLIENT_INFO')
variable that specifies the runtime locale used to pull the correct translations from SHIPPING_OPTION_TRANSLATIONS
into the SHIPPING_OPTIONS
view along with the SHIPPING_OPTIONS_BASE
table data. Each order has one set of Shipping Options associated with it.
The code lookup table LOOKUP_CODES
table contains codes that are used throughout the Fusion Order Demo application. For example, the PERSONS
table contains the columns person_type_code
, marital_status_code
, and gender
. These codes have corresponding rows in the LOOKUP_CODES
table, discriminating on the lookup_type
column. Foreign keys are not defined for these rows, but instead are enforced in the user interface by populating user interface components with LOOKUP_CODES
values for a particular lookup type. For example, when creating a new registration (also known as a person) in the user interface, the values that can be used for the person_type_code
are populated in a dropdown list from the lookup_code
values with lookup_type=person_type_code
.
The LOOKUP_CODES
table also supports the localization of the user interface. The table uses a combined key of code and language (obtained from runtime locale or preference) to determine the code's meaning. Each code has an entry for each supported language, as described in Section 2.2.1, "Translation Support in the Fusion Order Demo Schema".
Using addresses as an example, as shown in Figure 2-4: PERSONS
uses an intersection ADDRESS_USAGES
to accommodate multiple address information. In addition ADDRESS_USAGES
uses LOOKUP_CODES
to store both OWNER_TYPE_CODE
and USAGE_TYPE_CODE
information, returning the MEANING
(see table extract in Figure 2-5). ADDRESSES
directly accesses COUNTRY_CODES
to look up and use the COUNTRY_NAME
associated with the COUNTRY_ID
stored in ADDRESSES
. The PERSONS
table also directly stores PRIMARY_ADDRESS_ID
by a direct lookup to ADDRESSES
.
The correct translation is applied by using the LANGUAGE
columns in both LOOKUP_CODES
and COUNTRY_CODES
with the runtime locale/preference.
The lookup table DEMO_OPTIONS
defines the various options within the Fusion Order Demo application that are switched on. It also caches general configuration information such as email addresses and phone numbers to use as overrides in this demonstration scenario (for example, where email addresses are fictitious). This table is reserved for future use.
The Fusion Order Demo application runs using an Oracle database and Oracle JDeveloper 11g. The platforms supported are the same as those supported by JDeveloper.
To prepare the environment and run the Fusion Order Demo application, you must:
Install Oracle JDeveloper 11g and meet the installation prerequisites. The Fusion Order Demo application requires an existing Oracle database. For details, see Section 2.3.1, "How to Download the Application Resources".
Install the Fusion Order Demo application from the Oracle Technology Network. For details, see Section 2.3.2, "How to Install the Fusion Order Demo Schema".
Install Mozilla FireFox, version 2.0 or higher, or Internet Explorer, version 7.0 or higher.
Run the application on a monitor that supports a screen resolution of 1024 X 768 or higher. For details, see Section 2.3.3, "How to Run the Fusion Order Demo Application".
The Fusion Order Demo application requires an existing Oracle database. You run the Fusion Order Demo application using Oracle JDeveloper 11g.
Do the following before installing the Fusion Order Demo application:
Install Oracle JDeveloper. You need Oracle JDeveloper 11g Studio Edition to view the application's projects and run the application using the JDeveloper integrated server. You can download Oracle JDeveloper from:
http://www.oracle.com/technology/products/jdev/11/index.html
Note: Ensure that you download and install 11g and that it is the Studio Edition, not the Java Edition. You can verify these details in Oracle JDeveloper from the Help > About menu option. |
Download the Fusion Order Demo application ZIP file (FusionOrderDemo_R1.zip
). You can download the ZIP file from:
http://www.oracle.com/technology/products/jdev/samples/fod/index.html
Install an Oracle database. The Fusion Order Demo application requires a database for its data.
The SQL scripts were written for an Oracle database, so you will need some version of an Oracle RDBMS, such as 11g, or XE. The scripts will not install into Oracle Lite. If you wish to use Oracle Lite or some other database, then you will need to modify the database scripts accordingly. You can download an Oracle database from:
http://www.oracle.com/technology/
Specifically, the small footprint of the Oracle Express Edition (XE) is ideally suited for setting up the database on your local machine. You can download it from:
http://www.oracle.com/technology/products/database/xe/
You can download the Fusion Order Demo application from the Oracle Technology Network (OTN) web site.
To download the demo and install the FOD schema to your database:
Navigate to http://www.oracle.com/technology/products/jdev/samples/fod/index.html
and download the ZIP file to a local directory.
Start Oracle JDeveloper 11g and from the main menu choose File > Open.
In the Open dialog, browse to the location where you extracted the ZIP file to in Step 1 and select Infrastructure.jws from the infrastructure directory. Click Open.
In the Application Navigator, expand MasterBuildScript and then Resources, and double-click build.properties.
In the editor, modify the properties shown in Table 2-1 for your environment.
Table 2-1 Properties Required to Install the Fusion Order Demo Application
Property | Description |
---|---|
|
The root directory where you have Oracle JDeveloper 11g installed. For example:
|
|
The base JDBC URL for your database in the format
|
|
The port for your database. For example:
|
|
The SID of your database. For example:
|
|
The administrative user for your database. For example:
|
|
The table space name where FOD users will be installed. For example:
|
From the JDeveloper main menu, choose File > Save All.
In the Application Navigator, under the Resources node, right-click build.xml and choose Run Ant Target > buildAll.
In the Enter Property dialog, enter the password for the database system user and click Continue.
Once you enter the password, the Ant build script creates the FOD users and populates the tables in the FOD schema. In the Apache Ant - Log window, you will see a series of SQL scripts and finally:
buildAll:
BUILD SUCCESSFUL
Total time: nn minutes nn seconds
For more information on the demo schema and scripts, see the README.txt
file in the MasterBuildScript
project.
The Fusion Order Demo application consists of a web user interface and a business components layer. Specifically, the following projects are part of the Fusion Order Demo application:
StoreFrontService
: Provides access to the storefront data and provides transaction support to update data for customer information and orders.
StoreFrontUI
: Provides web pages that the customer uses to browse the storefront, place orders, register on the site, view order information, and update the user profile.
You run the Fusion Order Demo application by running the home.jspx
page in the StoreFrontUI
project. The StoreFrontUI
project uses JavaServer Faces (JSF) as the view technology, and relies on the Oracle ADF Model layer to interact with Oracle ADF Business Components in the StoreFrontService
project. To learn more about the Fusion Order Demo application and to understand its implementation details, see Section 2.4, "Taking a Look at the Fusion Order Demo Application".
To run the Fusion Order Demo application:
Open the application in Oracle JDeveloper:
From the JDeveloper main menu, choose File > Open.
Navigate to the location where you extracted the demo ZIP file to and select the StoreFrontModule.jws application workspace from the StoreFrontModule directory. Click Open.
Figure 2-6 shows the Application Navigator after you open the file for the application workspace. For a description of each of the projects in the workspace, see Section 2.4, "Taking a Look at the Fusion Order Demo Application".
In the Application Navigator, click the Application Resources accordion title to expand the panel.
In the Application Resources panel, expand the Connections and Database nodes.
Right-click FOD connection and choose Properties.
In the Edit Database Connection dialog, modify the connection information shown in Table 2-2 for your environment.
Table 2-2 Connection Properties Required to Run the Fusion Order Demo Application
Property | Description |
---|---|
Host Name |
The host name for your database. For example:
|
JDBC Port |
The port for your database. For example:
|
SID |
The SID of your database. For example:
|
Do not modify the user name and password fod/fusion. These must remain unchanged. Click OK.
In the Application Navigator, right-click StoreFrontService and choose Rebuild.
In the Application Navigator, right-click StoreFrontUI and choose Run StoreFrontUI.jpr.
The home.jspx
page within the StoreFrontUI
project is the default run target. When you run the default target, JDeveloper will launch the browser and display the Fusion Order Demo application home page.
Once the home page appears, you can browse the web site as an anonymous user, or you can choose to log in and place orders (may require registering as a customer first). Because the Fusion Order Demo application implements Oracle ADF Security to manage access to Oracle ADF resources, only the authenticated user will be able to view orders in their cart. Table 2-3 shows the users who are authorized as members of the fod-users
role to log into the Fusion Order Demo application.
Note: The Fusion Order Demo application ships with predefined user data. The schema for the application defines different types of users including customer, supplier, and staff types. All users are members of thefod-users role and are authorized to log in. However, only ngreenbe is the user type CUST (customer). When you log in as any other user, you will need to register as a customer before you can place an order. These additional users were created to support roles in other modules of the Fusion Order Demo application. |
Table 2-3 Supplied Users in the Fusion Order Demo Application
Username | Password | Application Role | Notes |
---|---|---|---|
|
|
|
Can add items to cart, check out, and view order information. This is the only user who is preregistered as a customer in the StoreFront module of Fusion Order Demo. |
|
|
|
Can add items to cart, but must register as a customer to check out and view order information. This user also has administration privileges ( |
|
|
|
Can add items to cart, but must register as a customer to check out and view order information. This user also has read-only privileges ( |
|
|
|
Can add items to cart, but must register as a customer to check out and view order information. These users may be added to to other roles in a future version of Fusion Order Demo. |
Once you have opened the projects in Oracle JDeveloper, you can then begin to review the artifacts within each project. The development environment for the Fusion Order Demo application is divided into two projects: the StoreFrontService
project and the StoreFrontUI
project.
The StoreFrontService
project contains the classes that allow the product data to be displayed in the web application. Figure 2-7 shows the StoreFrontService
project and its associated directories.
The StoreFrontService
project contains the following directories:
Application Sources
: Contains the files used to access the product data. Included are the metadata files used by Oracle Application Development Framework (Oracle ADF) to bind the data to the view.
META-INF
: Contains a file used in deployment.
The StoreFrontUI
project contains the files for the web interface, including the backing beans, deployment files, and JSPX files. Figure 2-8 shows the StoreFrontUI
project and its associated directories.
The StoreFrontUI
project contains the following directories:
Application Sources
: Contains the code used by the web client, including the managed and backing beans, property files used for internationalization, and the metadata used by Oracle ADF to display bound data.
Web Content
: Contains the web files, including the JSP files, images, skin files, deployment descriptors, and libraries.
You start the Fusion Order Demo application by running the home.jspx
page in the StoreFrontUI
project. For details about running the application using the default target, home.jspx
page, see Section 2.3.3, "How to Run the Fusion Order Demo Application".
When you enter the storefront site, the site is available for anonymous browsing. You can use this page to browse the catalog of products without logging into an account. The initial view shows the featured products that the site wishes to promote and gives you access to the full catalog of items. Products are presented as images along with the name of the product. Page regions divide the product catalog area from other features that the site offers.
Figure 2-9 shows the home page.
Where to Find Implementation Details
Following are the sections of the Oracle Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework that describe how to create a databound web page:
Providing the structure for the web page
The home page separates features of the site into regions that are implemented using a combination of Oracle ADF Faces (ADF Faces) templates and JavaServer Faces (JSF) page fragments. ADF Faces templates and the fragments allow you to add ADF databound components. For information about the steps you perform before adding databound user interface components to a web page, see Section 19.1, "Introduction to Developing a Web Application with ADF Faces".
Displaying information on a web page
To support data binding, the featured items on the tabbed region of the home page use EL (Expression Language) expressions to reference ADF data control usages in the declarative ADF page definition file. The page definition file, which JDeveloper creates for you when you work with the Data Controls panel to drag and drop databound ADF Faces components, is unique to each web page or page fragment. The ADF data control usages enable queries to the database and ultimately work with the JSF runtime to render the databound ADF Faces components, such as the ADF Faces image component used to display images from the PRODUCT_IMAGES
table. For information about creating a databound web page that references the ADF page definition file, see Section 21.1, "Introduction to Creating a Basic Databound Page".
Managing entry points to the application
The home page is supported by an ADF unbounded task flow. In general, the Fusion web application relies on this Oracle ADF Controller feature to define entry points to the application. The unbounded task flow for the entire home page and its page fragments describes view activities for displaying the home page, displaying the orders page, displaying the register user page, and it defines a task flow reference to manage the checkout process. JDeveloper helps you to create the task flow with visual design elements that you drag and drop from the Component Palette. When you create an unbounded task flow, the elements allow you to identify how to pass control from one activity in the application to the next. Because a view activity must be associated with a web page or page fragment, JDeveloper allows you also to create the files for the web page or fragment directly from the task flow diagram. The process of creating a task flow adds declarative definitions to an ADF task flow configuration file. The resulting diagram lets you work with a visual control flow map of the pages and referenced task flows for your application. For more information about specifying the entry points to the application using an ADF unbounded task flows, see Section 14.1, "Introduction to Task Flows".
To view detailed product information, you can click the product name link for any product in the home page. The product information is laid out with collapsing nodes organized by categories.
Figure 2-10 shows the detail dialog that you can view for a product.
You can also select the Statistics subtab on the home page to view a graphical representation of the number of orders that customers have placed for the featured items. To present the information so that quantities are easily compared, the graph sorts the products by the number of items ordered, in descending order.
Figure 2-11 shows the bar graph used to display the featured products' current order details.
Where to Find Implementation Details
Following are the sections of the Oracle Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework that describe how to develop the components used to support browsing product details:
Triggering an action to display data
To display data from the data model, user interface components in the web page are bound to ADF Model layer binding objects using JSF Expression Language (EL) expressions. For example, when the user clicks on a link to display an informational dialog, the JSF runtime evaluates the EL expression for the dialog's UI component and pulls the value from the ADF Model layer. At design time, JDeveloper creates declarative definitions of these ADF Model runtime objects when you work with the Data Controls panel to drag an attribute for an item of a data collection, and then choose to display the value, for example, as either read-only text or as an input text field with a label. JDeveloper creates all the necessary JSF tag and binding code needed to display and update the associated data. For more information about the Data Controls panel and the declarative binding experience, see Section 12.1, "Introduction to ADF Data Binding".
Displaying data in graphical format
JDeveloper allows you to create databound components declaratively for your JSF pages, meaning you can design most aspects of your pages without needing to look at the code. By dragging and dropping items from the Data Controls panel, JDeveloper declaratively binds ADF Faces UI components and ADF Data Visualization graph components to attributes on a data control using an ADF binding. For more information, see Section 25.1, "Introduction to Creating ADF Data Visualization Components".
To begin browsing, click the Start Shopping tab in the home page. This action changes the region of the page used to display details about featured products to a region that displays a product categories tree. You can collapse and expand the branch nodes of the tree to view the various product categories that make up the product catalog. The tree displays the product categories in alphabetical order, by category names. When you want to view all the products in a particular category, click its category node in the tree (for example, click Electronics, Media, or Office). The site refreshes the product information region to display the list of products organized as they appear in the database with an image and an accompanying description.
Figure 2-12 shows the home page with all the products in the Electronics category displayed.
Where to Find Implementation Details
Following are the sections of the Oracle Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework that describe how to implement master-detail navigation using separate components:
Synchronizing the display of data for separate components
You can declaratively create pages that display master-detail data using the Data Controls panel. The Data Controls panel displays master-detail related objects in a hierarchy that mirrors the one you defined in the application module data model, where the detail objects are children of the master objects. The Data Controls panel provides prebuilt master-detail ADF Faces components that display both the master and detail objects on the same page as any combination of read-only tables and forms. All you have to do is drop the detail collection on the page and choose the type of widget you want to use. If you do not want to use the prebuilt master-detail components, you can drag and drop master and detail objects individually as tables and forms on a single page or on separate pages. For more information about the data model, see Section 3.4, "Overview of the UI-Aware Data Model". For more information about various types of pages that display master-detail related data, see Section 23.1, "Introduction to Displaying Master-Detail Data".
Sorting data that displays in tables
Unlike with forms where you bind the individual UI components that make up a form to the individual attributes on the data collection, you bind the ADF Faces table component to the complete collection or to a range of data objects from the collection. The specific components that display the data in the columns are then bound to the attributes of the collection. The iterator binding handles displaying the correct data for each object, while the table component handles displaying each object in a row. You can set the Sort property for any column when you want the iterator to perform an order-by query to determine the order. You can also specify an ORDER BY
clause for the query that the view object in the data model project defines. For more information about binding table components to a collection, see Section 22.1, "Introduction to Adding Tables". For more information about creating queries that sort data in the data model, see Section 5.2, "Populating View Object Rows from a Single Database Table".
To search the product catalog, you have several choices. You can begin either by clicking the selection icon (a + symbol) on the Search tab on the accordion panel or by clicking the Search for Deals tab in the main region. When you click either of these, the home page displays both regions at once to allow you to enter a search criteria and view the search results. You use the Search tab on the accordion panel to perform a simple keyword search against the attributes common to all products, such as product names or product descriptions. When you select the attribute to search on from the dropdown list, the panel renders a search field using an appropriate input component to accept the search criteria. For example, in the case of the default searchable attribute ProductId, the search field uses a scrollable selection list field to increment the numeric value.
Figure 2-13 shows the home page with the search results returned for the product with an ID equal to 7.
As an alternative to entering a simple search, you can use the advanced search feature to define and save search criteria based on any combination of searchable fields that you select for the product. Click the Advanced link to open the Advanced Search dialog. Developer-defined saved searches like Find Products By Name appear in the Saved Search dropdown list.
Figure 2-14 shows the Advanced Search dialog with a single search criteria, Name, that the Find Products By Name saved search defines.
In addition to the developer-defined saved searches available in the Advanced Search dialog, the end user can create saved searches that will persist for the duration of their session. Enter the product search criteria in the Advanced Search dialog, then click the Save button to open the Create Saved Search dialog.
Figure 2-15 shows the Create Saved Search dialog that you use to specify how you want to save the search criteria you entered in the Advanced Search dialog. You can name the search, for example, Treo product name search, so that it will display in the Saved Search dropdown list of the Advanced Search dialog.
You can also manage your saved searches by selecting the Personalize function in the Saved Search dropdown list of the Advanced Search dialog.
Figure 2-16 shows the Personalize Saved Search dialog for the Find Products By Name search, with Show in Search List enabled so that it will appear in the Saved Search dropdown list. Note that because this search is not a runtime-defined search, the personalization options appear disabled.
Where to Find Implementation Details
Following are the sections of the Oracle Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework that describe how to define queries and create query search forms:
Defining the query for the search form to display
A query is associated with an ADF Business Components view object that you create for the data model project to define a particular query against the database. In particular, a query component is the visual representation of the view criteria defined on that view object. If there are multiple view criteria defined, each of the view criteria can be selected from the Saved Search dropdown list. These saved searches are created at design time by the developer. For example, in the Fusion Order Demo application, there are two view criteria defined on the ProductsVO
view object. When the query associated with that view criteria is run, both view criteria are available for selection. For more information, see Section 26.1, "Introduction to Creating Search Forms".
Creating a quick search form
A quick query search form has one search criteria field with a dropdown list of the available searchable attributes from the associated data collection. By default, the searchable attributes are all the attributes in the associated view object. You can exclude attributes by setting the attribute's Display control hint to Hide in the view object. The user can search against the selected attribute or search against all the displayed attributes. The search criteria field type will automatically match the type of its corresponding attribute type. For more information, see Section 26.1.2, "Quick Query Search Forms".
Creating a search form
You create a query search form by dropping a named view criteria item from the Data Controls panel onto a page. You have a choice of dropping only a search panel, dropping a search panel with a results table, or dropping a search panel with a tree table. For more information, see Section 26.2, "Creating Query Search Forms".
Displaying the results of a query search
Normally, you would drop a query search panel with the results table or tree table. JDeveloper will automatically wire up the results table or tree table with the query panel. If you drop a query panel by itself and want a results component or if you already have an existing component for displaying the results, you will need to match the query panel's ResultsComponentId
with the results component's ID. For more information, see Section 26.2.2, "How to Create a Query Search Form and Add a Results Component Later".
Until you attempt to access secure resources in the storefront site, you are free to browse the product catalog and update the shopping cart anonymously. However, when you click the My Orders or Checkout links that appear at the top of the home page, you will be challenged by the web container running the site to supply login credentials. The site requires that you enter a valid user name and password before it completes your request to display the linked page.
Note: The Fusion Order Demo application supports the new customer registration process, but that user is not added to the security implementation. Thus, you must use a predefined customer's user name and password to log in, as shown in Table 2-3. |
Figure 2-17 shows the login page fragment that displays before you can view order details or purchase items from the store. For demonstration purposes, log in as a customer by entering ngreenbe
and welcome1
for the Username and Password, respectively.
When you click the Log In button, the web container will compare your entries with the credential information stored in its identity store. If the web container is able to authenticate you (because you have entered the user name and password for a registered user), then the web container redirects to the web page specified by your link selection; otherwise, the site prompts you to create an account or to continue browsing as an unauthenticated user.
Where to Find Implementation Details
Following are the sections of the Oracle Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework that describe how to secure Oracle ADF resources so that users are required to log in to access those resources:
Enabling fine-grained security to secure Oracle ADF resources
Oracle ADF Security is a framework that provides a security implementation that is based on Java Authentication and Authorization Service (JAAS). The Oracle ADF implementation of JAAS is role-based. In JDeveloper, you define these roles and then make permission grants based on these roles to enable fine-grained security for Oracle ADF resources. JDeveloper supports declaratively defining the Oracle ADF policy store for the web pages of an ADF task flow and individual web pages associated with an ADF page definition. For information about securing Oracle ADF resources, see Section 29.5, "Defining ADF Security Policies".
Triggering dynamic user authentication
When you use Oracle ADF Security, authentication is triggered automatically if the user is not yet authenticated and they try to access a page that is not granted to the anonymous-role
role. After successfully logging in, another check will be done to verify if the authenticated user has view access to the requested page. For more information, see Section 29.3.5, "What You May Need to Know About ADF Authentication".
Performing permission checking within the web page
At runtime, the security policy you define for ADF resources is enforced using standard JAAS permission authorization to determine the user's access rights. If your application requires it, you can use Expression Language (EL) to surface server-side security enforcement directly on the user interface. You might use an EL expression to perform runtime permission checks within the web page to hide components that should not be visible to the user. You can also use Oracle ADF Security's implementation of expressions that are specific to the ADF task flow and ADF page definition to perform permission checks to prevent the user from being able to access a task flow or web page, see Section 29.11.1, "Using Expression Language (EL) with ADF Security".
You begin the order process by browsing the product catalog. When you click Add next to a product, the site updates the shopping cart region to display the item.
Figure 2-18 shows the cart summary with a single item added. The summary displays a subtotal purchase total for the items that appear in the cart.
When you are satisfied with the items in the cart, you can complete the order by clicking the Checkout link at the top of the home page. To check out and complete the order, you must become an authenticated user, as described in Section 2.4.2, "The Login Process".
After you log in, the site displays the checkout page with order details, such as the name and address of the user you registered as. The order is identified by an Order Information number that is generated at runtime and assigned to the order. An Order Summary region displays the order items that comprise the new order. This region is similar to the cart summary on the home page, except that it adds the cost of shipping and deducts any discounts that apply to the order to calculate the total purchase amount.
Figure 2-19 shows the checkout page with an order comprising four order items.
You can use the checkout page to customize details of the order information. For example, click the Edit icon next to the Payment Option Code field to display and edit payment funding information for the order.
Figure 2-20 shows the detail dialog for the Payment Option Code field.
Many of the fields of the payment options dialog offer user interface hints that guide you to enter specific information.
Figure 2-21 shows an example of a date entry (06-FEB-2009 10:47:21) that the format mask (dd-MMM-yyyy hh:mm:ss) defines for the Expiration Date field.
The Card Type field displays a dropdown list that allows you to select from a valid list of values.
Figure 2-22 displays the list of values for the Card Type field.
If you close the payment options dialog and click the Submit Order button in the checkout page, the purchase order is created and sent into a process flow. Thus, creating an order will invoke the ESB that then invokes the BPEL process flow that handles the order.
Where to Find Implementation Details
Following are the sections of the Oracle Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework that describe how to develop forms like the one used in the order checkout process:
Creating a databound input form
When you want to create an input form that collects values from the user, instead of having to drop individual attributes, JDeveloper allows you to drop all attributes for an object at once as an input form. The actual UI components that make up the form depend on the type of form dropped. You can create forms that display values, forms that allow users to edit values, and forms that collect values. For more information, see Section 21.6, "Creating an Input Form".
Defining format masks for input forms
Oracle ADF Business Components supports the ability to define control hints on attributes of view objects and entity objects in the data model project. Control hints are additional attribute settings that the view layer can use to automatically display the queried information to the user in a consistent, locale-sensitive way. The format mask is one of the hints that you can define. JDeveloper stores the hints in resource bundle files that you can easily localize for multilingual applications. For more information about specifying user interface hints in a data model project, see Section 5.13, "Defining Attribute Control Hints for View Objects".
Defining a list of values for input fields
Input forms displayed in the user interface can utilize attributes that you define in the data model project to predetermine a list of values (LOV) for individual fields. When the user submits the form with their selected values, Oracle ADF data bindings in the Oracle ADF Model layer update the value on the view object attributes corresponding to the databound fields. To facilitate this common design task, Oracle ADF Business Components provides declarative support to specify the LOV usage in the user interface. For more information about defining LOV-enabled attributes in a data model project, see Section 5.12, "Working with List of Values (LOV) in View Object Attributes".
Keeping track of transient session information
When you create a data model project that maps attributes to columns in an underlying table, your ADF entity objects can include transient attributes that display calculated values (for example, using Java or Groovy expressions) or that are value holders. For example, you might define an Orders
entity object with a transient attribute, such as InvoiceTotal
, to calculate the sum of CalculatedOrderTotal
and TotalShippingCost
attributes. In the Fusion Order Demo application, the order summary region displays the value of the InvoiceTotal
attribute. Because the attribute is used in the user interface, the actual expression is defined on the view object attribute that is used to specify the databound region. The entity object that the view object references, defines the attribute itself. For more information about defining transient attributes in the data model project, see Section 4.14, "Adding Transient and Calculated Attributes to an Entity Object".
The site requires that you become an authenticated user before you can display the checkout page. To make it possible for new customers complete the order process, the site needs to provide a way to guide users through customer registration. To begin, click the registration link on the home page and then click Register as a customer.
Customer registration progresses in steps, with one screen dedicated to each step. To represent the progression of these steps, the registration page displays a series of train buttons labelled Basic Information, Address, Payment Options, and Review. To navigate the customer registration process, you can click certain train buttons or you can click the Next button.
Figure 2-23 shows the first screen in the customer registration process. The train button bar displays the Basic Information button as enabled and highlighted to identify the current stop. Notice that the next train button, Address, is enabled but not highlighted, while the Payment options and Review train buttons appear disabled and grayed out. Together, these train buttons signify that you must complete the activity in a sequential flow.
Before you enter any information into the Basic Information form, click the Address train button. The page displays an error dialog to inform you that specific fields require a value before you can progress to the next step.
Figure 2-24 shows the error dialog with messages stating that the Basic Information form requires a user name and an email address.
Click OK to dismiss the error dialog. Then enter a user name and email address. Be sure to confirm the email address in the form.
Again, click Next to progress to the next task. This time, the site should display the Address screen with icon buttons that you can select to create a new address record in the database (or, in the case of an existing customer, to update an existing address record).
Figure 2-25 shows the Address screen with one column for Address Label and no row information. Because you are entering information as a new customer, no address record currently exists, so no rows are available to display below these columns.
Click New. The registration page changes to display an address input form and the current train stop remains on Address.
Figure 2-26 shows the empty address input form.
For the fields with an asterisk symbol (*), enter the address information specified. The asterisk symbol indicates that the value is required. Note that you must also select a country from the dropdown list since this information is required by the database. Then click Save & Return to create the new address record in the database.
Figure 2-27 shows the Address screen with the row information for the new address record.
This concludes the tour of the Fusion Order Demo application.
Where to Find Implementation Details
Following are the sections of the Oracle Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework that describe how to create a task flow like the one used in the registration process:
Grouping activities using a bounded task flow
A bounded task flow is a specialized form of task flow that has a single entry point and zero or more exit points. It contains its own set of private control flow rules, activities, and managed beans. An ADF bounded task flow allows reuse, parameters, transaction management, and reentry. Every Fusion web application contains an unbounded task flow, which contains the entry points to the application. The application can then call bounded task flows from activities within the unbounded task flow. For more information, see Section 14.1, "Introduction to Task Flows" and see Section 18.7.1, "ADF Bounded Task Flows as Trains".
Displaying the task flow using a train component
You can create a train based on activities that you define in an ADF bounded task flow that specifies the <train/>
element in its metadata. A bounded task flow is a specialized form of task flow that has a single entry point and zero or more exit points. It contains its own set of private control flow rules, activities, and managed beans. An ADF bounded task flow allows reuse, parameters, transaction management, and reentry. For more information, see Section 18.7.3, "How to Create a Train".
Requiring values to complete an input form
The input form displays attributes of a data collection you drop from the Data Controls panel. By default, the component sets the mandatory
control hint for these attributes to false
, which means that the required
attribute on the component will evaluate to false
as well. You can override this control hint by setting the required
attribute on the component to true
. If you decide that all instances of the attribute should be mandatory, you can change the mandatory
property on the attribute where it is defined by the ADF Business Components entity object. The entity object is a data model component that represents a row from a specific table in the database and that simplifies modifying its associated attributes. For more information, see Section 21.2, "Using Attributes to Create Text Fields" and see Section 4.10, "Setting Attribute Properties".