Sunteți pe pagina 1din 55

INTRODUCTION TO E-COMMERCE

Art Technology Group (ATG) was an independent Internet technology company specializing
in eCommerce software and on-demand optimization applications until its acquisition by Oracle
on January 5, 2011. ATG continues to be based in Cambridge, Massachusetts and operates under
its own name as a subsidiary of Oracle. The company is a provider of eCommerce software and
related on-demand commerce optimization applications. ATG's solutions provide merchandising,
marketing, content personalization, automated recommendations, and live-help
services. (Source WIKI).

BASICS OF ELECTRONIC COMMERCE (E-Commerce):


Wikipedia definition - Electronic Commerce, commonly known as (electronic marketing) e-
commerce or eCommerce, consists of the buying and selling of products or services over
electronic systems such as the Internet and other computer networks.

Benefits of E-commerce

Organization – Effective Utilization of Supply chain, Cost reduction, Improved Customer


relations, Global Reach, etc

Customer Benefits – Wide choice of products and services, Convenience, Instant Information
availability and Delivery, Product Feedbacks and blogs, Customization and personalization, etc

Societal benefits – Telecommuting, Economical pricing, Availability of Public services such as


Health care, Bill payments, Distribution of Government social services, etc.

TYPES OF E-COMMERCE APPLICATIONS :


• Business to Business (B2B) - Between business Partners
Companies doing business with each other such as manufacturers selling to distributors
and wholesalers selling to retailers. Pricing is based on quantity of order and is often
negotiable.
– www.nygard.com
• Business to Consumer (B2C) – Between individual customers and Business partners
Businesses selling to the general public typically through catalogs utilizing shopping
cart software
– www.amazon .com
– www.Egghead.com
• Consumer to Business (C2B) – Individuals selling to Business
C2B e-commerce occurs when consumers use the Internet to search for sellers, learn
about offers, or give feedback. A consumer posts his project with a set budget online and
within hours companies review the consumer's requirements and bid on the project. The
consumer reviews the bids and selects the company that will complete the project.
– www.Sulekha.com
• Consumer to Consumer (C2C) – Between Individual customers
C2C stands for transactions taking place between Customers/ Consumers
These Sites primarily offer goods and services to assist customers to interact
– www.Ebay.com
– www.expedia.ca

ATG Core Architecture and Framework

ATG Core architecture can be explained as below:

Major modules like DAS, DAF, DPS, DSS were explained in the bottom link.

components-of-atg-platform

Remaining modules like DCS, BCC, etc were explained in short in the below mentioned table.

The following tables list the module names for the main Oracle ATG Web Commerce applications, demos, and
reference applications. This is not an exhaustive list of all Oracle ATG Web Commerce modules.
Module Description

Adds missing administrative accounts for the ATG Control Center. For more information,
Admin.Init
see the Managing Access Control chapter.

Resets the default login accounts for the ATG Control Center. For more information, see
Admin.Reset
the Managing Access Control chapter.

Enables the Oracle ATG Web Commerce platform to use Oracle ATG Web Commerce
DAF.Search Search to index and search content from product catalogs and other repositories. See
the ATG Search Administration Guide.
Module Description

Enables an Oracle ATG Web Commerce server to accept connections from the ATG
DAS-UI Control Center.

Note: This module must be running if you want to use the ATG Control Center.

Runs the ATG Control Center in the same JVM used by the application server that the
DCC Nucleus-based application is running on. For more information, see the ATG Installation and
Configuration Guide.

DPS Oracle ATG Web Commerce Personalization

DSS Oracle ATG Web Commerce Scenarios

DSSJ2EEDemo Oracle ATG Web Commerce Adaptive Scenario Engine demo (Quincy Funds).

Repository Loader. Takes files that are stored in a file system, converts them into
RL repository items, and loads the items into the repository. To learn more, see the ATG
Repository Guide.

Browser-based administration interface for Oracle ATG Web Commerce’s SQL JMS
SQLJMSAdmin
message system. For more information, seeUsing the SQL-JMS Administration Interface.

Content Administration Modules


Module Description

Supports the building of browser-based user interfaces for an ATG


Content Administration (versioned) environment. The module includes
AssetUI
the Asset Picker and functionality related to it. Requires
the WebUI module (see below).

The Oracle ATG Web Commerce Business Control Center. Includes the
BizUI
Home page functionality.

Publishing Agent. Runs on production and staging servers and performs


PublishingAgent content deployment operations by communicating with the ATG Content
Administration server.

Publishing web agent. Runs on the production and staging web servers
PublishingWebAgent and performs web content deployment operations by communicating
with the ATG Content Administration server.

Publishing.base
ATG Content Administration. See the ATG Content Administration Programming
Module Description

Guide for more information.

The source module for the Web Application Reference Implementation


Publishing.WebAppRef
provided with ATG Content Administration.

The versioning module for the Web Application Reference


Publishing.WebAppRefVer
Implementation provided with ATG Content Administration.

Supplies the portlets that make up the Oracle ATG Web Commerce
Business Control Center interface. Including this module also causes
PubPortlet thePublishing.base, AssetUI, and BizUI modules to be included.
Include this module to perform most basic tasks in ATG Content
Administration, such as product evaluation.

Contains support for browser-based user interfaces. Examples are the


WebUI tree-based asset browsing feature, a calendar widget, and the View
Mapping system.

Portal Modules
Module Description

Portal.gears Includes the Portal Application Framework and baseline gears.

Portal Application Framework (PAF). At a minimum, you must include this module
Portal.paf to use Oracle ATG Web Commerce Portal. To learn more about the PAF, see
theATG Portal Administration Guide.

Portal.gear-name
Includes the specified gear or portlet. For example, if you create a gear
Portal.portlet-
name called productprices, include the modulePortal.productprices.

ATG Commerce Modules


Module Description

ATG Business Commerce

B2BCommerce Note: To run ATG Commerce, you must use one and only one of the following
modules:B2BCommerce,B2BCommerce.Versioned, B2CCommerce,
orB2CCommerce.Versioned.

Enables Business Commerce extensions to the ATG Commerce Search. See


B2BCommerce.Search
the ATG Search Administration Guide for more information.

B2BCommerce.Versio Use instead of B2BCommerce module if running ATG Merchandising. (Also


Module Description

ned requires modulesDCS-UI.Versioned and PubPortlet.)

Note: To run ATG Commerce, you must use one and only one of the following
modules:B2BCommerce,B2BCommerce.Versioned, B2CCommerce,
orB2CCommerce.Versioned.

Including this module also


includesB2BCommerce,DCS.DynamicCustomCatalogs.Versioned, and
their modules.

ATG Consumer Commerce

Note: To run ATG Commerce, you must use one and only one of the following
B2CCommerce modules:B2BCommerce,B2BCommerce.Versioned, B2CCommerce,
orB2CCommerce.Versioned.

Including this module also includes DCS and its modules.

Use instead of B2CCommerce module if running ATG Merchandising. (Requires


the DCS-UI.management and PubPortlet modules also.)

Note: To run ATG Commerce, you must use one and only one of the following
B2CCommerce.Versio
modules:B2BCommerce,B2BCommerce.Versioned, B2CCommerce,
ned
orB2CCommerce.Versioned.

Including this module also includesB2Commerce, DCS.Versioned, and their


modules.

Order Approval Portal Gear (Requires ATG Portal also.)


CommerceGears.orde Including this module also
rapproval
includesPortal.paf, Portal.authentication,Portal.templates, Por
tal.communities,B2BCommerce, and their modules.

Order Status Portal Gear (Requires ATG Portal also.)


CommerceGears.orde Including this module also
rstatus
includesPortal.paf, Portal.authentication,Portal.templates, Por
tal.communities,DCS, and their modules.

Third-party commerce module (from CyberSource Corp.) for authorizing credit


Cybersource cards, crediting and settling accounts, calculating taxes, and verifying
addresses.
Module Description

Including this module also includes DCS and its modules.

Base ATG Commerce module


DCS
Including this module also includes DSS, DPS, and their modules.

Provides tools for dealing with abandoned orders and shopping carts.
DCS.AbandonedOrder
Services
Including this module also includes DCS and its modules.

Runs custom catalogs in an ATG Commerce production environment, required


DCS.CustomCatalogs
to support pre-ATG 10.1 Commerce applications; otherwise unused.

Runs custom catalogs in an ATG Commerce development environment.


DCS.DynamicCustomC
atalogs
Including this module also includesDCS.CustomCatalogs and its modules.

Runs custom catalogs in an environment running ATG Commerce and ATG


Merchandising. (Requires the DCS-
DCS.DynamicCustomC UI.management and PubPortlet modules also.)
atalogs.
Versioned Including this module also
includesDCS.DynamicCustomCatalogs,DCS.CustomCatalogs.Versione
d, and their modules.

Use instead of the PublishingAgent module on the target server if ATG


DCS.PublishingAgen
Commerce repository items are deployed to that server.
t
Including this module also includesPublishingAgent, DCS, and their
modules.

Enables ATG Commerce to use ATG Search to index and search content from
DCS.Search
product catalogs and other repositories. See the ATG Search Administration Guide.

Use instead of DCS module if running ATG Commerce with ATG Merchandising.
DCS.Versioned
Including this module also includesPublishing.base, DCS, and their
modules.

ATG Commerce Sample Catalog


DCSSampleCatalog
Including this module also includes DCS and its modules.
Module Description

ATG Commerce order fulfillment


Fulfillment
Including this module also includes DCS and its modules.

ATG Business Commerce reference application (Motorprise)


MotorpriseJSP
Including this module also
includesB2BCommerce, DCS.AbandonedOrderServices, and their modules.

Third-party commerce module (from VeriSign) for handling credit card


PayFlowPro authorization, settlement, and crediting.

Including this module also includes DCS and its modules.

Third-party commerce module (from ADP Taxware) for calculating taxes,


Taxware verifying addresses and determining tax jurisdictions.

Including this module also includes DCS and its modules.

What is ATG Component? What is ATG Nucleus?

ATG component:

In ATG any Public Class/JavaBean Associated with a properties file is called as anATG component. Ideally speaking
the properties file of a component stores the configuration values like, class name it is associated with, Scope,
Dependency injections, some other Default values that are used in the java classes. It must be under the ATG
configPath.

Properties File Format:

