!--a11y-->
Mapping the Event Parameters
In the second step, you created actions for events on a tree node and assigned each of them a parameter. To ensure that these parameters correspond to the selected node at runtime, you must implement a parameter mapping.
...
1. To open the TreeView, double-click TreeView in the project structure in the Web Dynpro Explorer.
2. Choose the Implementation tab page.
3. Enter the following lines in the method wdDoModifyView():
public static void wdDoModifyView(IPrivateTreeView wdThis, IPrivateTreeView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime) { //@@begin wdDoModifyView if (firstTime) { IWDTreeNodeType treeNode = (IWDTreeNodeType) view.getElement("TheNode");
/* parameter mapping from parameter "path" to * parameter "selectedElement" */ treeNode.mappingOfOnAction().addSourceMapping( "path", "selectedElement"); /* parameter mapping from parameter "path" to * parameter "element". */ treeNode.mappingOfOnLoadChildren().addSourceMapping( "path", "element"); } //@@end }
|
To add
the missing imports, position the mouse pointer in the source code and in the
context menu, choose Source à Organize
Imports.
These lines create a parameter mapping from the UI element parameter path to the event parameter selectedElement or element. The parameter path is of type string and contains the string representation of the tree node that triggered the event onAction or onLoadChildren. You have already created the parameters selectedElement and element in the second step.
You have executed a parameter mapping. You can use the parameters element and selectedElement in the event handlers to access the node selected by the user.
Next step:
Event Handling: Expanding a Node
