Entering content frame

Function documentation Supply Function Locate the document in its SAP Library structure

Use

The supply function can be used to fill values for a context node only when they are actually needed. For example, instead of creating a collection with values and binding it to the node, the programmer specifies the collection by describing the function to be called by the Web Dynpro runtime environment (see Code Examples of Data Binding). The supply function supports the following functions:

·        The supply function returns the context node to be filled and the node elements of its parent as a parameter.

·        The collection of the node is empty. It is valid, however, when the supply function is executed.

·        The supply function fills the collection using the bind method or addElement method (see example).

·        The supply function allows the assignment of the lead selection.

·        When executing the supply function, the node can be accessed.

·        The supply function is described specifically for a node and therefore contains the correct classes for the parameter

The Web Dynpro runtime environment calls the supply function of a node when its data is needed and its collection is still invalid. This can be the case if:

  1. The collection or the node was just created.
  2. The lead selection of the parent node was modified due to a singleton node
  3. The application developer described the node as invalid using an API call

Signature

You must define the supply function for a specific node in the corresponding controller. The supply function has the following signature:

...

¡        void supply(ChildNode node, ParentElement parentElement);

Example

Source code example of a supply function:

public void supplyMostImportantOrders(
             IOrderNode node, 
             ICustomersElement parentElement) {
    // get max number of orders to display from context
    int maxOrders = wdContext.currentContextElement()
                             .getMaxOrdersToDisplay();
    // get orders for customer
    Collection orders = parentElement.modelInstance().getOrders();
    if (orders.size() > maxOrders) {
      // only add maxOrders orders
      Iterator it = orders.iterator();
      while(it.hasNext() && orders.size() < maxOrders) {
        node.addElement(it.next());
      }
    } else {
      // simply bind all orders
      node.bind(orders);
  }
}

 

 

Leaving content frame