The properties files read by Nucleus must follow a format that is recognized by the
class java.util.Properties. The rules for the format are as follows:

 1. Entries are generally expected to be a single line of the form:

propertyName=propertyValue
propertyName:propertyValue
 2. White space that appears between the property name and property value is ignored.

 3. Lines that start with the comment characters !or# are ignored. Blank lines are also ignored.

 4. The property value is generally terminated by the end of the line. White space following the
property value is not ignored, and is treated as part of the property value

 5. A property value can span several lines if each line is terminated by a backslash (‘\’) character.

Example:
targetCities=\
Detroit,\
Chicago,\
Los Angeles

 6. The characters newline, carriage return, and tab can be inserted with characters \n, \r, and \t,
respectively

 7. The backslash character must be escaped as a double backslash.

 8. UNICODE characters can be entered as they are in a Java program, using the \u prefix

ATG Nucleus:

A container that holds all these ATG components is nothing but ATG Nucleus. It is the core of the entire ATG system.
By reading the .properties files associated with each component, Nucleus figures out which components are to be used
in an application,initializes them to their default values,and decides how they connect to each other. This model
makes it easier for the developers to build ATG applications by configuring and using the in-built components instead
of writing Java code from scratch.
Basic ATG Nucleus Operations (In Detail) / How ATG Nucleus Works :
Nucleus performs one basic operation: resolving component names. Given the name of a component, Nucleus does its best to
find or create that component and return it.
 Within Nucleus, certain components can contain other components, forming a component hierarchy. For example, given the
name /services/logs/FileLogger, Nucleus resolves it by looking for components in the following locations:
1. Looks in the root container for the services component.
2. Looks in the services container for the logs component.
3. Looks in the logs container for the FileLogger component.
 Name resolution is not a difficult task. Nucleus shows its real power by creating components and hooking them up to
other components automatically. This function is invoked when Nucleus is asked to resolve a name of a component
that does not yet exist.

For example:

On startup, Nucleus is given a configuration path—a list of configuration directories that contain
the configuration files of various components. Within the configuration directories, Nucleus
expects to find a configuration file that uses the component name.
For example, to create the component /services/custom/CustomFile, which does not exist in
the nucleus components, and say, the configuration root directory
is <ATG10.1dir>/DAS/config, Nucleus looks forCustomFile’sconfiguration in:
<ATG10.1dir>/DAS/config/services/custom/CustomFile.properties

In Simple words: It creates and configures Nucleus components and organizes them into a
hierarchical namespace, essentially giving them a place to live so they can be referenced by other
components.

Scopes available in ATG

Nucleus gives a place to live for all its components. For managing their life span, it uses a
variable named "scope" for all its components. As, it is a nucleus property, it is preceded by $
sign.

An application component can be set to one of the following scopes:

 Global: Component is shared among all users.


 Session: Separate instances of the component are provided to each user.
 Request: Separate instances of the component are provided to each active request.

Specifying component scopes


You specify a component’s scope by setting its $scope property toglobal, session,
or request. For example, a NewPerson component might be set to session scope as follows:
$class=Person
$scope=session
name=Bill
age=28

Note: If a component’s $scope property is not explicitly set, it automatically


has global scope.

A component’s properties should always point to objects whose scope is equal to or greater than its own.
Thus, global-scope component properties should only point to objects that also have global scope;
session-scope component properties should only point to objects that have global or session scope;
while request-scope component properties can point to objects of any scope, including request.

Creating Custom Droplets

Droplet:
In simple Droplet is a combination of Servlets and javaBeans. You can embed these
droplets in your JSPs to display dynamic content. These droplets can be nested and pass
parameters between themselves. These Droplets are also called as DynamoServlets.There
are lot many out-of–box droplets provided by ATG.They are categorized into
 Standard Servlet Beans
Some of them include:

 IsEmpty
 IsNull
 ProtocolChange
 Range
 Redirect
 Switch
 TableForEach
 TableRange
 BeanProperty
 Cache
 Compare
 CurrencyFormatter
 ErrorMessageForEach
 For
 ForEach
 Format
 Repository Servlet Beans
Some of them include:

 ItemLookupDroplet
 NavHistoryCollector
 PipelineChainInvocation
 PossibleValues
 RelationalViewDroplet
 RQLQueryForEach
 RQLQueryRange
 SQLQueryForEach
 SQLQueryRange

 XML Servlet Beans


Some of them include:

 NodeForEach
 NodeMatch
 DOM
 XML Transform

 Transaction Servlet Beans


 EndTransactionDroplet
 TransactionDroplet
Parameters of a Servlet bean include:
• Input Parameter

– Input parameters are parameters you pass to the Servlet Beans

• Output Parameters

– Output parameters are parameters whose values are set by the Servlet bean

• Open Parameters

- Open parameters contain the HTML that is rendered by the servlet bean. The HTML that an
open parameter renders is marked off by beginning and ending dsp:oparam tags. This HTML
can include dynamic elements, such as dsp:valueof tags, for displaying the values of output
parameters
Parameter Scope :
o In general, the values of input, output, and open parameters apply only within the servlet bean that uses them ie.,
Private Scope.
o A parameter used by a servlet bean is undefined outside the beginning and ending dsp:droplet tags.
o The value of a page parameter applies everywhere on the page, including within the servlet bean (page scope).
o If the servlet bean has a parameter with the same name as the page parameter, the servlet bean parameter value
overrides the page value, but only within the servlet bean
Steps to create a Custom Droplet:
Step 1: Create a new ATG module. In Source folder create a Droplet class.
Step 2: Create a Properties file for the Droplet in the config folder
Example: TestDroplet.properties
Step 3: Droplet class should extend javax.servlet.Servlet or atg.servlet.DynamoServlet class
Step 4:Implement the service method of the Servlet

Example:

public class TestDroplet extends DynamoServlet {


int name;
public TestDroplet () {
System.out.println ("InTestDroplet Constructor");
}
public void service (DynamoHttpServletRequest request, DynamoHttpServletResponse response) throws
ServletException, IOException {
ServletOutputStream out = response.getOutputStream ();
out.println ("Hello World! My name is "+name);
}
public int getName () { return name; }
public void setName (int name) {
System.out.println ("setting name attribute to " + name);
this.age = age;
}
}
Step 5: call the droplet in your JSP as shown below.
<%@ taglib uri="/dspTaglib" prefix="dsp" %>
<dsp:page>
<html>
<head><title>Hello World</title></head>
<body>
Hello World!!!
<dsp:droplet name="/TestDroplet">
</dsp:droplet>
</body>
</html>
</dsp:page>

Step 6: Access your jsp from Browser. You will see the output.
WRITING CUSTOMIZED DROPLETS WITH PARAMETERS:

File name: test.jsp


<%@ taglib uri="/dspTaglib" prefix="dsp" %>
<dsp:page>
<html>
<head>
<title>DSBtest</title>
</head>
<body>
<h1>DSB Test </h1>
<p>From a java object:
<dsp:droplet name="/atg/droplet/test1">
<dsp:param name="name" value="atg-tips"/>
<dsp:oparam name="output">
Name is : <dsp:valueof param="myName"></dsp:valueof><br>
</dsp:oparam>
<dsp:oparam name="output1">
Project is : <dsp:valueof param="project"></dsp:valueof><br>
</dsp:oparam>
<dsp:oparam name="output2">
Module is : <dsp:valueof param="module"></dsp:valueof><br>
</dsp:oparam>
</dsp:droplet>
</body>
</html>
</dsp:page>
File name: test1.properties
$class=test.DropletA
$scope=global

File name: DropletA.java


public class DropletA extends DynamoServlet {
@Override
public void service(DynamoHttpServletRequest request,
DynamoHttpServletResponse response) throws ServletException,
IOException {
super.service(request, response);
request.setParameter("project", "MyProject");
System.out.println("DropletA.service() request object is : "+request);
request.serviceParameter("output1",request, response);
request.setParameter("module", "myModule");
System.out.println("DropletA.service() request object is : "+request);
request.serviceParameter("output2",request, response);

}
You can Create Droplets with Parameters also. Try it out and Post a
comment for any Queries.

Creating Custom Droplets

Droplet:
In simple Droplet is a combination of Servlets and javaBeans. You can embed these
droplets in your JSPs to display dynamic content. These droplets can be nested and pass
parameters between themselves. These Droplets are also called as DynamoServlets.There
are lot many out-of–box droplets provided by ATG.They are categorized into
 Standard Servlet Beans
Some of them include:

 IsEmpty
 IsNull
 ProtocolChange
 Range
 Redirect
 Switch
 TableForEach
 TableRange
 BeanProperty
 Cache
 Compare
 CurrencyFormatter
 ErrorMessageForEach
 For
 ForEach
 Format

 Repository Servlet Beans


Some of them include:

 ItemLookupDroplet
 NavHistoryCollector
 PipelineChainInvocation
 PossibleValues
 RelationalViewDroplet
 RQLQueryForEach
 RQLQueryRange
 SQLQueryForEach
 SQLQueryRange

 XML Servlet Beans


Some of them include:

 NodeForEach
 NodeMatch
 DOM
 XML Transform

 Transaction Servlet Beans


