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,

constantin

Former Member
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
  (
    "Items", 
    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", "ddic:com.sap.dictionary.string");

  /* 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>);
    itemsNode.addElement(e);
  }
}

wdDoModifyView(...)
{
  if (firstTime)
  {
    IWDUIElementContainer top = (IWDUIElementContainer) view.getRootElement();
    IWDDropDownByIndex itemSelector = (IWDDropDownByIndex) view.createElement(IWDDropDownByIndex.class, "ItemSelector");
    itemSelector.bindTexts("Items.text");
    top.addChild(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.)

Armin

0 View this answer in context

Helpful Answer

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