Show TOC

DEMODYNAMICLocate this document in the navigation structure

Use

The demo component DEMODYNAMIC shows a simple structure of a Web Dynpro component whose view is created generically at design time, and enhanced dynamically at runtime.

The Layout of the View TABLE_DDIC

The layout of this component view has three main elements: an input field and two group elements. The UI element Input Field is bound to a context node of the view controller, receives the input string of the user, and saves it in this context. The two Group elements are not bound; the context view does not provide any suitable context nodes. These two context nodes are not created or filled with data until runtime. Only then are the two UI elements bound to the dynamically created context nodes in the method WDDOMODIFYVIEW. The dynamic design of the view context is implemented in the method NEW_STRUCTURE, which itself uses some methods of the component's assistance class CL_WD_DEMO_DYN_MODEL.

Dynamic Creation of the Context Node

The method NEW_STRUCTURE is called by the handler method of the button event change_ structure . Once any input fields of the user have been handled, the dynamic creation of the required context node starts. First, new node information is created. A corresponding context node is then created and filled for this IF_WD_CONTEXT_NODE_INFO-type object. The methods required to create and design the context node are in the assistance class CL_WD_DEMO_DYN_MODEL, created for this demo component.

The Assistance Class CL_WD_DEMO_DYN_MODEL

The methods in this class have been copied from the service class CL_WD_DYNAMIC_TOOL . The simple nature of this example means that the methods can be used and called without any changes being made. Usually, however, you have to modify and add to these classes after copying them to an assistance class to meet the requirements of your own application.

The Method WDDOMODIFYVIEW

This method binds the UI elements to the dynamically created context node. To enable this, the methods CREATE_TABLE_FROM_NODE and CREATE_FORM_FROM_NODE are called from the assistance class. Both these methods were copied from the service class CL_WD_DYNAMIC_TOOL.

More information about Dynamic Programming is available in the SAP NetWeaver Developer's Guide.

The View DYNAMIC_NODE_TYPE

For this view, context nodes are created dynamically in the method WDDOINIT. Instead of each attribute being created dynamically, a structure is created first. Node information and a context node are then created from this structure (for more information, read Context in the Programming Guidelines .

Note

More information is available in Programming Manual for Web Dynpro ABAP