 EndTransactionDroplet
 TransactionDroplet
Parameters of a Servlet bean include:
• Input Parameter

– Input parameters are parameters you pass to the Servlet Beans

• Output Parameters

– Output parameters are parameters whose values are set by the Servlet bean

• Open Parameters

- Open parameters contain the HTML that is rendered by the servlet bean. The HTML that an
open parameter renders is marked off by beginning and ending dsp:oparam tags. This HTML
can include dynamic elements, such as dsp:valueof tags, for displaying the values of output
parameters

Parameter Scope :
o In general, the values of input, output, and open parameters apply only within the servlet bean that uses
them ie., Private Scope.
o A parameter used by a servlet bean is undefined outside the beginning and ending dsp:droplet tags.
o The value of a page parameter applies everywhere on the page, including within the servlet bean (page
scope).
o If the servlet bean has a parameter with the same name as the page parameter, the servlet bean parameter
value overrides the page value, but only within the servlet bean
Steps to create a Custom Droplet:
Step 1: Create a new ATG module. In Source folder create a Droplet class.
Step 2: Create a Properties file for the Droplet in the config folder
Example: TestDroplet.properties
Step 3: Droplet class should extend javax.servlet.Servlet or atg.servlet.DynamoServlet class
Step 4:Implement the service method of the Servlet

Example:

public class TestDroplet extends DynamoServlet {


int name;
public TestDroplet () {
System.out.println ("InTestDroplet Constructor");
}
public void service (DynamoHttpServletRequest request, DynamoHttpServletResponse response) throws
ServletException, IOException {
ServletOutputStream out = response.getOutputStream ();
out.println ("Hello World! My name is "+name);
}
public int getName () { return name; }
public void setName (int name) {
System.out.println ("setting name attribute to " + name);
this.age = age;
}
}
Step 5: call the droplet in your JSP as shown below.
<%@ taglib uri="/dspTaglib" prefix="dsp" %>
<dsp:page>
<html>
<head><title>Hello World</title></head>
<body>
Hello World!!!
<dsp:droplet name="/TestDroplet">
</dsp:droplet>
</body>
</html>
</dsp:page>

Step 6: Access your jsp from Browser. You will see the output.

WRITING CUSTOMIZED DROPLETS WITH PARAMETERS:


File name: test.jsp
<%@ taglib uri="/dspTaglib" prefix="dsp" %>
<dsp:page>
<html>
<head>
<title>DSBtest</title>
</head>
<body>
<h1>DSB Test </h1>
<p>From a java object:
<dsp:droplet name="/atg/droplet/test1">
<dsp:param name="name" value="atg-tips"/>
<dsp:oparam name="output">
Name is : <dsp:valueof param="myName"></dsp:valueof><br>
</dsp:oparam>
<dsp:oparam name="output1">
Project is : <dsp:valueof param="project"></dsp:valueof><br>
</dsp:oparam>
<dsp:oparam name="output2">
Module is : <dsp:valueof param="module"></dsp:valueof><br>
</dsp:oparam>
</dsp:droplet>
</body>
</html>
</dsp:page>
File name: test1.properties
$class=test.DropletA
$scope=global

File name: DropletA.java


public class DropletA extends DynamoServlet {
@Override
public void service(DynamoHttpServletRequest request,
DynamoHttpServletResponse response) throws ServletException,
IOException {
super.service(request, response);
request.setParameter("project", "MyProject");
System.out.println("DropletA.service() request object is : "+request);
request.serviceParameter("output1",request, response);
request.setParameter("module", "myModule");
System.out.println("DropletA.service() request object is : "+request);
request.serviceParameter("output2",request, response);

}
You can Create Droplets with Parameters also. Try it out and Post a
comment for any Queries.

Custom Form Handlers in oracle ATG

Form Handlers:
In many web applications users input are taken from the forms.A form may need to
handle user input in a variety of formats, check input for validity, handle errors, and pass input
to a servlet for processing or to a database for storage. ATG java classes that process these forms
are none other than Formhandlers.

• We can create forms in JSP Pages that set values of properties of Nucleus components directly
when the form is submitted.

• For more complex form handling operations, setting the values of properties directly is not
always desirable. It is generally preferable to first submit the form to a form handler.

• The form handler can evaluate the validity of the data, check for errors, and determine what
action to take (e.g., submit the data, direct the user to a different page, display an error message,
etc.)

• Often when you use a form handler, the form input fields are associated with properties of the
form handler rather than the component you ultimately want to modify

A form handler class must include one or more handler methods. A handler method is typically invoked when the
user clicks the submit button, and handles the processing of the form. Depending on the purpose of the form handler,
it can have several different handler methods that each perform a different operation. For example, a form handler
that works with user profiles might have separate handler methods for creating the profile, modifying the profile, and
logging the user in.

If the form uses FormHandler, the exceptions that occurred while processing the form are
stored in the following properties.

• formError : A Boolean that is true if any errors occurred when the form was processed.

• formExceptions : A vector of the exceptions that occurred when the form is processed.

• propertyExceptions : A read-only property that returns a Dictionary of subproperties, one for


each property set by the form. For any property that generated an exception, the corresponding
subproperty in the propertyExceptions Dictionary contains that exception. For any property that
did not generate an exception, the corresponding subproperty in the propertyExceptions
Dictionary is unset.
If a form handler returns “false” it will redirect to the same page. And if the form handler
returns “true” it will redirect it to the success URL.

For every handle method in a formhandler the order of


execution is:

• 1.beforeSetXXX() of the property

• 2.tag convertors (if any) will be applied(Note: Tag converters are converter classes that are used to convert the data
from input/ to output)

• 3.preXXX()

• 4.handleXXX()

• 5.postXXX()

• 6.afterSetXXX()

Displaying Error Messages in Form Handlers:

Use this droplet to loop through and display the error messages that are generated by a form:

<dsp: droplet name=“/atg/dynamo/droplet/ErrorMessageForEach”>

<dsp:oparam name=“output”>

<dsp:valueof param=“message”/><br>

</dsp:oparam>

</dsp:droplet>

ATG Form Handlers base classes:


Oracle ATG Web Commerce form handler classes all implement the
interfaceatg.droplet.DropletFormHandler. Three form handler base classes implement this interface:

 atg.droplet.EmptyFormHandler

 atg.droplet.GenericFormHandler

 atg.droplet.TransactionalFormHandler

EmptyFormHandler

atg.droplet.EmptyFormHandler implements the DropletFormHandler interface and provides empty implementations of


the methods in this interface.
GenericFormHandler

atg.droplet.GenericFormHandler extends EmptyFormHandler. It provides simple implementations


of DropletFormHandler interface methods and adds basic error handling logic. If errors occur in processing a form that
uses GenericFormHandler, the errors are saved and exposed as properties of the form handler component. This form handler
is included in the public API

TransactionalFormHandler

atg.droplet.TransactionalFormHandler extends atg.droplet.GenericFormHandler; it treats the form processing operation


as a transaction. Although this form handler methods are processed discretely, their results are saved simultaneously. The
transaction management occurs in the beforeGet and afterGet methods. This establishes the transaction before any of
properties are set or handler methods are called, rather than in the handler methods themselves.

You can create a form handler by extending one of these classes or any of their subclasses.

Some of the classes that extend the base class in ATG API are:

 SimpleSQLFormHandler for working with form data that is stored in a SQL database.

 RepositoryFormHandler for saving repository data to a database.

 ProfileFormHandler class to connect forms with user profiles stored in a profile repository

 SearchFormHandler for specifying properties available to a search engine.

Steps in Writing a Custom FormHandler:

Non Java Steps:

Step i: Create a JSP file calling the from handler.

In The above example the submit is given to LoginBean.login (note “l” is small in “login”) so the
LoginBean java class will call handleLogin() method (note “l” is Caps for “handle Method”).

Step ii: create properties file for the java class. Content will be similar to:

$class=managedBeans.LoginBean

$scope=global

JAVA STEPS:

Step 1: Create a java class extending the atg.droplet.GenericFormHandler base class.

Step 2: Provide the appropriate handlexxx methods. Each Handler method will be triggered by
corresponding dsp:input submit button from the jsp page.

Step 3: Provide either a Map data structure to hold the form data or provide individual fields

with apprppriate set/get methods.

Step 4: Write the desired codes and return the Boolean codes appropriately.

Step 5: Populate validation errors if any

Step 6: Forward the user to the appropriate success URL.

Posted by Sirisha Dhanekula at 06:12:00

13 comments:

Anonymous said...

create properties file for the java class. Content will be similar to:
$class=managedBeans.LoginBean
$scope=global

I have a question
Where i create the property file and how to name the property file
25 November 2013 at 22:24

kiranmai kolipakula said...

you can give any name. but make sure this name is the component you refer to in jsp
28 November 2013 at 08:03

kiranmai kolipakula said...

if u create ur properties file at /atg/formhandler/MyFormHandler.properties, in jsp the reference wil b


/atg/formhandler/MyFormHandler.
28 November 2013 at 08:12
Sirisha Dhanekula said...

you have to place it in config folder. and the path must be the same path u specified in your jsp.

Say you refer /xx/yy/zz/sampleBean in your jsp, then in "config" folder create xx folder, in that xx folder
create yy folder, again in that yy folder create zz folder and keep your properties file there.
Here in this scenario sampleBean.properties file must be created.

in that if u specify
$class=somePackage.SomeClass
in that properties file you have to create
"SomeClass" in "somePackage" in source(src folder).
28 November 2013 at 08:23

Anonymous said...

I am getting below error. can you please help me to fix it

atg.droplet.DropletException: Can't find property: username in class com.verizon.zubair.LoginBean

this is my class file


package com.verizon.zubair;
public class LoginBean extends GenericFormHandler {
private String username;
private String password;
private String message;

@SuppressWarnings("unused")
private String getUsername() {
return username;
}
@SuppressWarnings("unused")
private void setUsername(String username) {
this.username = username;
}
@SuppressWarnings("unused")
private String getPassword() {
return password;
}
@SuppressWarnings("unused")
private void setPassword(String password) {
this.password = password;
}
@SuppressWarnings("unused")
private String getMessage() {
return message;
}
private void setMessage(String message) {
this.message = message;
}
......
}

in jsp
dsp:input type="text" bean="/com/verizon/zubair/LoginBean.username" dsp:input

Properties
$class=com.verizon.zubair.LoginBean
$scope=global
The ATG platform supports JSPs as its primary authoring format/front end. The ATG has two tag libraries namely:

  JSTL

