cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Context Binding To Drop Down

Former Member
0 Kudos

Hi *,

I've got a piece of code which creates a group of drop down fields in a dynamic way. The content of the drop down fields has to be bound to value nodes in my view context. The binding is coded as follows:

wdContext.nodeProduct().nodeFeature(i).nodeElement(j).nodeValues().getCurrentElement().node().getNodeInfo().getAttribute("Name");

As you can see, I have got a context with nested value nodes: A product contains features. Features contain elements and elements contain values. For element[0] there is a set of values to be shown by the drop down field, for element[1] a different one and so on.

Unfortunately all of my drop down fields map to the first set of values at runtime. I have inspected the instances of wdContext.nodeProduct().nodeFeature(i).nodeElement(j).nodeValues() at runtime and they are different. I suppose the problem might be that getNodeInfo().getAttribute("Name") does always return the same instance of metadata.

Could anybody tell me what im doing wrong here?

Cheers,

Heiko Nolte

Message was edited by: Heiko Nolte

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Heiko,

First, what is .nodeFeature(i)??? Is it .nodeFeature().getFeatureElementAt(i)? Let us assume this.

Second, what type of drop-down you try to create? As far as you are binding to attribute, I can assume from your <u>setup</u> description that it is DropDownByKey [DDK] (and not DropDownByIndex [DDI]). However, from your <u>problem</u> description it seems that you are using DDI.

If combo type is DDK, then you are doing smth. completely wrong: DDK displays values based on enumeration of all possible values for attribute data type, but not from node elements. As a solution you need different attributes with populated value set for every combo.

Otherwise, if you are using DDI, you are wrong again: unless you are placing DDI as table cell renderer, values they are shown come from so-called lead selection path, i.e. WD traverse your context nodes by lead selection element on every step till "values" node. Then it uses elements of "values" node to populate DDI. Check this, try to select in code second element in nodeElement. You can either use a table (if it is appropriate) or use different "values" nodes for combos.

Regards,

VS

P.S. Btw,


wdContext
  .nodeProduct()
    .nodeFeature(i) /* .nodeFeature().getFeatureElementAt(i) */
      .nodeElement(j) /* .nodeElement().getElementElementAt(j) */

        .nodeValues()
          .getCurrentElement()
            .node()
              .getNodeInfo()
                .getAttribute("Name");

is the same as


wdContext
  .nodeProduct()
    .nodeFeature(i) // .nodeFeature().getFeatureElementAt(i)
      .nodeElement(j) // .nodeElement().getElementElementAt(j)
        .nodeValues()
          .getNodeInfo()
            .getAttribute("Name");

P.P.S. Prefer wdContext.nodeProduct().getNodeInfo().getChild("Element").getChild("Values").getAttribute("Name") i.e. metadata approach for traversing to attribute metadata. Otherwise you are at risk of NullPointerException if your context contains no data.