Developing ATG Applications with IBM WebSphere Studio by yme71001

VIEWS: 218 PAGES: 13

									Developing ATG Applications with IBM WebSphere Studio

                                                                                                                      µ
Developing ATG Applications with IBM
WebSphere Studio



             December 13, 2004

             This article shows you how to develop an ATG 7 application using IBM’s WebSphere Studio Application
             Developer (WSAD) 5.1. After working through the tutorial, you’ll be able to create ATG applications that
             can take advantage of WSAD’s many features, including its embedded test server. Note: This article
             assumes that you’re already familiar with ATG development and WSAD, but haven’t yet used WSAD to
             create an ATG application.


             Installing the ATG Development Tools Plug-in
             Before getting started, you’ll need to install the ATG Development Tools plug-in for Eclipse and WSAD.

                 1.   Start WSAD and select Help > Software Updates > Update Manager.

                 2.   Right-click in the Feature Updates view and select New > Site Bookmark from the pop-
                      up menu.

                 3.   In the New Site Bookmark dialog box, enter ATG in the Name field and
                      espilce/moc.gta.www//:ptth       in the URL field. The Update Manager adds an ATG
                      bookmark to the Feature Updates view.

                 4.   Expand the ATG bookmark and click on the plug-in you want to install.

                 5.   Click Install Now in the Preview view and follow the remaining prompts.

             Additional installation details are available on the ATG Developer Network
             (http://www.atg.com/portal/myatg/developer).


             Creating a New ATG Java Project
             After you install the ATG Development Tools plug-in, you’re ready to set up a new ATG Java project. To
             get started, select File > New > Project > Java > ATG Wizards > New ATG Module. (Note that this option
             creates a new project and a new ATG application module. You can also create a new project for an
             existing ATG module. For details, see the ATG documentation under Help > Help Contents in the
             Workbench.)




                                                                                                                        1
Art Technology Group, Inc. (www.atg.com)
                   Developing ATG Applications with IBM WebSphere Studio

µ




                                       Figure 1


    When the New ATG Module Project wizard (figure 1) opens, enter “HelloWorld” as the name of your new
    project and click Next.




2
                                                   Art Technology Group, Inc. (www.atg.com)
Developing ATG Applications with IBM WebSphere Studio

                                                                                                                    µ




                                                  Figure 2


             The ATG Application Stack screen (figure 2) prompts you to select the required applications for your
             project. For this example, keep the default value, ATG Adaptive Scenario Engine, and click Next.




                                                                                                                    3
Art Technology Group, Inc. (www.atg.com)
                   Developing ATG Applications with IBM WebSphere Studio

µ




                                         Figure 3


    The Module Configuration screen (figure 3) prompts you to select any other application modules required
    by your project. Since you selected ATG Adaptive Scenario Engine as a required application (figure 2), the
    DAS, DPS and DSS modules are already listed by default. If your project required any other modules, you
    could add them here. For this example, though, just accept the default values by clicking Next.




4
                                                     Art Technology Group, Inc. (www.atg.com)
Developing ATG Applications with IBM WebSphere Studio

                                                                                                                   µ




                                                  Figure 4


             You probably recognize the Java Settings screen (figure 4) since it’s a standard Eclipse page for defining
             new Java projects. In this screen, add a source folder called
                                                                        crs    and an output folder called
                                                                                                        sessalc     .
             (Note thatsessalc    is the default name for the output folder of an ATG application module.) It’s
             important that your output folder is different than your source folder. Otherwise, you could end up with a
             messy project that’s difficult to maintain.

             After you set up your source folder and output folder, click Next. Important: Make sure you don’t
             accidentally click Finish here, or you’ll miss the final step!




                                                                                                                     5
Art Technology Group, Inc. (www.atg.com)
                    Developing ATG Applications with IBM WebSphere Studio

µ




                                          Figure 5


    Finally, the J2EE Application screen (figure 5) prompts you to create a skeleton J2EE application. This
    application will be the basis for our J2EE project in WSAD. Fill out the form as shown above and click
    Finish.


    Updating the Module’s MANIFEST.MF File
    Eventually, we’ll want to run our project on WSAD’s built-in test server. At this point, though, our Java
    classes are located in a project (HelloWorld) that is unknown to the test server. We need to get those
    classes into the classpath of our application. We can do this by creating a “dummy”   raj.sessalc
    reference that will be used later on by the WSAD EAR project.

    For now, just add this dummy reference to the new application module’s      FM.TSEFINAM/FNI-ATEM    file by
    appending   raj.sessalc/bil     to the htaP-ssalC-GTA    attribute as shown below. Note that this JAR file
    does not exist yet; WASD will generate it automatically when you run your application on the test server.


             0.1 :noisreV-tsefinaM
          /gifnoc :htaP-gifnoC-GTA
     SAD SSD SPD SAD :deriuqeR-GTA
    dlroWolleh/sppa-ee2j :EE2J-GTA




6
                                                       Art Technology Group, Inc. (www.atg.com)
Developing ATG Applications with IBM WebSphere Studio

                                                                                                                     µ
                dlroWolleh/sppa-ee2j :eludoM-RAE-GTA
             raj.sessalc/bil sessalc :htaP-ssalC-GTA



             Generating an Initial ATG J2EE Application
             The New ATG Module Project wizard set up a skeleton ATG project and J2EE application for you. Now we’ll
             use the ATG Application Assembler wizard to turn that project and J2EE application into an application
             we can import into WSAD.

             Select File > Export > ATG J2EE Application to start the assembly wizard (figure 6). Select HelloWorld from
             the ATG Project list, fill in the other fields as shown below, and then click Finish.




                                                  Figure 6




             Importing the EAR File into WSAD
             The ATG Application Assembler wizard generated the file   rae.dlroWolleh\krow\:c   . We need to import
             this EAR file into WSAD so that we can take advantage of WSAD’s J2EE development features.




                                                                                                                      7
Art Technology Group, Inc. (www.atg.com)
                    Developing ATG Applications with IBM WebSphere Studio

µ
    Select File > Import > EAR File to import rae.dlroWolleh   . Accept all of the default settings in the Import
    EAR wizard. When if finishes, you’ll have the following new projects:

                      nimda_gta
              bje_partstoob_gta
                  partstoob_gta
                 EE2JdlroWolleh
                        ppa-bew

    The projects starting with the _gta prefix are utility projects that contain the ATG platform. The
    EE2JdlroWolleh     project is a WSAD EAR project. Finally, ppa-bew    is the WSAD web project where your
    JSP development will take place. Java code and Nucleus components should be generated in the
    HelloWorld Java project we created previously.


    Setting up Project References
    We’re almost there! We just need to define a utility JAR to keep our HelloWorld Java project and our J2EE
    projects in sync.

    Switch to the J2EE perspective in the Workbench. Open the EAR Deployment Descriptor for your
    EE2JdlroWolleh     project. Select the module tab at the bottom of the deployment descriptor editor.
    Scroll down to Project Utility JARs and click the Add button at the bottom of the form. In the Add Utility
    JAR dialog box (figure 7), select the HelloWorld project. In the URI field, enter the URI to the “dummy”
                   we defined earlier in
                          raj.sessalc     FM.TSEFINAM   . Note that this URI has been changed; all of the “/” have
    become . It’s important that you keep the new name, so enter
                            s_
    raj.sessalcs_bils_dlroWolleH_/bil            in the URI field. Finally, click Finish and be sure to save your
    changes to the Application Deployment Descriptor.




8
                                                       Art Technology Group, Inc. (www.atg.com)
Developing ATG Applications with IBM WebSphere Studio

                                                                                                                       µ




                                                   Figure 7



             Generally, it’s bad JSP development practice to embed Java code in your JSP pages. However, sometimes
             it can come in handy, especially for quick experimentation.

             If you’d like to include references to code in your HelloWorld Java application, you’ll need to update the
             build path of your ppa-bew     project to includedlroWolleH  and  bje_partstoob_gta      .

             Right-click on theppa-bew    web project and select Properties. In the Properties dialog (figure 8), select
             Java Build Path, click on the Projects tab, and check thebje_partstoob_gta      and  dlroWolleH     projects.




                                                                                                                          9
Art Technology Group, Inc. (www.atg.com)
                     Developing ATG Applications with IBM WebSphere Studio

µ




                                          Figure 8




     Testing HelloWorld
     Now let’s test out this setup. We’ll create a new Nucleus component (dlroWolleH/elpmaxe/dasw/        ) in
     our HelloWorld project, and we’ll display that component in a JSP page.

     First, create a new Java class,
                                  dlroWolleH.elpmaxe.dasw       , in the HelloWorld Java project. Next, open the
     ATG Component Browser view by selecting Window > Show View > Other > ATG > ATG Component
     Browser. Right-click on the HelloWorld project and select New Component from the pop-up menu.




10
                                                      Art Technology Group, Inc. (www.atg.com)
Developing ATG Applications with IBM WebSphere Studio

                                                                                                                  µ




                                                 Figure 9


             In the New Component dialog box (figure 9), enter dlroWolleH.elpmaxe.dasw           as the class name and
             dlroWolleH/elpmaxe/dasw/         as the Nucleus path. Note that the Component Editor opens automatically
             when you click Finish. Just click Cancel to close the editor since you don’t need to make any changes to
             thedlroWolleH    component.

             Now we need a JSP page to render our application. Switch to the web perspective and create a new
             psj.dlroWolleh  under the   ppa-bew project. Add the following code to your JSP page:


                               >% "psd"=xiferp "bilgaTpsd/"=iru bilgat @%<
                         >/"dlroWolleH/elpmaxe/dasw/"=naeb naebtropmi:psd<
                                                                >egap:psd<
                                                          >RB<!dlroW olleH
                  >/"dlroWolleH"=naeb foeulav:psd< si tnenopmoc suelcuN yM
                                                                >egap:psd/<


             In the above JSP code, #1 imports the DSP tag library, #2 imports the
                                                                                 dlroWolleH  Nucleus component
             into the JSP, and #3 renders ourdlroWolleH   component (a fully qualified component name is not
             necessary because of #2).

             Before we run our application on the WSAD test server, we need to generate EJB deployment code for the
             bje_partstoob_gta    project. To do this, right-click on
                                                      bje_partstoob_gta                  and select Generate >
             Deployment and RMIC Code. Choose the                         bean and click Finish.
                                                                  noisseShtapssalC




                                                                                                                  11
Art Technology Group, Inc. (www.atg.com)
                    Developing ATG Applications with IBM WebSphere Studio

µ
     Next, we need to create a new test server. Select File > New > Other > Server and Server Configuration
     and create a new server called “myserver,” as shown below (figure 10).




                                         Figure 10


     Now we’re ready to run our application. First, start your development database. (ATG applications require
     a running database.) Right-click on the project  EE2JdlroWolleh   and choose Run On Server. WSAD will
     start the embedded WebSphere test server. Our   EE2JdlroWolleh     project will be staged on that server.
     Point your browser to the following URL to view the JSP you created:

              http://localhost:9080/helloWorld/helloWorld.jsp


     Conclusion
     This article covered the basics of creating a simple ATG application in WSAD. We created a Java project
     and a skeleton J2EE application, which were used to export a single ATG J2EE Application. We imported
     that J2EE Application into WSAD so that we could take advantage of WSAD’s excellent J2EE development
     environment. Before running our application we created a utility JAR that linked our Java project and
     WSAD J2EE project together. Finally, we created a Nucleus component and rendered that component in a
     JSP page.




12
                                                       Art Technology Group, Inc. (www.atg.com)
Developing ATG Applications with IBM WebSphere Studio

                                                                                                                  µ
             We really only scratched the surface of ATG application development and WSAD features in this article. To
             learn more, see IBM’s WebSphere developerWorks site (http://www-
             136.ibm.com/developerworks/websphere/) and the ATG 7 product documentation
             (http://www.atg.com/en/support_services/support/product_resources/manuals.jhtml).




                                                                                                                 13
Art Technology Group, Inc. (www.atg.com)

								
To top