  DSP

JSTL Tag LIB:


The JavaServer Pages Standard Tag Library (JSTL) from Sun Microsystems handles generic Web application tasks
that are supported by all application servers. The JSTL tags can be classified, according to their functions, into
following JSTL tag library groups that can be used when creating a JSP page:
 Core Tags
 Formatting tags
 SQL tags
 XML tags
 JSTL Functions

For More details on JSTL Tag Library: refer to (Oracle Docs or Tutorials Point)

DSP Tag LIB:


The DSP tag library lets you access all data types in ATG’s Nucleus framework. Other functions provided by these tags
manage transactions and determine how to render data in a JSP. You should use tags from the DSP tag library only
for tasks that involve ATG resources. For generic Web application tasks, use JSTL tags.
In pages that import the DSP tag library, you should generally favor DSP tags over equivalent JSP tags. In general, the
corresponding DSP tag library tags provide enhanced functionality, such as support for the passing of object
parameters between pages. In particular, use dsp:include and dsp:param rather than their JSP equivalents.
The DSP tag library supports both scripting and the JSP Expression Language. For example, the following two tags
are equivalent:

<dsp:valueof param="<%= currentCourse %>"/>


<dsp:valueof param="${currentCourse}"/>

List of DSP taglibrary tags are explained in previous post (Click here for DSP
tags details)

Frequently used Out of box Components ( droplets and


formhandlers)
SOME OOB FORMHANDLERS:
Here are some of the commonly used FormHandlers, although ATG provides many out of the
box FormHandlers and even we can write our own custom FormHandlers by extending
GenericFormHandler class provided by ATG.

CartModifierFormHandler -- This formhandler is used to modify a ShoppingCart by adding


items to it, deleting items from it, modifying the quantities of items in it, and preparing it for the
checkout process.

ExpressCheckoutFormHandler -- The ExpressCheckoutFormHandler is used to expedite the


checking out of an Order. This supports creating a maximum of one Profile derived
HardgoodShippingGroup and one Profile derived CreditCard, followed by committing the Order.

SaveOrderFormHandler -- The SaveOrderFormHandler is used to save the user's current Order


based on a descriptive name that the user specifies. A new empty Order is then made the user's
current shopping cart. If a descriptive name for the Order is not specified, then one is created
based on the user's Locale and date and time.

ShippingGroupFormHandler -- The ShippingGroupFormHandler is used to associate


ShippingGroups with the various Order pieces. This component is used during the Order
checkout process, and any Order successfully processed by the ShippingGroupFormHandler is
ready for the next checkout phase, which may be Payment.

PaymentGroupFormHandler -- The PaymentGroupFormHandler is used to associate


PaymentGroups with the various Order pieces. This component is used during the Order
checkout process, and any Order successfully processed by the PaymentGroupFormHandler is
ready for the next checkout phase, which may be confirmation.

CommitOderFormHandler -- The CommitOrderFormHandler is used to submit the Order for


final confirmation. This calls the OrderManager's processOrder method. If there are no errors
with processing the Order, then the current Order in the user's ShoppingCart will be set to null
and the submitted Order will become the ShoppingCart's last Order.

CancelOderFormHandler -- The CancelOrderFormHandler is used to cancel the user's current


Order, which deletes the Order from the ShoppingCart.

RepositoryFromHandler -- Saves repository data to a database.

ProfileFormHandler -- Connects forms with user profiles stored in a profile repository.

SearchFormHandler -- Specifies properties available to a search engine.

SimpleSQLFormHandler -- Works with form data that is stored in a SQL database.

SOME OOB DROPLETS:


Compare (/atg/dynamo/droplet/Compare) -- The Compare servlet bean takes two objects as input
parameters and conditionally renders one of its open parameters, based on the relative values of the input
parameters. For all non-number properties, the comparison is accomplished by casting the two objects
tojava.lang.Comparable and calling Comparable.compareTo(). A comparison must involve properties
that share the same data type, unless those properties are instances of java.lang.Number

CurrencyFormatter (/atg/dynamo/droplet/CurrencyFormatter) --
TheCurrencyFormatter servlet bean takes a numeric value and displays that value as a currency amount,
formatting it based on the locale. The formatting includes the currency symbol, the placement of the symbol, and the
delimiters used. For example, if the value passed in is 20000, and the locale is en_US, the servlet bean formats the
value as $20,000.00; if the locale is de_DE, the servlet bean formats the value as 20.000,00 DM.

ErrorMessageForEach(/atg/dynamo/droplet/ErrorMessageForEach) --
The ErrorMessageForEach servlet bean takes a vector of form exceptions and, for each exception, displays an
appropriate error message. The exceptions are of classatg.droplet.DropletException, or a subclass of this
class. The vector of exceptions can either be passed automatically by the request that produces the exceptions, or
specified explicitly using the exception’s input parameter. For example, any form handler of
class atg.droplet.GenericFormHandler (or a subclass of this class) has a property
named formExceptions which is a vector of the exceptions that occurred while processing the form. To pass
these exceptions to the ErrorMessageForEach servlet bean, you can use a tag like this:
<dsp:param name="exceptions" bean="MyFormHandler.formExceptions"/>

For (/atg/dynamo/droplet/For) -- The For servlet bean implements a simple loop.


Given an integer parameter howMany, the For servlet bean renders its output parameter
that many times. The howMany parameter must be a String representation of an int.
Each iteration sets the index parameter to the current loop count, starting at 0, and sets
the count parameter to index + 1, starting at 1.
ForEach (/atg/dynamo/droplet/ForEach) -- The ForEach servlet bean renders a listing of elements specified
by the array parameter in the order you specify. The array parameter can be a Collection (Vector, List, or Set),
Enumeration, Iterator, Map, Dictionary, or array.
There are three input parameters that are not described below because there is a more favorable
method for accomplishing their tasks:

 elementName and indexName let you provide a parameter name other


than element and index, respectively.
 reverseOrder permits you to decide whether items should be counted in their natural
order or the reverse. Use the sortProperties input parameter instead.

IsEmpty (/atg/dynamo/droplet/IsEmpty) -- The IsEmpty servlet bean


conditionally renders one of its open parameters based on the value of its value input
parameter. If value is null or if the object is empty, then the output parameter true is
rendered. Otherwise, the output parameter false is rendered.
IsNull (/atg/dynamo/droplet/IsNull) -- The IsNull servlet bean conditionally
renders one of its open parameters based on the value of its value input parameter. If
value is null, then the output parameter true is rendered. Otherwise, the output
parameter false is rendered.
Range (/atg/dynamo/droplet/Range) -- The Range servlet bean is similar to the
ForEach servlet bean, except that it enables you to render a subset of the output array,
rather than the entire array. Range renders its output parameter for each element in its
array parameter, beginning with the array element that corresponds to the start
parameter and continuing until it has rendered a number of elements equal to the
howMany parameter. The array parameter can be a Collection (Vector, List, or Set),
Iterator, Enumeration, Map, Dictionary, or array.
Redirect (/atg/dynamo/droplet/Redirect) -- The Redirect servlet bean takes a full
or relative URL and redirects the user to the specified page. When the Redirect servlet
bean is invoked, the second page displays in response
RQLQueryForEach (/atg/dynamo/droplet/RQLQueryForEach) -- The
RQLQueryForEach servlet bean executes a RQL query and renders its output open
parameter once for each element returned by the query. The query can be a simple
query or can include parameters. Note that the syntax for specifying a parameter is
different from the syntax normally used in RQL.
Switch (/atg/dynamo/droplet/Switch) -- The Switch servlet bean conditionally
renders one of its open parameters based on the value of its value input parameter. This
value is turned into a string and used as the name of the parameter to render for this
case. You can use Switch to compare two dynamically defined values by setting the name
of one of your open parameters to one value and the Switch servlet bean’s value
parameter to the other

Basics of Repository API


Any E-commerce application needs a front end to display user, source code to manage why/what/ how we display
content to user and also takes care of what to do with the data entered by the user.

Data base layer can be of any type, it can be LDAP, SQL or File System Connector. When ever there is a change in
these DB selection, to avoid source code or java changes ATG introduced a concept called Data any where
architecture, which is also known as ATG Repository API.

In Short, A Repository API is a data access layer that defines a generic representation of a data store.
A data store may contain many diverse types of objects. The repository is not the data store
itself; instead, it is a collection of Java Beans whose properties can be found and stored in the
data store.

With the ATG Data Anywhere, the application logic created by developers uses the same
approach to interact with data regardless of the source of that data. One of the most powerful
aspects of this architecture is that the source of the data is hidden behind the ATG Repository
abstraction. It is easy to change from a relational data source to an LDAP directory as none of
the application logic needs to change. After data is retrieved from a data source, it is
transformed into an object-oriented representation. Manipulation of the data can be done
using simple getPropertyValueand setPropertyValue methods.

The ATG Data Anywhere Architecture offers several advantages over the standard data access
methods such as Java Data Objects (JDO), Enterprise Java Beans (EJB), and Java Database Connectivity (JDBC).

•Data Source independence


•Fewer lines of java code
•Unified view of all data
•Simplified transaction control
•Integration with other ATG product suites
•Maximum performance
•Fine-grained access control

The following Repository models exist in ATG :

– SQL Repositories - use ATG’s Generic SQL Adapter (GSA) connector to perform a mapping between ATG and data stored in a SQL
database. can be used to access content, user profiles, application security information, and more.

– SQL Profile Repository - included in the ATG Personalization module. Uses the Generic SQL Adapter connector to perform a
mapping for user data contained in a SQL database.

– LDAP Repository - Uses the Dynamo LDAP connector to access user data in an LDAP directory.

– Composite Repository - provides a means for using more than one data store as the source for a single repository.

– Versioned Repositories - an extension of the GSA used in ATG Publishing.

Repository Architecture
The repository provides a mechanism to retrieve the data elements, and creates a run-time representation of the
available metadata for each object. This goal is achieved through three main conceptual parts of the Repository API:

1. Repository Items
A repository is a collection of repository items. A repository item is a JavaBean component
that implements atg.repository.RepositoryItem or one of its sub-interfaces, and corresponds to the
smallest uniquely identifiable entity in the underlying data store. In the SQL repository, for example, a repository
item often corresponds roughly to a row in a table.

Properties:

Each repository item is composed of named properties that store the item’s data—for example, id, firstName,
and lastName. In the SQL repository, these properties generally correspond to table columns.

2. Item Descriptors

Each repository item belongs to an item type that is defined by a Repository item descriptor. An item
descriptor implements the atg.repository.RepositoryItemDescriptor interface and can
subclassatg.repository.ItemDescriptorImpl. An item descriptor provides the following information:

 The item type’s name


