Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

dynamiclly generated dropdownbyindex

hi everyone,

i need to create a dropdownbyindex-element dynamiclly in the code, with values from an dynamiclly generated arraylist. but i can only bind a value-node to the ddbi-element.

so. how can i create a value-node with one value-attribute dynamiclly and set the value according to the arraylist?

thanks and best regards,


Former Member replied

Example: Create a context node "Items" with a string attribute "text", create a DropDownByIndex "ItemSelector", bind it to the node. Fill the node from some array of strings.

void wdDoInit()
  /* Create the meta-data */
  IWDNodeInfo itemsNodeInfo = wdContext.getNodeInfo().addChild
    null, /* value node */ 
    true, /* singleton */ 
    false, true, /* cardinality = 0:n */
    false, false, /* selection = 0:1 */
    true, /* initialize lead-selection */
    null, /* data type */
    null, null /* no supplier and disposer */
  itemsNodeInfo.addAttribute("text", "");

  /* Fill the node from sample data */
  String[] values = { "First", "Second", "Third" };
  IWDNode itemsNode = wdContext.getChildNode("Items", 0);
  for (int i = 0; i < values.length; ++i)
    IWDNodeElement e = itemsNode.createElement();
    e.setAttributeValue("text", values<i>);

  if (firstTime)
    IWDUIElementContainer top = (IWDUIElementContainer) view.getRootElement();
    IWDDropDownByIndex itemSelector = (IWDDropDownByIndex) view.createElement(IWDDropDownByIndex.class, "ItemSelector");

Übungsaufgabe: Create an action and assign it to the "onSelect" event of the drop-down list. (Hint: You have to use a predefined event handler method.)


0 View this answer in context

Helpful Answer

Not what you were looking for? View more on this topic or Ask a question