Tutorial 1: Create a Hello world application in WebDynpro java 7.3
In this tutorial you will learn how to create a first WebDynpro java application in NWDS 7.3.This document is very helpful for the beginners and for learning perspective.
- SAP Netweaver Development Studio 7.3(NWDS) installed on your desktop.
- SAP Netweaver Application Server Java to run and test your application
Step 1.Create a Web Dynpro Development Component
To create a Web Dynpro development component, first you have to open a relevant perspective i.e Web Dynpro perspective.
Development Component is a container which can contain different kind of resources such as webdynpro java components,enterprise portal components etc.
- Go to Windows-> Open Perspective-> Web Dynpro
- Click on File option -> New-> others-> Web Dynpro and select Create a WebDynpro Development Component option
- Click on next option and then select a Software Component where you want to create the DC(s).You can select any software component of your choice. But here we are selecting MyComponents ->Click on Next->Enter name of your first WebDynpro Project say “HelloWorld”->Click on Next and Finish
Software Component is a deliverable, deployment unit comprises of development components.
Step 2.Create a Web Dynpro Component
WebDynpro Component is the heart of webdynpro java application. It is a reusable unit of code and set of controllers, views and models. Webdynpro java application doesn’t exist without a webdynpro component.
- To create a webdynpro component, right click on HelloWorld project->Select New ->Component
- Enter name of your component say “FirstComp”->Click on Next->Finish
While creating WebDynpro component, window and view will be automatically created .As you can see in Fig 2, Default Window and Views option is selected by default. Click on Next option and you will see FirstCompWindow and FirstCompView are created automatically in Fig 3 and then click on Finish.
- Now a Web Dynpro Component ”FirstComp” is created along with a Window “FirstCompWindow”, a View “FirstCompView” and a controller. See the project structure in Fig 4 and 5:
Component Controller is the master controller and it is used to code business logics.
Lifespan of component controller is equal to lifespan of component.
View is used to display data on the output screen. End user can interact with your application through view only.
Step 3.Display Hello World in Web Dynpro java application
To display hello World in Web dynpro java application, first you have to add an UI element in your view ”FirstCompView”.Follow the below steps to do so:
- Right click on FirstCompView->Select View editor option
- Drag and Drop Text view UI element in FirstCompView Editor
- Go to Properties tab and Enter ‘Hello World’ in text property and save the changes.
Step 4.Deploy and run Web Dynpro application on your server
To run webdynpro java application , create an application in “helloworld” Web Dynpro java project and then deploy on your server.
- Right click on Applications and select create application option
- Enter name of your Web Dynpro java application say ”FirstApp” and click on Next option
- Then choose a reference of Web Dynpro component .You can either create a new component or choose an existing one. Here we are selecting option of “Use Existing Component” as we are already created a “FirstComp” in project.
- Click on Next option and “FirstComp” component will automatically be mapped with your application and then select Finish option.
Now before running this application on your server, you have to configure server details in your local NWDS 7.3.
To do so you can go to WindowsàPreferencesàSAP AS Java and then add your server details using add option.
- Right Click on FirstApp application->Click on Deploy New Archive and Run option. It will ask for admin userid/password for deployment.
Step 5.Here is your first Hello World Web Dynpro java application