ATG - How to start creating a Hello World component and module example?

atg
Knowledge Craving picture Knowledge Craving · Jan 6, 2014 · Viewed 14.4k times · Source

I'm new to ATG, and I've only been able to install ATG v10.2 successfully with JBoss.
However, since creating components and modules in ATG can be done in different ways, so I would like to know if there's any "Hello World" example for both module and component.

I have already searched in Google, but the different articles present in Internet don't mention point-wise in details, in a sequential manner.
So it will be great, if people can detail out the steps for a newbie, as I at least need to get started with one example, which I can later use as a base for other complex ones.

Thanks a lot to every one out there!

Note:-
I also know J2EE and MVC to some extent, where I can submit forms and save the user-input data to DB, without any significant issues.
I'm also going through the ATG Page Developer Guide at this moment.

Answer

Buddha picture Buddha · Jan 11, 2014

There are so many concepts in ATG, that makes coming up with Hello World program little difficult. Do you mean to create one JSP page and deploy it like commerce reference store? Do you want to create a component just to see in Dyn/Admin? Do you want to create a hello world repository? Depending on what you want to do, the approach to take will be different.

To work with ATG, you don't have to know about saving values in database. If you approach ATG programming with J2EE & MVC experience, you may find it little difficult to cope with it unless you start with a fresh mind, because things are very different in ATG.

As @radimpe covered creating a hello world droplet, I will show how to create a simple component so that it can be viewed in Dyn/Admin.

Creating a HelloWorld component: That just appears in DynAdmin Create an Eclipse project with following structure.

Elipse project structure

Following is the content of each of the file shown in the above screenshot

HelloWorldComponent.java

package com.buddha.components;

import atg.nucleus.GenericService;
import atg.nucleus.ServiceException;

public class HelloWorldComponent extends GenericService {

    public String firstStr = "Dummy Value"; /* This value will be overwritten */

    public String getFirstStr() {
        return firstStr;
    }

    public void setFirstStr(String firstStr) {
        this.firstStr = firstStr;
    }

    @Override
    public void doStartService() throws ServiceException {
        super.doStartService();
        System.out.println("Hello ATG Component!");
    }

    @Override
    public void doStopService() throws ServiceException {
        super.doStopService();
        System.out.println("Hello ATG Component! Stops now!");
    }
}

Manifest.MF

Manifest-Version: 1.0
ATG-Required: DafEar.Admin 
ATG-Config-Path: config/
ATG-Class-Path: ./bin/ 

HelloWorldComponent.properties

$class=com.buddha.components.HelloWorldComponent
firstStr=HelloWorld

Build the project and copy the project folder into ${DYNAMO_ROOT} and run the following command to generate an ear file of your project and deploy it in your jboss server.

runAssembler.bat -jboss HelloWorld.ear -m EXP_HelloATGComponentWorld

Navigate to Dyn/Admin and search for the component HelloWorldComponent and click on the component listed in the search results.

SearchResults of the component we have just created

Click on it to go to the component page to see the property we have created and its value given in properties file. Component Property we have created

You can observe the log as something like this 21:53:00,485 INFO [stdout] (http-/0.0.0.0:8080-1:ipaddr=127.0.0.1;path=/dyn/admin/nucleus//com/buddha/components/HelloWorldComponent;sessionid=gT4bmHj5WKs1Rf85GN0Z+9Qu) Hello ATG Component! This line is generated because of the sysout in our doStartService(); You can also give other methods that can be called through dyn/admin or interact with other components. Best of Luck.

Source: Creating a component in Oracle Commerce Platform