Web Dynpro enables you to statically declare objects at design time. This considerably reduces the programming effort. Dynamic UI Generation, however, enables you to develop programming sequences declared at design time and to develop source code that overwrites existing declarations. This could be for example configuration-driven parts of the user interface.
To create UI elements dynamically, the code has to be written into the wdDoModifyView method. The parameter firstTime specifies whether the wdDoModifyView method was called for the first time during the lifetime of the view.
Creating and Adding a UI element
public static void wdDoModifyView(IPrivate<view name> wdThis, IPrivate<view name>.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime) { //@@begin wdDoModifyView if(firstTime){ IWDButton theButton = (IWDButton)view.createElement(IWDButton.class, "myFirstButton"); IWDGroup theGroup = (IWDGroup)view.getElement("Group1"); theGroup.addChild(theButton); theButton.bindText ("<ContextNodeName>.<ContextAttributeName>"); } //@@end }
Deleting all Dynamically Created UI Elements
You can remove all UI Elements, you have created programmatically using the following coding:
view.resetView();