+ All Categories
Home > Documents > ATG Framework

ATG Framework

Date post: 08-Mar-2015
Category:
Upload: rangachary-srinivasan
View: 2,527 times
Download: 3 times
Share this document with a friend
139
1 ATG Relationship Management Platform (formely Dynamo e- Business Platform) R.Srinivasan Vamsoft
Transcript
Page 1: ATG Framework

1

ATG Relationship Management Platform (formely Dynamo e-

Business Platform)

R.Srinivasan

Vamsoft

Page 2: ATG Framework

2

ATG Platform

• The ATG Platform and its suite of products is a flexible, Java-based development environment for building personalized applications for the Web and other communication channels (e-mail messaging, wireless devices, etc.).

• The platform and its related products, include Dynamo Application Server, ATG Portal, ATG Commerce, ATG Content Administration, and the ATG Control Center.

Page 3: ATG Framework

3

ATG Platform

Application Server

Dynamo Application Framework

ATG Personalization + ATG Scenarios

ATGPortal

ATGCommerce

ATGPublishing

ATG Merchandising

ATG CSC

OutReachCampaignOptimizer

KnowledgeResponse

Management

ACIATG

Search

ATGRecommendations

Page 4: ATG Framework

4

• The ATG Platform includes the following core components:

• DAF - Dynamo Application Framework • DPS - ATG Personalization Module• DSS – ATG Scenarios Module

ATG Platform

Page 5: ATG Framework

5

• The Dynamo Application Framework (DAF) runs on top of our application server and supplies essential facilities for application development and deployment viz., – Nucleus– Repositories– Tag libraries– Droplets & FormHandlers

• This portable framework is designed to run on the industry’s leading J2EE application servers, like JBoss, IBM WebSphere and Oracle WebLogic.

ATG Platform

Page 6: ATG Framework

6

• The Personalization module (DPS) provides tools for visitor profiling and content targeting, enabling to deliver personalized content to customers according to their characteristics and preferences.

• The Scenarios module (DSS) adds advanced scenario-based personalization features to the ATG Platform. Using the scenario editor, business managers can design, test, and fine-tune customer management scenarios that track and respond to customer behavior. Business processes can be exposed as workflows. Data analysis and reporting tools, including ready-made business chart templates, are available for charting scenario data.

ATG Platform

Page 7: ATG Framework

7

Add-on Products• ATG Portal provides a customizable framework

for building personalized Web portals for specific user communities.

• A manufacturing company, for example, might create separate portals for employees, customers, and partners, each providing access to different content and services. The Portal Application Framework (PAF) is the infrastructure developers use to create and administer portals and the individual gears that render content and features (a stock ticker or discussion forum, for example) within portal pages. ATG Portal comes with a set of page template and baseline gears that you can use for your own portals.

Page 8: ATG Framework

8

• ATG Commerce includes everything we need to build and manage personalized ecommerce Web sites. ATG Consumer Commerce provides business-to-consumer (B2C) storefront development features -- product catalog management, pricing, inventory, customer service, etc.

• ATG Business Commerce adds support for business-to-business (B2B) transactions, including B2B payment methods (purchase orders, requisitions), account-specific product catalogs and price lists, multiple shipping/billing addresses, etc.

Add-on Products

Page 9: ATG Framework

9

• ATG Content Administration (earlier known as ATG Publishing) provides a streamlined system for modifying and deploying content on your site.

• The system keeps track of multiple versions of publishable assets (scenarios or catalog items, for example) within specific publishing projects.

• Using the workflow editor, you can define how each project moves through the various stages of the publishing process: content creation, editing, check-in, approval, QA and deployment on the live site.

Add-on Products

Page 10: ATG Framework

10

Additional Applications

• ATG Merchandising application runs on top of ATG Publishing and ATG Commerce and give the Commerce Business users a way of creating and maintaining versioned content of various items like ProductCatalog, Personalization targeters etc.,

• ATG CSC (Commere Service Center) is a web based application that also integrates a ticketing system, which can be used by the Commerce Call center agents to manage customers, Orders etc., ATG Knowledge and Response Management accumulates and provides CRM related information.

• ATG Outreach and Campaign Optimizer are used by the marketing people to create promotions, scenarios etc., to track visitor behaviour and tune the commerce system.

Page 11: ATG Framework

11

• Finally, the ATG Control Center (ACC) is the integrated user interface for the ATG Relationship Management Platform and its supported products.

• The ACC provides application developers, page designers, site administrators, business managers, and other members of your project team with point-and-click access to the tools they need for building and maintaining ATG applications

Page 12: ATG Framework

12

Facilities Supplied by DAF

• The ATG Platform is supported by a foundation layer called the Dynamo Application Framework (DAF), which runs on top of our application server.

• Our application server handles tasks such as session management, load balancing, clustering, and SNMP monitoring.

• DAF supplies additional facilities for application development and deployment, including:

Page 13: ATG Framework

13

Nucleus• Nucleus is the central registry for the JavaBeans

that contain our application-level logic. • It creates and configures Dynamo components

and organizes them into a hierarchical namespace so they can be referenced by other components.

• By reading the various configuration files associated with each component, Nucleus figures out what components to use in an application, what their initial properties are, and how they connect to each other.

• Nucleus, thus allows developers to build applications in a component-oriented manner.

Facilities Supplied by DAF

Page 14: ATG Framework

14

• Nucleus is the mechanism that creates and configures new components, then gives those components a place to "live" so they can be found by other components.

• In Nucleus, every component has a unique name, allowing components to refer to each other. Components are organized into a hierarchy, similar to a file system. This results in component names such as /atg/dynamo/service/Scheduler and gives Nucleus the ability to resolve relative names, such as ../service/Scheduler. Furthermore, Nucleus components are JavaBeans, affording all the advantages of the JavaBean standard.

Page 15: ATG Framework

15

• The Pages and Components task area in the ATG Control Center shows all of the components currently registered in Nucleus (by module or by path) and provides templates to help we create new ones, either from existing Dynamo classes or our own Java classes.

• When it comes to configuring components for our application, we can use the built-in Component Editor to specify initialization parameters and the way the components link together. The ACC creates the necessary configuration files automatically.

• DAF also provides a Web-based component browser, as part of the Dynamo Administration interface, that we can use to examine and modify components in a running Nucleus application.

Page 16: ATG Framework

16

Tag libraries • Originally the presentation language used by the

framework was JHTML. There are lots of custom tags provided in JHTML to access the dynamo components.

• With JSP becoming the defacto presentation language for java, the framework provides the DSP tag library to access Nucleus components and render dynamic content from our JavaServer Pages (JSPs).

• Earlier DAF also contained a Core tag library for tags for flow control, manipulating data and handling transactions which has been now deprecated in favour of the JSTL core tag library.

Facilities Supplied by DAF

Page 17: ATG Framework

17

Dynamo Servlet Beans• Dynamo Servlet Beans are specialized Nucleus

components that can be embedded in our JSPs to display dynamic content.

• Using Dynamo Servlet Beans minimizes the amount of Java code that has to appear in HTML and the amount of HTML that has to be hard-coded into Java classes and also enables the developer to take a “Dispatcher View” approach of MVC2 Design pattern.