 Item type properties
 The class of the Java object used to represent the item type—for example, Integer or String

Repository item descriptors depend on a combination of the underlying data store and the configuration of the
repository.

3. Repository Queries
All repositories have the ability to execute queries. A query is a request to find all items of a particular item
type that fits a certain set of criteria. Those criteria are specified in terms of the item type’s properties.
The Repository API can express a wide variety of queries, including queries that match patterns in text, query through
collections, or even query through complex values. Queries can also specify the order in which to return results, and
can specify which results from a large result set to return.
Queries can be built and executed with the Repository API. For complex queries, this can be a tedious task. In these
cases, or in cases where the Repository API should not be used directly, queries can be represented in a textual form
called Repository Query Language (RQL).

Elements Of Repository API

Mutable Repository
•The base interfaces of a repository define an immutable data store. It provides a read-only version of the elements contained
in the repository.

•Mutable Repository is extension of the Repository interfaces that provide facilities to create, update, and remove items from a
repository

Elements of Repository API

•atg.repository.Repository
–This interface provides methods to access RepositoryItems, RepositoryViews and ItemDescriptors corresponding to the
three main elements of the repository

•atg.repository.RepositoryView
–RepositoryView can be used to search for items in repository when you don’t have an exact repository ID
–Item descriptors and RepositoryViews often have a one-to-one relationship and often have the same name
–viewNames property of the Repository component gives the list of views available for the Repository
–Default View returns all items of the Repository which can be accessed by defaultViewName property
•atg.repository.RepositoryItem
–The atg.repository.RepositoryItem interface is the immutable interface that represents an element from a repository. Each
RepositoryItem is uniquely identified through its repositoryId property
–The ItemDescriptor that describes the dynamic bean info about the item is available through the ItemDescriptor property
–getPropertyValue(String pPropertyName) method can be used to retrieve the attributes of the RepositoryItem
•atg.repository.MutableRepository
–createItem
•createItem(String pDescriptorName)
•createItem(String pId, String pDescriptorName).
–addItem
•RepositoryItem addItem(MutableRepositoryItem pItem)
–removeItem
•removeItem(String pId, String pDescriptorName)
–updateItem
•Fetch a mutable version of the repository item through the getItemForUpdate and getItemsForUpdate methods. These
methods return instances of MutableRepositoryItem. This interface extends RepositoryItem
–setPropertyValue(String pPropertyName, Object pPropertyValue)
•Use the setPropertyValue method of MutableRepositoryItem to change as many properties as you wish. These changes will not be
reflected in the repository until the final updateItem operation is invoked.
•Save the changes with the updateItem method. This method extracts all the changes required for the item and updates the item in
the data store. Depending on how you have configured transactional behavior, the update can be committed immediately, or
the update may happen automatically when the associated transaction commits

SQL Repository Data Models

SQL Repository Data Models in ATG

• The ATG Dynamo SQL repository can be used to connect ATG applications to a SQL database
• The SQL repository is implemented through the atg.adapter.gsa package. (GSA stands for "Generic SQL Adapter")
• The main Dynamo component in the SQL repository is an instance of the atg.adapter.gsa.GSARepository class, which
implements the interfaces atg.repository.MutableRepository and atg.repository.content.ContentRepository and which
extends the class atg.repository.RepositoryImpl
• Whenever you need to create a new SQL repository instance, you should instantiate the
atg.adapter.gsa.GSARepository class

Repository setup steps


Step1: Create a Repository Definition File
• This template is an XML file that defines repository item descriptors and their attributes, and describes the
relationship of your SQL repository to the SQL database. While the SQL repository can represent a variety of data
models, it cannot easily represent any arbitrary data model. Thus, it is usually a good idea to design the SQL
repository schema before you design your SQL database schema.
Step2: Create a SQL Repository Component
• This component’s “definitionFiles” property points to the repository definition file.
Step3: Set up Database Tables
• Can add tables in the same table space as ATG Platform tables or different
• ATG provides a tool to create database tables based on repositories:
startSQLRepository –outputSQL

Data Types in Definition file of ATG, SQL data type and Java object mappings are shown in below table:

data-type Java Object Type Recommended SQL Data Type


Attribute
Value

String String VARCHAR


VARCHAR or CLOB (Oracle)

big string String LONG VARCHAR or CLOB

Date java.util.Date DATETIME (Sybase or MS)


DATE (DB2 or Oracle)

timestamp java.sql.Timestamp DATETIME (Sybase or MS)


DATE (Oracle 8i)
TIMESTAMP (DB2 or Oracle 9i)

enumerated String INTEGER

boolean Boolean NUMERIC(1)

Int Integer INTEGER

Byte Byte INTEGER

Binary byte[] LONG VARBINARY (Sybase or MS)


LONG RAW or BLOB (Oracle)
BLOB (DB2)

Short Short INTEGER


SMALLINT (DB2)

Float Float FLOAT (DB2, Sybase or MS)


NUMBER (Oracle)
Double Double DOUBLE (DB2, Sybase or MS)
NUMBER (Oracle)

Long Long NUMERIC(19), BIGINT (DB2)

Table Types in ATG Repositories:


An item descriptor in an SQL repository defines a repository item type. It specifies
repository item properties and the database tables and columns that store the data of those
properties. Item descriptor can have different types of tables, they are:
1. Primary
2. Auxiliary
3. Multi

Primary Table:

• Each item descriptor must have one and only one primary table.
• The primary table is specified using the type="primary" XML attribute in a <table> tag.
• The primary table must define a column or columns that store the repository ID.
• This column is specified using the id-column-names attribute.
<table name="user" type="primary" id-column-name="id">

properties...

</table>
• Use “id-column-names” if the primary keys are more than one.

Auxiliary Table:
• To specify a relationship of one to one, we will use auxiliary tables. The Auxiliary table is specified using the
type="auxiliary" XML attribute in a <table> tag.
• Example: Each user has a single address. For the purposes of this example, the user information is stored in a
separate table from the user’s address information.
• The columns in the id-column-names attribute of auxiliary table must be listed in the same order as they are in the
id-column-names attribute of the primary table.
<item-descriptor name="user">

<table name="dps_user" type="primary" id-column-names="id">

<property name="login" data-type="string"/>

</table>
<table name="dps_address" type="auxiliary" id-column-names="id">

<property name="address1"/>

<property name="city"/>

<property name="state"/>

<property name="zip"/>

</table>

</item-descriptor>

Multi Table:
• To specify a relationship of many to one, many to many we will use auxiliary tables.
• The Multi table is specified using the type="multi" XML attribute in a <table> tag.
• The multi-column-name attribute ensures that the ordering of the multi-values are maintained. The column
specified by the multi-column-name attribute is used for multi-valued properties of data type array, map, and list and
is not used for sets (which are unordered). For map type properties, the values in the column specified by the multi-
column-name attribute must be a string. For list or array type properties, these values should be an integer or
numeric type, and must be sequential.
• As with auxiliary tables, the ordering of the ID column names is important. The columns specified by this attribute
must list table columns in the same order as the id-column-names attribute of the primary table.
• The <property> tag for a multi-valued property sets the following attributes:
data-type is set to One of the following: array,set,map,list
For example:
<property ... data-type="array" ..
component-data-type is set to A primitive data type such as int, string, etc..
SQL repository does not support references to binary types
For example:
<property name="interests" column-name="interest" data-type="array" component-data-type="string"/>
component-item-type is set to The item descriptor name of the referenced repository items
For example:
<property name="..." column-name="designers" data-type="array"
component-item-type="user"/>

By default, null values are not allowed in multi-valued properties. You can specify to allow
null values at two levels:

• Enable all multi-valued properties in a repository to accept null values by setting the repository property
allowNullValues to true
• Allow null values for an individual property by setting its <property> tag attribute allowNullValues to true

In general, auxiliary and multi tables should not have REFERENCES constraints that point to
each other. Instead, each of these tables can have a REFERENCES constraint that points to the
primary table for the repository item. This limitation exists because the SQL repository processes
insert and delete statements for auxiliary and multi tables in the same order. As a result, if you
specify REFERENCES constraints between an auxiliary and a multi table or vice versa, a
constraint error results on the insert or the delete.

Best Practices
•Define primary key of table as String or Long

•Avoid using multiple primary keys to a table (Not more than 1)

•Incase we need to have composite primary key which has more than 1 key, Add a new id column as part of the primary key

•Identify strong and week relationships and represent accordingly

•Normalize the data model and introduce redundancy where ever is required

•Highly normalized data model kills the performance

Repository Cache Modes in ATG Commerce

Efficient database access is important to many ATG applications. You should design an
application so it requires minimal access to the data base and ensures data integrity. An
intelligent caching strategy is central to achieving these goals.

Item Caches & Query Caches


For each item descriptor, an SQL repository generally maintains two caches:
 Item Caches
 Query Caches

Item Caches

Item caches hold the values of repository items, indexed by repository IDs. An item cache entry is invalidated
when that item is updated. The scope of an entry’s invalidation depends on its caching mode.
Query Caches

Query caches hold the repository IDs of items that match given queries. When a query returns repository items whose
item descriptor enables query caching, the result set is cached as follows:
 The query cache stores the repository IDs.
 The item cache stores the corresponding repository items.
A query cache entry can be invalidated for two reasons:

