Start of Content Area

Background documentation Data Binding for DropDownByIndex Elements  Locate the document in its SAP Library structure

The view context provides the content to be displayed in the dropdown list box and the selected index.

The view context must contain a context node X that can store any number of node elements (X.cardinality=0..n). Each node element represents an entry in the dropdown list box.

The context node X contains a context attribute y that provides the texts for the list entries. The data type of the context attribute y can be any simple data type – for example, String, int, and so on. If the data type of the context attribute y is not of the type String, this type is converted into a String representation by the Web Dynpro Framework. The selected value is specified by the lead selection of the node X.

The texts property of the DropDownByIndex UI element is bound to the attribute y by assigning the path of the context X.y to the texts property.

Example for Data Binding of the DropDownByIndex UI Element:

Procedure at design time:

...

       1.      Create a view with the name TestView.

       2.      Insert the DropDownByIndex UI element as a container child of the TestView view. (Step 1)

       3.      Create the context structure, as described in step 2.
Create the context node X with the cardinality 0..n. Insert the value attribute y of the type String into this node. Then perform the data binding of the DropDownByIndex UI element in the Properties window of the View Designer. The
texts property must be bound to the value attribute y with the context path description TestView.X.y (step 3).
The context path TestView.X.y describes the attribute y in the context node X of the view context of the TestView view.

You can fill the context with test data using the following controller implementation.

public void wdDoInit()

  {

    //@@begin wdDoInit()

   String[] letters = new String []

   {"A", "B", "C", "D"};

 

//Create context elements for the node "X"

   List nodeElements = new ArrayList();

   for (int i =  0; i <letters.length; ++i)

   {

      IPrivateTestView.IXElement xElement = wdContext.createXElement();

      xElement.setY(letters[i]);

      nodeElements.add(xElement);

   }

 

//Bind node element list to the node

   wdContext.nodeX().bind(nodeElements);

 

//Set node’s lead selection which determines the selected item

   wdContext.nodeX().setLeadSelection(1);

 

    //@@end

  }

Behavior at runtime:

At runtime, a context node consists of a number of node elements, which contain the values to be displayed – as illustrated in step 4 of the diagram below. The lead selection is set to the second value (zero-based index). Step 5 shows the dropdown list box with the possible values A, B, C, and D, as displayed in the browser.

This graphic is explained in the accompanying text

 

End of Content Area