5lfn*ulpp ulfnjulpppio#jpdlopfrp kdvdqrq

150
Learn more from Oracle University at oracle.com/education/ Oracle Commerce: Platform Fundamentals for Developers Rel 11.1 Activity Guide D86560GC10 Edition 1.0 | January 2015 | D89765 Rick Grimm (rickgrimmfl@gmailcom) has a non-transferable license to use this Student Guide Unauthorized reproduction or distribution prohibited Copyright© 2017, Oracle and/or its affiliates

Upload: others

Post on 24-Mar-2022

1 views

Category:

Documents


0 download

TRANSCRIPT

Learn more from Oracle University at oracle.com/education/

Oracle Commerce: Platform Fundamentals for Developers Rel 11.1

Activity Guide D86560GC10 Edition 1.0 | January 2015 | D89765

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Disclaimer This document contains proprietary information and is protected by copyright and other intellectual property laws. You may copy and print this document solely for your own use in an Oracle training course. The document may not be modified or altered in any way. Except where your use constitutes "fair use" under copyright law, you may not use, share, download, upload, copy, print, display, perform, reproduce, publish, license, post, transmit, or distribute this document in whole or in part without the express authorization of Oracle. The information contained in this document is subject to change without notice. If you find any problems in the document, please report them in writing to: Oracle University, 500 Oracle Parkway, Redwood Shores, California 94065 USA. This document is not warranted to be error-free. Restricted Rights Notice

If this documentation is delivered to the United States Government or anyone using the documentation on behalf of the United States Government, the following notice is applicable: U.S. GOVERNMENT RIGHTS The U.S. Government’s rights to use, modify, reproduce, release, perform, display, or disclose these training materials are restricted by the terms of the applicable Oracle license agreement and/or the applicable U.S. Government contract.

Trademark Notice

Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.

Authors Craig Canestrari Karin Layher

Technical Contributors and Reviewers Jay Cross Kevin Johnson Rick Wilson Chris Aakre Graphic Designer Rajiv Chandrabhanu

Editors Aju Kumar Vijayalakshmi Narasimhan

Publishers Joseph Fernandez Sumesh Koshy Pavithran Adka Srividya Rameshkumar

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015. Oracle and/or its affiliates. All rights reserved.

Oracle Commerce: Platform Fundamentals for Developers Rel 11.1 Table of Contents

i

Table of Contents

Practices for Lesson 1: Oracle Commerce Application Structure and Deployment ..................................1-1 Practices for Lesson 1: Overview ...................................................................................................................1-2 Practice 1-1: Creating and Deploying an Application Module ........................................................................1-3

Practices for Lesson 2: Nucleus Components ..............................................................................................2-1 Practices for Lesson 2: Overview ...................................................................................................................2-2 Catching Up ...................................................................................................................................................2-3 Practice 2-1: Modifying a Component Configuration ......................................................................................2-4 Practice 2-2: Creating a Component ..............................................................................................................2-6 Practice 2-3: Registering a Module with the ACC ..........................................................................................2-8

Practices for Lesson 3: Custom Components ...............................................................................................3-1 Practices for Lesson 3: Overview ...................................................................................................................3-2 Catching Up ...................................................................................................................................................3-3 Practice 3-1: Creating a Custom Component Class .......................................................................................3-4

Practices for Lesson 4: The DSP Tag Library ................................................................................................4-1 Practices for Lesson 4: Overview ...................................................................................................................4-2 Catching Up ...................................................................................................................................................4-3 Practice 4-1: Using the DSP Tag Library .......................................................................................................4-4

Practices for Lesson 5: Dynamo Servlet Beans ............................................................................................5-1 Practices for Lesson 5: Overview ...................................................................................................................5-2 Catching Up ...................................................................................................................................................5-3 Practice 5-1: Using Dynamo Servlet Beans ...................................................................................................5-4 Practice 5-2: Writing Custom Dynamo Servlet Beans ....................................................................................5-6

Practices for Lesson 6: Repository Architecture ..........................................................................................6-1 Practices for Lesson 6: Overview ...................................................................................................................6-2 Catching Up ...................................................................................................................................................6-3 Practice 6-1: Working with Repositories .........................................................................................................6-4

Practices for Lesson 7: SQL Repository Configuration Basics ...................................................................7-1 Practices for Lesson 7: Overview ...................................................................................................................7-2 Catching Up ...................................................................................................................................................7-3 Practice 7-1: Configuring SQL Repositories ...................................................................................................7-4

Practices for Lesson 8: Additional SQL Repository Data Models ...............................................................8-1 Practices for Lesson 8: Overview ...................................................................................................................8-2 Catching Up ...................................................................................................................................................8-3 Practice 8-1: Creating Item Subtypes .............................................................................................................8-4

Practices for Lesson 9: Repository Form Handlers ......................................................................................9-1 Practices for Lesson 9: Overview ...................................................................................................................9-2 Catching Up ...................................................................................................................................................9-3 Practice 9-1: Using Repository Form Handlers ..............................................................................................9-4

Practices for Lesson 10: Repository API .......................................................................................................10-1 Practices for Lesson 10: Overview .................................................................................................................10-2 Catching Up ...................................................................................................................................................10-3 Practice 10-1: Using the Repository API ........................................................................................................10-4

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015. Oracle and/or its affiliates. All rights reserved.

Oracle Commerce: Platform Fundamentals for Developers Rel 11.1 Table of Contents

ii

Practices for Lesson 11: Derived Properties .................................................................................................11-1 Practices for Lesson 11: Overview .................................................................................................................11-2 Catching Up ...................................................................................................................................................11-3 Practice 11-1: Creating an Overridable Derived Property ..............................................................................11-4

Practices for Lesson 12: Versioned and Hierarchical Repositories ............................................................12-1 Practices for Lesson 12: Overview .................................................................................................................12-2 Catching Up ...................................................................................................................................................12-3 Practice 12-1: Adding Versioning Capability to a Repository .........................................................................12-4

Practices for Lesson 13: SQL Repository Caching .......................................................................................13-1 Practices for Lesson 13: Overview .................................................................................................................13-2 Catching Up ...................................................................................................................................................13-3 Practice 13-1: Preloading the SQL Repository Cache ...................................................................................13-4

Practices for Lesson 14: Introduction to Core Commerce and the Product Catalog .................................14-1 Practices for Lesson 14: Overview .................................................................................................................14-2 Catching Up ...................................................................................................................................................14-3 Practice 14-1: Exploring the CRS Storefront and Catalog Repositories .........................................................14-4

Practices for Lesson 15: Extending the Product Catalog ............................................................................15-1 Practices for Lesson 15: Overview .................................................................................................................15-2 Catching Up ...................................................................................................................................................15-3 Practice 15-1: Building and Deploying the Store ............................................................................................15-4 Practice 15-2: Extending the Product Catalog ...............................................................................................15-7

Practices for Lesson 16: The User Profile .....................................................................................................16-1 Practices for Lesson 16: Overview .................................................................................................................16-2 Catching Up ...................................................................................................................................................16-3 Practice 16-1: Extending the Profile ...............................................................................................................16-4 Practice 16-2: Updating the User Profile Details Page ...................................................................................16-7

Practices for Lesson 17: Custom Form Handlers and Transactions ...........................................................17-1 Practices for Lesson 17: Overview .................................................................................................................17-2 Catching Up ...................................................................................................................................................17-3 Practice 17-1: Creating a Custom Form Handler ...........................................................................................17-4

Practices for Lesson 18: Pipeline Processors ...............................................................................................18-1 Practices for Lesson 18: Overview .................................................................................................................18-2 Catching Up ...................................................................................................................................................18-3 Practice 18-1: Exploring Pipeline Configurations ...........................................................................................18-4

Practices for Lesson 19: REST Web Services ...............................................................................................19-1 Practices for Lesson 19 ..................................................................................................................................19-2

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 1: Oracle Commerce Application Structure and Deployment

Chapter 1 - Page 1

Practices for Lesson 1: Oracle Commerce Application Structure and Deployment

Chapter 1

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 1: Oracle Commerce Application Structure and Deployment

Chapter 1 - Page 2

Practices for Lesson 1: Overview

Practices Overview In this practice, you will create an Oracle Commerce application module that contains a simple Java EE application. You will use this module and application as the container for the work you will complete in many practices in this course. You will then assemble and deploy the module, and start it on WebLogic.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 1: Oracle Commerce Application Structure and Deployment

Chapter 1 - Page 3

Practice 1-1: Creating and Deploying an Application Module

Overview In this practice, you will create an Oracle Commerce application module that contains a simple Java EE application. You will use this module and application as the container for the work you will complete in many practices in this course. You will then assemble and deploy the module, and start it on WebLogic.

Your Practice Environment Your instructor or IT department will provide you with the access details to a dedicated Linux lab environment that you will use for the duration of the training. The environment contains everything that you need to complete the practices for this course, including a full installation of Oracle Commerce, supporting software, tools, and student files:

• Oracle Commerce Platform 11.1

• Oracle Commerce Guided Search 11.1

• Oracle Commerce Reference Store 11.1

• Oracle 12c Standard One Database

• WebLogic Application Server 12c

• Eclipse 4.3 (Kepler)

• JDK 1.7

• Course-specific files for student exercises (“PFD”)

• A web browser

The following folders will be referenced throughout these practices. The symbolic names listed will be used for quick reference, and correspond to the designated path locations in the lab environment:

• <atgroot> : /oce111

Top-level directory where Oracle Commerce (ATG) and supporting software is installed

• <atgdir> : /oce111/ATG11.1

Contains the installation of the Oracle Commerce platform

• <coursedir> : /oce111/Training/PFD

Contains the setup, source, and solution files for this course

• <wldir> : /oce111/Middleware/wlserver

Contains the WebLogic application server installation

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 1: Oracle Commerce Application Structure and Deployment

Chapter 1 - Page 4

Problem Statement Create an Oracle Commerce module called Sandbox, which contains a simple Java EE application. Create a project in Eclipse to manage your Sandbox development tasks, and import and enable Ant build scripts to assemble and deploy your application module. Start the application server (WebLogic) and Oracle Commerce, and deploy the Sandbox application. Visit the application root page and the ATG Administration home page to verify your work.

The lab work for the early lessons of this course will be completed within the context of this application. The Sandbox application will be a bare-bones “scratch pad” work area used to demonstrate basic operations, functionality, syntax, and mechanics. It will simply act as a container where you can exercise learned skills and test your work.

Note that after you have mastered the basic skills, your hands-on practice work will transition to the Commerce Reference Store environment, where you will gain insight into and experience with a simulation of a real-world implementation of Oracle Commerce capabilities.

Several starter and support files for this practice are available to you in <coursedir>/src/lesson01 and <coursedir>/scripts. The starter files provide a template that you will need to edit to complete this practice. The support files are provided to assist you in building and deploying your application; you will not be required to edit these files. The following table provides descriptions of these files:

Starter files

MODULE-TEMPLATE (directory) Oracle Commerce module template, representing a skeletal application module that contains a simple Java EE application. This is to be copied into your Oracle Commerce environment, renamed, and imported into Eclipse. Key elements require editing to define your Sandbox module.

Support files

build.xml Pre-configured Ant build scripts to be used to update files on a running instance of WebLogic Server. This file is specifically written to deploy, assemble, and undeploy the Sandbox application, employing the Oracle Commerce runAssembler and WebLogic deployment interface to implement the build process. It requires integration into the Sandbox module Eclipse development environment.

build.properties Defines key configuration values for the scripts included in build.xml

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 1: Oracle Commerce Application Structure and Deployment

Chapter 1 - Page 5

Guided Instructions

Task 1: Create a “Sandbox” application module and Java EE application An Oracle Commerce module template has been pre-created for you, representing a skeletal application module that contains a simple Java EE application. You will copy this module into your Oracle Commerce environment, import the module into Eclipse, and edit key elements to create your Sandbox module.

1. Open your desktop File Browser and copy the

<coursedir>/src/lesson01/MODULE-TEMPLATE folder to <atgdir>.

2. In the ATG11.1 folder, rename the MODULE-TEMPLATE folder Sandbox.

3. Open the Sandbox/j2ee-apps folder and locate the myapplication-j2ee subfolder. This is your Java EE application definition folder. Rename this folder sandbox-j2ee.

4. Open the sandbox-j2ee folder and locate the myapplication-web.war subfolder. Rename this folder sandbox-web.war.

5. Navigate to the (Sandbox)/META-INF folder and edit the MANIFEST.MF file. You can use the gedit editor by right-clicking the file and selecting “Open with gedit.” Set the manifest attributes as shown in the following table and save the file.

Manifest Attribute Value

ATG-Config-Path config/

ATG-Class-Path classes/

ATG-Required DSS DafEar.Admin

ATG-J2EE j2ee-apps/sandbox-j2ee

ATG-EAR-Module j2ee-apps/sandbox-j2ee

Specifying DSS as a required module identifies Scenario Server as the baseline for Sandbox. DSS is considered the minimum Oracle Commerce baseline configuration. DSS in turn includes DPS (Personalization), which includes DAS (Dynamo core services). The features and components of all these servers are available to the Sandbox application.

Note that you include the DafEar.Admin module because it is required to run the ATG Server Administration UI.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 1: Oracle Commerce Application Structure and Deployment

Chapter 1 - Page 6

6. Navigate to the j2ee-apps/sandbox-j2ee/META-INF folder and edit the application.xml file. Set the configuration parameters as shown in the following table and save the file.

Parameter Value

display-name sandbox-j2ee

description sandbox-j2ee ear file

web uri sandbox-web.war

context root /sandbox

7. Navigate to the j2ee-apps/sandbox-j2ee/sandbox-web.war/WEB-INF folder and edit the web.xml file. Set the context root parameter as shown in the following and save the file:

<context-param>

<param-name>context-root</param-name>

<param-value>/sandbox</param-value>

</context-param>

Task 2: Import the Sandbox module into Eclipse 8. Start Eclipse via the shortcut on the desktop.

9. Select File > New > Project. Select Java Project from the wizard menu, and then select Next.

10. Enter the project name Sandbox, deselect the “Use default location” option, and set the project location to your newly created Sandbox module folder (/oce111/ATG11.1/Sandbox).

11. Click Finish.

12. The Project Navigator should be started by default on the left side of your Eclipse display. You can always start the Project Navigator view by selecting Window > Show View > Navigator.

13. Open the Sandbox project and explore the directory structure. Note the location of the file assets.

Task 3: Import the Sandbox Ant build files For this course, pre-configured Ant build scripts will be used to update files on a running instance of WebLogic Server. Ant is a tool for automating the software build process, implemented in Java and well-suited to building Java projects. The Ant scripts for this course have been specifically written to deploy, assemble, and undeploy the Sandbox application. You will integrate these scripts into the Sandbox module Eclipse development environment.

14. In Eclipse, in the Project Navigator, open the Sandbox project and locate the j2ee-apps/sandbox-j2ee/ folder. Right-click the folder and select Import.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 1: Oracle Commerce Application Structure and Deployment

Chapter 1 - Page 7

15. In the General folder, select the import source to be File System and click Next.

16. For the source (“From”) directory, browse to and select /oce111/Training/PFD/scripts. Click OK.

17. Select the two build files (build.properties, build.xml) and click Finish.

18. Make sure that the Ant tab is viewable (Window > Show View > Ant).

19. On the Ant tab, select the Add Buildfiles icon .

20. Navigate to the build.xml file under sandbox-j2ee and click OK.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 1: Oracle Commerce Application Structure and Deployment

Chapter 1 - Page 8

21. On the Ant tab, expand Sandbox and you should see the following tasks:

Task 4: Notate the Sandbox index.jsp file

