
In the view of a mobile UI component, you can statically declare UI elements at design time. However, dynamic programming in mobile UI components allows you to develop programming sequences declared at design time and to develop source code that overwrites existing declarations.
Dynamic Modification of a View
The wdDoModifyView method is defined in the controller implementation of the view. It allows the application programmer to insert source code, which is used to customize an application.
All modifications of UI elements that cannot be made using declarative data binding at design time are provided by the wdDoModifyView method. For example, the wdDoModifyView method is used if a UI element is to be rendered only at runtime.
In this way, you can add source text to the controller implementation of the view in order to program the parts of the user interface that are not yet known at design time. For example, this could be configuration-driven parts of the user interface. The wdDoModifyView method is called for every view before it is displayed on the screen. It should only be used to modify a view and therefore should not contain any source text that references controllers. The method is used to modify UI elements of a view in order to enhance the possibilities for UI development at design time.
The implementation of the wdDoModifyView method must always be defined between the comment lines //@@begin and //@@end , which is the user coding area. Otherwise, a runtime error occurs.
The classes View and ViewItem provide the methods required for modifying UI elements.
More information: http://help.sap.com/javadocs ->Mobile 7.3-> Mobile Applications for Handhelds -> com.sap.tc.mobile.wdlite.progmodel.core.viewitem (Package) -> ViewItem
//Creating a button dynamically in the View
ButtonViewItem button = view.getRootElementViewItem().createButton("Ok");
//Setting the action event for the button
button.setOnAction(this.onActionClick);
//Removing the button from the View
view.getRootElementViewItem().remove(button);