• As a result, Java programmers and page designers can work independently and applications are easier to maintain.

• DAF comes with a set of ready-made Dynamo Servlet Beans that you can use in your pages.

Facilities Supplied by DAF

Page 18: ATG Framework

18

Form Handlers• Form handlers are specialized Nucleus components

that can be embedded in our JSPs to do form validation and based on the results do certain actions like inserting into database, forwarding the user to some other JSP page etc.,

• Using Form Handlers is the way to achieve “Service To Workers” approach of MVC2 design pattern.

• DAF comes with a set of ready-made Form handlers like ProfileFormHandler, ShoppingCartModifier etc., that we can use in your pages either directly or customize them using the extension points given.

Facilities Supplied by DAF

Page 19: ATG Framework

19

Repository API• The Repository API (atg.repository.*) is a data

access layer that defines a generic representation of a data store.

• Whenever ATG applications needs to load, store, or query a data store, they make the appropriate calls through this API. The API then accesses the underlying data storage device, translating the API calls into whatever calls are needed to access that particular data store.

Facilities Supplied by DAF

Page 20: ATG Framework

20

• Implementations of the Repository API exist to access data stores such as relational databases, LDAP systems, and content management systems.

• In addition, the Composite Repository feature enables us to consolidate multiple data sources and make them available to our application as a single, queryable repository.

• The Secured Repository Adapter provides fine-grained access control to repository item descriptors, individual repository items, and even individual properties through the use of Access Control Lists (ACLs).

Page 21: ATG Framework

21

Component-centric Development Model

Page 22: ATG Framework

22

• This Framework is totally a component-centric development platform. The Dynamo Web applications you create are assembled out of individual JavaBean components, which are configured and linked together by .properties files within Nucleus, Dynamo’s open object framework.

• Nucleus is the core of the entire Dynamo system. It creates and configures Dynamo components (also called beans and JavaBeans) and organizes them into a hierarchical namespace, essentially giving them a place to “live” so they can be referenced by other components.

• By reading the .properties files associated with each component, Nucleus figures out which components to use in an application, what their initial properties are, and how they connect to each other.

• This model makes it possible for us to build Dynamo applications by configuring pre-built components instead of writing a lot of Java code from scratch.

Page 23: ATG Framework

23

WHAT IS A COMPONENT?• Components are pre-developed pieces of application code

that can be assembled into working application systems.• In Short, A Building Block.• A Component Can Be Designed To Manage Simple

Functionality Or Even A Very Big Module..• Components Will Be Put Inside A Construct Called As

Container To Make Them Work. The Container Provides the Application Context(or The Environment) And Provides Management And Control Services For These Components. Client Components Will Normally Be A Web Form Or An Applet Whereas Server Components Are Non-visual And Will Be Executed Inside Web Servers ,TP Monitors Etc.,

• A Component Has To Strictly Adhere To The Standard Component Model.

Page 24: ATG Framework

24

COMPONENT MODELComponent Model:• defines the basic architecture of a component, specifying the

structure of its interfaces and the mechanisms by which it interacts with the container and other components.

• Provides guidelines to create & implement components that can work together to form a larger application.

GUIDELINESGranularity : a component can be very small or even

complex.Standard Interface : the component must provide a

standard interface that will enable other components to access its properties and methods.

Customization without much refactoring : Application developer must be able to change the properties & behaviour of a component without going thro’ its source code.

Page 25: ATG Framework

25

COMPONENT ARCHITECTURE• Practice of delivering solutions by

building/buying interoperable components.

• Components need not necessarily be objects. They can be any program functionality.

• Components can be used for managing GUI functionality or even server-side functionality.

Page 26: ATG Framework

26

COMPONENT ARCHITECTURE

EXAMPLES OF COMPONENT ARCHITECTURE

• COM/DCOM• JAVA BEANS• CORBA COMPONENTS

Page 27: ATG Framework

27

ADVANTAGES

• Code reusability• Reduced development time• Container independent• Entire application behaviour can be

changed by modifying one/some of the components (applicable to J2EE)

Page 28: ATG Framework

28

ADVANTAGES• Makes application development more cost

effective by reducing the time to market.• Reusing components improves the quality

of the application since the components would have been exhaustively tested and debugged before being released in the market.

• Also reusing components means the developers can concentrate on newer areas than doing the same chores.

Page 29: ATG Framework

29

ADVANTAGES

• Components will allow you to adapt and reconfigure your work processes and deliverables without requiring wholesale replacement and restructuring of your IT

environment. • The use of components enables the

continuous, incremental and successful improvements, which quite often yield revolutionary results.

Page 30: ATG Framework

30

What is a component in ATG?

• A public java class with appropriate properties with set/get methods.

• A acompanying .properties file specifying the class name and the scope and also any default values.

• The properties file will also contain any dependency injections of other components.

• The .properties file must be under the CONFIGPATH of the ATG.

• The name of the component is the full path name of the .properties file under the configpath starting with a “/”. For example, /com/vam/firstbean.

• CONFIGPATH variable is computed dynamically during startup based on the modules started, their order of startup and based on the entry in the MANIFEST.MF file of every module started.

Page 31: ATG Framework

31

Dynamo Model Vs. J2EE

Operating System

JVM (DAS)

Nucleus (ContainingComponents,repositories etc)

JHTML with Custom Tags

Operating System

JVM (J2EE ApplicationServer)

Web Container(ContainsJava beans, Tag handlers etc)

JSP Pages

Original Dynamo Model of Development

J2EE Model of development

Page 32: ATG Framework

32

DAF Model Today

Operating System

JVM (J2EE ApplicationServer)

Web Container

Nucleus (ContainingComponents,repositories etc)

DSP Tag Library

Web Application (JSP)

Page 33: ATG Framework

33

Design Patterns followed in DAF

MVC2 in a Dispatcher View Strategy

MVC2 in a Service To Workers Strategy