22. In Eclipse, in the Project Navigator, open the Sandbox project and locate the j2ee-apps/sandbox-j2ee/sandbox-web.war folder.

23. Double-click the index.jsp file and examine the simple page code content.

24. Add a personal notation to the file, such as including your name in the displayed text. This will help you to quickly verify in an upcoming step that your application is correctly deployed. Save your edit.

Task 5: Start your WebLogic and Oracle Commerce servers 25. From the PFD Server Startup Scripts folder on your desktop, double-click WLSAdmin.sh.

When prompted, choose “Run in Terminal.” This will keep a log window open on the desktop so you can see the startup progress and view logging messages.

When the server is started, you should see something similar to:

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 1: Oracle Commerce Application Structure and Deployment

Chapter 1 - Page 9

26. Now you need to start the Oracle Commerce Sandbox server. From the PFD Server Startup Scripts folder on your desktop, double-click SandboxDev.sh. When prompted, choose “Run in Terminal.” This server will take longer to start. You will know it’s started when you see something similar to:

Task 6: Deploy your Sandbox application 27. In Eclipse, on the Ant tab, double-click the deploy task.

This will actually run three of the Ant tasks. It will first run the undeploy task, which will remove the Sandbox application from the ATG server (if one has previously been deployed), then it will run the ear task, which will assemble all the files and libraries needed to create the EAR file that can be deployed to the server. Lastly, it will run the deploy task and deploy the EAR file to the server. You can see its progress on the Console tab in Eclipse and will know it has completed when you see something similar to:

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 1: Oracle Commerce Application Structure and Deployment

Chapter 1 - Page 10

Task 7: Test your application 28. In a browser, visit your web application’s home page at

http://localhost:7303/sandbox. This is defaulted to the test page (index.jsp) you edited in an earlier step. This page will confirm that the application is running correctly. Verify that the edits you made earlier are included on the page.

29. Navigate to the ATG Administration UI at http://localhost:7303/dyn/admin. When prompted, log in as user admin with password Password1.

30. Note that quick links to these pages are included in the PFD URL Bookmarks folder on your desktop:

• Visit Sandbox home page

• Visit Sandbox Administration UI

You can make use of these links throughout this course. You may also want to bookmark these locations in the browser for quick access.

Note: Now that your Sandbox application has been deployed, starting the server from the startup script (in the PFD Server Startup Scripts folder) will automatically start the Sandbox application. If you need to shut down or restart the server, you will not necessarily need to redeploy the application via the Ant Task (unless you have code, configuration, or page changes that you want to push to the server).

You will be called upon to redeploy (via Ant) the Sandbox application many times as you work through the practices for this course. The server need not be started for you to deploy; if you deploy your application and the server is not running, deployment will pend until the server is started.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2: Nucleus Components

Chapter 2 - Page 1

Practices for Lesson 2: Nucleus Components

Chapter 2

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2: Nucleus Components

Chapter 2 - Page 2

Practices for Lesson 2: Overview

Practices Overview In these practices, you will override the properties of a global component with application-specific values set from the Sandbox module’s local configuration layer. You will also create and configure a component based on an out-of-the-box component class, which is instantiated in the Sandbox configuration layer and which resides in the Sandbox Nucleus namespace. Finally, you will register the Sandbox configuration layer and namespace with the ACC.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2: Nucleus Components

Chapter 2 - Page 3

Catching Up

Dependencies You should have successfully completed the following practice:

Lesson 1: Oracle Commerce Application Structure and Deployment

• Practice 1-1: Creating and Deploying an Application Module

It is essential that you have a working Sandbox Java EE web application in place and that you are comfortable working in Eclipse to complete the remaining practices.

If you started but did not complete the practice to create and deploy the Sandbox application module, continue from where you left off and complete the practice before proceeding. The instructor can assist you if you are unable to complete the practice successfully.

If your web application is not working as intended and you would like to start over, go to the Eclipse Project View, right-click the Sandbox project and select Delete. Select “yes” when asked if you want to delete the project files. This will reset you back to the default practice environment state and you can follow the guided instructions from the beginning to successfully build your Sandbox web application.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2: Nucleus Components

Chapter 2 - Page 4

Practice 2-1: Modifying a Component Configuration

Overview In this practice, you will override the properties of a global component with application-specific values set from the Sandbox module’s local configuration layer.

Problem Statement Use the Sandbox component configuration layer to set the default “from address” and “subject” properties of the global /atg/dynamo/SMTPEmail component to values specific to the application. You can refer to the Oracle Commerce Programming API documentation for a complete definition of the SMTPEmail component class, including a full list of properties.

Guided Instructions

Task 1: Modify the global SMTPEmail component configuration values

The global SMTPEmail component resides in the /atg/dynamo/service Nucleus namespace. You need to create a local configuration layer for this namespace in Sandbox, and add a properties file to override the module-specific values.

1. In the Eclipse Project Navigator, locate the Sandbox config folder.

2. Right-click the config folder and select New > Folder. Enter atg/dynamo/service as the folder name and click Finish.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2: Nucleus Components

Chapter 2 - Page 5

3. Select the config/atg/dynamo/service folder, and then right-click and select New > File. Enter SMTPEmail.properties as the file name. The new file should open in the Eclipse file editor panel.

4. Add configuration values for the properties outlined in the following table:

Property Value

defaultFrom [email protected]

defaultSubject Thank you

Enter values of your choice for the properties above; however, remember that the property value syntax is <property-name>=<property-value>.

5. Save your edits .

6. Run the deploy Ant task (select Window > Show View > Other … Ant to view the Ant tab if it is not already visible). This will redeploy your web application. Remember to wait for the “Build successful” log message in the Console window to verify that the application was deployed successfully.

Task 2: Verify your work using the ATG Administration UI 7. Access the ATG Administration UI by opening a browser and navigating to

http://localhost:7303/dyn/admin. Remember that you may also use the desktop URL bookmarks (or any bookmark you created in the first lesson).

8. Click the Component Browser link and browse to the SMTPEmail component. You will need to reference the full Nucleus name: /atg/dynamo/service/SMTPEmail.

9. Scroll down to the Properties table and verify that the live property values of SMTPEmail.defaultFrom and SMTPEmail.defaultSubject are set to your modified values.

