0

How to programmatically add elements to a value node in Web Dynpro for Java

Background

This article demonstrates how to programmatically add elements to a node value. Web Dynpro has this concept of context programming. A context is a hierarchical tree data structure that can consist of nodes where each node can represent a list of elements something similar in Java.

Hardware Environment

n/a

Software Environment

  • Windows 7 Professional SP1
  • Java 2 SDK 1.4.2 for Windows 32-bit
  • SAP NetWeaver Developer Studio Version 7.0.09 for Java
  • SAP NetWeaver Application Server
    • ​sap.com/SAP-JEECOR  – 7.00 SP26 (1000.7.00.26.1.20120307143343)
    • sap.com/SAP-JEE – 7.00 SP26 (1000.7.00.26.0.20120109175405)

Create a Web Dynpro Project

Create a Web Dynpro Project via File -> New -> Web Dynpro Project

01-node-element-sample

Modify the View

1. Open the NodeElementSampleView by double-clicking it, go to the implementation tab, and put some codes
Add the following block of code within the //@begin others and //@end

 2. Add the following codes within the wdDoInit() method and between //@@begin wdDoInit() and //@@end

Modify the View’s Layout

1. Create a Node value in the View’s context

 03-node-element-sample_wm
2. Add a TextView and DropDownByIndex UI elements
04-node-element-sample_wm
3. Bind the DropDownByIndex texts property to context’s Vn_UserTypeList.userTypeDescription
05-node-element-sample_wm
06-node-element-sample_wm
4. Optional – create an Application to run this Web Dynpro application
NOTE: You’ll a NetWeaver Application Server
07-node-element-sample_wm
 
08-node-element-sample_wm
10-node-element-sample_wm
 5. Deploy and Run New Web Dynpro Application
11-node-element-sample_wm

Sample Output

 12-node-element-sample_wm