Dependency Injection or IoC (Inversion Of Control

More details about this available in Appendix

Page 34: ATG Framework

34

Separation between page Development and Application Development - the ATG way

Page 35: ATG Framework

35

MAKING JSP EXTENSIBLE

• Use Java Beans to separate the Business content from the presentation content and reuse the code.

• Define custom tags and a tag library for the oft-used functionalities.

Page 36: ATG Framework

36

JSP Design Basics• Aim in web application design must be to

separate logic and presentation. Based on this, there are two approaches to JSP design:

• Page-Centric or client-serverPage-Centric or client-server : in this type, requests are made directly to the JSP page that produces response.

• Dispatcher or n-tierDispatcher or n-tier : Request is initially made to a JSP or a servlet that acts as a mediator or controller, dispatching requests to a JSP pages and JavaBeans as appropriate.

Page 37: ATG Framework

37

Page-Centric or Client-Server

Browser

Browser

JSP or servletsclient requests are

interceptedhere

EJBjava beans dB

Request/

response

Page 38: ATG Framework

38

Characteristics of page-centric design

• JSP/servlets access enterprise resources like EJBs directly and generate responses by themselves.

• Simple to program and allows the page author to generate the dynamic content easily and based upon the request and state of resources.

• But scalability is not there and manageability is difficult because it ends up bundling too much of java code within a JSP page especially if the JSP pages are maintained by the designers.

• There are two variants of this model.• Page viewPage view• page-view with beanpage-view with bean

Page 39: ATG Framework

39

Page view

• this approach is easy to get started.• All java code will be embedded within HTML.• Trade-off is as the business logic grows the

pages go out of control and also there is very little reusability.

JSPBusiness

processing

request

response

Page 40: ATG Framework

40

Page view with Bean

• this architecture is used when page view becomes too much cluttered with Business logic.

• The java code is relegated to a worker bean leaving the JSP clean and maintainable by the designers.

• JSP can be modified without affecting the Business logic

JSPWorker

BeanBusiness

processing

request

response

Page 41: ATG Framework

41

• Consequences of the single-page approach– Heavy HTML and Java coupling– The coder of the JSP file must be both a page designer

and a Java developer. The result is often either terrible Java code or an ugly page, or sometimes both.

– Java and JavaScript blur– As the pages become larger, there can be a tendency to

implement some JavaScript. When the JavaScript appears in a page, the script can get confused with the Java code. An example of a possible point of confusion is using client-side JavaScript to validate the email field.

Embedded flow logic– To understand the entire flow of the application, you

have to navigate all of the pages. Imagine the spaghetti logic on a 100-page Web site.

Page 42: ATG Framework

42

Debugging difficulties– In addition to being ugly to look at, HTML tags, Java

code, and JavaScript code all in one page makes it difficult to debug problems.

– Tight coupling– Changes to business logic or data means possibly

touching every page involved.

Aesthetics – Visually, in large pages, this type of coding looks messy.

When doing Microsoft ASP development, you would commonly see 1000-line pages. Even with syntax coloring, it is still difficult to read and understand.

Page 43: ATG Framework

43

• A JSP tag is simply a way of abstracting out code from a JSP file. Some people think of JSP tags as macros for JSP files, where the code for the tag is contained in the servlet. (The macro perspective is almost true.) we do not want to see HTML tags in Java code, and also Java code in a JSP file. The entire point of JSP technology is to allow the page designer to create servlets without being distracted with Java code. Tags allow Java programmers to extend JSP files by making Java code look like HTML.

Page 44: ATG Framework

44

• JSP tags require a container that runs JSP 1.1 or later.

• JSP tags run on the server and are not interpreted by the client like HTML tags are.

• JSP tags provide proper code re-use.

Page 45: ATG Framework

45

MODELEncapsulates application state

Responds to state queriesExposes application functionality

Notifies views of the changes

VIEWRenders the models

Requests update from modelsSends user gestures to controller

Allow controller to select view

CONTROLLERDefines application behaviuor

Maps user actions to model updatesSelects view for response

5. Query the state

4. Change notification

2. User gestures

View

selection

3. State change

Method callsEvents

1. Register as an observer

MVC Architecture

Page 46: ATG Framework

46

• Model– The model encapsulates the state of the application. It

knows nothing about the view or controller.

• View– The view provides the presentation of the model. It is

the look of the application. The view can access the model getters, but it has no knowledge of the setters. The view should be notified when changes to the model occur.

Controller– The controller reacts to the user input. It creates and

sets the model.

Model-View-Controller (MVC)

Page 47: ATG Framework

47

• For the Web, the classical form of MVC cannot be applied. So a Web adaptation of MVC, also commonly known as Model 2 or MVC2 has been brought in.

• The Web brought some unique challenges to software developers, most notably the stateless connection between the client and the server. This stateless behavior made it difficult for the model to notify the view of changes. On the Web, the browser has to re-query the server to discover modification to the state of the application.

MVC2 / Model2

Page 48: ATG Framework

48

MVC2 / Model2

• A JSP or a Servlet will act as a mediator or controller, delegating the requests to other components like JSP or Java Beans. The View will be another JSP.

• There are two design patterns that can be followed to apply MVC2 :

Mediator-View/Dispatcher-View (a Mediator-View/Dispatcher-View (a pull based MVC)pull based MVC)

service to workers (a push based service to workers (a push based MVC)MVC)

Page 49: ATG Framework

49

Dispatcher-View

Controller PresentationJSP

Workerbean

Business Layer (may

Be EJBs)request

Simple valueJava Beans

1. populates3. Uses/re-populates

2. Forward the

controlRenders response

Page 50: ATG Framework

50

• Mediator works with a presentation JSP page and a worker bean to fulfil a service request.

• The mediator initially handles the request and delegates it to a JSP/bean combination.

• The presentation JSP populates the bean properties from the request parameters and then uses the bean to prepare the data for presentation.

Dispatcher-View

Page 51: ATG Framework

51

Service To Workers

Controller Servlet1.request

JSP7. response

workers

EJBs

db

delegate

Javabean Business

Layer

5. Returns the presentation JSP name

3.execute

6.forward

2.populate

4.Business call

3. Uses/re-populates

Page 52: ATG Framework

52

• The mediating Servlet handles the request from the client.

• Initial delegation point is a worker bean that processes our business data and data access code.

• After the worker bean has completed its responsibility of populating the intermediate model for the JSP, the mediating component dispatches to the JSP to generate the presentation.

• This architecture provides a cleaner separation between the view and the controller

Service To Workers

Page 53: ATG Framework

53

IoC or Dependency Injection• Another important benefit of the dynamo framework is

that it uses the Dependency Injection or the Inversion of Control design pattern.

• This facilitates the developers to concentrate on the business logic coding rather than the infrastructure coding.

• The Container is responsible for tying up the necessary components and make it available as and when our application required the same.

• Every component will have a dedicated .propeties file to enable the developer to specify the necessary dependencacies.

Page 54: ATG Framework

54

IoC or Dependency Injection• What is it?

– A way of sorting out dependencies between objects and automatically “injecting” references to collaborating objects on demand

• Who determines how the objects should be injected?

– The IoC framework, usually via configuration files• Benefits

– Removes the responsibility of finding or creating dependent objects and moves it into configuration

– Reduces coupling between implementation objects and encourages interface based design

– Allows an application to be reconfigured outside of code

– Can encourage writing testable components

Page 55: ATG Framework

55

• Inversion of Control (IoC) is a design pattern that addresses a component's dependency resolution, configuration and lifecycle.

• IoC is also relevant to simple classes, not just components. • The most significant aspect to IoC is dependency resolution

and most of the discussion surrounding IoC dwells solely on that.

• Simply put, a component designed according to IoC does not go off and get other components that it needs in order to do its job.

• It instead declares these dependencies, and the container supplies them. Thus the name IoC/DIP/Hollywood Principle. The control of the dependencies for a given component is inverted.

• It is no longer the component itself that establishes its own dependencies, but something on the outside.

• That something could be a container like dynamo, but could easily be normal code instantiating the component in an embedded sense.

Page 56: ATG Framework

56

Traditional way of obtaining references

public void service(… ) throws .. {

DataSource ds=new InitialContext().lookup(“dynamo:/atg/dynamo/service/jdbc/MyDS”);

Connection conn=ds.getConnection();

…..

Page 57: ATG Framework

57

Dynamo way of obtaining references

private DataSource dataSource;public void setDataSource(DataSource ds)public void setDataSource(DataSource ds){{dataSource=ds; //setter InjectiondataSource=ds; //setter Injection}}…public void service(… ) throws .. {Connection conn=dataSource.getConnection();…..• The .properties file will look like

$class=somepkg.someclass

dataSource=/atg/dynamo/service/jdbc/sqlPoolFakeXA

Page 58: ATG Framework

58

• Linking Property Values• In a system containing many components, it is not usual for several

components to be initialized with the same property values. • If we configure the values independently, this can lead to confusion for

the administrator if the value is changed in one component, but not changed in the other components.

• So we want the Nucleus to link one property value to the value of another

• property in another service.• To do this, append a “^” to the name of the property you want to set. • For the value, enter the component name and property name whose

value is to be copied into this property.• For example if there is a second bean whose age property is dependent

on firstbean age property, then the properties file of second bean will look like this,where firstbean is a nucleus name relative to secondbean.

$class=vam.secondbeanage^=firstbean.age

• Note : The ^ character must come right after the age name without any intervening white space, otherwise it will not be set.

Page 59: ATG Framework

59

Questions to Ponder?• What is the role of META-INF\MANIFEST.MF in

setting up the module dependencies?• What are the steps in creating a component in ATG?• What is the effect of layering the .properties file in

ATG?• What is the default location of our java classes in ATG?• What care must be taken when layering .properties file

that contain multi-value properties?• What are the various attributes that <dsp:valueof can

take?• When changes will get reflected when the .properties

file of a global component is changed?• Can one java class me made into multiple components?

Page 60: ATG Framework

60

Droplets

Page 61: ATG Framework

61

• Write a java class extending the atg.servlet.DynamoServlet class.

• Override the service() method and provide the logic there.• Identify the appropriate Input parameters that can be

passed to droplet and the OPARAMS the droplet will render and also the various output parameters the droplet will set in the request.

• Write the BeanInfo class and define all the necessary parameters in that.

• Make the droplet into a component using the ATG Component Browser.

• Embed the droplet in a JSP page using the <dsp:droplet ..> tag and pass the necessary parameters.

• Us the OPARAM tags to mix the HTML content and the dynamic values returned by the droplet.

Steps in writing a Droplet

Page 62: ATG Framework

62

Form Handlers

Page 63: ATG Framework

63

Form Handling

• Many Web applications obtain information from users by having them fill out 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.

• Through the use of special attributes, we can use JSP pages to associate HTML form tags to the properties of Nucleus components:

Page 64: ATG Framework

64

– A page can automatically display the current value of a Nucleus component’s property as the default value in a form element.

– When a form is submitted, the values that the user enters can be used to set the values of component properties. A single form can set any number of properties in any number of Nucleus components.

– Forms can be made to interact directly with a SQL database. Information a user submits can be stored in a database, or used to query a database for information to display.

– When a form is submitted, the form input elements can trigger actions in the application.

Page 65: ATG Framework

65

Form Handlers• 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.

Page 66: ATG Framework

66

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

Page 67: ATG Framework

67

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

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

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

• propertyExceptionspropertyExceptions : 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.

Page 68: ATG Framework

68

• ATG Relationship Management Platform includes the following form handler classes: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. You can also extend these and other form handler classes to handle the specific needs of your application.

Page 69: ATG Framework

69

Steps in writing a FormHandler

• Create a java class extending the atg.droplet.GenericFormHandler base class.

• Provide the appropriate handleXXX methods. Each Handler method will be triggered by a corresponding dsp:input submit button from the JSP page.

• Provide either a Map data structure to hold the form data or provide individual fields with appropriate set/get methods.

• Write the validation logic inside the handler methods and return appropriate boolean codes.

• Populate validation errors, if any, into the formExceptions Vector or proceed to do the business logic.

• Forward the user to the appropriate success URL.

Page 70: ATG Framework

70

CORE DYNAMO SERVICES

Page 71: ATG Framework

71

• Dynamo comes with a host of Dynamo Foundation Classes that can be used as Nucleus components. Because these classes provide functionality that is generally useful across many applications, these classes are often called servicesservices.

• Like all Dynamo components, these Dynamo Foundation Classes are created and configured through configuration files (properties files, most often) in the Nucleus configuration tree.

• Some services are meant to be used by multiple applications, and are thus instantiated once in a well-known place. For example, the Scheduler service is used by many applications, and is instantiated as part of the standard Dynamo configuration.

• Other services are instantiated and configured differently for different applications, sometimes creating many instances for the same application. And finally, other services are not instantiated at all, but instead are extended by subclasses, which should then be instantiated.

Page 72: ATG Framework

72

• Scheduler ServiceScheduler Service– Most server-side applications have tasks that need to

be performed on a periodic or recurring basis. – For example, a component in the application may

need to clear a cache every 10 minutes, or send out e-mail at 2AM every morning, or rotate a set of log files on the first of every month. Dynamo includes a Scheduler service, atg.service.scheduler.Scheduler, which keeps track of scheduled tasks and executes the appropriate services at specified times.

– Administrators can see a list of all scheduled tasks by looking up /atg/dynamo/service/Scheduler in the Dynamo Component Browser (http://localhost:8830/nucleus/)

Page 73: ATG Framework

73

Scheduling a TaskScheduling a Task• In order for a component to schedule a task, the component

needs a pointer to the Scheduler, which is usually set as a property.

• The component then schedules a new task by calling addScheduledJob on the Scheduler. The Scheduler handles things from there, waiting until the time comes to execute the job.

• When the Scheduler executes a job, it calls performScheduledTask on the object that is supposed to perform the task, which must implement atg.service.scheduler.Schedulable.

• Most often the component that scheduled the task will also be the Schedulable that will handle the task, but this is not strictly required.

• When a component schedules a task, it must specify enough information for the Scheduler to handle the scheduling:

Page 74: ATG Framework

74

• A name for the scheduled job, which is not used except when it is displayed to the administrator.

• The name of the component scheduling the job. Once again, this is not used except for purposes of displaying to the administrator.

• The Schedulable object that will handle the job. Most often this is the same as the component scheduling the job, but need not be the case.

• A flag indicating whether the job should run in a separate thread when its time comes, run in the same thread that all other scheduled services run in, or run in a dedicated, reusable thread.

• If it runs in the same thread, then no other scheduled services can run until that job finishes. If the job is long and expensive, it should run in a separate thread. If the job is short, then it should run in the same thread.

• The Schedule that indicates when the job should run. This is specified as an object that implements atg.service.scheduler.Scheduleatg.service.scheduler.Schedule.

Page 75: ATG Framework

75

• 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 (e.g., 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 addScheduledJob method of the Scheduler.

• When a job is added to the Scheduler, the Scheduler returns a job ID for the job, which is an integer that can later refer to that job.

• For example, to stop a scheduled job, you can call removeScheduledJob on the Scheduler, passing in the ID of the job to be stopped.

• When the Schedulable object is called to perform a task, it is passed the ScheduledJob object that was used to schedule that task. This is useful in the case where a single service is supposed to perform several kinds of scheduled tasks, and needs the properties of the ScheduledJob to determine which task it is supposed to perform.

Page 76: ATG Framework

76

• SCHEDULER_THREADSCHEDULER_THREAD: The Job runs in the Scheduler’s own thread. This is the most efficient mechanism but it blocks the scheduler from performing any other job till this is complete. Use this if the jobs started are not long running. Not suitable for jobs involving I/O operations.

• SEPARATE_THREADSEPARATE_THREAD: Each time the job is triggered, a new thread is created to run the job and the thread is destroyed once the job completes.

• REUSED_THREADREUSED_THREAD: A pool of threads is created for that job and the threads are re-used. Will not block the Scheduler.

Page 77: ATG Framework

77

• The different types of Schedules can also be created programmatically by creating new instances of RelativeSchedule, PeriodicSchedule, or CalendarSchedule.

• RelativeScheduleRelativeSchedule• A RelativeSchedule specifies a time relative to the current

time. For example, the following specifies a task that will occur in 30 seconds:

schedule=in 30 seconds • PeriodicSchedulePeriodicSchedule• A PeriodicSchedule specifies a task that will occur at regular

intervals. There are three parameters for this Schedule. The first is the period between jobs. For example:

schedule=every 20 minutes A second parameter lets you specify a period to wait before

starting the schedule:schedule=every 10 seconds in 20 minutes • This will wait 20 minutes before starting the periodic task.

Once it starts, it executes every 10 seconds.

Page 78: ATG Framework

78

• The third parameter determines whether or not the PeriodicSchedule should attempt to catch up if it misses jobs.

• For example, suppose that the period is 2 seconds. Now assume that the job occurs at time A. Another job should occur at time A+2. But suppose that the Scheduler doesn't get around to handling the job until time A+5.

• This might happen if the polling interval is greater than the job's period (technically, this will occur if the polling interval is greater than half the period).

• The next time it will schedule for the job is A+6, which means that the job at A+4 is missed.

• If the PeriodicSchedule is instructed to catch up, then at time A+5, the job will occur twice, once for A+2, and once for A+4. The next job will occur at A+6.

• If the PeriodicSchedule is instructed not to catch up, then the job that would have occurred at A+4 will be discarded. The following example sets a PeriodicSchedule not to catch up missed jobs:

• schedule=every 10 seconds in 20 minutes without catchup

Page 79: ATG Framework

79

• CalendarScheduleCalendarSchedule• A CalendarSchedule specifies a task that will

occur according to units of the calendar and clock.

• For example, you can schedule a task to occur at 2:30am on the 1st and 15th of every month.

• The format looks like this:schedule=calendar <months> <dates> <days

of week> <occurrences in month> <hours> <minutes>

Page 80: ATG Framework

80

Dynamo Initial Services

startDynamo

NucleusinitialServiceName

/InitialinitialServices

/atg/InitialinitialServices

/atg/dynamo/Initial

/atg/modules/Initial

/atg/commerce/Initial

Other Services

/atg/dynamo/startServers /VMSystem Other Services

Page 81: ATG Framework

81

Starting our components Automatically

• The way to start multiple components during ATG startup is to define a single component that refers to all of the components that must be started, then start that single component.

• Nucleus includes a component called InitialService that exists specifically for this purpose.

• The Nucleus.properties file includes this line:initialServiceName=/Initial

• This refers to the Initial service, which is defined by the Initial.properties configuration file as follows:

$class=atg.nucleus.InitialServiceinitialServices=\/atg/Initial,\VMSystem,\/atg/dynamo/StartServers

Page 82: ATG Framework

82

• SamplerSampler– Once an application has been deployed, monitoring the

state of that application becomes an important task. – In the JavaBeans model, the current state of the

application is usually exposed through properties.– These properties are often read-only, meaning that they

expose only the getX method. – Dynamo provides a Sampler service that you can

configure to monitor a set of component properties. – The Sampler can be instructed to generate periodic

samples of the specified components, or to generate samples of the component on demand.

Page 83: ATG Framework

83

• SecureRandomGeneratorSecureRandomGenerator– Dynamo includes a component you can use to

generate secure random numbers. This component, with a Nucleus address of /atg/dynamo/service/random/SecureRandom, can generate random numbers more efficiently than the Java class, java.security.SecureRandom, since it provides the random number generator with a random seed, rather than using the slower process of Java's SeedGenerator.

Page 84: ATG Framework

84

• IdGeneratorIdGenerator– In many circumstances, a Dynamo application

may need to generate unique identifiers. – For example, each repository item in a

repository needs a unique repository ID, so that the item can be retrieved by its ID.

– The atg.service.idgen package provides an interface and implementations that you can use to generate unique IDs in a variety of ways.

– SQLIdGeneratorSQLIdGenerator– TransientIdGeneratorTransientIdGenerator– ObfuscatedSQLIdGeneratorObfuscatedSQLIdGenerator

Page 85: ATG Framework

85

• ResourcePoolResourcePool– atg.service.resourcepool.ResourcePool – A Base

class for creating our components that can be pooled.

• EmailSenderEmailSender– Dynamo includes a facility for sending e-mail,

and a JavaMail-based implementation for sending Internet e-mail through SMTP. The e-mail interface is called atg.service.email.EmailListener, and the SMTP implementation is called atg.service.email.SMTPEmailSender. Internally, SMTPEmailSender uses JavaMail's SMTP implementation to send the e-mail.

Page 86: ATG Framework

86

Servlet Pipeline

Page 87: ATG Framework

87

• One of Dynamo's most important tasks is handling HTTP requests. In handling these requests, Dynamo uses session tracking, page compilation, Dynamo Server Pages, and other powerful extensions to the basic Web server model.

• Request handling can usually be broken down into a series of independent steps. Each step may depend on additional information being available about the request, so order does matter.

• However, the individual steps are separable. For example, a typical request might go through these steps:

– Examine the incoming cookies to match the request to a session.

– Compare the request URI against a list of restricted directories, to make sure that the user has permission to access the specified directory.

– Translate the request URI into a real file name, taking "index" files into account when the file name refers to a directory.

Page 88: ATG Framework

88

– Given the file name's extension, determine the MIME type of the file.– From the MIME type, dispatch the request to the appropriate

handler.For "text/html" MIME types, handle the request by looking in a cache to see if the file is already in the cache. If so, serve the data from the cache.If the file is not in the cache, read the file from disk and serve it.

• This is only one of many possible request-handling configurations. Other configurations might dispatch based on a beginning path such as /cgi-bin.

• Other configurations might move the session-tracking step to be performed only for files with the MIME type "text/session-tracked."

• In Dynamo, each of these steps is represented by a single Nucleus service that also implements the Servlet interface.

• Every request sent to the Dynamo server is dispatched to the servlet pipeline. The request is delivered to the servlet at the head of the pipeline. Each servlet in turn performs its specific function on the request. Each servlet is also given a pointer to the next servlet in the pipeline.

Page 89: ATG Framework

89

• When a servlet is done acting on the request, it can pass the request to the next servlet. This linked-list of servlets is called the servlet pipeline.

• Treating the request-handling process as a pipeline of independent elements allows request-handling to be treated in a component-oriented manner.

• This allows you to use Nucleus to customize the request-handling process through configurable components, thereby giving you the flexibility that is often required by large applications.

Page 90: ATG Framework

90

• There are two request-handling pipelines used by Dynamo: the DAS servlet pipeline (for JHTML requests) and the DAF servlet pipeline (for JSP requests).

• When a JHTML page is requested, the DAS servlet pipeline runs through the set of servlets appropriate for conditions of the request as would the DAF servlet pipeline for JSP requests.

• Because JHTML is a proprietary language, it relies on the page compiler provided in the DAS servlet pipeline to generate JHTML into a servlet that’s rendered as HTML by the application server.

• Other minor differences exist between the request-handling pipelines, but many of the classes invoked for each are the same.

Page 91: ATG Framework

91

How a request is processed?• A request processed by an application server will follow this

path. • The process described here assumes that you’ve configured

your Web application to use PageFilter and DynamoProxyServlet just as demonstrated in atg_bootstrap.war.

• When a user performs an action that prompts a response, the application server creates an instance of the HttpServletRequest and HttpServletResponse.

• Based on the directories and file extension of the requestURI, the application server uses servlet and filter mappings defined in web.xml to determine the next resource to call.

• By default, PageFilter is mapped to handle JSP requests. When the application server invokes PageFilter, it checks the request and response for a reference to a Dynamo request and response pair.

Page 92: ATG Framework

92

• The pair won’t exist so PageFilter will start the DAF servlet pipeline by calling DynamoHandler, the first servlet in the pipeline.

• The DAF servlet pipeline will process through a series of servlets that modify the request and response by extracting path information and providing session, user, and security information.

• The last servlet in the pipeline is TailPipelineServlet. It is responsible for calling FilterChain.doFilter(), which invokes the next filter defined in web.xml.

• The web application, unless it uses ATG Portal, won’t include other servlet filters by default.

Page 93: ATG Framework

93

• As specified in web.xml, a call for a page in the dyn directory, which holds all JHTML pages, causes the application server to invoke DynamoProxyServlet, the resource responsible for starting the DAS servlet pipeline by calling DynamoHandler.

• The DAS servlet pipeline performs the same request and response handling tasks as the DAF servlet pipeline.

• One task common to both pipelines is the compiling of JHTML pages by PageCompileServlet, one of the servlets in the pipeline.

• By default, no filters are involved in request-handling process; if you create custom servlet filters, they will be invoked before DynamoProxyServlet.

Page 94: ATG Framework

94

DynamoHttpServletRequest & DynamoHttpServletResponse

• One of the functions of the servlet pipeline is to modify a request as it runs through various processing elements.

• For example, one pipeline element might find the file associated with a given pathInfo, and use that file name to set the pathTranslated property of the request.

• ATG provides a class called atg.servlet.DynamoHttpServletRequest. This class implements HttpServletRequest, but also provides methods that allow you to change the properties of the request, such as setPathInfo or setPathTranslated.

• There is also a corresponding atg.servlet.DynamoHttpServletResponse that allows you to change properties of the HttpServletResponse, such as the output stream, and access its values, such as statusCode.

Page 95: ATG Framework

95

• The very first element of the servlet pipeline converts an incoming HttpServletRequest/Response pair into a DynamoHttpServletRequest /Response pair and allows subsequent elements of the servlet pipeline to use the additional functions provided by DynamoHttpServletRequest /Response.

• To access information contained in the request and response in your page, do so by making direct calls to HttpServletRequest and HttpServletResponse.

• When you need Dynamo-specific information held only by the Dynamo request and response, you should import the request or response using the atg.servlet.ServletUtil class.

• For example, to access the state object parameter, your JSP might use this code:

<%= atg.servlet.ServletUtil.getDynamoRequest(request).getObjectParameter("state") %>

• Any references to the Dynamo request and response will be interpreted as calls to the generic HttpServletRequest or HttpServletResponse.

Page 96: ATG Framework

96

Page 97: ATG Framework

97

Components added by B2C

Page 98: ATG Framework

98

Page 99: ATG Framework

99

• CommerceCommandServlet• Class atg.commerce.order.CommerceCommandServlet• Component

/atg/commerce/order/CommerceCommandServlet• CommerceCommandServlet has an actionMap property that

matches actions to the servlets that process those actions.• When a request includes a dcs_action parameter,

CommerceCommandServlet checks the value of the dcs_action, locates the action’s corresponding servlet using actionMap, and calls that servlet.

• For example, if a request attempts to add an item to a user’s cart by URL, the dcs_action will be addItemToCart and the AddItemToCartServlet will be called.

Page 100: ATG Framework

100

• PromotionServlet• Class atg.commerce.promotion.PromotionServlet• Component /atg/commerce/promotion/PromotionServlet• When PromotionServlet is enabled (enabled property set to

true), PromotionServlet scans the requestURI for the PROMO parameter, and when it is present, matches the promotion ID associated to it against the promotion IDs in the promotionItemDescriptorNames property to ensure that the promotion is active.

• When a match is found, PromotionServlet checks to see if the user qualifies for the promotion by examining the Profile RepositoryItem for persistency and the Promotion giveToAnonmousProfiles property for a value of true.

• If either condition is met, PromotionServletadds the promotion ID to the Profile activePromotions property.

Page 101: ATG Framework

101

Components added by B2B

Page 102: ATG Framework

102

Page 103: ATG Framework

103

Customizing Servlet Pipeline• The standard DAS servlet pipeline is invoked every time

Dynamo handles a request. • An additional servlet pipeline is used by the Dynamo

Administration interface. This pipeline starts at /atg/dynamo/servlet/adminpipeline/AdminHandler.

• We can customize the existing pipelines in Dynamo by adding servlets. The components in a servlet pipeline should be globally scoped.

• The atg.servlet.pipeline package provides interfaces that provide various mechanisms for linking servlets to create a pipeline. The heart of the servlet pipeline is the PipelineableServlet interface.

• All servlets in a pipeline must implement this interface. Servlets that implement PipelineableServlet have a nextServlet property that points to the next component to invoke.

Page 104: ATG Framework

104

• This is the primary pipelining mechanism used by the standard DAS servlet pipeline.

• Dynamo also provides an implementation class, PipelineableServletImpl, that implements this interface; our classes can implement PipelineableServlet by subclassing PipelineableServletImpl.

• The PipelineableServlet interface has two subinterfaces that provide additional mechanisms for determining the next component to invoke: InsertableServlet and DispatcherPipelineableServlet.

• Servlets that implement the InsertableServlet interface have an insertAfterServlet property that enables the servlet to insert itself in a specific spot in the pipeline.

• The key advantage of this mechanism is that it does not require modifying any existing servlets in the pipeline.

Page 105: ATG Framework

105

• For example, suppose you have a servlet pipeline in which a servlet called Servlet1 invokes a servlet called Servlet2.

• Now suppose you want to insert another servlet, Servlet1a, between these two servlets in the pipeline.

• If Servlet1a implements PipelineableServlet, you can reroute the pipeline by changing the value of the Servlet1.nextServlet property so it points to Servlet1a rather than Servlet2, and set Servlet1a.nextServlet to point to Servlet2. But if Servlet1a implements InsertableServlet, all you have to do is set Servlet1a.insertAfterServlet to point to Servlet1, and Servlet1a will automatically be “spliced” into the pipeline right after Servlet1 and before Servlet2.

• Servlet1a is able to do this because it effectively sets its own nextServlet property to the value of Servlet1’s nextServlet property and rewrites Servlet1’s nextServlet property to point to Servlet1a.

Page 106: ATG Framework

106

import javax.servlet.*;import javax.servlet.http.*;import java.io.*;import atg.servlet.*;import atg.servlet.pipeline.*;public class URIPrinter extends PipelineableServletImpl {public URIPrinter () {}public void service (DynamoHttpServletRequest request,DynamoHttpServletResponse response) throws IOException, ServletException {System.out.println ("Handling request for " +request.getRequestURI ());passRequest (request, response);}}

A Sample Pipeline Servlet

Page 107: ATG Framework

107

1. Compile your servlet as URIPrinter.java.Create a new component as an instance of the URIPrinter class. For convenience, put this component in the configuration tree at /atg/dynamo/servlet/dafpipeline/URIPrinter.

2. Modify the DAF servlet pipeline to insert your URIPrinter between,say,DynamoHandler and TransactionServlet components.

3. The head of the DAF servlet pipeline is the service called /atg/dynamo/servlet/dafpipeline/DynamoHandler. The default value of DynamoHandler’s nextServlet property is TransactionServlet, meaning that the DynamoHandler will pass its requests to the TransactionServlet.

4. Change the DynamoHandler’s nextServlet property to point to your URIPrinter and then Set your URIPrinter’s nextServlet property to the TransactionServlet.

5. Now when you run Dynamo, it prints out a message for each request before the request is handled by the remaining servlets.

Page 108: ATG Framework

108

• You can also modify a pipeline by inserting servlets that subclass atg.servlet.pipeline.InsertableServletImpl.

• InsertableServletImpl is an implementation of InsertableServlet that inserts itself into an existing servlet pipeline at startup.

• This capability is required because it is difficult to use Nucleus configuration files to splice into a pipeline whose configuration cannot be determined when the configuration files are written.

• A servlet that implements InsertableServlet explicitly adds itself to a pipeline when the service starts, and uses the insertAfterServlet property to determine its location.

• Such a servlet may be the first servlet in its own secondary servlet pipeline, in which case it will have a nextServlet property.

Page 109: ATG Framework

109

• If so, it inserts itself into the primary pipeline after the insertAfterServlet servlet by changing that servlet’s nextServlet property to the InsertableServlet servlet.

• Then, the InsertableServlet servlet changes the nextServlet property of the last servlet in the secondary pipeline to point to the next servlet in the primary pipeline.

Page 110: ATG Framework

110

• To add an InsertableServlet to the servlet pipeline:1. Write your servlet, extending InsertableServletImpl.2. Define it as a component in the Nucleus hierarchy. It does

not really matter where you put your servlet in the component hierarchy (though the location will affect references to other components if you use relative path names).

3. Set the insertAfterServlet property of your servlet to point to the path of the pipeline servlet you want your servlet to follow.

4. For example, if you want your servlet to follow the DynamoServlet in the pipeline, use:

insertAfterServlet=/atg/dynamo/servlet/pipeline/DynamoServlet

1. Add the path to your servlet to the initialServices property of /atg/dynamo/servlet/Initial:

initialServices+=/myServlet

Page 111: ATG Framework

111

import javax.servlet.*;import javax.servlet.http.*;import java.io.*;import atg.servlet.*;import atg.servlet.pipeline.*;public class URIPrinter extends InsertableServletImpl {public URIPrinter () {}public void service (DynamoHttpServletRequest request,DynamoHttpServletResponse response)throws IOException, ServletException{System.out.println ("Handling request for " +request.getRequestURI ());passRequest (request, response);}}

Page 112: ATG Framework

112

LiveConfig Layer• To enable liveconfig, add the following line to the WEB-INF/ATG-

INF/dynamo.env file in the atg_bootstrap.war module of our EAR file: – atg.dynamo.liveconfig=on

• The application assembler automatically includes this line in dynamo.env if we specify the –liveconfig flag when you invoke the runAssembler command. The following settings are enabled by default in liveconfig mode:

– disable checking for changed .properties files– Turn off checkFileNameCase property– Set the java compiler– Setup web server error pages– Shuts of serverina and internal https server– Disable performance monitor– Adjust pageCheckSeconds property from 1 to 60– Adjust fileCacheSize to 2 million entries– Enable Repository Cache lock Managers– Adjust SessionManager properties

Page 113: ATG Framework

113

• The following settings are not enabled by default:– Set logging levels in global.properties– Disable screen log– Turn off Repository Database verification– Configure Repository cache modes– Pre-populate Caches on startup

Page 114: ATG Framework

114

• During development, we can configure ATG to check the case of file names by setting the checkFileNameCase property of the Nucleus component to true.

• Doing so prevents Nucleus from creating new components unnecessarily if, for example, we create a component named Person and then mistakenly refer to it as person.

• The checkFileNameCase property has no effect on UNIX platforms. It imposes a small performance cost on Windows. Therefore, once our application is no longer in active development and we are not creating new components often, you should set the checkFileNameCase property back to false (the default).

• The recommended deployment configuration (false) is set in the liveconfig configuration layer.

Enabling checkFileNameCase on Windows

Page 115: ATG Framework

115

Sharing Session Information Between Applications

Page 116: ATG Framework

116

• If we run multiple ATG applications on the same site, we may want to share session-scoped Nucleus components between WAR files included in the same EAR file.

• By default, ATG makes the atg_bootstrap.war file the parent web application. It ships with the following information in the web.xml file:

<servlet><servlet-name>SessionNameContextServlet</servlet-name><servlet-class>atg.nucleus.servlet.SessionNameContextServlet</servlet-class></servlet>

• There can be only one parent web app specified per EAR file. In all other web applcations, the web.xml must contain the following entry.

<context-param><param-name>atg.session.parentContextName</param-

name><param-value>/dyn</param-value></context-param>

Page 117: ATG Framework

117

SUNDRY

Page 118: ATG Framework

118

Creating New Components• ATG Control Center includes templates to help you create new Dynamo

components quickly and easily.• There are the standard templates you’ll see when you select [all

modules]:– Empty Targeter helps you create an iterator component that lets you

specify the order in which content is rendered to a subset of users.– Generic Component helps you create new components from any

existing Dynamo classes or your own Java classes.– HTML File Repository helps you define an HTML repository by

specifying the files it will contain and the attributes that describe them.– Slot helps you set up a slot by letting you determine the repository

items it will manage and how it will manage them.– SQL Form Handler helps you create a component for inserting,

updating, and deleting objects in a specified SQL table.– SQL Query helps you create a component that performs queries

against a SQL database.– XML File Repository helps you define an XML repository by

specifying the files it will contain and the attributes that describe them.

Page 119: ATG Framework

119

Dynamo Application Server

• Dynamo Application Server (DAS) is the high-performance, Java-based engine that drives our Dynamo and J2EE applications.

• DAS runs continuously behind the scenes to handle HTTP requests and manage other essential tasks (database connectivity, session management, messaging, transactions, etc.).

• Nucleus, Dynamo's open object framework, serves as the central registry for the JavaBeans, Servlets, and Enterprise JavaBeans (EJBs) that contain our application-level logic.

Page 120: ATG Framework

120

Page 121: ATG Framework

121

JSP Vs. JHTML

Page 122: ATG Framework

122

• Differences Between JHTML and JSP• Coming from the same origins, JHTML and JSP share many of the same

features. Both allow simple embedding of Java code• directly into the page. In JHTML, this is accomplished with the <java>

tag:

<java>

out.println("Hello, world!");

</java>• In JSP, this is accomplished by using the scriptlet syntax:

<%

out.println("Hello, world!");

%>• Displaying the values of scripting variables is similar as well. In JHTML,• <valueof param="foo.bar"/>• And in JSP,• <%= foo.getBar() %>

Page 123: ATG Framework

123

<importbean bean="/atg/dynamo/droplet/ForEach">

<droplet bean="ForEach"><param name="array" value="param:people"><oparam name="output"><valueof param="element.firstName"/><br></oparam></droplet>In JSP, this can be expressed with a tag library:<%@ taglib uri=http://java.sun.com/jstl/coreprefix="core" %><core:forEachitems='<%=request.getParameter("people")%>'var="element"><%= element.getFirstName() %><br></core:forEach>

Page 124: ATG Framework

124

The DSP Tag LibraryIn order to reduce the amount of time and effort required to move an

application from JHTML to JSP, ATG has written the DSPTag Library, which provides the JHTML syntax to JSP developers.

Nearly all of the JHTML tags are available, as well as thestandard HTML tags that are extended by JHTML. There are some

minor differences due to the subtleties of each environment.The tags that support URLs, including<dsp:a><dsp:frame><dsp:iframe><dsp:img><dsp:include><dsp:link>include a page attribute that can optionally be used instead of their href

or src attributes. The page attribute differs fromthe href or src attributes in that the absolute URL values are resolved to

the Web application's root, not the Web server'sroot. This means a tag<dsp:a href="/test.jsp"/>Test</a>will create a link to http://server:port/test.jsp,

Page 125: ATG Framework

125

while<dsp:a page="/test.jsp"/>Test</a>will create a link to

http://server:port/WebAppContextRoot/test.jsp. This allows a DSP Web application to be

moved from URL to URL within the application server without having to change the JSP source.

Two new tags, <dsp:page> and <dsp:getvalueof> are utility tags for working with JSP. The <dsp:page> tag is used to

"wrap" all pages which use the DSP tag library: it is responsible for retrieving the Dynamo HttpServletRequest and Response

objects, as well as calling the Dynamo servlet pipeline. <dsp:getvalueof> retrieves a parameter or bean value, and makes the value available as a JSP scripting variable.

Page 126: ATG Framework

126

Page 127: ATG Framework

127

Page 128: ATG Framework

128

<dsp:importbean bean="/atg/dynamo/droplet/Switch"/><dsp:importbean bean="/atg/dynamo/servlet/RequestLocale"/><dsp:importbean bean="/atg/dynamo/droplet/Redirect/><dsp:setvalue bean="RequestLocale.refresh" value=" "/><dsp:droplet name="Switch"><dsp:param bean="RequestLocale.locale.language" name="value"/><dsp:oparam name="fr"><dsp:droplet name="Redirect"><dsp:param name="url" value="fr/index.jsp"/></dsp:droplet></dsp:oparam><dsp:oparam name="de"><dsp:droplet name="Redirect"><dsp:param name="url" value="de/index.jsp"/></dsp:droplet></dsp:oparam><dsp:oparam name="default"><dsp:droplet name="/atg/dynamo/droplet/Redirect"><dsp:param name="url" value="en/index.jsp"/></dsp:droplet></dsp:oparam></dsp:droplet>

Page 129: ATG Framework

129

Page 130: ATG Framework

130

Page 131: ATG Framework

131

Page 132: ATG Framework

132

Page 133: ATG Framework

133

Page 134: ATG Framework

134

SimpleSQLFormHandler• Dynamo defines a class,

atg.droplet.sql.SimpleSQLFormHandler, which implements a form handler for querying, inserting, updating, and deleting rows from a database table. This form handler requires that each row to be edited can be uniquely identified by a set of key columns.

• In other words, it cannot be used for queries, updates, or deletes that operate on more than one row at a time.

• When we create a form handler component, we set properties that specify the URL of a JDBC driver to connect to, the name of a table to edit, and identifiers for the rows and columns to edit.

Page 135: ATG Framework

135

• We can then embed this component in forms in JSP Pages.

• The form fields are used to set the form handler’s value property. The value property is a Dictionary whose subproperties store values that identify the current row in the form, indexed by the name of the column.

• The value subproperties can either be keys used to look up an item, or new values for an update or insert operation. After the lookup operation occurs, these subproperties are set to the row that was returned.

Page 136: ATG Framework

136

• After a form operation (lookup, update, delete, or insert) has been completed, you may want to redirect the user to a new page. As in standard HTML, you can use the action attribute of the form tag to specify a page to display when the form is submitted.

• The action attribute allows you to specify only a single page. You may want to specify several different pages, with the page the user is directed to dependent on the nature of the form operation and whether or not it succeeds.

• The SimpleSQLFormHandler has a set of properties you can use to control navigation after a form operation. These properties specify the URLs to which the user is redirected on certain error and success conditions. Each submit handler method (except for handleReset) has a corresponding SuccessURL and ErrorURL property. Thus, the following properties are available:– lookupSuccessURL and lookupErrorURL– updateSuccessURL and updateErrorURL– insertSuccessURL and insertErrorURL– deleteSuccessURL and deleteErrorURL

• An additional property specifies the URL to use if a database error occurs when submitting the form:– dbErrorURL

Page 137: ATG Framework

137

• The default value of each of these properties is null, so you must set these properties explicitly (either in the form handler component or on the page). If the values of these properties are not set, the page specified by the action attribute of the form is displayed when the form is submitted. For example, suppose you include these two lines:

<dsp:form action="index.jsp" method="post">

<dsp:input bean="MyFormHandler.lookupErrorURL" type="hidden"

value="notFound.jsp"/>

</dsp:form>• If a lookup operation fails, the user is redirected to the page

notFound.jsp. But if a lookup operation succeeds, and the value of lookupSuccessURL is not set, the user is taken to index.jsp (the page specified by the action attribute).

Page 138: ATG Framework

138

$class=atg.droplet.sql.SimpleSQLFormHandler

$scope=session

connectionURL^=TableManager.connectionURL

keyColumns=NAME

tableName=SKIER

DBErrorURL=sqlError.jsp

Page 139: ATG Framework

139

$class=atg.repository.servlet.RepositoryFormHandler

$scope=request

repository=/srini/repositories/emp

requireIdOnCreate=false

Repository Form Handler


Recommended