 A cached item property that was specified in the original query is modified.
 Items of a queried item type are added to or removed from the repository.
If query caching is enabled, the first time this query is issued, the result set is retrieved from the database and stored
in the query cache. Then, the next time this same query is issued, the SQL repository can retrieve the result set from
the cache, rather than needing to access the database.

Cache Modes
The SQL repository implements several different modes of caching. Which mode is to be chosen depends on the
nature of your Dynamo application. We can set the default caching mode on each item descriptor in a repository.
Each property’s definition can override the cache mode of its item-descriptor.
The caching modes implemented in the SQL repository are:
• No Caching (disabled)
When caching is disabled for an item, its property values are cached only during the current transaction, and only if
the transaction requires one or more of that item’s properties. This ensures a consistent view of item data while the
transaction is in progress. Thus, multiple calls to getPropertyValue() for the same property within the same
transaction require only one database query. Cached item properties are reloaded from the datastore for each
transaction.
• Inherited
You can set a property to inherit the default caching mode by setting its cache-mode attribute to inherit. This setting
can be useful when a property’s caching mode is set to disabled at one point in the configuration path and you want to
reset the property to the default caching mode at a later point.
• Simple Caching (caching is handled separately in each VM, with no invalidation events to synchronize updates
from different server instances).
A server obtains changes to an item’s persistent state only after the cached entry for that item is invalidated. This
mode is suitable for read-only repositories such as product catalogs, where changes are confined to a staging server,
and for architectures where only one server handles a given repository item type.
• Locked Caching (read and write locks are used to synchronize the caches)
A multi-server application might require locked caching, where only one ATG instance at a time has write access to
the cached data of a given item type. You can use locked caching to prevent multiple servers from trying to update the
same item simultaneously.
Prerequisites
Locked caching has the following prerequisites:
 Item descriptors that specify locked caching must disable query caching by setting their query-cache-size attribute
to 0.
 A repository with item descriptors that use locked caching must be configured to use a ClientLockManager
component; otherwise, caching is disabled for those item descriptors. The repository’s lockManager property is set to
a component of type atg.service.lockmanager.ClientLockManager
 At least one ClientLockManager on each ATG instance where repositories participate in locked caching must be
configured to use ServerLockManager.
 A ServerLockManager component must be configured to manage the locks among participating ATG instances.
• Distributed Caching (caching with cache invalidation events) types of distributed caching are
a. Distributed TCP caching (uses TCP to broadcast cache invalidation events to all servers )
b. Distributed JMS caching (uses JMS to broadcast cache invalidation events to all servers )
c. Distributed hybrid caching (uses Both)
Distributed TCP
The following requirements apply:
Real-time access to item changes
Infrequent updates to cached items
Modest number of item caches to monitor
Distributed JMS
The following requirements apply:
Reliable delivery of invalidation messages
Infrequent updates to cached items
Large number of item caches to monitor
Distributed hybrid
The following requirements apply:
Real-time access to item changes
Large number of cached items to monitor across many clients
Infrequent updates to cached items
By default, the SQL repository uses simple caching. To enable a different cache mode for an item descriptor, set the
cache-mode attribute in the <item-descriptor> tag of the repository definition file:
<item-descriptor name="profile" cache-mode="locked">

Repository Query API


• All repositories have the ability to execute queries
• Queries can be built and executed using the Repository API.
• Queries can be represented in a textual form called Repository Query Language (RQL)
• The basic elements of Repository Query API
1. atg.repository.QueryBuilder : an interface
2. atg.repository.QueryOptions : a class
QueryBuilder interface defines the available query operations that repositories support. The QueryBuilder interface
enables you to build Query objects that can be passed to the repository. A Query is constructed from
QueryExpressions. Each Query relates one or more QueryExpressions and a query operation. Queries can use
standard logical query operations such as AND, OR, NOT, EQUALS, GREATER THAN, LESS THAN OR EQUALS,
and more complicated query operations such as collection inclusion, and pattern matching.
 Query Creation Example
– Given a RepositoryView, we initialize a QueryBuilder for it:
QueryBuilder b = view.getQueryBuilder();
– Next, create a QueryExpression for the gender property and QueryExpression for the constant
female:
QueryExpression female = b.createConstantQueryExpression ("female");
– Create a ComparisonQuery that incorporates the gender and femaleQueryExpressions:
Query femaleQuery = b.createComparisonQuery(gender, female,
QueryBuilder.EQUALS);
– Pass the resulting Query to the RepositoryView for execution:
items = view.executeQuery(femaleQuery);
• The QueryOptions class to specify the ways it can be modified.
– RepositoryItem[] executeQuery(Query equerry, QueryOptions pQueryOptions);

SAMPLE QUERY BUILDER CODE:


MutableRepository pRepository =
(MutableRepository)ServletUtil.getCurrentRequest().resolveName("/atg/userprof
iling/ProfileAdapterRepository");
RepositoryItemDescriptor userDesc = pRepository.getItemDescriptor("user");
RepositoryView userView = userDesc.getRepositoryView();
QueryBuilder userBuilder = userView.getQueryBuilder();
QueryExpression userType =
userBuilder.createPropertyQueryExpression("userType");
QueryExpression two = userBuilder.createConstantQueryExpression(new
Integer(2));
Query userTypeIsTwo = userBuilder.createComparisonQuery(userType, two,
QueryBuilder.EQUALS);
RepositoryItem[] answer = userView.executeQuery(userTypeIsTwo);
System.out.println("running query: userType = 2");
if (answer == null)
{
System.out.println("no items were found");
}
else
{
for (int i=0; i<answer.length; i++)
System.out.println("id: " + answer[i].getRepositoryId());
}
userType < 2 AND login STARTS WITH "j"

RQL in ATG (Repository Query Language)

ATG’s Repository Query Language, or RQL, is a generic language for formulating


queries that map to any repository implementation, such as SQL or LDAP. The
repository connectors translate those queries into a syntax that the underlying data
store understands.

Advantages of RQL over SQL


• Not specific to databases, can be used with any supported data source
• Understands relationships between repository items
• Higher level than SQL
• Designed to support more than just relational databases
• A generic language for formulating queries

Repository Query Language


We can use RQL in several different ways:
1. RQL servlet beans
2. RQL filter

3. Include RQL queries in <query-items> tags in the XML repository definition file mainly
used for unit testing queries

4. Use RQL directly by creating an atg.repository.rql.RqlStatement object. Get an RqlQuery object


from the RqlStatement object, and in turn get an atg.repository.Query object from the RqlQuery
object. This approach can be simpler than using the QueryBuilder class to create the Query
object.

All of the standard comparison operators can be used, as well as logical operators like
AND, OR, and NOT

 Collection Queries
Use the INCLUDES, INCLUDES ANY, or INCLUDES ALL operators only for
querying multi- valued properties

 Includes Item Queries


repositories support properties that are arrays or collections of items belonging to
another (or the same) item descriptor

 Is Null Queries
Seeing whether an expression evaluates to null should be done with an IS NULL
query. For example

 Count Expressions
COUNT (addresses) > 3

 Full Text Search Queries


firstName MATCHES "abr “

 ID-based Queries
ID IN { ["dept2", "emp345"], ["dept2", "emp346"], ["dept2", "emp347"] }

 Order By Directives
age > 30 ORDER BY firstName SORT ASC CASE IGNORECASE

 Range Directives
age > 30 RANGE 40+10
 Parameterized Field Queries

name = ?0.name AND age = ?0.age

RQL JAVA Examples


RepositoryView view = repository.getView ("person");
RqlStatement statement = RqlStatement.parseRqlStatement ("age > ?0");
Object params[] = new Object[1];
params[0] = new Integer(23);
RepositoryItem [] items =statement.executeQuery (view, params);

Here is another example that demonstrates a text comparison query:

RqlStatement statement = RqlStatement.parseRqlStatement("lastName STARTS WITH


?0");
Object params[] ={new String ("m")};
items = statement.executeQuery (view, params);)

Catalogs in ATG and How to extend them

•The Product catalog is the foremost component in a Commerce Application.


•The product catalog is a collection of repository items (categories, products, media, skus etc.) that provides the
organizational framework for a commerce site.
•ATG Commerce includes a default catalog implementation, based on the Dynamo SQL Repository, that can be used as
it is or extended as necessary.
•ATG Control Center, or ATG business control center allows editing and creation of Repository items for a catalog.
Product catalog stores all the catalog related objects. Full path of product repository is
atg/commerce/catalog/ProductCatalog
The structure of ATG Commerce catalogs and the various catalog-related objects, includes
– Catalogs
– Categories
– Products
– SKUs
- Media related objects
Product Catalog Repository Item Types: Linking is shown below

Catalogs: Catalogs are a container for a navigational structure made up of categories. Catalogs can
contain links to subcatalogs and to categories.

Categories: Categories have properties that link them to other categories and to products. They can also
link to other catalogs.
Products : Products have properties that link them to other products and to SKUs (stock-keeping
units).Contain links for text and images used to describe a group
of SKUs

SKU : is the actual unit that is shipped to the user, Pricing is generally done at SKU level. A product can have several
different SKUs associated with it, representing varieties, sizes, and colors.

Categories do not, “contain” products, nor do products “contain” SKUs. Rather, the objects are peers that are linked
together through their various properties

Extending the Catalog


There are multiple ways to extend the catalog:
– Add properties to an existing item type
– Remove or modify properties of an existing item type
– Create a subtype of an existing item type
– Create a new item type

User Profile in ATG


A user profile is a set of attributes that represent the data you want to store for a site user, for example login name,
password, e-mail address, registration date, and so on. ATG applications use profile repositories to manage user
profiles.

When a user starts a session on an ATG server, a new profile object is created. The profile object starts off empty if
anonymous. If the user logs in, the information stored about that user in the Profile Repository is loaded into the
profile object on the server. From this point onward, changes to the profile object will be saved in the Profile
Repository at designated times.

The profile object may contain information gathered before the user logged in, and this information is merged while
the login is done based on the requirements.

GROUP USERS:

There are two ways to group USERS for personalization:


– Profile Repository
Profile Repository uses "organization" item descriptor to group "user". Each user can belong to one and only one
organization. can link an user to organization using BCC or by scenarios.
(for Detailed explanation of SCENARIOS click here)
– Segments
User segments become read only boolean properties of a profile. Users can be in any number of segments.
Store application can use one or both the approaches depending on the requirements

Customizations to Profile:
A profile can be customized in N number of ways.

- can extend oob item descriptor


- can create a new item type
- can customize to include a new payment method like loyal points
- can customize components related to profile like wishlist, giftlist, saved carts, price lists etc..

ATG Slots, Scenarios, Targeters

Targeter determines which content to show to individual customers (personalized view).


Slots function as a placeholder in JSP pages where the customized content to be showed.
Scenario links between slots and Targeters.

In Detail:
When a customer accesses a JSP page that has slot, that slot requests content. The Slot calls a scenario which contains
rules that tells which Targeter to run. Targeter determines the appropriate content for the customer. The Scenario
returns the content to the JSP page and the slot is populate.

Guidelines for usage of scenarios and Targeters (or) scenarios Vs


Targeters:
If you want to personalize content as a result of a site visitor’s doing something specific (for example, logging in), use
a scenario. In simple scenario is event based whereas Targeter is not.
If you need to set up highly complex rules to match content to visitors, use targeters.If you want to set up a long-term
approach to content and visitor management, use scenarios.

WishList and GiftLists in ATG

Both WishList and GiftList in ATG is implemented using gift list repository in ATG.

Primary differences between wish list and gift list are explained
below:

Wish list for a user is nothing but list of his favorite items. User can store his favorite items for his future purchases.
Gift list for a user is explained in the below example:
Say user is having his wedding on some date, and he is interested in getting some particular things as gifts, then he
will populate giftlist and share it with different other users in our application.

WISHLIST GIFTLIST
User is associated with only one wishlist. There can be ‘N ’ number of lists associated with user
Wishlist is Private to the User. And only user can Giftlist can be made public or private based on the
purchase items from his wish list interest of the user. Only public list can be shared to
other users. Other users can purchase items for the
owner of that list.
Wishlist will not have any shipping address associated Giftlist will have a shipping address associated with it.
with it.
By default a wishlist is created for ATG user User has to create his giftLists
Public Giftlists of others can be viewed using
‘OtherGiftlists’

Giftlist Repository:

The Giftlists repository is the layer between Oracle ATG Web Commerce and the database itself. It provides an
interface to the database layer to persist gift list information. The Giftlists repository uses the SQL Repository
implementation. The Giftlists repository is defined in the giftlists.xml definition file, located in the
Commerce configuration path at /atg/commerce/gifts/. This XML file defines item descriptors for gift lists
and gift list items.

Gift List Form Handlers:

The /atg/commerce/gifts/GiftlistFormHandler accepts input from the customer to create, update and
delete gift lists, as well as to add items to and remove items from gift lists. Properties in the handler are used to store
user input for processing, as well as to store success and failure URLs for redirect after processing. Some handle
methods have pre- and post- methods defined to make it easier to extend the methods.

The /atg/commerce/gifts/GiftlistSearch form handler searches the repository for gift lists. The form
handler uses input from the customer, such as owner name, event name, event type and state, to find gift lists
published by other customers.

ATG Scheduler

If the Dynamo application want to perform a task at regular intervals of time or a period of time it
includes a scheduler service (atg.service.scheduler.Scheduler) which executes the appropriate services
at specified times.
Dynamo also includes
a SingletonSchedulableService,atg.service.scheduler.SingletonSchedulab
leService, which enables multiple Dynamo servers to run the same scheduled service, while
guaranteeing that only one instance of the service performs the scheduled task at a time. This provides
some protection from server failures, as the loss of one Dynamo server does not prevent the scheduled
service from running on another Dynamo server.

Scheduling a Task in ATG:


In order to schedule a task, a component needs a pointer to the Scheduler, which is usually set as a
component property. The component schedules a new task by calling addScheduledJob on the
Scheduler. The Scheduler executes the job as scheduled.
When the Scheduler executes a job, it calls performScheduledTask on the object that performs
the task, which must implementatg.service.scheduler.Schedulable. Typically, the
component that schedules the task is also the Schedulable component that executes it, but this is
not strictly required.
When a component schedules a task, it must provide the Scheduler with the following information:
 A name for the scheduled job; used only for display to the administrator.
 The name of the component scheduling the job; used only for display to the administrator.
 The Schedulable object that handles the job; typically, the same as the component that schedules
the job.
 A flag that indicates how to run the job:
o In a separate thread.
o In the same thread as other scheduled services.
o In a dedicated, reusable thread.
If a job runs in the same thread as other services, no other scheduled services can run until the job
finishes. If the job is long and expensive, it should run in a separate thread. If the job is short, it should
run in the same thread. The Schedulethat indicates when the job should run. This is specified as an
object that implements atg.service.scheduler.Schedule. The scheduler package
provides a set of useful Schedule types, including schedules that represent an event at a specific time,
schedules that represent periodic events, and schedules that represent events based on the calendar—
for example, on the 1st and 15th of every month. Usually the Schedule is passed in as a property. All
of this information is encapsulated in a ScheduledJob object, which is passed to the
Scheduler’saddScheduledJob()method.When a job is added to the Scheduler, the Scheduler
returns an integer job ID, which you can later use to reference that job. For example, to stop a scheduled
job, you can call removeScheduledJob on the Scheduler, passing in the ID of the job to stop.

To make sure that your task starts automatically with dynamo Start :
Add your component to one of the inital arrays in an Initial component.
In initial.properties add your scheduler component created to initialServices property.

If you want to run the schedulers manually you can do it from dyn/admin.

Example Scheduler:

ATG Rest WebServices Introduction


The ATG REST Web Services provide access to Nucleus components. The Oracle ATG Web Commerce
platform REST Web Services expose methods that get component data and get and set component
property values. You cannot use the Oracle ATG Web Commerce platform REST Web Services to delete
components.
REST Web Services exposes data and function resources through the use of Uniform Resource
Identifiers (URIs). These resources are used within simple, well-defined operations. HTTP methods are
used by the REST services to point to a resource. Each HTTP request returns an HTTP response, which
indicates the status of the operation. The application that receives the request identifies the format of
the response, which is JSON or XML. REST clients may be accessed from any browser, and security can
be configured for each call.

The application path for REST URLs, which is the portion of the URL that follows the hostname and
port number, starts with /rest/. The REST MVC framework uses /model.The Legacy REST framework
uses /bean, /repository or /service, depending on the component used.

For example:
http://servername:port/rest/model/atg/commerce/order/purchase/CartMo
difierActor/addItemToOrder

HTTP requests and responses are the way that the ATG REST Web Services communicate. The
following HTTP methods are used and supported by ATG REST Web Services:

Method Explanation
Use this method to return data.
Examples of the values you may get are repository item and Nucleus
GET
component property values, RQL query results, repository items, and
Nucleus components.
Use this method to invoke functionality or make changes to your Oracle
ATG Web Commerce platform server.
POST
For example, you may invoke methods, update Nucleus component
properties, and create repository items.
(Legacy REST Only) Use this method to make changes to your Oracle
ATG Web Commerce platform server.
PUT
For example, you may update repository item and Nucleus component
property values.
DELETE (Legacy REST Only) Use this method to remove repository items.

Returning Data
ATG REST Web Services returns the results of operations that you perform in an HTTP response
message body. The output data can be returned in either JavaScript Object Notation (JSON) or
eXtensible Markup Language (XML) format.

Enabling REST Services:

After adding the REST module to current module list in CIM follow the steps given in
integration-of-atg-with-rest-webservices

When using REST services, you want to prevent the processing of malicious site requests. Oracle ATG
Web Commerce platform uses a request parameter_dynSessConf, which contains a session
confirmation number, to verify that a request is legitimate. For further information on session
confirmation numbers, and the warnings that occur if the request is not legitimate

Actor Types
The REST MVC API’s modular and extensible functionality is based on actors, which uses a number of
different types of actors to perform a variety of functions.
The atg.service.actor.Actor interface contains the following actor types that perform
specific actions or provide configurations.

 Component Actor – You use this actor to set component property values or invoke methods on
a component, or to read component property values
 Droplet Actor – Use this actor when you want to invoke droplets and output data from the
droplet to the ModelMap. Inputs are mapped to the dropletinput parameter. Other types of
actors can be nested in the oparamparameter of a DropletActor
 Form Actor – Use this actor to set up form handler inputs and submit a form
 JSP Actor – This actor invokes a JSP page and adds the JSP response or JSP-defined variables
to the ModelMap
 Nested Actor – These actors allow you to invoke actor-chains from within other actor-chains,
helping to define modular units of work that can be combined and extended.
 Variable Actor – The VarActor enables you to set variables in the actor context

Bean Filtering

The BeanFilterService filters the properties of a java bean or repository item and converts beans
into a map of properties. The BeanFilterService reads XML definition files that define which
properties of a Java class or repository item should be included in the filtered view of the object. The
XML definitions include ways to remap property names and transform properties.
By default, the BeanFilterService is applied to the ModelMap by the REST MVC framework
before generating a JSON or XML response. However, you can filter objects at any time. For example,
you can use the BeanFilterService as aComponentActor to filter a repository item before
adding it to the ModelMap.

Key Constituents Of Ecommerce

ATG Market Presence


Creating new ATG module with Merchandizing / ATG BCC
setup for new module
Step 1:
Create two domains with two ports associated. Let’s take dshop, dbcc for example. And set
protocol.jar file in “classpath” of startWeblogic.cmd file in both the domains. (Refer previous
post for how to create a new domain)
Step 2:
Create Database Users. (Refer previous post for how to Create Database Users using Oracle and
sql developer).
Creating users using MySQL:
i. create database dshop;

ii. CREATE USER 'PROD'@'localhost' IDENTIFIED BY 'PROD';


iii. grant all on *.* to 'PROD'@'localhost';

iv. CREATE USER 'PUB'@'localhost' IDENTIFIED BY 'PUB';


v. grant all on *.* to 'PUB'@'localhost';

vi. CREATE USER 'A'@'localhost' IDENTIFIED BY 'A';


vii. grant all on *.* to 'A'@'localhost';

viii. CREATE USER 'B'@'localhost' IDENTIFIED BY 'B';


ix. grant all on *.* to 'B'@'localhost';
Step 3:
i. Run “startWeblogic.cmd” file in both the domains.
ii. Run cim.bat which is located in<<ATG_DIR>>\home\bin\cim.bat
iii. Create schemas required.
Step 4:
i. In eclipse, create a new ATG module (say MyShop) under ATG installation path.
ii. Fill in all the details and proceed. (Refer previous post for creating new ATG module )
iii. Create Data Sources Properties files for shop.
As we are using switching data sources we have to give the bellow configurations.

iv. in /atg/dynamo/service/jdbc folder


JTDataSource.properties must point to production (core) datasource,
DirectJTDataSourcemust point to production (core) datasource,
SwitchingDataSourceAmust point to DataSourceA,
SwitchingDataSourceBmust point to DataSourceB.

In ProductCatalog.properties, PriceLists.properties, SiteRepository.propertiesthe dataSource


should be pointed toSwitchingDataSource(in case of switching data base otherwise no need of
these properties files.)

v. Edit Manifest.MF with ATG-Required property.


Manifest-Version: 1.0
ATG-Config-Path: config/
ATG-Required: DAS DCS DPS PublishingAgent
ATG-J2EE: j2ee-apps/kshop
ATG-EAR-Module: j2ee-apps/kshop
ATG-Class-Path: bin

vi. Edit build.xml as required for application assembly.

vii. Create a new folder “Versioned” inside your new module (MyShop/Versioned).

viii. Create config folder inside (MyShop/Versioned).


Configurations must be as following:

ix. in /atg/dynamo/service/jdbc folder


JTDataSource.properties must point to publishing datasource,
DirectJTDataSourcemust point to publishing datasource,
SwitchingDataSourceA must point to DataSourceA,
SwitchingDataSourceB must point to DataSourceB.

In ProductCatalog.properties, PriceLists.properties, SiteRepository.properties the dataSource


should be pointed topublishing(in case of switching data base otherwise no need of these
properties files.)

In DirectJTDataSource_production.properties, change JNDIname to core(prod) data source


In other xxxxxx_production.properties, change data source to switching datasource.

x. Create Manifest.MF file in (MyShop/Versioned). Edit it as shown below.


xi. Edit build.xml to include another target for versioned
(<arg line=" -m DafEar.Admin MyShop MyShop.Versioned" />)

xii. After build, once BCC server is up with no errors, if we are not able to open bcc page, we need
to do the below things:
a. In <ATG-DIR>/home/localconfig/atg/dynamo/service/jdbc/ (create one if you don’t find it!)
folder
create new files FakeXADataSource.properties and JTDataSource.properties.
In FakeXADataSource.properties, add below lines:
$class=atg.service.jdbc.FakeXADataSource
URL=jdbc:oracle:thin:@localhost:1521/xe
user=publishing_username
password=publishing_password
driver=oracle.jdbc.xa.client.OracleXADataSource(driver class)
In JTDataSource.properties, add below lines
$class=atg.service.jdbc.MonitoredDataSource
dataSource=/atg/dynamo/service/jdbc/FakeXADataSource

b. Run <ATG-DIR>/BIZUI/install/importBizui.bat

NOTE: While running, if you get any SQLExceptions w.r.t drivers, we should add
CLASSPATH with driver(ojdbc14.jar) path and add the path(path to ojdbc14.jar) to
PATH variable.

Posted by Sirisha Dhanekula at 05:17:00

Thursday, 14 November 2013 changing priceInfo.currencyCode value in atg,How to configure


Currency Code for Price Info in ATG 2 comments

How to configure Currency Code for Price Info in ATG /


changing priceInfo.currencyCode value in atg

PricingTools Determine the Pricing Locale. PricingTools returns the


configureddefaultLocale property. The pricing engines use this to determine the currency
code. If you are using Oracle ATG Web Commerce’s multisite feature and want to use different
currency codes for different sites, you can take the following steps:

1. Add a pricing locale to the Site repository items.


2. Override the PricingTools.getDefaultLocale method to retrieve the currency code
for the site

Instaed of overriding PricingTools.getDefaultLocale method what you can also


do is:

1. Create the following folder structure


2. In PricingTools.properties add the bellow property, build and verify.

defaultLocale = <<your desired locale>>

eg: defaultLocale = en_IN (for india) this locale will return currency code as INR.

FOR ANY QUERIES KINDLY POST A COMMENT.

Posted by Sirisha Dhanekula at 08:16:00

Thursday, 14 November 2013 Products Not Getting Displayed for Anonymous user in ATG, Products
Not Getting Displayed in ATG 0 comments
Products Not Getting Displayed in ATG / Products Not Getting
Displayed for Anonymous user in ATG
If you are not able to see the products in the module you created in ATG or Products Not Getting
Displayed and no error is there in your server console then:

Probably this might be because of null value in the default catalog in the profile when it is
getting created. to overcome this:

1. Create folder Structure similar to the following

2. In CatalogTools.properties add

defaultCatalogId=<<Some catalogId you have already created>>

eg: defaultCatalogId=catalog20004

Build and check the output. This will help.

FOR ANY CLARIFICATIONS KINDLY POST A COMMENT.

Posted by Sirisha Dhanekula at 06:41:00

Thursday, 14 November 2013 How to add a Sku to cart, How to display products and skus in
ATG, How to display Sku images, ProductLookUp droplet,SKUlookUp Droplet 1 comments

How to display products and skus in ATG, How to add a Sku to


cart, How to display Sku images
After Creating New ATG MODULE,( Refer Previous Post Here)

Use the Following Out Of the BOX Atg droplets to display. Code Snippet is as shown bellow:

<%@ taglib uri="http://www.atg.com/taglibs/daf/dspjspTaglib1_0" prefix="dsp" %>


<dsp:importbean bean="/atg/userprofiling/Profile" var="Profile"/>
<dsp:page>
<dsp:droplet name="/atg/dynamo/droplet/ForEach">

<dsp:param name="array" bean="/atg/userprofiling/Profile.catalog.allRootCategories" />


<dsp:param name="elementName" value="category" />
<dsp:oparam name="output">
<br/>

<dsp:a href="categoryNavigation.jsp">

<dsp:valueof param="category.displayName" />

<dsp:param name="categoryId" param="category.id" />

</dsp:a>

</dsp:oparam>

</dsp:droplet>

</dsp:page>
categoryNavigation.jsp:

<%@ taglib uri="http://www.atg.com/taglibs/daf/dspjspTaglib1_0" prefix="dsp" %>


<dsp:page>
<dsp:droplet name="/atg/commerce/catalog/CategoryLookup">

<dsp:param name="id" param="categoryId" />

<dsp:param name="elementName" value="category" />

<dsp:oparam name="output">
<dsp:droplet name="/atg/dynamo/droplet/ForEach">

<dsp:param name="array" param="category.childCategories" />

<dsp:param name="elementName" value="category" />

<dsp:oparam name="output">

<br />

<dsp:a href="categoryNavigation.jsp">

<dsp:valueof param="category.displayName" />

<dsp:param name="categoryId" param="category.id" />


</dsp:a>

</dsp:oparam>

</dsp:droplet>

<dsp:droplet name="/atg/dynamo/droplet/ForEach">

<dsp:param name="array" param="category.childProducts" />

<dsp:param name="elementName" value="childProduct" />

<dsp:oparam name="output">
<ul>
<br />
<dsp:valueof param="childProduct.id" />
<dsp:valueof param="childProduct.displayName" />
<dsp:valueof param="childProduct.childSKUs" />
<dsp:droplet name="/atg/dynamo/droplet/ForEach">
<dsp:param name="array" param="childProduct.childSKUs" />
<dsp:param name="elementName" value="childSKU" />
<dsp:oparam name="output">
<li> <dsp:valueof param="childSKU.id" />
<dsp:valueof param="childSKU.displayName" />
<dsp:valueof param="childSKU.listPrice" />
<img src='/walletshop<dsp:valueof param="childSKU.largeImage.url"/>'/>
<dsp:form id="addSku" action="categoryNavigation.jsp">
<dsp:input
bean="/atg/commerce/order/purchase/CartModifierFormHandler.addItemCount" value="1"
type="hidden"/>
<dsp:input
bean="/atg/commerce/order/purchase/CartModifierFormHandler.addItemToOrderSuccessURL"
value="/walletshop/catagrydisplay.jsp" type="hidden"/>
<dsp:input
bean="/atg/commerce/order/purchase/CartModifierFormHandler.addItemToOrderErrorURL"
value="/walletshop/errors.jsp" type="hidden"/>
<dsp:input
bean="/atg/commerce/order/purchase/CartModifierFormHandler.items[0].productId"
paramvalue="childProduct.id" type="hidden"/>
<dsp:input
bean="/atg/commerce/order/purchase/CartModifierFormHandler.items[0].quantity"
type="hidden" value="1" />
<dsp:input
bean="/atg/commerce/order/purchase/CartModifierFormHandler.items[0].catalogRefId"
paramvalue="childSKU.id" type="hidden" />
<dsp:input
bean="/atg/commerce/order/purchase/CartModifierFormHandler.pageFlow" value="true"
type="hidden" />
<dsp:input
bean="/atg/commerce/order/purchase/CartModifierFormHandler.addItemToOrder" value="add"
type="hidden"/>
<input type="submit" value="Submit"/>
</dsp:form>

</li>
</dsp:oparam>
</dsp:droplet>
</ul>
</dsp:oparam>

</dsp:droplet>

</dsp:oparam>

</dsp:droplet>
</dsp:page>

THE FORM IN THE categoryNavigation.jsp IS TO ADD ITEM TO CART.

Posted by Sirisha Dhanekula at 06:19:00

Tuesday, 13 August 2013 ATG Scheduler, Example ATG Scheduler,Scheduling a Task in ATG 0 comments
ATG Scheduler

If the Dynamo application want to perform a task at regular intervals of time or a period of time it includes a
scheduler service (atg.service.scheduler.Scheduler) which executes the appropriate services at specified times.
Dynamo also includes
a SingletonSchedulableService,atg.service.scheduler.SingletonSchedulableService,
which enables multiple Dynamo servers to run the same scheduled service, while guaranteeing that only one instance
of the service performs the scheduled task at a time. This provides some protection from server failures, as the loss of
one Dynamo server does not prevent the scheduled service from running on another Dynamo server.
Scheduling a Task in ATG:
In order to schedule a task, a component needs a pointer to the Scheduler, which is usually set as a component
property. The component schedules a new task by calling addScheduledJob on the Scheduler. The Scheduler
executes the job as scheduled.
When the Scheduler executes a job, it calls performScheduledTask on the object that performs the task, which
must implementatg.service.scheduler.Schedulable. Typically, the component that schedules the task
is also the Schedulable component that executes it, but this is not strictly required.
When a component schedules a task, it must provide the Scheduler with the following information:
 A name for the scheduled job; used only for display to the administrator.
 The name of the component scheduling the job; used only for display to the administrator.
 The Schedulable object that handles the job; typically, the same as the component that schedules the job.
 A flag that indicates how to run the job:
o In a separate thread.
o In the same thread as other scheduled services.
o In a dedicated, reusable thread.
If a job runs in the same thread as other services, no other scheduled services can run until the job finishes. If the job
is long and expensive, it should run in a separate thread. If the job is short, it should run in the same thread.
The Schedulethat indicates when the job should run. This is specified as an object that
implements atg.service.scheduler.Schedule. The scheduler package provides a set of
useful Schedule types, including schedules that represent an event at a specific time, schedules that represent
periodic events, and schedules that represent events based on the calendar—for example, on the 1st and 15th of every
month. Usually the Schedule is passed in as a property. All of this information is encapsulated in
a ScheduledJob object, which is passed to the Scheduler’saddScheduledJob()method.When a job is added
to the Scheduler, the Scheduler returns an integer job ID, which you can later use to reference that job. For example,
to stop a scheduled job, you can call removeScheduledJob on the Scheduler, passing in the ID of the job to stop.

To make sure that your task starts automatically with dynamo Start :
Add your component to one of the inital arrays in an Initial component.
In initial.properties add your scheduler component created to initialServices property.

If you want to run the schedulers manually you can do it from dyn/admin.

Example Scheduler:

S-ar putea să vă placă și