Skip to Content
author's profile photo
Former Member

How to access a dynamic created attribute in a context node?

<i>Hello,</i>

<i>who could help? I can't set a value for a dynamically created attribute which is bind to a table.</i>

<i>My context of the view looks as follow (is defined in NetWeaver):</i>

- Context

- Availability (Node)

- vctxService (Attribute)

- vctxServiceDesc (Attribute)

- ... (further predefined attributes)

- ... (some have to be set dynamically as follows)

<i>Then I have added attributes dynamically in the wdDoModifyView(...) - method, as follows:</i>

...

for (int i = 0; i < max; i++) {

// some code to dynamically create table columns

...

// adding attributes dynamically

IWDAttributeInfo attrInfo = wdContext.nodeAvailability().getNodeInfo(). addAttribute("vctxAvailability_" + i, "ddic:com.sap.dictionary.string");

tv.bindText(attrInfo); // bind to TextView in table

...

}

<i>In the method onPlugFrom... I tried to set the values for the attributes "vctxAvailability_ + i" as follows:</i>

for (int i = 0; i < max; i++) {

IAvailabilityElement newAvailNodeElement = wdContext.createAvailabilityElement();

// some values will be set for the

// predefined attributes of AvailabilityNode

// newAvailNodeElement.set...( value );

// newAvailNodeElement.setVctxService( xy.getServ() );

...

// now the values of dynamically created and added

// attributes in AvailabilityNode will be added

// THIS DOESN'T WORK

newAvailNodeElement.setAttributeValue ("vctxAvailability_" + i, "value" + i);

...

}

<i>It would be great if someone could help me.

Thanks in advance.

Kind regards,

Carsten</i>

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • author's profile photo
    Former Member
    Posted on Jul 02, 2004 at 05:20 PM

    Hi Carsten,

    i'm not quite sure about the sequence the methods are invoked in your scenario. Maybe the onPlugFrom..() method is called before wdDoModifyView() and so you access the dynamic attributes before they are actually created.

    By the way, there's no need to add the attributes in wdDoModifyView() (binding the UI elements is something different), doing this in wdDoInit() would be much more safer in this case, since wdDoInit() is always the first method invoked when a controller is accessed for the first time.

    Hope that helps.

    Regards

    Stefan

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Carsten,

      Here is a sample code that creates context attributes dynamically and also sets values:

      //Creates a node

      IWDNodeInfo nodeInfo = wdContext.wdGetAPI().getRootNodeInfo().addChild("TestNode", null, true, true, false, true, false, true, null, null, null);

      //If you want to bind the node to a model node then the

      //second argument to the above method should be the

      //model class.

      //Creates an attribute under the node just created.

      IWDAttributeInfo testAttrib = wdContext.wdGetAPI().getRootNodeInfo().getChild("TestNode").addAttribute("testAttrib", "ddic:com.sap.dictionary.string");

      IWDNodeElement testNode = wdContext.getChildNode("TestNode", IWDNode.LEAD_SELECTION).getCurrentElement();

      IWDNode testNode2 = wdContext.getChildNode("TestNode", IWDNode.LEAD_SELECTION);

      //Now you can bind testNode with the Model Node

      //You can also set a value to the newly created attribute

      testNode.setAttributeValue("testAttrib", new String("Value"));

      Hope this helps.

      Shakeel

  • author's profile photo
    Former Member
    Posted on Jul 03, 2004 at 10:42 AM

    Hi,

    Very much thanks for the help.

    One point is unclear for me. If I create dynamically a table in wdDoModifyView(...). Then create the dynamic attributes in onPlugFrom...(...). Where should I do then the binding from the attributes to the table - and how will it work if onPlugFrom...(...) will be called before wdDoModifyView(...). The table doesn't exist if onPlugFrom...(...) is called before wdDoModifyView(...).

    Is it a way to put all created nodes with the new attributes in a Vector and iterate them in wdDoModifyView(...) to bind them to the table?

    Thanks in advance,

    Carsten

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Stefan,

      Thanks a lot for your help. Yes in this case I were a little bit confused 😉 But now I have done it as you described and it works fine !

      Thanks and kind regards,

      Carsten