10. Scroll up and click the View Service Configuration link. Review the source files that provide the configuration value for the component properties, noting in particular the Sandbox layer configurations. Rick Grimm (ric

kgrimmฺfl@gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2: Nucleus Components

Chapter 2 - Page 6

Practice 2-2: Creating a Component

Overview In this practice, you will create and configure a component based on an out-of-the-box component class, which is instantiated in the Sandbox configuration layer and which resides in the Sandbox Nucleus namespace.

Problem Statement Create and configure a session-scoped customer email inquiry form handler component based on the out-of-the-box EmailFormHandler component class. Provide default values for the “recipient,” “subject,” and “use request locale” properties. Refer to the Oracle Commerce Programming API documentation for a complete definition of the EmailFormHandler component class, including a full list of properties.

Guided Instructions

Task 1: Create a local component based on the EmailFormHandler class

A custom class called atg.service.email.EmailFormHandler is provided out of the box as a baseline Oracle Commerce component class. It has several configurable properties, but the only ones that you will be concerned with for this practice are the following:

• recipient (String)

• subject (String)

• useRequestLocale (boolean)

1. Create a sandbox folder in the Sandbox config folder. This will create a /sandbox Nucleus namespace when you next assemble your application. This namespace will be used to classify your local component configurations, and this folder is where your local component properties files will reside.

2. Create a file in the config/sandbox folder called EmailInquiryFormHandler.properties. This is your local email form handler component definition file.

3. Use the following table to set the configuration values for your new component:

Property Value

$class atg.service.email.EmailFormHandler

$scope session

recipient [email protected]

subject Support Inquiry

useRequestLocale true

Enter values of your choice for the last three properties in the table above, but make sure you enter the class and scope as specified.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2: Nucleus Components

Chapter 2 - Page 7

4. Save your edits .

5. Deploy your changes (via the Ant task).

Task 2: Verify your work using the ATG Administration UI 6. Access the ATG Administration UI, and select the Component Browser. Note that the

Sandbox configuration folder and the EmailInquiryFormHandler component are not displayed. This is because the component has not yet been referenced, and therefore, has not yet been started. You can start it now and view its properties by appending the component name to the URL for the /sandbox folder in the Admin UI: //localhost:7303/dyn/admin/nucleus/sandbox/EmailInquiryFormHandler

7. Scroll down to the Properties table and verify that the live property values reflect your configuration values from above.

8. Note that you can modify a live property value by clicking the property and entering a new value in the New Value box. Ensure that you click Change Value after you have entered your change.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2: Nucleus Components

Chapter 2 - Page 8

Practice 2-3: Registering a Module with the ACC

Overview In this practice, you will register the Sandbox configuration layer and namespace with the ACC so that the Sandbox configuration layer will appear in the Components window of that tool, allowing you to more easily view, create, modify, and debug Sandbox-based components.

Problem Statement Create and/or configure the following properties files to establish Sandbox as a recognized module in the ACC:

• The Sandbox CONFIG.properties file

• The /atg/modules/Sandbox.properties file

• The /atg/modules/config/ModuleManager.properties file

Guided Instructions

Task 1: Edit the Sandbox CONFIG.properties file

Each module may have a CONFIG.properties file at the top level of its /config folder. This file labels and configures a configuration layer in the ATG Control Center for that module. The template you used to create your Sandbox module included a default version of this file. In this task, you will modify that file and set some configuration parameters for use with the ACC.

1. Open the config/CONFIG.properties file in the Eclipse file editor.

2. Set the name property to Sandbox and the defaultForUpdates property to true. The defaultForUpdates flag indicates that the changes made to components in the ACC are reflected in this configuration layer by default. This is typically set to false so that localconfig remains the default update layer, but for instructional purposes, you will set this layer as the default now.

In your practice environment, the <atgdir>/home/localconfig/CONFIG.properties file has been pre-configured to disable it as the default layer for ATG updates. You may want to locate this file in the file system and verify that the defaultForUpdates property has been set to false. This ensures that the changes you make in the practices for this course default to the Sandbox layer. Again, this is primarily for instructional purposes, so that you can observe the effects of the configuration parameters in the Sandbox module.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2: Nucleus Components

Chapter 2 - Page 9

Task 2: Create a Module component and add it to the master module list

3. Create a config/atg/modules folder in the Sandbox module.

4. Create a component of class atg.service.modules.Module in the config/atg/modules folder. Give it the same name as the module (Sandbox). Your Sandbox.properties file should look like the following:

$class=atg.service.modules.Module

moduleName=Sandbox

This creates a component with a Nucleus address of /atg/modules/Sandbox of class atg/service.modules.Module with the moduleName property set to Sandbox.

5. Add a ModuleManager.properties file in the same directory. This file references a global component with a Nucleus address of /atg/modules/ModuleManager that maintains a list of modules presented in the ACC. Your properties file should contain one line:

modules+=Sandbox

This line simply adds the Sandbox module to the list of recognized modules in the ACC.

6. Make sure that your files are saved and deploy your changes.

Task 3: Start the ACC and verify your work 7. Go to the ATG Administration UI and click the ATG Control Center Administration link.

8. Select the Start ACC in Server VM option.

9. When prompted, log in using the login ID admin and password Password1.

10. Select Pages and Components > Components by Module and verify that Sandbox is included in the list of modules.

11. Select Pages and Components > Components by Path and verify that the hierarchy includes the sandbox path.

12. Open Sandbox > EmailInquiryFormHandler.

13. Modify the “Configured Value” of the subject property and save the component.

14. From Eclipse, open (or reload) the /config/sandbox/EmailInquiryFormHandler.properties file and verify that changes made from the ACC are saved in this configuration layer.

If time allows, navigate through the ACC and become familiar with how components are organized, created, and updated. You will use the ACC many times in the practices for this course so it is beneficial to become familiar with its features and user interface.

15. Close the ACC when you are done verifying your work.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2: Nucleus Components

Chapter 2 - Page 10

A note about the ACC connection to the server At times the ACC may time out, disconnecting from the Oracle Commerce server while still running in the server’s VM. If that happens, choosing Tools > Connect to server may allow you to successfully log in again. Also note that when restarting the server or running a deployment, you should shut down the ACC first, and then restart it after the server is back up.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Custom Components

Chapter 3 - Page 1

Practices for Lesson 3: Custom Components

Chapter 3

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Custom Components

Chapter 3 - Page 2

Practices for Lesson 3: Overview

Practices Overview In this practice, you will set up your Eclipse project for Java development and create a custom component Java class. You will then create and deploy a globally scoped component based on your custom class.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Custom Components

Chapter 3 - Page 3

Catching Up

Dependencies You should have successfully completed the following practice:

Lesson 1: Oracle Commerce Application Structure and Deployment

• Practice 1-1: Creating and Deploying an Application Module

It is essential that you have a working Sandbox Java EE web application in place and that you are comfortable working in Eclipse to complete the remaining exercises.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Custom Components

Chapter 3 - Page 4

Practice 3-1: Creating a Custom Component Class

Overview In this practice, you will set up your Eclipse project for Java development and create a custom component Java class. You will then create and deploy a globally scoped component based on your custom class.

Problem Statement Write a simple custom component class that manages a list of store-related events. For this practice, you will keep it very simple and include getter and setter methods for three properties:

• The title of the event list (String)

• A list of events (List of Strings)

• A flag indicating whether the event list is active (boolean)

Create a store events component based on the custom component class, providing default configuration values for the properties.

In a real-world application, your custom component class would likely implement and expose some custom processing that manages, processes, or manipulates its properties. For this practice, the intent is to illustrate the basic structure of a component class, how the property methods must be implemented to work within the Nucleus framework, and how logging is implemented within components. As such, a simple set of requirements has been specified to emphasize these objectives. If you have additional time, you are encouraged to add more complexity to your implementation.

Guided Instructions

Task 1: Set up your Eclipse project for Java development 1. In Eclipse, select Window > Show View > Project Explorer.

2. Make sure that the Sandbox project is selected.

3. Select Project > Properties, and select the Java Build Path option on the left.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Custom Components

Chapter 3 - Page 5

4. On the Source tab, you need to make sure that the “Source folders on build path” property includes Sandbox/src. This is the folder in your Sandbox module where custom Java code will reside. This folder can be named anything of your choice, but src is the default folder that was supplied in the original module template. Note that multiple source folders can be specified for a project, but for Sandbox we will only have the one folder.

To specify the source folder for Sandbox, click the Add Folder button, then select the check box next to the src subfolder, and then click OK.

5. Select “Allow output folders for source folders” and enter Sandbox/classes as the default output folder. This is the folder into which your compiled class files will be saved. Again, this is user-configurable, but classes is the default folder that was specified in the module template (and is specified in the MANIFEST.MF file).

6. On the Libraries tab, click the Add External JARs… button and navigate to oce111/ATG11.1/DAS/lib/. Select classes.jar and servlet.jar and click OK. Make sure that these libraries are displayed in the list of JAR files included on the build path. These Oracle Commerce libraries are required to build your custom component class.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Custom Components

Chapter 3 - Page 6

7. Click OK to save your settings.

8. Switch the Eclipse perspective to the Java EE view (Window > Open Perspective > Other … Java EE).

9. If the Ant tab is not visible, select Window > Show View > Other … Ant. In this perspective, the Ant tab is visible in the panel along the bottom.

Task 2: Write a custom EventsManager Java class

10. Right-click the src folder and select New > Class.

11. On the New Java Class panel, enter sandbox as the class Package and EventsManager as the class Name.

12. For the Superclass, open the browse tab and enter GenericService in the “Choose a type” box. Select GenericService - atg.nucleus and click OK.

13. Make sure that the “Constructors from superclass” option is selected.

14. Click Finish. Your EventsManager.java file should open in the file editor.

15. Eclipse creates a skeleton class file for you. Complete your class by coding the following:

• Import java.util.List.

• Create private member variables and getters and setters (methods) for the following properties:

Property Type

title String

active boolean

events List<String>

Remember that the getter method signature for boolean properties is isProperty ().

Hint: In Eclipse, if you define a member variable, you can then select it and choose Generate Getters and Setters from the Source menu to automatically generate the code.

• Insert a logDebug() output line in each of your methods, which logs an indication that the method has been called. Make sure that your logDebug() lines are displayed only if isLoggingDebug() returns true.

• You do not need to provide any code for the constructor.

16. Make sure Project > Build Automatically is set.

17. Save your file. The Java code will automatically compile on save.

18. Check for and resolve any errors.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Custom Components

Chapter 3 - Page 7

Task 3: Create a StoreEvents component based on your component class

19. Create a global StoreEvents component in config/sandbox based on the custom sandbox.EventsManager class. Configure your component as listed in the following table:

Property Value

$class sandbox.EventsManager

$scope global

title Online Store Events

active true

events New Looks Eyewear, Designer Preview, Punk Styles

loggingDebug true

As always, you can enter your own values for the list title and events.

20. Run the deploy Ant task to push your new class and component to the live server.

21. Use the Component Browser of the Administration UI to start your component and verify that the values of the properties are set to the defaults specified in the configuration file. Remember, you can start your component by browsing to the following URL:

http://localhost:7303/dyn/admin/nucleus/sandbox/StoreEvents/

22. Observe the logging output in the Sandbox server log window and verify that your logging messages are correctly reporting that the property get methods have been called.

23. Modify the above property values via the Admin UI and verify in the logging window that the set methods are called.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Custom Components

Chapter 3 - Page 8

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4: The DSP Tag Library

Chapter 4 - Page 1

Practices for Lesson 4: The DSP Tag Library

Chapter 4

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4: The DSP Tag Library

Chapter 4 - Page 2

Practices for Lesson 4: Overview

Practice Overview In this practice, you will declare the DSP tag library for use in a JSP and use specialized tags to display Nucleus component values and manage page fragments.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4: The DSP Tag Library

Chapter 4 - Page 3

Catching Up

Dependencies You should have successfully completed the following practice:

Lesson 1: Oracle Commerce Application Structure and Deployment

• Practice 1-1: Creating and Deploying an Application Module

It is essential that you have a working Sandbox Java EE web application in place and that you are comfortable working in Eclipse to complete the remaining exercises.

In addition, the following practice must be completed before continuing:

Lesson 3: Custom Components

• Practice 3-1: Creating a Custom Component Class

If you need to quickly catch up, you can copy the provided solution files (in <coursedir>/solutions/lesson03/) to the locations outlined in the guided instructions. Note, however, that you may be copying over some of your own previous work. Therefore, ensure that you make backups of any files that contain code or data that you may want to reference later.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4: The DSP Tag Library

Chapter 4 - Page 4

Practice 4-1: Using the DSP Tag Library

Overview In this practice, you will declare the DSP tag library for use in a JSP and use specialized tags to display Nucleus component values and manage page fragments.

Problem Statement Use the DSP tag library to display the properties of the StoreEvents component (which you created in the previous lesson) on the Sandbox home page. The values can be simply listed on the page without any formatting. Create a parameter-driven page fragment to display a lesson number and title header for your work. Because you are making only JSP edits, you can use the update_files Ant task to deploy the pages to your live Sandbox application.

Guided Instructions

Task 1: Declare the DSP tag library 1. In Eclipse, browse to /Sandbox/j2ee-apps/sandbox-j2ee/sandbox-web.war and

double-click index.jsp to edit.

2. Declare the DSP tag library at the top of the page by using the taglib declaration. Note that this line must be the first non-comment line in the JSP.

<%@ taglib uri="/dspTaglib" prefix="dsp" %>

3. Enclose the entire page under the taglib declaration within <dsp:page> … </dsp:page> tags.

Task 2: Display StoreEvents component properties on a page

4. Add a simple lesson header on the page, below the welcome message but before the </dsp:page> tag. The HTML might look like the following:

<h2>Lesson 4: The DSP Tag Library</h2>

5. Use the <dsp:importbean> tag at the top of the page (but below the <dsp:page> tag) to declare the StoreEvents component. This is optional but will allow you to reference the component on the page without specifying the full component path.

<dsp:importbean bean="/sandbox/StoreEvents"/>

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4: The DSP Tag Library

Chapter 4 - Page 5

6. Under the lesson 4 header, use the <dsp:valueof> tag to display the title and events properties of the StoreEvents component on the page. Remember that the syntax is:

<dsp:valueof bean="component.property"/>

You might want to precede each property with identifying text, such as “The name of the event group is” and “The events of this event group are.”

7. For the active property, instead of displaying the value, use the <dsp:setvalue> tag to set the value to false. This is purely for instructional purposes, so you can see how properties can be set as well as read from a page. Remember that the syntax is:

<dsp:setvalue bean="component.property " value="value"/>

You might want to precede the property setting with text such as “Setting this event group to inactive.”

8. Run the update_files Ant task to copy your work to the WebLogic server. Note that this Ant task is different from the one you ran in previous practices. This script copies only the modified JSPs into the running Sandbox application rather than initiating a full redeployment of the application. This task does not include a server restart, and completes much quicker than a full deployment. In many of the upcoming practices, you will be required to deploy only updated JSPs and will use this task to efficiently push the pages live.

9. Load the Sandbox home page at http://localhost:7303/sandbox/. Remember that you may also use the desktop URL bookmarks (or any bookmark that you created in the first lesson).

10. Verify that the lesson 4 section header and the component properties are displayed. Your page may look something like the following:

11. Examine the Sandbox server logging window, and verify that the debug messages indicate that the property getters and setters are called.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4: The DSP Tag Library

Chapter 4 - Page 6

Task 3: Create and use a parameter-driven lesson header page fragment 12. Create a lessonHeader.jsp file in the /j2ee-apps/sandbox-j2ee/sandbox-

web.war folder. (Right-click the folder, select New > File, enter the file name, and click Finish.)

13. Declare the DSP tag library and add the closing and ending page tags.

14. Between the page tags, include HTML to display a lesson header in the format “Lesson number : name.” The lesson number should be generated by an input page parameter named lessonNumber, while the lesson name should be generated by an input page parameter named lessonTopic.

Remember that the syntax for referencing a parameter is <dsp:valueof param=”…”/>.

15. Modify index.jsp to include lessonHeader.jsp by using the <dsp:include> tag in place of the static Lesson 4 header. Be sure to pass in the lessonNumber and lessonTopic parameters by using the <dsp:param> tag.

16. Run the update_files Ant task.

17. Reload the Sandbox home page to verify your changes.

Note that, going forward, you can use this lesson header page fragment for each of the practices in which you are required to edit the index.jsp file to practice your skills.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 5: Dynamo Servlet Beans

Chapter 5 - Page 1

Practices for Lesson 5: Dynamo Servlet Beans

Chapter 5

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 5: Dynamo Servlet Beans

Chapter 5 - Page 2

Practices for Lesson 5: Overview

Practices Overview In these practices, you will use standard Dynamo Servlet Beans to display dynamic and conditional content on a page. You will also write a custom Dynamo Servlet Bean class, and use that bean in a JSP to display conditional content.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 5: Dynamo Servlet Beans

Chapter 5 - Page 3

Catching Up

Dependencies You should have successfully completed the following practice:

Lesson 1: Oracle Commerce Application Structure and Deployment

• Practice 1-1: Creating and Deploying an Application Module

It is essential that you have a working Sandbox Java EE web application in place and that you are comfortable working in Eclipse to complete the remaining practices.

In addition, the following practice must be completed before continuing:

Lesson 3: Custom Components

• Practice 3-1: Creating a Custom Component Class

If you need to quickly catch up, you can copy the provided solution files (in <coursedir>/solutions/lesson03/) to the locations outlined in the guided instructions. However, note that you may be copying over some of your own previous work. Therefore, ensure that you make backups of any files that contain code or data that you may want to reference later.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 5: Dynamo Servlet Beans

Chapter 5 - Page 4

Practice 5-1: Using Dynamo Servlet Beans

Overview In this practice, you will use standard Dynamo Servlet Beans to display dynamic and conditional content on a page.

Problem Statement Use the Switch and ForEach Dynamo Servlet Beans to conditionally display a formatted list of the store events managed by the custom StoreEvents component. The requirements are the following:

• Check the value of the active property of the StoreEvents component.

• If the list is inactive, display a message indicating “The Store Events group is inactive.”

• If the list is active but there are no events (events), display a message indicating “No upcoming events.”

• If the list is active and there are events, display the list title (title) followed by a bulleted list of the events (events).

Guided Instructions 1. Edit index.jsp, adding a lesson header for this lesson (Lesson 5: Dynamo Servlet

Beans).

2. Insert a Switch droplet (/atg/dynamo/droplet/Switch) with the following configuration and functionality:

• Set the value input parameter to the active property of the StoreEvents component. Remember that this is a JavaBean rather than a static value, so you need to use the bean= syntax.

• Create an oparam for the false case, displaying the inactive message.

• Create an oparam for the true case. Insert a ForEach droplet to display iterative event information, as shown in the following step.

3. Configure the ForEach droplet as follows:

• Set the array input parameter to the events property of the StoreEvents component. Again, remember that this is a JavaBean rather than a static value; therefore, you need to use the bean= syntax.

• For the outputStart oparam, display the title property of the StoreEvents component and start an unordered list (<ul>).

• For the outputEnd oparam, end the unordered list (</ul>).

• For the empty oparam, display the no events message.

• For the output oparam, display the event held by the element output parameter.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 5: Dynamo Servlet Beans

Chapter 5 - Page 5

4. Save your changes.

5. Run the update_files Ant task.

6. Reload the Sandbox home page to verify your work. If the page was coded correctly, the “The Store Events group is inactive” message might be displayed. This is because in the practice for lesson 4, you included the line to set the active property to false on the page, and reloading the page sets the property. You have now verified the false case of your Switch droplet.

7. To test the true case, edit the Lesson 4 section of index.jsp and set the active property to true.

8. Run the update_files Ant task.

9. Reload the home page to verify that your event list is displayed properly.

10. To test the empty case, use the Administration UI (or the ACC) to clear the event list. Then reload the home page.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 5: Dynamo Servlet Beans

Chapter 5 - Page 6

Practice 5-2: Writing Custom Dynamo Servlet Beans

Overview In this practice, you will write a custom Dynamo Servlet Bean class, and use that bean in a JSP to display conditional content.

Problem Statement Create a custom ContainsText Dynamo Servlet Bean that tests if a string contains a specified substring. The input and open parameters are defined as follows: (There are no output parameters.)

Input Parameters

value String Source string that will be searched

matchValue String Substring that will be searched for in the value string

Open Parameters

true Rendered if value contains matchValue

false Rendered if value does not contain matchValue

error Rendered if an exception occurs, or if one of the input parameters is null

Use the custom ContainsText Dynamo Servlet Bean with your list of store events to display conditional “DISCOUNT EVENT” prefix for any event that includes the word “Sale.”

Guided Instructions

Task 1: Write the custom ContainsText Dynamo Servlet Bean class

1. Right-click the src/sandbox folder and create a new Java class, named ContainsText, based on the atg.servlet.DynamoServlet superclass. (The class will reside in the sandbox package.)

2. Complete the servlet bean implementation by using the following guidelines:

• The servlet bean should include a method with the following signature:

public void service (DynamoHttpServletRequest request, DynamoHttpServletResponse response)

throws javax.servlet.ServletException, java.io.IOException

• The service() method should retrieve the value and matchValue String input parameters.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 5: Dynamo Servlet Beans

Chapter 5 - Page 7

• The service() method should perform the following:

o Test that both input parameters are not null.

o If not null, use the String.contains() method to determine if value contains matchValue.

o If so, render the true oparam.

o If not, render the false oparam.

o If either input parameter is null, render the error oparam.

3. Save ContainsText.java, confirming that it was compiled without error.

Task 2: Create a ContainsText component based on your custom class

4. Create a new globally scoped component called /sandbox/ContainsText based on the sandbox.ContainsText class. Note that there are no properties to configure for this component.

Task 3: Use the custom ContainsText Dynamo Servlet Bean in a JSP

5. Edit index.jsp. Locate the output oparam of the ForEach servlet bean, which you implemented in the previous practice. This is where you displayed each event item.

6. Use the ContainsText servlet bean to prepend the text “DISCOUNT EVENT:” to any event that contains the word “Sale” (the true oparam). In this usage, there is no need to render anything for the false or error conditions.

Note that, in this case, to work around the limitation of nested tag attributes, you need to use the <dsp:getvalueof> tag to assign the value you want to a local Java variable name, and then use a JSP Expression tag to access the value. Here is the JSP fragment if you need help:

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 5: Dynamo Servlet Beans

Chapter 5 - Page 8

7. Save your changes.

8. Add a sale event to the properties files for the StoreEvents component.

9. Run the deploy Ant task.

10. Reload the Sandbox home page and verify that your custom servlet bean renders the conditional text.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6: Repository Architecture

Chapter 6 - Page 1

Practices for Lesson 6: Repository Architecture

Chapter 6

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6: Repository Architecture

Chapter 6 - Page 2

Practices for Lesson 6: Overview

Practices Overview In this practice, you will display repository data on Java Server Pages by using standard repository servlet beans.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6: Repository Architecture

Chapter 6 - Page 3

Catching Up

Dependencies You should have successfully completed the following practice:

Lesson 1: Oracle Commerce Application Structure and Deployment

• Practice 1-1: Creating and Deploying an Application Module

It is essential that you have a working Sandbox Java EE web application in place and that you are comfortable working in Eclipse to complete the remaining practices.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6: Repository Architecture

Chapter 6 - Page 4

Practice 6-1: Working with Repositories

Overview In this practice, you will display repository data on Java Server Pages by using standard repository servlet beans.

Problem Statement In this practice, you work with the Profile Adapter Repository, one of the fundamental baseline repositories provided out of the box with the Oracle Commerce platform. The Profile Adapter Repository models and maintains profile information for registered site users. You will learn much more about profiles and user account management in a later lesson, but the Profile Adapter Repository is an excellent example that can be used to demonstrate the concepts and capabilities discussed in this lesson. The Profile Adapter Repository is included as part of the DPS layer and comes populated with sample users in the installation configuration set up in your practice environment.

Use the RQLQueryForEach servlet bean to retrieve and display a list of all user items from the Profile Adapter Repository (/atg/userprofiling/ProfileAdapterRepository), ordered by last name. Display each item as a link to a single User Details page, passing in the (profile) item ID as a parameter. Create and configure an ItemLookupDroplet component for the user item type, and use your ItemLookupDroplet on the User Details page to display properties of the user identified by the input parameter.

The table below provides a convenient summary of the item descriptors and properties of the Profile Adapter Repository that are relevant for this practice. The user profile is much more complex and manages many more properties than those listed in the table. You will not, however, need to display the full set of user properties on your User Details page, but rather a sample of the properties will suffice to demonstrate the concepts. This table provides the names and types for properties that you will consider in this practice.

Item Descriptor: user

Property Display Name Type

id Id String

firstName First name String

lastName Last name String

email Email address String

gender Gender String (female, male)

dateOfBirth Date of Birth java.util.Date

homeAddress Home address contactInfo (see below)

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6: Repository Architecture

Chapter 6 - Page 5

Item Descriptor: contactInfo

Property Display Name Type

id Id String

postalCode Postal code String

country Country String

Guided Instructions

Task 1: Explore the Profile Adapter Repository 1. Start the ACC if it is not currently running.

2. In the ACC, select People and Organizations > Profile Repository to view the Profile Adapter Repository. (Note that, by design, repositories are primarily accessed from the Content menu in the ACC; the profile repository is an exception.) Spend a few minutes becoming familiar with the user and contactInfo item types by performing the following tasks:

• List items of type User.

• Select a user and examine the properties.

• List items of type Contact Information.

• Select an item and examine its properties.

• Use the query icon to perform a complex query on the repository. Example: items of type user whose home address : postal code starts

with 9

• Clear the query by clicking whose and selecting any item.

3. In the Administration UI Component Browser, locate the /atg/userprofiling/ProfileAdapterRepository component and examine the user and contactInfo item descriptors. List items of each type and examine the output. Note the difference between the property names (used in code) and their display values (used in tools such as the ACC and the Administration UI).

The ACC and the Administration UI are both valuable tools for working with and debugging repositories. Each has its benefits, and you are encouraged to become comfortable with both.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6: Repository Architecture

Chapter 6 - Page 6

Task 2: Display a dynamic list of registered users 4. Edit index.jsp and add a lesson subheader for this lesson (Lesson 6: Repository

Architecture).

5. Insert an RQLQueryForEach droplet (/atg/dynamo/droplet/RQLQueryForEach) with the following configuration and functionality:

• Set the repository input parameter to “/atg/userprofiling/ProfileAdapterRepository”. Because this is a static value, you need to use the value= syntax.

• Set the itemDescriptor input parameter to “user”.

• Set the queryRQL input parameter to “ALL ORDER BY lastName”.

• For the outputStart oparam, display “List of registered users:” and start an unordered list (<ul>).

• For the outputEnd oparam, end the unordered list (</ul>).

• For the empty oparam, display “No users currently registered.”

• For the output oparam, display the last name and first name (comma separated) of the user held by the element output parameter.

6. Save your changes.

7. Run the update_files Ant task.

8. Reload the Sandbox home page and verify that the list of users is displayed.

9. Edit index.jsp and link the usernames to a JSP called userDetail.jsp. You will create this JSP in just a moment. Provide a page parameter called itemId and set it to the id of the user.

Hint: Use the <dsp:a> tag to implement the link.

10. Save your changes, run the update_files Ant task, reload the home page, and verify that the usernames are now links.

Task 3: Create a repository-based user details page 11. Create a /sandbox/UserLookupDroplet component and configure it as follows:

Property Value

$class atg.repository.servlet.ItemLookupDroplet

repository /atg/userprofiling/ProfileAdapterRepository

itemDescriptor user

12. Create a userDetail.jsp file in the /j2ee-apps/sandbox-j2ee/sandbox-web.war folder. Declare the DSP tag library and add the closing and ending page tags.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6: Repository Architecture

Chapter 6 - Page 7

13. Insert a UserLookupDroplet droplet (/sandbox/UserLookupDroplet) with the following configuration and functionality:

• Set the id input parameter to the input user Id (that is, the itemId parameter).

• For the empty oparam, display a message indicating that the user was not found.

• For the output oparam, display a header displaying the user’s first and last names (for example, “Profile information for John Doe”), followed by the user details listed in the Item Descriptor definition tables above (email, gender, date of birth, postal code, country). Precede each with a label (the name of the property). For the date of birth property, try using a tag converter to display the date in MMMMMMMM dd, yyyy format.

14. Add a link back to the home page at the bottom of the page.

15. Save your changes.

16. Run the update_files Ant task.

17. Reload the Sandbox home page and click a user.

18. Verify that the User Details page is loaded and that the user details are correctly displayed.

19. Click the link at the bottom of the page to return to the home page.

20. Remember to close the ACC when you are done with your work.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6: Repository Architecture

Chapter 6 - Page 8

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7: SQL Repository Configuration Basics

Chapter 7 - Page 1

Practices for Lesson 7: SQL Repository Configuration Basics

Chapter 7

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7: SQL Repository Configuration Basics

Chapter 7 - Page 2

Practices for Lesson 7: Overview

Practices Overview In this practice, you will create and configure a SQL repository, including writing and testing the repository definition file, creating the repository component, and registering the repository for access in the ACC.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7: SQL Repository Configuration Basics

Chapter 7 - Page 3

Catching Up

Dependencies You should have successfully completed the following practice:

Lesson 1: Oracle Commerce Application Structure and Deployment

• Practice 1-1: Creating and Deploying an Application Module

It is essential that you have a working Sandbox Java EE web application in place and that you are comfortable working in Eclipse to complete the remaining practices.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7: SQL Repository Configuration Basics

Chapter 7 - Page 4

Practice 7-1: Configuring SQL Repositories

Overview In this practice, you will create and configure a SQL repository, including writing and testing the repository definition file, creating the repository component, and registering the repository for access in the ACC.

Problem Statement In this practice, you create a Trunk Show Repository that contains information about special retail events sponsored or hosted by an online store. A trunk show is a special one-off event in which vendors present merchandise directly to customers for preview and/or purchase before it is made generally available to the public. Typically, clients view the merchandise, place orders, and then wait for the vendor to manufacture and deliver the goods. If the merchandise has a designer, the vendor may choose to have the designer present at the event to enhance the customers’ experience. Prototypes, samples, remnants, and leftover items from runway shows are also sometimes offered at trunk shows. Trunk shows may be open to the general public or may be confined to special customers or those on an invitation list.

Our simplified representation of trunk shows will initially support only online events and will require two item types: events (the trunk show details) and designers (individuals whose designs or products are featured in the trunk show). There is a many-to-many relationship defined between events and designers. Each event may feature the works of multiple designers, represented via a single property (event.designers), while designers can be associated with multiple events (designer.events).

The type property of the event item type identifies whether the event is hosted online, in a brick-and-mortar store, or at some specialized location. Although only online events are considered in this iteration, your definition should allow for specification of any of these three types. You will consider in-store events in the next lesson.

id name startDate endDate type designers

event

id firstName lastName events

designer

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7: SQL Repository Configuration Basics

Chapter 7 - Page 5

For this practice, create the SQL repository definition for the Trunk Show Repository. The definition file will include item descriptors for the event and designer item types described above. The SQL database tables associated with these types have already been created in the Oracle database in your environment. These tables are currently empty. You will populate them with repository-item data as part of this practice.

After creating the repository definition file, create a Trunk Show Repository component, test your work by using the startSQLRepository tool, and register the repository with the ACC. Use the pre-configured support files to populate the repository with data and verify that the repositories work with supplied site pages.

Several starter and support files are available to you in <coursedir>/src/lesson07. The starter files provide templates or frameworks that you will need to edit to complete this practice. The support files are provided to assist you in populating the database and testing your work (and as such, do not require editing). The following table provides descriptions of these files:

Starter files

TrunkShowRepository.xml Trunk Show Repository definition file template

TrunkShowRepository.properties Trunk Show Repository component configuration file template

Support files

TrunkShow-Data.xml Predefined event and designer items in repository <add-item> XML format; to be used with startSQLRepository to populate the Trunk Show Repository

index-SHOWS.jsp JSP fragment to be inserted into index.jsp to verify the work completed in this practice; displays a list of trunk show events

TrunkShowLookupDroplet.properties Trunk Show Repository Item Lookup droplet component configuration file; used in trunkShowDetail.jsp

trunkShowDetail.jsp JSP that displays the details for the trunk show event identified by the input parameter

TestSandbox module Module stub for running startSQLRepository; bypasses WebLogic by transforming Sandbox into an ATG-managed, rather than application-server-managed, data source

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7: SQL Repository Configuration Basics

Chapter 7 - Page 6

The SQL definitions of the Trunk Show tables: CREATE TABLE trunkshow_designer (

id VARCHAR2(32) not null,

first_name VARCHAR2(32) null,

last_name VARCHAR2(32) null,

primary key(id)

);

CREATE TABLE trunkshow_event (

id VARCHAR2(32) not null,

name VARCHAR2(100) null,

description LONG VARCHAR null,

event_type VARCHAR2(32) null,

url VARCHAR2(100) null,

image VARCHAR2(100) null,

start_date DATE null,

end_date DATE null,

primary key(id)

);

CREATE TABLE trunkshow_event_designers (

event_id VARCHAR2(32) not null

references trunkshow_event(id),

designer_id VARCHAR2(32) not null,

primary key(event_id, designer_id)

);

Guided Instructions

Task 1: Copy starter and support files into the Sandbox project 1. Copy all of the .properties and .xml files located in <coursedir>/src/lesson07

(four files) to <atgdir>/Sandbox/config/sandbox.

2. Copy all of the .jsp files located in <coursedir>/src/lesson07 (two files) to <atgdir>/Sandbox/j2ee-apps/sandbox-j2ee/sandbox-web.war.

Note that, in Eclipse, you may have to right-click a folder and select Refresh to see any folders manually copied into the project hierarchy. You can also use the Eclipse import feature to copy files.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7: SQL Repository Configuration Basics

Chapter 7 - Page 7

Task 2: Define the Trunk Show Repository item types 3. Edit config/sandbox/TrunkShowRepository.xml. Note that the repository definition

has been started for you, including the full definition for the designer item descriptor. You will need to complete the definition for the event item descriptor. The following tables provide a summary of the item descriptor properties that are relevant for this lesson, along with their table mappings.

Item Descriptor: designer

display property: lastName

Property Type Table Table Column

id string trunkshow_designer id

firstName string trunkshow_designer first_name

lastName string trunkshow_designer last_name

events set of event

trunkshow_event_designers event_id

Item Descriptor: event

display property: name

(default item descriptor for the Trunk Show Repository)

Property Type Table Table Column

id string trunkshow_event id

name string trunkshow_event name

startDate timestamp trunkshow_event start_date

endDate timestamp trunkshow_event end_date

type enumerated (online, special,

in-store)

trunkshow_event event_type

designers set of designer

trunkshow_event_designers designer_id

Some helpful reminders and guidelines:

• The type attribute of the table tag for tables with a simple single-value primary key should be set to primary.

• You do not have to specify a column-name attribute in a property tag if the column name is the same as the property name.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7: SQL Repository Configuration Basics

Chapter 7 - Page 8

• For the type enumerated property of the event item, include the <attribute name="useCodeForValue" value="false"/> tag and use <option value="…" code="…"/> tags to define the possible values.

• The designers property of the event item descriptor represents one side of a many-to-many relationship. It requires its own table tag (for the trunkshow_events_designers table) and its type is multi. Be sure to use the component-item-type attribute to define the type.

Task 3: Create the Trunk Show Repository component 4. Edit the TrunkShowRepository.properties starter file that you copied into your

module earlier in this lesson. Examine the properties that have already been set, so you understand how the repository component is configured.

5. Complete the properties configuration by setting definitionFiles to the repository definition file you just created (/sandbox/TrunkShowRepository.xml) and repositoryName to TrunkShowRepository.

6. Save your changes.

Task 4: Test your work using startSQLRepository

7. You can check your work by using the startSQLRepository tool with the provided TestSandbox module. The TestSandbox module is very simple; its MANIFEST.MF file sets a dependency on Sandbox, and its config folder overrides the JTDataSource component used by Sandbox repositories. It continues to refer to the same database you have been using all along. The override transforms it into an ATG-managed, rather than application-server-managed, data source.

Open a terminal window, change directory to <atgdir>/home, and enter the following (all on one line):

bin/startSQLRepository –m TestSandbox –repository

/sandbox/TrunkShowRepository

Resolve any errors or warnings before proceeding.

Task 5: Register the repository with the ACC 8. To manage the Trunk Show Repository via the ACC and have it started automatically

whenever the server starts up, you need to add it to the list of repositories managed by the /atg/registry/ContentRepositories component. Create a configuration layer for this component in the Sandbox configuration folder (Sandbox/config/). Add the new repository to the initialRepositories property by including a single line in the .properties file:

initialRepositories+=/sandbox/TrunkShowRepository

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7: SQL Repository Configuration Basics

Chapter 7 - Page 9

9. Run the deploy Ant task.

10. Start the ACC.

11. Verify that the Trunk Show Repository is accessible from the Content menu.

12. Use the ACC to add a few sample designer and event items. Select Content >

TrunkShowRepository, and then click the New Item button. You do not need to add more than one or two items because this is just to demonstrate the ACC capability. You will import additional items in the next task.

Task 6: Import predefined items into the Trunk Show Repository To save you some time, several predefined designer and event items are provided for you in repository <add-item> XML format. All you have to do to import the predefined items is run startSQLRepository.

13. From a terminal window, change directory to <atgdir>/home, and enter the following command (all on one line):

bin/startSQLRepository -m TestSandbox -import

../Sandbox/config/sandbox/TrunkShow-Data.xml –repository

/sandbox/TrunkShowRepository

14. Use the ACC to list designer and event items. Verify that the predefined items have been added to the repository

Task 7: Use predefined Trunk Show detail pages to verify your work 15. Open the index-SHOWS.jsp file. This contains a JSP fragment that you can copy into

index.jsp to verify the work completed in this practice. It provides a droplet that displays a list of trunk show events. This will save you the effort of writing the page code to query the repository, a skill that you already demonstrated in a previous lesson.

16. Open index.jsp and add a lesson subheader for this lesson (Lesson 7: SQL Repository Configuration Basics). Insert the text from index-SHOWS.jsp below the lesson header.

Note that the fragment you just added references the trunkShowDetail.jsp page that you copied into your module earlier in this lesson. Again, this JSP has been provided to save you the effort of writing the details page code. It uses a pre-created TrunkShowLookupDroplet component to find a trunk show in the repository. If your repository is configured correctly, this fragment and page should work for you.

17. Save your changes.

18. Run the update_files Ant task.

19. Load the Sandbox home page and verify that the Lesson 7 section is displayed and that it contains a list of trunk shows from the repository.

20. Select a trunk show and verify that the details page is displayed and includes the show data pulled from the repository.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7: SQL Repository Configuration Basics

Chapter 7 - Page 10

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8: Additional SQL Repository Data Models

Chapter 8 - Page 1

Practices for Lesson 8: Additional SQL Repository Data Models

Chapter 8

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8: Additional SQL Repository Data Models

Chapter 8 - Page 2

Practices for Lesson 8: Overview

Practices Overview In this practice, you will create a subtype of an item descriptor, create items of that subtype, and optionally display the unique subtype properties on a page.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8: Additional SQL Repository Data Models

Chapter 8 - Page 3

Catching Up

Dependencies You should have successfully completed the following practice:

Lesson 1: Oracle Commerce Application Structure and Deployment

• Practice 1-1: Creating and Deploying an Application Module

It is essential that you have a working Sandbox Java EE web application in place and that you are comfortable working in Eclipse to complete the remaining practices.

In addition, the work described in the following practice must be completed before continuing:

Lesson 7: SQL Repository Configuration Basics

• Practice 7-1: Configuring SQL Repositories

Be sure to complete the above practice before proceeding. If you need to quickly catch up, you can copy the provided source and solution files (in <coursedir>/src/lesson07/ and <coursedir>/solutions/lesson07/) to the locations outlined in the guided instructions. Note, however, that you may be copying over some of your own previous work, Therefore, ensure that you create backups of any files that contain code or data that you may want to reference later.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8: Additional SQL Repository Data Models

Chapter 8 - Page 4

Practice 8-1: Creating Item Subtypes

Overview In this practice, you will create a subtype of an item descriptor, create items of that subtype, and optionally display the unique subtype properties on a page.

Problem Statement In this practice, you will use item descriptor inheritance to implement in-store trunk shows as a subtype of standard (online) trunk show events. The in-store events will require an additional property that identifies the venue (store) where the show is being held. For greater flexibility and reusability, you will implement the venue information as a unique Trunk Show Repository item type defined by its own item descriptor.

Extend the Trunk Show Repository definition by adding a venue item type that contains the store name and the city where the store is located.

Create a subtype of the event item descriptor called inStoreEvent, adding a property of type venue (your new item descriptor). Each in-store event can be associated with one and only one venue.

There are two steps for implementing a subtype. First, modify the base item type to define a subtype property (in this case, the event item). Then, define the subtype item with its additional properties (inStoreEvent).

Modify the Trunk Show Details page to display the venue name and location if trunk show is an in-store event.

The additional SQL database tables required to implement the venue item type and the in-store event subtype have already been created in the Oracle database in your environment. The SQL table definitions are the following:

id name startDate endDate type venue designers

id name city

venue inStoreEvent

id firstName lastName events

designer

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8: Additional SQL Repository Data Models

Chapter 8 - Page 5

CREATE TABLE trunkshow_venue (

id VARCHAR2(32) not null,

name VARCHAR2(100) null,

description LONG VARCHAR null,

street1 VARCHAR2(100) null,

street2 VARCHAR2(100) null,

state VARCHAR2(32) null,

city VARCHAR2(50) null,

zip VARCHAR2(10) null,

phone VARCHAR2(20 null,

image VARCHAR2(100) null,

url VARCHAR2(100) null,

primary key(id)

);

CREATE TABLE trunkshow_event_venue (

event_id VARCHAR2(32) not null

references trunkshow_event(id),

venue_id VARCHAR2(32) null,

primary key(event_id)

);

Guided Instructions

Task 1: Define the Trunk Show Repository venue item type

1. Edit config/sandbox/TrunkShowRepository.xml and add the definition for the venue item descriptor. The table below provides a summary of the item descriptor properties and their table mappings.

Item Descriptor: venue

display property: name

Property Type Table Table Column

id string trunkshow_venue id

name string trunkshow_venue name

city string trunkshow_venue city

Task 2: Implement an inStoreEvent subtype for event

2. Edit config/sandbox/TrunkShowRepository.xml and add the sub-type-property attribute to the item-descriptor tag for the event item, setting it to the type property.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8: Additional SQL Repository Data Models

Chapter 8 - Page 6

3. Create an item descriptor for the inStoreEvent subtype. The following table provides a summary of the subtype’s unique property and its table mapping.

Item Descriptor: event-fundraiser

Property Type Table Table Column

venue set of venue

trunkshow_event_venue venue_id

Some helpful reminders and guidelines:

• Set the item descriptor super-type to event and the sub-type-value to in-store.

• The table type is auxiliary and the id-column-name is event-id.

4. Save your work.

Task 3: Test your work using startSQLRepository

5. From a terminal window, change directory to <atgdir>/home, and enter the following (all on one line):

bin/startSQLRepository –m TestSandbox –repository

/sandbox/TrunkShowRepository

Resolve any errors or warnings before proceeding.

Task 4: Import predefined venue items into the Trunk Show Repository

6. To save you some time, several predefined venue items are provided for you in repository <add-item> XML format. Copy the <coursedir>/src/lesson08/TrunkShow-VenueData.xml file to <atgdir>/Sandbox/config/sandbox. (Note that it is not essential that this file reside in the Sandbox module, but it is recommended that you copy the file to this location to keep all your files in the same place.)

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8: Additional SQL Repository Data Models

Chapter 8 - Page 7

7. Run the following from a terminal window (all on one line):

bin/startSQLRepository -m TestSandbox -import

../Sandbox/config/sandbox/TrunkShow-VenueData.xml –repository

/sandbox/TrunkShowRepository

Task 5: Create an in-store event using the ACC 8. Shut down the ACC, run the deploy Ant task, and restart the ACC.

9. In the Trunk Show Repository, create an event item, selecting inStoreEvent as the item type. Verify that the venue property is included. Add a venue from the list of imported venue items.

10. Save your work.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8: Additional SQL Repository Data Models

Chapter 8 - Page 8

Task 6: Update trunkShowDetails.jsp to display venue data for in-store events

11. Edit trunkShowDetails.jsp and use the Switch servlet bean to display a line that lists the venue name and city if the event is an in-store trunk show. The input to the Switch droplet should be the event’s type property. The oparams of the Switch servlet bean must match possible values for the switch input; in this case, a single oparam called in-store.

12. Save your work.

13. Run the update_files Ant task.

14. Navigate to the Trunk Show Detail page for the in-store event you added, and verify that the venue name and city are displayed.

15. Choose a non-in-store event and verify that venue name and city are not displayed.

16. Close the ACC when you are done verifying your work.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9: Repository Form Handlers

Chapter 9 - Page 1

Practices for Lesson 9: Repository Form Handlers

Chapter 9

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9: Repository Form Handlers

Chapter 9 - Page 2

Practices for Lesson 9: Overview

Practices Overview In this practice, you will use the Repository Form Handler to add, modify, and delete repository items.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9: Repository Form Handlers

Chapter 9 - Page 3

Catching Up

Dependencies You should have successfully completed the following practice:

Lesson 1: Oracle Commerce Application Structure and Deployment

• Practice 1-1: Creating and Deploying an Application Module

It is essential that you have a working Sandbox Java EE web application in place and that you are comfortable working in Eclipse to complete the remaining practices.

In addition, the following practice must be completed before continuing:

Lesson 7: SQL Repository Configuration Basics

• Practice 7-1: Configuring SQL Repositories

If you need to quickly catch up, you can copy the provided source and solution files (in <coursedir>/src/lesson07/> and <coursedir>/solutions/lesson07/, respectively) to the locations outlined in the guided instructions. Note, however, that you may be copying over some of your own previous work. Therefore, ensure that you make backups of any files that contain code or data that you may want to reference later.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9: Repository Form Handlers

Chapter 9 - Page 4

Practice 9-1: Using Repository Form Handlers

Overview In this practice, you will use the Repository Form Handler to add, modify, and delete repository items.

Problem Statement Create a request-scoped Repository Form Handler component that will be used to add events to the Trunk Show Repository (/sandbox/TrunkShowRepository). This form handler will also be used to modify and delete events.

Create a New Event page that uses the form handler to support entry of a new event item. You need to include only the properties (name, start date, end date, type, and designers) associated with online event types, as described in a previous lesson. Add a link to this page from the Sandbox home page.

Create an Edit Event page to support modification of event data. Add a link to this page from the Event Details page (supplied to you in a previous lesson). Include a delete option on the Edit Event page to remove the event item from the repository.

Guided Instructions

Task 1: Create a TrunkShowRepository form handler component

1. Create a request scoped form handler component called TrunkShowFormHandler based on the atg.repository.servlet.RepositoryFormHandler component class and configure it as follows:

Property Value

$class atg.repository.servlet.RepositoryFormHandler

$scope request

repository /sandbox/TrunkShowRepository

itemDescriptorName event

requireIdOnCreate false

clearValueOnSet false

Task 2: Create a page to add a new event item

2. Create a newEvent.jsp file in the /j2ee-apps/sandbox-j2ee/sandbox-web.war folder. Declare the DSP tag library and add the opening and closing page tags.

3. Import the /sandbox/TrunkShowFormHandler component at the top of the page for easier reference.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9: Repository Form Handlers

Chapter 9 - Page 5

4. Insert a form (<dsp:form … >) to support the entry of a new event item. Use the following configuration and functionality guidelines:

• Set the action of the form to this JSP (newEvent.jsp).

• The form should support entry of the following event properties: name, startDate, endDate, type.

• Remember to connect each form input field to the associated property by using the TrunkShowFormHandler.value.myProperty syntax.

• Make the following properties required: name, startDate, endDate.

• Use a tag converter for entry of startDate and endDate (such as date=“M/dd/yyyy”).

• Use the <dsp:select> tag for entry of type, allowing options of online, special, and in-store.

• Link a submit button (<dsp:input type=“submit” …/>) to the appropriate submission handler method (TrunkShowFormHandler.create).

• Add a hidden input field to set the TrunkShowFormHandler.createSuccessURL property to index.jsp.

Optional:

• Add fields to support entry of the designers property. To do this, insert an RQLQueryForEach droplet that iterates through all of the designer items in the Trunk Show Repository. For each item, add a form input field of type checkbox that connects the designer item to the designers property of the event. Display the designer firstName and lastName as the check box option.

In the input tag, you will need to connect the designer id property (repository id) to the event item using the designers.RepositoryIds syntax:

<dsp:input bean="TrunkShowFormHandler.value.designers.RepositoryIds" type="checkbox" paramvalue="element.id"/>

5. At the beginning of the form (inside the <dsp:form> tag), handle errors by looping through the form handler’s exceptions by using the ErrorMessageForEach servlet bean. For each error, display the message output parameter.

6. Edit index.jsp and add a lesson subheader for this lesson (Lesson 9: Repository Form Handlers). Add a link to newEvent.jsp.

7. Save all your changes.

8. Run the update_files Ant task.

9. Reload the Sandbox home page, and click the New Event link.

10. Verify that the New Event form is displayed.

11. Attempt to add a new event but leave a few of the mandatory fields blank.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9: Repository Form Handlers

Chapter 9 - Page 6

12. Verify that the form is redisplayed with a list of error messages at the top of the page.

13. Fix the errors and resubmit a correctly completed form.

14. Verify that the Sandbox home page is displayed and that your new event is displayed in the list of events under the Lesson 7 heading.

Task 3: Create a page to edit or delete an event item

15. Create an editEvent.jsp file in the /j2ee-apps/sandbox-j2ee/sandbox-web.war folder. Declare the DSP tag library and add the opening and closing page tags.

16. Again, import the /sandbox/TrunkShowFormHandler component at the top of the page for easier reference.

Important Note: You may want to copy the content of your newEvent.jsp file to editEvent.jsp and use it as the starting point for the work in this task. The pattern is very much the same, and you can save a lot of typing by copying your earlier work as a template.

17. The event to be updated will be defined by an input parameter called eventId. For the TrunkShowFormHandler to know which event is to be modified, the repositoryId property of the form handler needs to be set. Just before the form described below, add a <dsp:setvalue> tag to set the repositoryId property of the form handler to the eventId parameter passed in from the calling page.

18. Insert a form (<dsp:form … >) to support the update of an event item. Use the following configuration and functionality guidelines:

• Set the action of the form to this JSP (editEvent.jsp).

• Include the same error processing implemented for newEvent.jsp.

• Like in the previous step, make sure to use the eventId input parameter to set the repositoryId property of the form handler via a hidden input field within the form. You must give this field the name eventId for the form error handling to work when the page is redisplayed.

• To save time, the form can update just a few properties (enough to illustrate the concept). Allow editing of the following three properties: name, startDate, and endDate.

• Again, remember to connect each form input field to the associated property using the TrunkShowFormHandler.value.myProperty syntax.

• Again, make the following properties required: name, startDate, and endDate.

• Link a Submit button (<dsp:input type=”submit” …/>) to the appropriate submission handler method for item update (TrunkShowFormHandler.update).

• Add a hidden input field to set the TrunkShowFormHandler.updateSuccessURL property to trunkShowDetail.jsp. Use the <dsp:getvalueof id="aId" param="eventId" > with <dsp: <%="trunkShowDetail.jsp?itemId=" + aId%> method to pass the page parameter to the updateSuccessURL page.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9: Repository Form Handlers

Chapter 9 - Page 7

• Link a Submit button (<dsp:input type=”submit” …/>) to the appropriate submission handler method for item deletion (TrunkShowFormHandler.delete).

• Add a hidden input field to set the TrunkShowFormHandler.deleteSuccessURL property to index.jsp.

19. Edit trunkShowDetail.jsp and add link to editEvent.jsp, passing in the eventId page parameter set to the current event Id (element.id).

20. Save all your changes.

21. Run the update_files Ant task.

22. Reload the Sandbox home page, click a trunk show event from the event list, and then click the edit event details link.

23. Verify that the Edit Event form is displayed.

24. Attempt to edit the event data but leave a mandatory field blank.

25. Verify that the form is redisplayed with a list of error messages at the top of the page.

26. Fix the errors and resubmit a correctly completed form.

27. Verify that the Event Details page is displayed and that the event details reflect your changes.

28. Click the edit event details link again.

29. Delete the event.

30. Verify that the Sandbox home page is displayed and that the event has been deleted.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9: Repository Form Handlers

Chapter 9 - Page 8

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 10: Repository API

Chapter 10 - Page 1

Practices for Lesson 10: Repository API

Chapter 10

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 10: Repository API

Chapter 10 - Page 2

Practices for Lesson 10: Overview

Practices Overview In this practice, you will use the Repository programming interface to programmatically manipulate repository data within Java code.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 10: Repository API

Chapter 10 - Page 3

Catching Up

Dependencies You should have successfully completed the following practice:

Lesson 1: Oracle Commerce Application Structure and Deployment

• Practice 1-1: Creating and Deploying an Application Module

It is essential that you have a working Sandbox Java EE web application in place and that you are comfortable working in Eclipse to complete the remaining practices.

In addition, the following practices must be completed before continuing:

Lesson 3: Custom Components

• Practice 3-1: Creating a Custom Component Class

Lesson 7: SQL Repository Configuration Basics

• Practice 7-1: Configuring SQL Repositories

Lesson 8: Additional SQL Repository Data Models

• Practice 8-1: Creating Item Subtypes

If you need to quickly catch up, you can copy the provided source and solution files (in <coursedir>/solutions/lesson03/, <coursedir>/src/lesson07/, <coursedir>/solutions/lesson07/, and <coursedir>/solutions/lesson08/) to the locations outlined in the guided instructions. Note, however, that you may be copying over some of your own previous work. Therefore, ensure that you make backups of any files that contain code or data that you may want to reference later.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 10: Repository API

Chapter 10 - Page 4

Practice 10-1: Using the Repository API

Overview In this practice, you will use the Repository programming interface to programmatically manipulate repository data within Java code.

Problem Statement Extend the Store Events component that you wrote in an earlier lesson to support management of Trunk Show data by adding a repository property (getter and setter methods) to the EventsManager component class and updating the StoreEvents component properties file to configure the property. Add a method to the class that queries for and deletes all of the Trunk Show in-store events (inStoreEvent items) associated with the venue whose repository ID is specified in an input to the method. This custom method could be used to implement the deletion of a venue and all of its associated events in a single custom form entry (covered in a later lesson), depending upon the specific requirements of the application. In a real-world solution, you would more likely have a requirement to include some status property for the event that you would set to “canceled” (or some such value) if a venue becomes inactive or unavailable. However, for instructional purposes, this practice calls for the deletion of the associated events to give you some practice with the Repository API. To test your work, a support page called EventsManagerTest.jsp has been provided for your use in <coursedir>/src/lesson10. This file is described in the following table:

Support file

EventsManagerTest.jsp Test page that accepts a venueId input parameter and attempts to delete all in-store events associated with the venue via a call to the deleteEventsAtVenue method of a component (sandbox/EventsManager) based on the EventsManager component class. The results of the attempt are rendered to the page.

Guided Instructions

Task 1: Add a repository property to the Store Events component

1. Edit EventsManager.java and import atg.repository.*.

2. Add a private member variable and a getter and setter (methods) for the following property:

Property Type

repository Repository

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 10: Repository API

Chapter 10 - Page 5

3. Save your work. Resolve any compilation errors.

4. Edit StoreEvents.properties and add the following property value configuration:

Property Value

repository /sandbox/TrunkShowRepository

5. Save your work.

Task 2: Implement a “Delete Events at Venue” method 6. Edit EventsManager.java and import atg.repository.rql.*.

7. Add a deleteEventsAtVenue (String pVenueId) method that uses the Repository API to find and delete all in-store events (inStoreEvent repository items) that are associated with the venue whose venue ID is specified by the given String input parameter. Your code should use an RQL query to retrieve all in-store events at that venue (that is, all in-store events whose venue’s id property matches the ID passed in to the method), and then loop through and delete each venue. Include logging debug messages, printing the ID of each deleted event, so you can verify the activity via the logging output window. However, you should ensure that you avoid referencing an event object pointer after it has been deleted.

Remember that in addition to the course slides, you can use the Oracle Commerce API Reference for help.

8. Save your work. Resolve any compilation errors.

Task 3: Test your repository deletion method 9. Copy the EventsManagerTest.jsp file from <coursedir>/src/lesson10 to

<atgdir>/Sandbox/j2ee-apps/sandbox-j2ee/sandbox-web.war.

10. Edit index.jsp and add a lesson subheader for this lesson (Lesson 10: Repository API). Add a link to the test page, including a venueId parameter but without including a specific value (EventsManagerTest.jsp?venueId=). This is insufficient to test your method because a venue ID will need to be supplied, but it provides an easy bookmark for your verification to follow.

11. Deploy your changes by running the deploy Ant task.

12. Navigate to the test page from the Sandbox home page and verify that a message is displayed indicating that a venue ID is required.

13. Start the ACC and create several in-store events, specifying the same venue for each. Note the repository ID of the venue.

14. Reload EventsManagerTest.jsp, this time including the venue ID in the URL (…/EventsManagerTest.jsp?venueId=xxxxxx, where xxxxxx is the repository ID of the venue).

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 10: Repository API

Chapter 10 - Page 6

15. Verify that the rendered page indicates that your venue’s in-store events have been deleted. If the deleteEventsAtVenue method has been coded correctly, all the venue’s events should be deleted from the Trunk Show Repository.

16. In the ACC, list all items of type inStoreEvent and verify that all the events at the specified venue have been deleted.

17. Examine the server logging window to verify that your debug output messages (including an entry for each individual event deletion) are displayed.

18. Close the ACC after you verify your work.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11: Derived Properties

Chapter 11 - Page 1

Practices for Lesson 11: Derived Properties

Chapter 11

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11: Derived Properties

Chapter 11 - Page 2

Practices for Lesson 11: Overview

Practices Overview In this practice, you will configure a repository definition to implement an overridable derived property.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11: Derived Properties

Chapter 11 - Page 3

Catching Up

Dependencies You should have successfully completed the following practice:

Lesson 1: Oracle Commerce Application Structure and Deployment

• Practice 1-1: Creating and Deploying an Application Module

It is essential that you have a working Sandbox Java EE web application in place and that you are comfortable working in Eclipse to complete the remaining practices.

In addition, the following practices must be completed before continuing:

Lesson 7: SQL Repository Configuration Basics

• Practice 7-1: Configuring SQL Repositories

Lesson 8: Additional SQL Repository Data Models

• Practice 8-1: Creating Item Subtypes

If you need to quickly catch up, you can copy the provided source and solution files (in <coursedir>/src/lesson07/, <coursedir>/solutions/lesson07/, and <coursedir>/solutions/lesson08/) to the locations outlined in the guided instructions. Note, however, that you may be copying over some of your own previous work. Therefore, you must ensure that you take backups of any files that contain code or data that you may want to reference later.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11: Derived Properties

Chapter 11 - Page 4

Practice 11-1: Creating an Overridable Derived Property

Overview In this practice, you will configure a repository definition to implement an overridable derived property.

Problem Statement In this practice, you will add properties to the Trunk Show Repository event and venue item definitions that identify an associated URL where information can be found for that event or venue. Although the URL for events and venues can (and should) be unique, the event URL for in-store events will be configured to derive its value from the venue URL if no specific event URL is defined. Further, the derived URL will be settable, overriding the property derivation and, in turn, setting the event URL.

The SQL database tables that support the Trunk Show Database already have columns to support the URL properties. You can find the complete definition in the activity guides for the lessons titled “Repository Configuration Basics” and “Additional SQL Repository Data Models,” but the following tables are included again here for your reference:

CREATE TABLE trunkshow_event (

id VARCHAR2(32) not null,

name VARCHAR2(100) null,

description LONG VARCHAR null,

event_type VARCHAR2(32) null,

url VARCHAR2(100) null,

image VARCHAR2(100) null,

start_date DATE null,

end_date DATE null,

primary key(id)

);

CREATE TABLE trunkshow_venue (

id VARCHAR2(32) not null,

name VARCHAR2(100) null,

description LONG VARCHAR null,

street1 VARCHAR2(100) null,

street2 VARCHAR2(100) null,

state VARCHAR2(32) null,

city VARCHAR2(50) null,

zip VARCHAR2(10) null,

phone VARCHAR2(20 null,

image VARCHAR2(100) null,

url VARCHAR2(100) null,

primary key(id)

);

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11: Derived Properties

Chapter 11 - Page 5

Guided Instructions

Task 1: Add url properties to the event and venue item descriptors

1. Edit TrunkShowRepository.xml and add url properties to the definitions for the event and venue item descriptors. The following tables provide a summary of the additional item descriptor properties and their table mappings:

Item Descriptor: event

Property Type Table Table Column

eventURL string trunkshow_event url

Item Descriptor: venue

Property Type Table Table Column

venueURL string trunkshow_venue url

2. Save your work.

Task 2: Add an overridable transient url property to inStoreEvent

3. In TrunkShowRepository.xml, add a transient url property to the inStoreEvent item descriptor. Set the property’s data type to string and the writable attribute to true.

4. Configure the property as a derivation from venue.venueURL but with an override property of the event’s eventURL.

5. Test your work using startSQLRepository.

6. Deploy your changes by running the deploy Ant task.

7. Start the ACC.

8. List items of type event and verify that the items now have an eventURL property.

9. List items of type venue and verify that the items now have a venueURL property. Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11: Derived Properties

Chapter 11 - Page 6

10. List items of type inStoreEvent (create one if none exist) and verify that the url derived property is included.

11. Select an in-store event and enter a URL for its associated venue. Verify that the url property for the in-store event is derived from the venue’s URL.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11: Derived Properties

Chapter 11 - Page 7

12. Enter a URL for the event. Verify that the url property for the in-store event is now derived from the event URL.

13. Override the url value by directly editing that field. Save your change and verify that the eventURL override property is set to your new value.

14. Close the ACC when you are done verifying your work.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11: Derived Properties

Chapter 11 - Page 8

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Versioned and Hierarchical Repositories

Chapter 12 - Page 1

Practices for Lesson 12: Versioned and Hierarchical Repositories

Chapter 12

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Versioned and Hierarchical Repositories

Chapter 12 - Page 2

Practices for Lesson 12: Overview

Practices Overview In the practice, you will consider the steps required to add version capability to a SQL repository.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Versioned and Hierarchical Repositories

Chapter 12 - Page 3

Catching Up

Dependencies You should have successfully completed the following practice:

Lesson 1: Oracle Commerce Application Structure and Deployment

• Practice 1-1: Creating and Deploying an Application Module

It is essential that you have a working Sandbox Java EE web application in place and that you are comfortable working in Eclipse to complete the remaining exercises.

In addition, the following practice must be completed before continuing:

Lesson 7: SQL Repository Configuration Basics

• Practice 7-1: Configuring SQL Repositories

If you need to quickly catch up, you can copy the provided source and solution files (in <coursedir>/src/lesson07/ and <coursedir>/solutions/lesson07/, respectively) to the locations outlined in the guided instructions. Note, however, that you may be copying over some of your own previous work. Therefore, ensure that you make backups of any files that contain code or data that you may want to reference later.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Versioned and Hierarchical Repositories

Chapter 12 - Page 4

Practice 12-1: Adding Versioning Capability to a Repository

Overview In this practice, you will consider the steps required to add versioning capability to a SQL repository.

Problem Statement The current Trunk Show Repository configuration represents an unversioned repository. For this practice, review the Trunk Show Repository and supporting SQL table definitions and consider what steps would be required to add versioning.

Note that the Sandbox application, as currently configured, is built on the minimum module configuration of DSS, DPS, and DAS. To add versioning, a dependency on Oracle Commerce Publishing (the Content Administration layer) is required. Adding this layer to Sandbox and performing the component and database extensions required to fully implement versioning are out of scope for this course. However, an understanding of the impact of versioning and the steps required to prepare a repository definition for Content Administration is an important consideration when embarking on repository design and implementation.

Guided Instructions

Task 1: Review the Trunk Show Repository definition 1. Open TrunkShowRepository.xml. Review the item descriptor definitions and think

about the changes required to add versioning to the repository. Consider the following guidelines:

• Define column-name and id-column-names attributes explicitly, even when they are identical to the property’s name.

• Set the required attribute to true for properties linked to non-nullable columns.

• Set the readable and writable attributes to true in all property tags within a table for all properties whose value is to be maintained across versions. Note that, by default, all properties are readable and writable.

• Remove special characters, such as hash (#) and slash (/) from repository id properties.

• Add a display-name-resource attribute to all item-descriptor tags.

Task 2: Review the SQL Table definitions 2. The Trunk Show SQL table definition script is available in your environment at

<coursedir>/setup/sql/PFD-TrunkShow.sql. Open this file and review the table definitions. Think about the changes required to support versioning. Consider the following guidelines:

• Remove unique indexes from all columns.

• Remove unique constraints from all columns.

• Remove foreign key references.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Versioned and Hierarchical Repositories

Chapter 12 - Page 5

• For all primary tables, add eight new columns (asset_version, workspace_id, branch_id, is_head, version_deleted, version_editable, pred_version, and checkin_date).

• Create indexes for workspace_id and checkin_date columns.

• For all auxiliary and multi tables, add one new column (asset_version).

• Change all primary keys to composite primary keys (include asset_version).

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Versioned and Hierarchical Repositories

Chapter 12 - Page 6

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13: SQL Repository Caching

Chapter 13 - Page 1

Practices for Lesson 13: SQL Repository Caching

Chapter 13

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13: SQL Repository Caching

Chapter 13 - Page 2

Practices for Lesson 13: Overview

Practices Overview In this practice, you will configure a repository so that items are preloaded upon repository startup, enable query caching on those items, and review caching statistics via the Administration UI.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13: SQL Repository Caching

Chapter 13 - Page 3

Catching Up

Dependencies You should have successfully completed the following practice:

Lesson 1: Oracle Commerce Application Structure and Deployment

• Practice 1-1: Creating and Deploying an Application Module

It is essential that you have a working Sandbox Java EE web application in place and that you are comfortable working in Eclipse to complete the remaining practices.

In addition, the following practices must be completed before continuing:

Lesson 7: SQL Repository Configuration Basics

• Practice 7-1: Configuring SQL Repositories

Lesson 8: Additional SQL Repository Data Models

• Practice 8-1: Creating Item Subtypes

If you need to quickly catch up, you can copy the provided source and solution files (in <coursedir>/src/lesson07/, <coursedir>/solutions/lesson07/, and <coursedir>/solutions/lesson08/) to the locations outlined in the guided instructions. Note, however, that you may be copying over some of your own previous work. Therefore, you must ensure that you make backups of any files that contain code or data that you may want to reference later.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13: SQL Repository Caching

Chapter 13 - Page 4

Practice 13-1: Preloading the SQL Repository Cache

Overview In this practice, you will configure a repository so that items are preloaded upon repository startup, enable query caching on those items, and review caching statistics via the Administration UI.

Problem Statement Configure the Trunk Show repository so that all items are preloaded upon startup of the repository. Preloading the cache involves querying the repository defined in a repository definition file by using XML repository operation tags. By default, query caching is disabled. Enable query caching for all items in the repository (by setting the query cache size to a number greater than 0, which is the default value). Use the Administration UI to view cache statistics and invalidate the cache.

Guided Instructions

Task 1: Preload the Trunk Show Repository cache 1. Before configuring cache preloading, view the cache statistics. From the Administration UI,

select the Component Browser, browse to the /sandbox/TrunkShowRepository component, and note the Cache usage statistics section of the page.

2. Click Reset Cache Statistics so that you will observe refreshed statistics the next time you restart the server.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13: SQL Repository Caching

Chapter 13 - Page 5

3. Edit TrunkShowRepository.xml. At the end of the file, after all the item-descriptor tags but before the closing gsa-template tag, add a query-items tag for each of the item types in the Trunk Show Repository: designer, venue, event, and inStoreEvent. The query-items tags generate a potentially large amount of output on startup. To avoid this, you can add the quiet="true" attribute to the tags. For this practice, try adding quiet="true" to the venue, event, and in-store event queries but not to the designer query (quiet="false"), so that you can become familiar with the logging output.

4. Test your work using startSQLRepository. Note the query output. Resolve any errors before continuing.

5. Deploy your changes by running the deploy Ant task.

6. Return to the TrunkShowRepository page in the Component Browser and examine the Cache usage statistics.

7. Close any open browser windows. In a new browser window, clear the cached pages. (In Firefox, go to Tools > Clear Recent History, or press Ctrl + Shift + Delete and click the Clear Now button). Browse through several trunk shows from the Sandbox home page. Reload the cache statistics page for TrunkShowRepository and note the cache hits.

Task 2: Configure query caching 8. Note that, on the Cache usage statistics page, query caching is currently disabled.

9. In TrunkShowRepository.xml, for each item-descriptor tag, add a query-cache-size="100" attribute.

10. Test your work using startSQLRepository.

11. Deploy your changes by running the deploy Ant task.

12. Browse through several trunk shows on the site, and then reload the Cache usage statistics. Note that query caches are no longer disabled, and that they show several reused queries.

Task 3: Manually invalidate the cache 13. On the TrunkShowRepository page in the Component Browser, locate the Methods

section and the invalidateCaches method. Click the method name, and then click the Invoke Method button to call it.

14. Reload the Trunk Show Repository cache usage statistics and note that the caches (total hits) are now empty.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13: SQL Repository Caching

Chapter 13 - Page 6

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14: Introduction to Core Commerce and the Product Catalog

Chapter 14 - Page 1

Practices for Lesson 14: Introduction to Core Commerce and the Product Catalog

Chapter 14

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14: Introduction to Core Commerce and the Product Catalog

Chapter 14 - Page 2

Practices for Lesson 14: Overview

Practices Overview In this practice, you will start the Commerce Reference Store server, explore the storefront, and take a close look at the Product Catalog–related repositories.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14: Introduction to Core Commerce and the Product Catalog

Chapter 14 - Page 3

Catching Up

Dependencies The practices for this lesson have no dependencies on preceding practices.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14: Introduction to Core Commerce and the Product Catalog

Chapter 14 - Page 4

Practice 14-1: Exploring the CRS Storefront and Catalog Repositories

Overview In this practice, you will start the Commerce Reference Store server, explore the storefront, and take a close look at the Product Catalog–related repositories.

Problem Statement The practices for the previous lessons of this course were completed within the context of the rudimentary Sandbox application. Starting with this lesson and moving forward, your hands-on practices will be completed in the Commerce Reference Store (CRS) environment, where you will gain insight into and experience with a simulation of a real-world implementation of Oracle Commerce capabilities. The baseline modules that support CRS have already been installed and configured in the environment. CRS has already been assembled and deployed, so you will not have to complete an initial deployment before starting CRS for this exercise. Note that you will set up Eclipse for CRS development in the next lesson.

For this practice, start the Commerce Reference Store (Production) server. Visit the CRS storefront and explore its functionality, noting in particular the catalog navigation elements and how catalog products are displayed. Start the ACC and explore the Catalog Repository, noting the different item types and their relationships to each other.

Guided Instructions

Task 1: Start the Commerce Reference Store production server 1. Make sure that the WebLogic server is running. If it is not, open the PFD Server Startup

Scripts folder on your desktop and double-click WLSAdmin.sh. When prompted, choose “Run in Terminal.”

2. If your Sandbox server is running, you can shut it down by selecting its terminal window and pressing Ctrl + C.

3. From the PFD Server Startup Scripts folder, double-click StoreProduction.sh. When prompted, choose “Run in Terminal.” This server will take longer to start. Wait for startup to complete (noting “The server started in RUNNING MODE” in the terminal logging window).

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14: Introduction to Core Commerce and the Product Catalog

Chapter 14 - Page 5

Task 2: Visit and explore the CRS Storefront 4. Visit the CRS home page at http://localhost:7103/crs.

Note that the CRS server runs on port 7103 (versus port 7303 for the Sandbox server). This is true of the CRS server Administration UI (http://localhost:7103/dyn/admin) as well.

Note also that quick links to these pages are included in the PFD URL Bookmarks folder on your desktop (Visit Store home page, Visit Store Administration UI).

5. Explore the storefront, noting the catalog navigation bar and drop-down menus of sub-categories and featured products.

6. Select a product to open the product details page. Examine the page elements.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14: Introduction to Core Commerce and the Product Catalog

Chapter 14 - Page 6

7. Note the product navigation breadcrumb trail.

8. Explore the various other pages and features of the site.

Task 3: Explore the Catalog repositories

9. Start the ACC.

10. Select Catalog Management > Catalog Elements. From this menu, you can explore the full complement of Catalog-related repository items.

11. List items of type Catalog and explore the item properties.

12. List items of type Category and explore the item properties. Select various categories and note the relationships with child products and related categories.

13. List items of type Product and explore the item properties. Select various products and note the relationships with SKUs.

14. List items of type SKU and explore the item properties. Select various SKUs and note the relationships with parent products.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14: Introduction to Core Commerce and the Product Catalog

Chapter 14 - Page 7

15. If time allows, take a quick look at the various other elements of the product Catalog repository, as well as the other repositories that support the Commerce Reference Store (Pricing, Purchases and Payments, Customer Service, and so on).

16. Close the ACC when you are done verifying your work.

17. Examine the /atg/commerce/catalog/ProductCatalog repository via the Administration UI Component Browser. As always, the Component Browser can be a useful tool for troubleshooting and managing application elements.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14: Introduction to Core Commerce and the Product Catalog

Chapter 14 - Page 8

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 15: Extending the Product Catalog

Chapter 15 - Page 1

Practices for Lesson 15: Extending the Product Catalog

Chapter 15

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 15: Extending the Product Catalog

Chapter 15 - Page 2

Practices for Lesson 15: Overview

Practices Overview In this practice, you will configure Eclipse to manage your Commerce Reference Store development work. You will then extend the catalog by adding a custom property to the product repository item definition and deploy your changes.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 15: Extending the Product Catalog

Chapter 15 - Page 3

Catching Up

Dependencies The practices for this lesson have no dependencies on preceding practices.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 15: Extending the Product Catalog

Chapter 15 - Page 4

Practice 15-1: Building and Deploying the Store

Overview In this practice, you will configure Eclipse to manage your Commerce Reference Store development work. You will then build, assemble, and deploy CRS.

Problem Statement You will complete your development work for Commerce Reference Store in a module called MyStore, which has been pre-established and configured and is provided for you with the course support files. MyStore has a very simple configuration. As specified in its manifest file, it has a dependency on all of the standard out-of-the-box modules that comprise Commerce Reference so that the entire store is included when MyStore is deployed. It includes folders for custom component configurations and for custom code, but does not include a Java EE application because CRS front-end components are implemented in the Storefront module (on which MyStore has a dependency). It also includes Ant scripts for building, assembling, and deploying your application (but no task for copying JSP files as there are no front-end components directly managed in this module).

For this practice, copy the MyStore module into the Commerce Reference Store directory structure. Import the module into Eclipse and enable the Ant build scripts. Build the module, assemble the EAR, and deploy it to your production server. Visit the store home page and the ATG Administration home page to verify your work.

The support files for this lesson are available to you in <coursedir>/src/lesson15.

Support files

MyStore (directory) Oracle Commerce module, which provides a development environment for custom Commerce Reference Store configuration and functionality; to be copied into your Oracle Commerce environment and imported into Eclipse

Note: In this and upcoming practices, you will be asked to build, assemble, and deploy customizations to Commerce Reference Store. The build tools used for CRS in these practices are the same as those you used with Sandbox. The Ant scripts for assembly and deployment are customized specifically for the MyStore module. These Ant scripts employ, respectively, the Oracle Commerce runAssembler and WebLogic deployment interface to implement the build process.

There are a variety of tools that you can use in development to manage the build and deployment process. Oracle Commerce has alternate Ant build scripts that ship with CRS that can be used to build a CRS module. Oracle Commerce Configuration and Installation Manager (CIM) has facilities for EAR assembly and the WebLogic Admin UI can be used directly to manage server deployments. For constancy and ease of adoption, these practices continue to use custom Ant scripts, which are conveniently integrated entirely within Eclipse.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 15: Extending the Product Catalog

Chapter 15 - Page 5

Unlike Sandbox, which you were able to deploy many times in succession without the need to manually shut down the server, for MyStore, you will be asked to stop the Commerce Reference Store (production) server in between deployments. Although this is not strictly necessary, and multiple redeployments should run successfully, you may encounter resource errors due to the large footprint of the CRS application. To avoid resource issues and more efficiently manage these more time-consuming CRS deployments, the instructions in this and the following practices will ask you to shut down CRS before redeploying the MyStore EAR and restarting the server.

Guided Instructions

Task 1: Import the MyStore module into Eclipse 1. Open your desktop File Browser and copy the <coursedir>/src/lesson15/MyStore

folder to the <atgdir>/CommerceReferenceStore/Store folder.

2. In Eclipse, select File > New > Project. Select Java Project from the wizard menu, and then click Next.

3. Enter the project name MyStore, deselect the “Use default location” option, and set the project location to the MyStore module folder (/oce111/ATG11.1/CommerceReferenceStore/Store/MyStore).

4. Click Finish.

5. Note that you now have two projects in Eclipse: Sandbox and MyStore. Make sure that your work for the remaining lessons is completed in MyStore. You may want to collapse the folder hierarchy for Sandbox to avoid any accidental edits.

6. Open the MyStore project and explore the directory structure, noting the preconfigured components.

7. Make sure that the Ant tab is viewable (Window > Show View > Ant).

8. On the Ant tab, click the Add Buildfiles icon .

9. Navigate to the build.xml file at the top level of the MyStore project and click OK.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 15: Extending the Product Catalog

Chapter 15 - Page 6

10. On the Ant tab, expand MyStore and you should see the deploy, ear, and undeploy tasks. (Note that there is no update_files task for MyStore.)

11. Shut down the CRS server if it is running.

12. Double-click the deploy task.

As with Sandbox, this will actually run three of the Ant tasks. It will first run the undeploy task that will remove MyStore from the ATG server (if it has previously been deployed), then it will run the ear task, which will assemble all the files and libraries needed to create the EAR file that can be deployed to the server. Lastly, it will run the deploy task and deploy the EAR file to the server. You can see its progress on the Console tab in Eclipse.

13. When deployment is complete, restart the CRS server.

Task 2: Test your work 14. Visit the Commerce Reference Store home page and verify that the store is active.

15. The component settings needed to register MyStore with the ACC have been pre-configured in the MyStore module. You can use this configuration to verify that MyStore was correctly deployed. Use the Administration UI Component Browser to browse to the atg/modules/ModuleManager component and view the modules property. Verify that MyStore is included in the list of modules.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 15: Extending the Product Catalog

Chapter 15 - Page 7

Practice 15-2: Extending the Product Catalog

Overview In this practice, you will extend the catalog by adding a custom property to the product repository item definition.

Problem Statement In reference to the earlier work you have done in creating a Trunk Show Repository in the Sandbox application, extend the product catalog product item definition to include an enumerated property that specifies a trunk show product classification:

Classification Description

standard A product that is part of a regular mass-produced product line

one-of-a-kind A singular item (such as a hand-made artwork) that is not produced in quantity

preview An item from an upcoming product line that has not yet gone into mass production

vintage A unique singular item from a past product line that can be considered a classic of its kind

The classification should default to standard if no value is defined.

The SQL database table that is required to support this classification has already been created in the Oracle database in your environment. The SQL definition follows for your reference:

CREATE TABLE mys_product (

product_id VARCHAR2(32) not null,

trunkshow_class VARCHAR2(32) not null,

constraint mys_product primary key (product_id),

constraint mys_product_d_f foreign key (product_id) references dcs_product (product_id)

);

As with Sandbox, a MyStore stub module has been provided for you to test your repository definition file edits. Starter and support files for this lesson are described in the following table:

Starter file

customCatalog.xml Template for the catalog repository extension definition

Support files

TestMyStore module Module stub for running startSQLRepository; bypasses WebLogic by transforming MyStore into an ATG-managed, rather than application-server-managed, data source

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 15: Extending the Product Catalog

Chapter 15 - Page 8

Guided Instructions

Task 1: Extend the product repository item 1. In Eclipse, in the MyStore config folder, create an /atg/commerce/catalog/custom

folder to hold the module-specific catalog extension definition.

2. Import customCatalog.xml from <coursedir>/src/chapter15 to /atg/commerce/catalog/custom. Alternatively, you can also copy the file manually, but be sure to refresh the folder so you can see the file in Eclipse.

3. Note that the item descriptor tag for the catalog product item includes an xml-combine=”append” attribute because this is not a new item definition but an extension of the existing item descriptor.

4. Define the catalog extension based on the following product item descriptor property and table mapping detail:

Item Descriptor: product

Property Type Table Table Column

trunkShowClass enumerated mys_product trunkshow_class

Some helpful hints:

• Include a table tag in the descriptor, specifying the mys_product table. The table is of type auxiliary, and the id-column-name is product_id.

• In the property tag, include a category attribute for the custom property, classifying it under My Store Extensions, and a display-name attribute to display a readable name (Trunk Show Class) in the ACC.

• Also in the property tag, set the data-type attribute to "enumerated" and set a default value of "standard".

• Include the <attribute name="useCodeForValue" value="false"/> tag and use <option value="…" code="…"/> tags to define the possible values.

5. Save your work.

Task 2: Test your work using startSQLRepository

6. In a terminal window, change directory to <atgdir>/home, and enter the following (all on one line):

bin/startSQLRepository –m TestMyStore –repository

/atg/commerce/catalog/ProductCatalog

Resolve any errors or warnings before proceeding.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 15: Extending the Product Catalog

Chapter 15 - Page 9

Task 3: Verify your work using the ACC 7. Run the deploy Ant task.

8. Start the ACC.

9. Select Catalog Management > Catalog Elements.

10. List items of type product and select a product.

11. Verify that the Trunk Show Class property is listed under the new MyStore Extensions category, and that it is set to the default value of standard.

12. Select the property and verify that all four classification options are available values for the property.

13. Close the ACC when you are done verifying your work.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 15: Extending the Product Catalog

Chapter 15 - Page 10

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 16: The User Profile

Chapter 16 - Page 1

Practices for Lesson 16: The User Profile

Chapter 16

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 16: The User Profile

Chapter 16 - Page 2

Practices for Lesson 16: Overview

Practices Overview In this practice, you will add a property to the user profile definition. You will then update the user details page, displaying your additional profile property.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 16: The User Profile

Chapter 16 - Page 3

Catching Up

Dependencies You should have successfully completed the following practice:

Lesson 15: Extending the Product Catalog

• Practice 15-1: Building and Deploying the Store

It is essential that you have a working MyStore Java EE web application in place to complete the remaining practices.

If you started but did not complete the exercise to configure and deploy the MyStore application module, continue from where you left off and complete the practice before proceeding. The instructor can assist you if you are unable to complete the practice successfully.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 16: The User Profile

Chapter 16 - Page 4

Practice 16-1: Extending the Profile

Overview In this practice, you will add a property to the user profile definition.

Problem Statement For this practice, migrate the Trunk Show Repository that you created in the Sandbox module to the MyStore module, and extend the user profile definition to include a module-specific custom property that identifies the user’s preferred designers. The SQL database table associated with this extension has already been created in the database. This table is currently empty. You will populate it with user data when you verify your work.

When migrating the Trunk Show Repository, you need to copy only the repository definition file and the repository component. You do not need to migrate the supporting components that you created in the preceding practices. You also want to replicate the configuration necessary to register the repository with the ACC and have it started automatically on server startup. Note that you could copy the repository over to MyStore, preserving the /sandbox configuration layer and Nucleus namespace, but it makes more sense to create a /mystore configuration layer in your MyStore module and have your module-specific components reside there.

Note that, as configured in the practice environment, your Sandbox server and the Commerce Reference Store access the same user space in the database. As such, the Trunk Show Repository data that you are familiar with from your work with Sandbox will be available in the MyStore / CRS application. This configuration is not recommended as a best practice, but has been implemented here to streamline the environment and for the convenience of the practices.

The SQL definition of the Trunk Show profile extension table: CREATE TABLE trunkshow_prefdesigners ( id VARCHAR2(32) not null references dps_user(id), designer VARCHAR2(32) not null, primary key(id, designer) );

After you have created the profile extension definition file, test your work using startSQLRepository, and then use the ACC to verify the new property definition.

A userProfile.xml starter file is available to you in <coursedir>/src/lesson16. This file can serve as a template for the profile extension definition.

Guided Instructions

Task 1: Migrate the Trunk Show Repository to MyStore 1. In Eclipse, in the MyStore config folder, create a /mystore subfolder to create a new

Nucleus namespace to hold the module-specific components and definition files.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 16: The User Profile

Chapter 16 - Page 5

2. Import or copy TrunkShowRepository.xml and TrunkShowRepository.properties (from <atgdir>/Sandbox/config/sandbox) into the MyStore config/mystore folder.

3. Edit TrunkShowRepository.properties and modify the definitionFiles property to point to /mystore/TrunkShowRepository.xml (rather than /sandbox/TrunkShowRepository.xml).

4. To access the Trunk Show Repository via the ACC and have it started automatically whenever the server starts, add it to the list of repositories managed by the /atg/registry/ContentRepositories component. Create a configuration layer for this component in the MyStore configuration folder (MyStore/config/). Add the repository to the initialRepositories property by including a single line in the .properties file:

initialRepositories+=/mystore/TrunkShowRepository

5. Shut down the CRS server if it is running.

6. In the MyStore project, run the deploy Ant task.

7. When deployment is complete, restart the CRS server.

8. Start the ACC.

9. Verify that the Trunk Show Repository is accessible from the Content menu.

10. Verify that the repository contains the familiar designer, event, and venue items from previous practices.

11. Close the ACC when you are done verifying your work.

Task 2: Add the preferredDesigners property to the user profile definition

12. In Eclipse, create a MyStore /config/atg/userprofiling folder to hold the module-specific profile extension definition.

13. Import or copy the userProfile.xml starter file from <coursedir>/src/lesson16 to MyStore/config/atg/userprofiling.

14. Define the profile extension based on the following user item descriptor property and table mapping detail:

Item Descriptor: user

Property Type Table Table Column

favoriteDesigners set of designer

trunkshow_prefdesigners designer

Some helpful hints:

• Add a table tag to the descriptor of the user item, specifying the trunkshow_prefdesigners table.

• Remember that the table is of type multi, and the id-column-name is id.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 16: The User Profile

Chapter 16 - Page 6

• Be sure to use the component-item-type attribute to define the type.

• Because the designer item descriptor is in an external repository (to the profile), be sure to include the repository= attribute, set to /mystore/TrunkShowRepository.

• Include a category attribute for the custom property, classifying it under Favorites, and a display-name attribute to display a readable name (Favorite Designers) in the ACC.

15. Save your work.

Task 3: Test your work using startSQLRepository

16. In a terminal window, change directory to <atgdir>/home, and enter the following (all on one line):

bin/startSQLRepository –m TestMyStore –repository

/atg/userprofiling/ProfileAdapterRepository

Resolve any errors or warnings before proceeding.

Task 4: Verify your work using the ACC 17. Shut down the CRS server.

18. In the MyStore project, run the deploy Ant task.

19. When deployment is complete, restart the CRS server.

20. Start the ACC.

21. Select People and Organization > Users and select a user.

22. Verify that the Favorites category is displayed and includes the Favorite Designers property. (You may need to scroll down to see the category.)

23. Verify that you can add favorite designers for a user.

24. Close the ACC when you are done verifying your work.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 16: The User Profile

Chapter 16 - Page 7

Practice 16-2: Updating the User Profile Details Page

Overview In this practice, you will update the user details page, displaying your additional profile property.

Problem Statement For this practice, update the Commerce Reference Store user details page to include display of the custom preferred designers property. Note that unlike the back-end store components you modified in the last couple of practices, store page updates are not implemented in the MyStore module. MyStore does not contain any front-end components or a Java EE application. Rather, the store pages are modified directly in the Storefront module. To modify these pages easily from Eclipse, you will import Storefront into Eclipse as another Java project.

Because you are editing only JSPs in Storefront, you will not need to build the Storefront module independently. The updated Storefront pages will be included automatically when you assemble and deploy the MyStore module because MyStore has a dependency on Storefront.

The CRS user details page that you will need to update is called profileMyInfo.jsp and it is located at /j2ee-apps/Storefront/store.war/myaccount/gadgets/ in the Storefront Java EE application. The JSP snippet needed to display the preferred designers profile property is provided for you in <coursedir>/src/lesson16.

Guided Instructions

Task 1: Import the Storefront module into Eclipse 1. In Eclipse, select File > New > Project. Select Java Project from the wizard menu, and

then click Next.

2. Enter Storefront as the project name, deselect the “Use default location” option, and set the project location to the Storefront module folder (/oce111/ATG11.1/CommerceReferenceStore/Store/Storefront).

3. Click Finish.

4. Note that you now have three projects in Eclipse: Sandbox, MyStore, and Storefront. Ensure that your work is completed in the appropriate module.

5. Open the Storefront project and explore the directory structure.

Task 2: Add the preferredDesigners property to the user profile display

6. In Storefront, locate /j2ee-apps/Storefront/store.war/myaccount/gadgets/profileMyInfo.jsp

and open it for editing.

7. This page displays the user’s profile properties. Examine the page code.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 16: The User Profile

Chapter 16 - Page 8

8. Insert the ForEach droplet required to conditionally display the new “favorite designers” (favoriteDesigners) property. This code snippet is available to you in <coursedir>/src/lesson16/favoriteDesigners-SNIPPET.jsp. Insert this code directly below the closing </dd> tag that delineates the display of the “receive emails” property (so that the user’s preferred designers are displayed immediately below the email preference).

9. Save your work.

Task 3: Verify your work in CRS 10. Shut down the CRS server if it is running.

11. In the MyStore project, run the deploy Ant task.

12. When deployment is complete, restart the CRS server.

13. Load the CRS storefront home page and log in as a user for whom you added one or more favorite designers in the previous practice. The login link is located in the upper-right corner of the page. Note that the login credentials for all sample users are <name>@example.com and password. If necessary, you can launch the ACC to add preferred designers for additional users.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 16: The User Profile

Chapter 16 - Page 9

14. Go to the user details page by clicking the Account link.

15. Verify that the favorite designers are displayed with the user detail.

16. If the ACC is active, close it when you are done verifying your work.

Optional Practice If time allows, examine the profile form handler page code that implements profile property updates in Commerce Reference Store. This code is located in the Storefront module at

/j2ee-apps/Storefront/store.war/myaccount/accountProfileEdit.jsp.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 16: The User Profile

Chapter 16 - Page 10

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 17: Custom Form Handlers and Transactions

Chapter 17 - Page 1

Practices for Lesson 17: Custom Form Handlers and Transactions

Chapter 17

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 17: Custom Form Handlers and Transactions

Chapter 17 - Page 2

Practices for Lesson 17: Overview

Practices Overview In this practice, you will create a custom form handler and use that form on a page.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 17: Custom Form Handlers and Transactions

Chapter 17 - Page 3

Catching Up

Dependencies You should have successfully completed the following practice:

Lesson 15: Extending the Product Catalog

• Practice 15-1: Building and Deploying the Store

It is essential that you have a working MyStore Java EE web application in place to complete the remaining practices.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 17: Custom Form Handlers and Transactions

Chapter 17 - Page 4

Practice 17-1: Creating a Custom Form Handler

Overview In this practice, you will create a custom form handler and use that form on a page.

Problem Statement For this practice, create a custom form handler component class that serves as a template for a simple online contest entry. The contest implementation will support a single question, configurable as a property value, with two simple user inputs: an answer to the question and a notification email address.

For this practice, a successful contest entry submission can simply log a message to the debug console. The purpose of this practice is to demonstrate the construction and basic operation of the custom form handler. As such, you will not be called upon to implement any complex contest entry processing. In a real-world scenario, the form might store the contest entry in a repository, forward the entry to some external system, or determine a result in real time. The solution would likely also integrate with the user profile and other store repositories. In the interest of time, the requirements for this implementation are kept minimal. If time allows, you are encouraged to enhance your solution using the skills and knowledge acquired in this course.

The form handler component should support the following properties:

• The contest question (String)

• The user’s answer (String)

• The user’s notification email address (String)

• A flag indicating whether a successful entry was submitted (boolean)

• The URL to redirect to upon successful form submission (String)

• The URL to redirect to upon unsuccessful form submission (String)

Create a session-scoped component based on your custom form handler component class. Provide default configuration values for the contest question, and initialize the entry submission flag to “false.” Note that the other properties will be set on form submission.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 17: Custom Form Handlers and Transactions

Chapter 17 - Page 5

Update the CRS storefront user details page (profileMyInfo.jsp) to include display of the contest form directly above the profile details. The form could be placed on some other page, but you should add it to the user details page because you are familiar with it from the preceding practice and the JSP is fairly simple and easy to edit. The JSP snippet needed to display the contest entry form is provided for you in <coursedir>/src/lesson17.

The form handler and page code should be implemented to allow a single submission of the contest entry per session.

Guided Instructions

Task 1: Set up your MyStore Eclipse project for Java development 1. In Eclipse, select the MyStore project.

2. Select Project > Properties, and select the Java Build Path option from the menu on the left.

3. On the Source tab, make sure that the “Source folders on build path” property includes MyStore/src. Click the Add Folder button, select the check box next to the src subfolder, and click OK.

4. Select the “Allow output folders for source folders” check box and enter MyStore/classes as the default output folder. This is the folder into which your compiled class files will be saved.

5. On the Libraries tab, click the Add External JARs button and navigate to oce111/ATG11.1/DAS/lib/. Select classes.jar and servlet.jar and click OK. Make sure that these libraries are displayed in the list of JAR files included on the build path. These Oracle Commerce libraries are required to build your custom component class.

6. Click OK to save your settings.

7. Make sure Project > Build Automatically is set.

Task 2: Create a Custom ContestEntryFormHandler Component Class

8. In the MyStore project, right-click the src folder and create a new Java class, named ContestEntryFormHandler, based on the atg.droplet.GenericFormHandler superclass and residing in the mystore package.

9. Complete the form handler implementation using the following guidelines:

• Import the following classes: atg.droplet.GenericFormHandler, atg.servlet.DynamoHttpServletRequest, and atg.servlet.DynamoHttpServletResponse.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 17: Custom Form Handlers and Transactions

Chapter 17 - Page 6

• Create private member variables, and getters and setters (methods) for the following properties:

Property Type

question String

answer String

emailAddress String

entrySubmitted boolean

validateSuccessURL String

validateErrorURL String

Remember that the getter method signature for boolean properties is isProperty ().

• Implement a handleValidate() method with the following signature:

public boolean handleValidate(DynamoHttpServletRequest request,DynamoHttpServletResponse response) throws java.io.IOException

• The handleValidate() method should first check to see if any form errors have

occurred and, if so, log a “Contest form submitted with errors” message and redirect to the validateErrorURL (if it is not null).

• If there are no form errors, the handleValidate() method should log a “Contest form successfully submitted” message and include the answer and emailAddress properties in the output. It should then set the entrySubmitted property to true and redirect to the validateSuccessURL (if it is not null).

• Remember that the handle method must return false if you redirect within the method, and true otherwise.

10. Save your file. The Java code will automatically compile on save.

11. Check for and resolve any errors.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 17: Custom Form Handlers and Transactions

Chapter 17 - Page 7

Task 3: Create a ContestEntryFormHandler component

12. In the MyStore config/mystore folder, create a session-scoped ContestEntryFormHandler component based on the custom mystore.ContestEntryFormHandler class. Configure your component as shown in the following table:

Property Value

$class mystore.ContestEntryFormHandler

$scope session

question Who will win Designer of the Year?

entrySubmitted false

loggingDebug true

13. Save your work.

Note that you may want to incrementally test your work by deploying your changes now and verifying the basic operation of your new from handler component and component class via the Administration UI Component Browser. Alternatively, you can wait and test your work together with the page changes you will complete in the next task.

Task 4: Add a contest entry form to the user details page 14. In Eclipse, select the Storefront project.

15. Open /…/store.war/myaccount/gadgets/profileMyInfo.jsp for editing.

16. Insert a Contest Entry Form above the Personal Information section. This code snippet is available to you in <coursedir>/src/lesson17/contestForm-SNIPPET.jsp. Insert the code directly above the <h3> tag that starts the user details section.

As coded, the form redirects to this same page on success or failure, but the Switch droplet is used to include the form on the page only if it has not already been submitted in this session. Note that both form field values (answer, emailAddress) are required.

17. Save your work.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 17: Custom Form Handlers and Transactions

Chapter 17 - Page 8

Task 5: Verify your work in CRS 18. Shut down the CRS server if it is running.

19. In the MyStore project, run the deploy Ant task.

20. When deployment is complete, restart the CRS server.

21. Load the CRS storefront home page and log in as any user (using, for instance, [email protected] and password).

22. Go to the user details page by clicking the Account link.

23. Verify that the contest entry form is displayed above the user detail.

24. Submit an incomplete form.

25. Verify that the page is redisplayed with a list of errors above the contest entry form. Verify that your form error logging debug message is output to the server terminal window.

26. Resubmit a fully completed form.

27. Verify that the page is redisplayed without the contest entry form. Verify that your validation success logging debug message is output to the server terminal window.

28. Log out and log back in, creating a new session.

29. Go to the user details page and verify that the contest entry form is once again displayed.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 18: Pipeline Processors

Chapter 18 - Page 1

Practices for Lesson 18: Pipeline Processors

Chapter 18

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 18: Pipeline Processors

Chapter 18 - Page 2

Practices for Lesson 18: Overview

Practices Overview In this practice, you will use the Administration UI and the ACC to explore Oracle Commerce pipeline configurations.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 18: Pipeline Processors

Chapter 18 - Page 3

Catching Up

Dependencies The practices for this lesson have no dependencies on preceding practices.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 18: Pipeline Processors

Chapter 18 - Page 4

Practice 18-1: Exploring Pipeline Configurations

Overview In this practice, you will use the Administration UI and the ACC to explore Oracle Commerce pipeline configurations.

Problem Statement Use the Administration UI Component Browser to explore the Request Handling servlet pipeline configuration, including the Head Pipeline component, the various servlets that make up the pipeline, and how the servlets are chained.

Review the Commerce processor pipeline architecture, including the Pipeline Manager components and the XML definition of the processor chains. Use the Pipeline Editor in the ACC to explore a visual representation of the chains and the components that support the various processors.

Note that you will build and insert a custom Commerce order pipeline processor in the follow-on Oracle Commerce: Customizing the Commerce Platform Rel. 11.1 course.

Guided Instructions

Task 1: Explore the Request Handling servlet pipeline 1. Start the CRS server if it is not already running.

2. From the Administration UI, select the Component Browser and browse to /atg/dynamo/servlet/dafpipeline/DynamoHandler. This is the head of the Request Handling pipeline. Note that the class of this component is atg.servlet.pipeline.HeadPipelineServlet.

3. Note the servlets that make up the complete pipeline. They are listed, in pipeline order, under Servlet Pipeline.

4. In the Properties section, note that the value of the nextServlet property points to the next servlet in the chain, /atg/multisite/SiteContextPipelineServlet. Click the property value to view the configuration and property values of that (SiteContextPipelineServlet) component.

5. Verify that the servlets are chained in this manner, through to the last servlet in the pipeline.

6. Take some time to explore the configuration of the various servlets.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 18: Pipeline Processors

Chapter 18 - Page 5

Task 2: Review the Commerce processor pipelines 7. From the Administration UI Component Browser, browse to

/atg/commerce/PipelineManager. This component manages the pipelines associated with order processing. Note that the class of this component is atg.commerce.pipeline.CommercePipelineManager.

8. Note the many pipelines managed by this component. They are listed under Pipeline Chains.

9. Commerce pipeline processors are configured via XML files. Click the definitionFile property (under Properties) to see the detailed combined XML configuration that defines this pipeline group.

10. Review other Commerce pipelines at:

• /atg/commerce/payment/PaymentPipelineManager

• /atg/commerce/fulfillment/FulfillmentPipelineManager

• /atg/commerce/invoice/pipeline/InvoicePipelineManager

• /atg/commerce/payment/PaymentPipelineManager

Task 3: Explore the Pipeline Editor in the ACC 11. Start the ACC.

12. Select Utilities > Pipeline Editor.

13. Click the Open Pipeline Definition icon .

14. Select /atg/commerce/PipelineManager and click the Open Pipeline Definition button.

15. Note the pipelines listed along the left side of the window. These pipelines match those you reviewed in the Administration UI Component Browser.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 18: Pipeline Processors

Chapter 18 - Page 6

16. Scroll down until you see the processOrder pipeline. Follow the flow to the right, noting the various processors that make up the order processing pipeline.

17. Note that you can edit the details for a processor by double-clicking its name. Take care not

to make any edits in this exercise as you are only reviewing the capabilities of the tool and viewing the existing pipeline configurations.

18. Note that by right-clicking and selecting Edit Selected Processor Component, you can view a processor’s component configuration, including class, Nucleus namespace, properties, and methods. Again, ensure that you do not make any edits.

19. Review other pipelines if time allows.

20. Close the ACC when you are done examining the pipelines.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 19: REST Web Services

Chapter 19 - Page 1

Practices for Lesson 19: REST Web Services

Chapter 19

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 19: REST Web Services

Chapter 19 - Page 2

Practices for Lesson 19

Practices Overview There are no practices for this lesson.

Rick Grimm (rickgrimmฺfl@

gmailฺcom) has a non-transferable license

to use this Student Guideฺ

Una

utho

rized

repr

oduc

tion

or d

istri

butio

n pr

ohib

itedฺ

Cop

yrig

ht©

201

7, O

racl

e an

d/or

its

affil

iate

sฺ