cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with context binding

Former Member
0 Kudos

Hi all,

I have the following problem with my context element.

I have this structure in my context:

DynamicText (valueNode)

Person (valueAttribute)

SourceRegistration (valueAttribute)

Persons (valueNode in node DynamicText)

Persons (valueAttribute in node Persons)

Now im trying to fill this context data in my code like this:

IPublicTESTComponent.IDynamicTextElement dynamicText = wdContext.createDynamicTextElement();

dynamicText.setSourceRegistration("sourceRegistration");

dynamicText.setPerson("person");

Collection personList = new ArrayList();

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

IPersonsElement dynamicPerson = wdContext.createPersonsElement();

dynamicPerson.setPersons("test person: " +i);

personList.add(dynamicPerson);

}

wdContext.nodePersons().bind(personList);

wdContext.nodeDynamicText().bind(dynamicText);

On this code i receive the following fault message:

com.sap.tc.webdynpro.progmodel.context.ContextException: Node(TESTComponent.DynamicText.Persons): cannot bind or add elements because the node has no valid parent

How can I bind the persons on this context please?

Accepted Solutions (1)

Accepted Solutions (1)

vijayakhanna_raman
Active Contributor
0 Kudos

Hi,

1)Set the Node persons of property singleton to false.

2)Add the person element to the Dynamic text node

IPublicTESTComponent.IDynamicTextElement dynamicText = wdContext.createDynamicTextElement();

dynamicText.setSourceRegistration("sourceRegistration");

dynamicText.setPerson("person");

<b>wdContext.nodeDynamicText.addElement(dynamicText);</b>

Collection personList = new ArrayList();

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

IPersonsElement dynamicPerson = wdContext.createPersonsElement();

dynamicPerson.setPersons("test person: " +i);

<b>dynamicText .nodePersons.addElement(dynamicPerson);</b>

}

Regards,

Vijayakhanna Raman

Answers (3)

Answers (3)

Former Member
0 Kudos

Is "Persons" a non-singleton node (singleton=false)?

If yes, you should create the node elements like this:


IDynamicTextElement dynamicText = wdContext.createDynamicTextElement();
wdContext.nodeDynamicText().addElement(dynamicText);
dynamicText.setSourceRegistration("sourceRegistration");
dynamicText.setPerson("person");

for (int i=0; i < 4; i++) 
{
  IPersonsElement person = dynamicText.nodePersons().createPersonsElement();
  dynamicText.nodePersons().addElement(person);
  person.setPersons("test person: " + i);
}

Armin

Former Member
0 Kudos

Ok thnx All!!

I couldn't reward points to all of you, so I rewarded 1 Problem solved and 2 very helpfull.

siarhei_pisarenka3
Active Contributor
0 Kudos

Hi

The problem in the code I see DynamicText node must be supplied before Persons one because it's a parent node.

Binding the Persons node depends on property "singleton" setted on the node. If 'singleton'==false

wdContext.nodeDynamicText().bind(dynamicText);
wdContext.nodeDynamicText().getDynamicTextElementAt(0).nodePersons().bind(personList);

If 'singleton'==true ensure that 'initializeLeadSelection' property of DynamicText node is TRUE then use

wdContext.nodeDynamicText().bind(dynamicText);
wdContext.nodePersons().bind(personList);

BR

Sergei

Former Member
0 Kudos

Hello B.Van,

Use the following code:


  IPublicTestComponent.IDynamicTextElement dynamicText =     
  wdContext.createDynamicTextElement();

  dynamicText.setSourceRegistration("sourceRegistration");
  dynamicText.setPerson("person");

  wdContext.nodeDynamicText().bind(dynamicText);
  /** Bind the element first to the parent node*/

  IPublicTestComponent.IPersonsElement dynamicPerson = null;

  for (int i=0; i<4; i++) 
  {
    dynamicPerson = wdContext.createPersonsElement();
    dynamicPerson.setPersons("test person: " +i);
    wdContext.nodePersons().addElement(dynamicPerson);
  }

Bala