Q. What design pattern followed by FormHandler?
Ans. MVC2 Service to Worker (a push based MVC) design pattern is used for FormHandlers.
Q. What is important design patterns used in ATG?
Ans. ATG uses following design patterns.
MVC2 Service to Worker (a push based MVC) design pattern is used for FormHandlers.
MVC2 Dispatcher View (a pull based MVC) design pattern is used by Dynamo Servlet Beans (droplets).
Inversion of Control (Dependency Injection) design pattern is used by Nucleus to tie components. This design pattern is used for inter-linking of components.
Q. Which class to extend while creating custom ATG Droplets?
Ans. Custom droplet can be created by extending the DynamoServlet.java class. Package for this java class is atg.servlet.DynamoServlet.java
Q. What is ATG FormHandlers?
Ans. FormHandler is an ATG component that is used to push data from JSP form to back-end system.
FormHandler are mostly used for server side validations of form data before that passes to back-end components or to read / write in repository and re-direct the user to different pages, depending on the results of the form submission. A FormHandler class must include one or more Handle method.
Q. What is Base class of all ATG FormHandlers?
Ans. The base / super class of FormHandler is GenericFormHandler.java. The package for this java class is atg.droplet.GenericFormHandler.
Q. What is the class hierarchy for ATG Formhandlers? How to create a FormHandler?
Ans. All FormHandler in ATG by-default implements an interface i.e. DropletFormHandler.
There are 3 different top level implementation of this interface. They are as below.
atg.droplet.EmptyFormHandler extends GenericService implements DropletFormHandler.
atg.droplet.GenericFormHandler extends EmptyFormHandler.
atg.droplet.TransactionalFormHandler extends GenericFormHandler.
1. EmptyFormHandler - The EmptyFormHandler is the most simplest to implement. It implements the DropletFormHandler interface and defines blank body implementations of the methods given in this interface.
ATG Page 39
2. GenericFormHandler extends EmptyFormHandler. It defines the simple implementations of the DropletFormHandler interface methods and the 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.
3. TransactionalFormHandler extends GenericFormHandler, It treats the form processing operation as a transaction. Though the methods invoked by this form handler are processed discretely, but their results are saved simultaneously. The beforeGet and afterGet methods do the transaction management. This establishes the transactions before any of your properties are set or handler methods are called.
Q. What is ATG tag library?
Ans. ATG tag library is a variant of jsp standard tag library. However ATG provides its own set of tag libraries e.g. dsp, dspel, core.
Q. What are the various attributes possible with <dsp:valueof> tag?
Ans. Both <dsp:valueof> & <dsp:param> can have “bean”, “param” & “value” attribute.
Bean attribute is use to access the ATG component.
Param is use to access value of a parameter being passed on JSP or defined in an ATG component.
Value is hard coded value on the JSP.
Q. What is Droplet and what is the use of droplet?
Ans. Droplet is also known as Dynamo Servlet Bean. Droplet is use to retrieve & render data in JSP.
Droplet is use to pull information from back-end components / database and render the same on JSP.
Droplets are based on MVC2 Despatcher View design pattern. Idea behind droplet is to keep HTML and Java code separate. There are many out of box droplets available to perform various tasks. We can also custom droplet as per requirement.
Q. What are the best practices to be followed during ATG development?
Ans. Some of the best practices are defined here. This has huge impact on the performance. Never compromise with the coding standards and guidelines shared by ATG.
1. Best practices for Component Resolution - The ATG Framework is very unique by its architecture and component centric environment. The components are stored in the Nucleus which is representing the components in a hierarchical structure and the components are looked up using the request.resolveName(“alias name”) method. But this is costly.
ATG Page 40
The better option is to do a Dependency Injection of necessary components like DataSource, Repository etc., to the needed components. But in case, the injection is not possible, like a droplet or formhandler which needs to work with various datasources or repositories etc., then the components need to be resolved.
ATG framework contains the atg.nucleus.naming package which includes the class
‘ComponentName’ that enable you to pre-parse frequently-used component. You can assign a name to a component, storing the name and its corresponding component in a HashTable. This typically results in faster name resolution for components and parameters.
You can use a ComponentName object to represent any Nucleus component.
To get the unique ComponentName for a given String, call the static getComponentName(String) method. This method looks the given string up in the hashtable of component names and either returns the value or creates a new one with the string that was passed in. This acts like a ServiceLocator design pattern. For example, you can set a ComponentName value like this -
public final static ComponentName PEACH =
ComponentName.getComponentName("/atg/fruits/Peach");
2. Best practices for Repository Caching - There are three cache modes i.e. Simple, Locked and Distributed. Simple mode is better if the application is running on single JVM and is not clustered across.
If the ATG applications are deployed on a cluster of servers, then we have to go in for either Locked caching or Distributed Caching.
For repositories like ProfileAdapterRepository, where at the most one server alone will be handling the updates, it is better to use Locked caching with proper configuration of ClientLockManager and ServerLockManager.
Caching should generally be disabled when there is a possibility that the underlying data will be changed by a non-Dynamo repository application.
3. LiveConfig Settings - The settings in Dynamo’s base configuration layer are optimized for application development, but may not be appropriate for a production environment.
When our application is ready for production environment, we should enable the settings in the liveconfig configuration layer. This layer, which is disabled by default, overrides many of the default configuration settings with values that are more appropriate for a deployed site.
ATG Page 41
For example, the liveconfig configuration layer improves Dynamo’s performance by reducing error checking and detection of modified properties files. To enable liveconfig, add the following line to the WEB-INF/ATG-INF/dynamo.env file in the atg_bootstrap.war module of EAR file.
atg.dynamo.liveconfig=on
The application assembler automatically includes this line in dynamo.env if you specify the –liveconfig flag when you invoke the runAssembler command.
4. Logging Best Practice - Performance can also be improved by disabling the screen log and having only the File log. The component /atg/dynamo/service/logging/ScreenLog are the one which is logging to the screen by default, or it may also be a custom component like our own formatting logger. We can disable logging to the screen by setting the loggingEnabled property of the ScreenLog to false.
Also set the log level to minimum Info and not Debug as otherwise there will be large number of log messages.
Q. What is the tag to import component?
Ans. Tag to import component is <dsp:importbean>.
Q. What is the tag to import page?
Ans. Tag to import page is <dsp:include>
Q. What is <DSP:oparam> tag?
Ans. <dsp:oparam> tag supplies a parameter to the current servlet bean. dsp:oparam (open parameter) takes the value supplied to it in a JSP and passes it to the current dsp:droplet tag.
Each servlet bean maintains a set of open parameters which the servlet bean can set, service, and deliver as output to a JSP.
Q. What is FormException property?
Ans. FormException is a vector of the exceptions that occur during form processing.
Q. What is PropertyException and is it a read-write property?
Ans. PropertyException is a read-only property that returns a Dictionary of subproperties i.e. one for each property set by the form. For each property that generates an exception, a corresponding subproperty in the propertyExceptions Dictionary contains that exception. For each property that does
ATG Page 42
not generate an exception, the corresponding subproperty in the propertyExceptions Dictionary is unset.
Q. What is FormError?
Ans. FormError is a boolean that is set to true if any errors occur during form processing.
Q. How to check if submitted form had any error?
Ans. Using FormError attribute we can check if any error occurred in form submission. If error occurred then FormError will be true.
Q. How to display all exception occurred during Form submission?
Ans. Using FormException, we can display all exception occurred during Form submission.
Q. What is the FormHandler to interact directly with SQL DB or How to interact directly with SQL DB?
Ans. We can interact directly with an SQL database using SimpleSQLFormHandler, which is an instance of the class atg.droplet.sql.SimpleSQLFormHandler. A subclass of atg.droplet.GenericFormHandler, this class supports SQL database table queries, inserts, updates, and deletions.
Q. Why the param parameter is used in Droplet?
Ans. It is used for both i.e. request and input parameter.
Q. Which droplet can be used to populate select box in DSP?
Ans. For & ForEach droplet can be used to populate select box.
Q. What is the input parameter type for ForEach droplet?
Ans. Array is an input parameter for ForEach droplet.
Q. Which method needs to be overridden while extending a droplet or writing custom droplet?
Ans. Service method needs to be overridden.
Q. What are Targetting droplets available in ATG?
Ans. ATG provides five targeting servlet beans (droplet). Four of them use a targeter together a set of items from a content repository, and render the items on the page. They differ only in how many items they actually display. They are as follow.
• TargetingForEach displays all of the items returned by the targeter.
• TargetingFirst displays the first n items, where n is a number you specify.
• TargetingRange displays a range of items, such as the third through the seventh.
• TargetingRandom displays n items chosen randomly.
ATG Page 43
• TargetingArray differs from the others because it does not format the output of the targeting operation. Instead, we have to use another servlet bean to format the output.
Q. What is the return type of Switch droplet?
Ans. Switch droplet evaluates the input parameters and return String.
Q. What is the use of TableForEachDroplet?
Ans. Use of this droplet is as follow.
1. Displays each element of an array.
2. Arranging the output in a two-dimensional format.
Q. what is the name of Droplet looks for an item in a specific repository based on item id & renders / return item on page?
Ans. ItemLookupDroplet retrieves an item from specific repository by item-id.
Q. what is the default location of java class and component in ATG?
Ans. Java classes resides in lib folder and components are resides in config folder.
Q. What is the use-case of ATG-Required in Manifest.MF file?
Ans. Following are the usecases.
a. Specifying modules on which this module depends. While running the application assembler, the modules listed here also are included in the application.
b. When the application starts, the manifests of the modules listed here are processed before the current module’s, in least-dependent to most-dependent order.
Q. Can one Java class be made in to multiple components?
Ans. Yes, one Java class can be used to make multiple components.
Q. Where Component files are located in ATG module?
Ans. Component files are located under <App-Root>/config directory.
Q. Which component should a shareable component be registered with?
Ans. /atg/multisite/SiteGroupManager
Q. Identify the problem with the following targeter rule-set?
ATG Page 44
Ans. Rules cannot contains two accept directives.
Q. Which of the following two outcomes are achieved by the following snippet of code?
<dsp:importbean bean= "/Project/ShippingConf"/>
Ans. Makes the Shipping Conf available to the EL through the name ShippingConf.
Q. Which two DSP Tags can specify a tag converter?
Ans. dsp:valueof and dsp:input
Q. How does a developer preserve request scoped objects on redirects?
Ans. By adding a_request id parameter to the form as a hidden variable.
Q. What is the best way to display the contents of an open parameter in a Custom Droplet?
Ans. Use the request.serviceParameter method to render the open parameter.
Q. To encrypt userID cookie, what must you do?
Ans. Edit propertycookieHashKey of/atg/userprofiling/CookieManager.
ATG Page 45
Q. Consider the following code snippet:
To get an output of "Joe Bruin", What two methods should the droplet use in the code?
a. getLocalParameter("first") and getLocalParamter("last") b. getParameter("first") and getLocalParameter("last") c. getLocalParameter("first") and getParameter("last") d. getPageParameter("first") and getParameter("last") Ans. B
Q. What are custom dsp tags?
Ans. DSP tags are ready to use tags to render content dynamically by linking Nucleus components directly to your JSPs. Essentially, the DSP tag libraries let you connect your JSP content to the Java code at work behind the scenes so you can separate your application logic from your presentation layer. ATG provides you with three tag libraries JSTL, DSP/DSPEL, and Core. You can find these tag libraries in /DAS/taglib.
Q. Difference between dsp and dspel tags?
Ans. The DSP tag library tags support runtime expressions, such as references to scripting variables.
These tags use id attribute to name the scripting variables they create. The DSPEL tag library tags support JSTL Expression Language (EL) elements that are also evaluated at runtime. These tags often produce a result object named by the var attribute.
Q. How to write custom tag?
Ans. For custom tags we need to write the properties file and a class files to define the functions. We need to include a tag file with extension .tld. (tag library definition) and in the page include the path of the tag uri <% tag uri ..%>. we can write a custom tag to calculate the shipping rate with promotion and save it and then extend wherever required.
ATG Page 46
Q. What is ATG tag library?
Ans. Atg tag library is a variant of jsp standard tag library. However atg provides its own set of tag libraries e.g. dsp, dspel and core.
Q. Difference between dsp:include and jsp:include?
Ans. Dsp imports all objects of type class also, whereas jsp imports only primitive types. Jsp includes are dynamic where as dsp include are for data which is smaller than 64 kb. ATG created the DSP tag library as a mechanism for accessing all data types, including those that exist in ATG Nucleus framework. Other functions provided by these tags manage transactions and determine how data is rendered in a JSP. It is best to use tags from the DSP tag library only for tasks that involve Dynamo Application Framework (DAF) resources. Dsp tag support for the passing of object parameters between pages. In particular, use dsp:include rather than jsp:include, and use dsp:param rather than jsp:param.
ATG Page 47