cancel
Showing results for 
Search instead for 
Did you mean: 

Context Problem

Former Member
0 Kudos

Hi Forum,

I have a problem with my ViewContext and the Nodes.

I have the following context:

RootContext->Products(1:n)[value node]->County(1:1)[value node]->C_BEZ(value attibute)

First I am doing a loop over my Products and setting a Date, then I want so set the value in the subnode "Country". Now the problem: How can a access the subnode "Country" from each "Product" row.


int n = wdContext.nodeProducts().size();
Date d = wdContext.currentContextElement().getDate();
for (int i = n - 1; i >= 0; --i) {
IWDNodeElement element = wdContext.nodeProducts().getElementAt(i);
// This works!!!!
element.setAttributeValue("DATE", d);
// Only in the first Product the County gets set
Iterator iter = wdContext.nodeProducts().getElementAt(i).node().getNodeInfo().iterateChildren();
int c = 0;
while (iter.hasNext()) {
IWDNodeInfo nodeInfo = (IWDNodeInfo) iter.next();
IWDNode currentNode = wdContext.nodeProducts().getChildNode(nodeInfo.getName(), IWDNode.LEAD_SELECTION);
currentNode.getElementAt(c).setAttributeValue("C_BEZ", "TEXT");
c++;
}

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Chris,

Make node Country non-singleton (set singleton=false in context designer), then access it like:


IPrivate<ControllerName>.IProductsElement product 
  = wdContext.nodeProducts().getProductsElementAt(i);
IPrivate<ControllerName>.IContryNode countries 
  = product.nodeCountry();

Valery Silaev

SaM Solutions

http://www.sam-solutions.net

Former Member
0 Kudos

Hi Valery,

thank you very much! You solved my problem... think still have to learn a lot about the WD API!

Chris

Former Member
0 Kudos

I recommend reading the book "Inside Web Dynpro for Java" by Chris Whealy. It explains the context API rather good.

Armin

Answers (0)